summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--chat.h2
-rw-r--r--command.c4
-rw-r--r--handle.c44
3 files changed, 39 insertions, 11 deletions
diff --git a/chat.h b/chat.h
index 43df641..8573ad8 100644
--- a/chat.h
+++ b/chat.h
@@ -246,8 +246,8 @@ extern struct Replies {
 	uint list;
 	uint mode;
 	uint names;
-	uint ops;
 	uint topic;
+	uint who;
 	uint whois;
 } replies;
 
diff --git a/command.c b/command.c
index efc095c..92f1271 100644
--- a/command.c
+++ b/command.c
@@ -176,8 +176,8 @@ static void commandNames(uint id, char *params) {
 
 static void commandOps(uint id, char *params) {
 	(void)params;
-	ircFormat("NAMES %s\r\n", idNames[id]);
-	replies.ops++;
+	ircFormat("WHO %s\r\n", idNames[id]);
+	replies.who++;
 }
 
 static void commandInvite(uint id, char *params) {
diff --git a/handle.c b/handle.c
index e3efe47..7519b87 100644
--- a/handle.c
+++ b/handle.c
@@ -499,26 +499,52 @@ static void handleReplyNames(struct Message *msg) {
 		char *user = strsep(&name, "@");
 		enum Color color = (user ? hash(user) : Default);
 		completeAdd(id, nick, color);
-		if (replies.ops && (prefixes == nick || prefixes[0] == '+')) continue;
-		if (!replies.ops && !replies.names) continue;
+		if (!replies.names) continue;
 		catf(&cat, "%s\3%02d%s\3", (buf[0] ? ", " : ""), color, prefixes);
 	}
 	if (!cat.len) return;
 	uiFormat(
 		id, Cold, tagTime(msg),
-		"%s \3%02d%s\3 are %s",
-		(replies.ops ? "The operators of" : "In"),
+		"In \3%02d%s\3 are %s",
 		hash(msg->params[2]), msg->params[2], buf
 	);
 }
 
 static void handleReplyEndOfNames(struct Message *msg) {
 	(void)msg;
-	if (replies.ops) {
-		replies.ops--;
-	} else if (replies.names) {
-		replies.names--;
+	if (replies.names) replies.names--;
+}
+
+static char whoBuf[1024];
+static struct Cat whoCat = { whoBuf, sizeof(whoBuf), 0 };
+
+static void handleReplyWho(struct Message *msg) {
+	require(msg, false, 7);
+	if (!replies.who) return;
+	if (!whoCat.len) {
+		catf(
+			&whoCat, "The operators of \3%02d%s\3 are ",
+			hash(msg->params[1]), msg->params[1]
+		);
 	}
+	char *prefixes = &msg->params[6][1];
+	if (prefixes[0] == '*') prefixes++;
+	prefixes[strspn(prefixes, network.prefixes)] = '\0';
+	if (!prefixes[0] || prefixes[0] == '+') return;
+	catf(
+		&whoCat, "%s\3%02d%s%s\3%s",
+		(whoCat.buf[whoCat.len - 1] == ' ' ? "" : ", "),
+		hash(msg->params[2]), prefixes, msg->params[5],
+		(msg->params[6][0] == 'H' ? "" : " (away)")
+	);
+}
+
+static void handleReplyEndOfWho(struct Message *msg) {
+	require(msg, false, 2);
+	if (!replies.who) return;
+	replies.who--;
+	uiWrite(idFor(msg->params[1]), Cold, tagTime(msg), whoBuf);
+	whoCat.len = 0;
 }
 
 static void handleReplyNoTopic(struct Message *msg) {
@@ -1196,6 +1222,7 @@ static const struct Handler {
 	{ "311", handleReplyWhoisUser },
 	{ "312", handleReplyWhoisServer },
 	{ "313", handleReplyWhoisGeneric },
+	{ "315", handleReplyEndOfWho },
 	{ "317", handleReplyWhoisIdle },
 	{ "318", handleReplyEndOfWhois },
 	{ "319", handleReplyWhoisChannels },
@@ -1210,6 +1237,7 @@ static const struct Handler {
 	{ "347", handleReplyEndOfInviteList },
 	{ "348", handleReplyExceptList },
 	{ "349", handleReplyEndOfExceptList },
+	{ "352", handleReplyWho },
 	{ "353", handleReplyNames },
 	{ "366", handleReplyEndOfNames },
 	{ "367", handleReplyBanList },
c.c?id=087dcc0be343494728162eb12e05ad8a42f77f22&follow=1'>Consolidate hilex formatters into hilex.cJune McEnroe 2021-01-12Remove hacky tagging from hilexJune McEnroe God that makes the lexers so much simpler. 2021-01-12Add htagml -iJune McEnroe 2021-01-12Render tag index in HTMLJune McEnroe 2021-01-12Add htagml -xJune McEnroe 2021-01-12Prevent matching the same tag twiceJune McEnroe 2021-01-12Process htagml file line by lineJune McEnroe This simplifies some things, adds support for line number tag definitions, and should enable combining htagml with other preprocessors in the future. 2021-01-12Split fields by tab onlyJune McEnroe Also don't fail hard on non-forward-search definitions. 2021-01-12List both Makefile and html.sh under README.7June McEnroe 2021-01-12Add htagml exampleJune McEnroe 2021-01-12Use mandoc and htagml for bin htmlJune McEnroe 2021-01-12Add htagmlJune McEnroe 2021-01-12Replace causal.agency with a simple mdoc pageJune McEnroe 2021-01-11Publish "Using vi"June McEnroe 2021-01-11Enable diff.colorMovedJune McEnroe 2021-01-10Set less search case-insensitiveJune McEnroe 2021-01-10Set EXINITJune McEnroe neovim is laggy as hell in my OpenBSD VM, so I switched to vi so I could type without getting frustrated. 2021-01-09Add c -t flag to print expression typeJune McEnroe Also add missing float case. 2021-01-05Update taglineJune McEnroe