about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-10-02 19:38:37 -0400
committerJune McEnroe <june@causal.agency>2020-10-02 19:38:37 -0400
commitf7f5acbbe2a848d2c827aed0fe8410e48300c1e9 (patch)
treea4967b2ac419cfde81a951b65e47fde6481d6db9
parentUse WHO for /ops (diff)
downloadcatgirl-f7f5acbbe2a848d2c827aed0fe8410e48300c1e9.tar.gz
catgirl-f7f5acbbe2a848d2c827aed0fe8410e48300c1e9.zip
Double up /help for server help
While the automatic search via LESS is neat, I don't think it's very
useful. Just always open the manual to the COMMANDS section, and fix it
to append to LESS rather than replace it.
-rw-r--r--catgirl.19
-rw-r--r--chat.h1
-rw-r--r--command.c10
-rw-r--r--handle.c15
4 files changed, 31 insertions, 4 deletions
diff --git a/catgirl.1 b/catgirl.1
index 6a45722..160ba6f 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -1,4 +1,4 @@
-.Dd September 30, 2020
+.Dd October  2, 2020
 .Dt CATGIRL 1
 .Os
 .
@@ -338,12 +338,17 @@ with
 and interpret its output
 as input to the current window,
 including as commands.
-.It Ic /help Op Ar search
+.It Ic /help
 View this manual.
 Type
 .Ic q
 to return to
 .Nm .
+.It Ic /help Ar topic
+List the server help for a topic.
+Try
+.Ic /help index
+for a list of topics.
 .It Ic /ignore Op Ar pattern
 List message filtering patterns
 or temporarily add a pattern.
diff --git a/chat.h b/chat.h
index 8573ad8..cd8798c 100644
--- a/chat.h
+++ b/chat.h
@@ -241,6 +241,7 @@ extern struct Replies {
 	uint away;
 	uint ban;
 	uint excepts;
+	uint help;
 	uint invex;
 	uint join;
 	uint list;
diff --git a/command.c b/command.c
index 92f1271..3af1246 100644
--- a/command.c
+++ b/command.c
@@ -421,14 +421,20 @@ static void commandExec(uint id, char *params) {
 
 static void commandHelp(uint id, char *params) {
 	(void)id;
-	uiHide();
 
+	if (params) {
+		ircFormat("HELP :%s\r\n", params);
+		replies.help++;
+		return;
+	}
+
+	uiHide();
 	pid_t pid = fork();
 	if (pid < 0) err(EX_OSERR, "fork");
 	if (pid) return;
 
 	char buf[256];
-	snprintf(buf, sizeof(buf), "ip%s$", (params ?: "COMMANDS"));
+	snprintf(buf, sizeof(buf), "%spCOMMANDS$", (getenv("LESS") ?: ""));
 	setenv("LESS", buf, 1);
 	execlp("man", "man", "1", "catgirl", NULL);
 	dup2(utilPipe[1], STDERR_FILENO);
diff --git a/handle.c b/handle.c
index 7519b87..988aeb2 100644
--- a/handle.c
+++ b/handle.c
@@ -302,6 +302,18 @@ static void handleErrorNoMOTD(struct Message *msg) {
 	(void)msg;
 }
 
+static void handleReplyHelp(struct Message *msg) {
+	require(msg, false, 3);
+	if (!replies.help) return;
+	urlScan(Network, msg->nick, msg->params[2]);
+	uiWrite(Network, Warm, tagTime(msg), msg->params[2]);
+}
+
+static void handleReplyEndOfHelp(struct Message *msg) {
+	(void)msg;
+	if (replies.help) replies.help--;
+}
+
 static void handleJoin(struct Message *msg) {
 	require(msg, true, 1);
 	uint id = idFor(msg->params[0]);
@@ -1253,6 +1265,9 @@ static const struct Handler {
 	{ "478", handleErrorBanListFull },
 	{ "482", handleErrorChanopPrivsNeeded },
 	{ "671", handleReplyWhoisGeneric },
+	{ "704", handleReplyHelp },
+	{ "705", handleReplyHelp },
+	{ "706", handleReplyEndOfHelp },
 	{ "900", handleReplyLoggedIn },
 	{ "904", handleErrorSASLFail },
 	{ "905", handleErrorSASLFail },