summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-03-22 11:40:58 -0400
committerJune McEnroe <june@causal.agency>2020-03-22 11:40:58 -0400
commit0d0a6d15757f02eaee879e4f7f1bb3c24dab8f1d (patch)
treefd35f5e36fd6898e93a317723f41cf138053e5ca
parentHandle user mode changes (diff)
downloadcatgirl-0d0a6d15757f02eaee879e4f7f1bb3c24dab8f1d.tar.gz
catgirl-0d0a6d15757f02eaee879e4f7f1bb3c24dab8f1d.zip
Handle RPL_CHANNELMODEIS
-rw-r--r--handle.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/handle.c b/handle.c
index 4392094..fa3f36b 100644
--- a/handle.c
+++ b/handle.c
@@ -512,13 +512,13 @@ static void handleReplyUserModeIs(struct Message *msg) {
 		if (UserModes[(byte)*ch]) {
 			catf(buf, sizeof(buf), ", %s", UserModes[(byte)*ch]);
 		} else {
-			catf(buf, sizeof(buf), ", mode %c", *ch);
+			catf(buf, sizeof(buf), ", +%c", *ch);
 		}
 	}
 	uiFormat(
 		Network, Warm, tagTime(msg),
-		"\3%02d%s\3\tis%s",
-		self.color, self.nick, (buf[0] ? &buf[1] : buf)
+		"\3%02d%s\3\tis %s",
+		self.color, self.nick, (buf[0] ? &buf[2] : buf)
 	);
 }
 
@@ -537,6 +537,35 @@ static const char *ChanModes[256] = {
 	['v'] = "voice",
 };
 
+static void handleReplyChannelModeIs(struct Message *msg) {
+	require(msg, false, 3);
+	uint param = 3;
+	char buf[1024] = "";
+	for (char *ch = msg->params[2]; *ch; ++ch) {
+		if (*ch == '+') continue;
+		const char *name = ChanModes[(byte)*ch];
+		if (!name) name = (const char[]) { '+', *ch, '\0' };
+		if (
+			strchr(network.paramModes, *ch) ||
+			strchr(network.setParamModes, *ch)
+		) {
+			assert(param < ParamCap);
+			catf(
+				buf, sizeof(buf), ", has %s of %s",
+				name, msg->params[param++]
+			);
+		} else {
+			catf(buf, sizeof(buf), ", is %s", name);
+		}
+	}
+	uiFormat(
+		idFor(msg->params[1]), Cold, tagTime(msg),
+		"\3%02d%s\3\t%s",
+		hash(msg->params[1]), msg->params[1],
+		(buf[0] ? &buf[2] : "has no modes")
+	);
+}
+
 static void handleMode(struct Message *msg) {
 	require(msg, true, 2);
 
@@ -1017,6 +1046,7 @@ static const struct Handler {
 	{ "319", handleReplyWhoisChannels },
 	{ "322", handleReplyList },
 	{ "323", handleReplyListEnd },
+	{ "324", handleReplyChannelModeIs },
 	{ "330", handleReplyWhoisGeneric },
 	{ "331", handleReplyNoTopic },
 	{ "332", handleReplyTopic },
href='/bubger/commit/bubger.1?id=f82e2e1518bbe8f38e44f40e3c3d50d31ed6558d&follow=1'>Use %R for RFC numbers in STANDARDS sectionJune McEnroe 2020-04-26Add mailto spec to STANDARDSJune McEnroe 2020-04-26Increase space between nav itemsJune McEnroe 2020-04-26Add mailto address for the archiveJune McEnroe 2020-04-26Put dates on new lines in indexJune McEnroe 2020-04-26Include <> around Message-Id in mailto: URLsJune McEnroe 2020-04-26Add link to index on thread pagesJune McEnroe 2020-04-26Fall back to Content-Type name parameter for attachmentsJune McEnroe 2020-04-26Remove margins in article.message headerJune McEnroe 2020-04-26Generate index.atomJune McEnroe 2020-04-26Generate XHTML content in Atom entriesJune McEnroe 2020-04-25Style index pageJune McEnroe 2020-04-25Render index.htmlJune McEnroe 2020-04-25Wrap <summary> replies count in <data>June McEnroe 2020-04-25Accumulate thread envelopes before concatenationJune McEnroe 2020-04-24Free envelope in concatDataJune McEnroe 2020-04-24Use replyTo address in mailto:June McEnroe 2020-04-23Wrap quoted lines in <q>June McEnroe