about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--handle.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/handle.c b/handle.c
index 7dfd85a..a2d0ddd 100644
--- a/handle.c
+++ b/handle.c
@@ -240,6 +240,7 @@ static void handleReplyISupport(struct Message *msg) {
 			strsep(&msg->params[i], "(");
 			set(&network.prefixModes, strsep(&msg->params[i], ")"));
 			set(&network.prefixes, msg->params[i]);
+			assert(strlen(network.prefixes) == strlen(network.prefixModes));
 		} else if (!strcmp(key, "CHANMODES")) {
 			set(&network.listModes, strsep(&msg->params[i], ","));
 			set(&network.paramModes, strsep(&msg->params[i], ","));
@@ -484,6 +485,45 @@ static void handleTopic(struct Message *msg) {
 	}
 }
 
+static void handleMode(struct Message *msg) {
+	require(msg, true, 2);
+	if (!strchr(network.chanTypes, msg->params[0][0])) {
+		// TODO: User mode changes.
+		return;
+	}
+	uint id = idFor(msg->params[0]);
+	bool set = false;
+	uint param = 2;
+	for (char *ch = msg->params[1]; *ch; ++ch) {
+		if (*ch == '+') {
+			set = true;
+		} else if (*ch == '-') {
+			set = false;
+		} else if (strchr(network.prefixModes, *ch)) {
+			assert(param < ParamCap);
+			char *nick = msg->params[param++];
+			char *mode = strchr(network.prefixModes, *ch);
+			char prefix = network.prefixes[mode - network.prefixModes];
+			// TODO: Invert nick if targeting self?
+			uiFormat(
+				id, (!strcmp(nick, self.nick) ? Hot : Cold), tagTime(msg),
+				"\3%02d%s\3\t%s \3%02d%c%s\3",
+				hash(msg->user), msg->nick,
+				(set ? "grants" : "revokes"),
+				completeColor(id, nick), prefix, nick
+			);
+		} else if (strchr(network.listModes, *ch)) {
+			// TODO
+		} else if (strchr(network.paramModes, *ch)) {
+			// TODO
+		} else if (strchr(network.setParamModes, *ch)) {
+			// TODO
+		} else {
+			// TODO
+		}
+	}
+}
+
 static void handleErrorUserNotInChannel(struct Message *msg) {
 	require(msg, false, 4);
 	uiFormat(
@@ -828,6 +868,7 @@ static const struct Handler {
 	{ "INVITE", handleInvite },
 	{ "JOIN", handleJoin },
 	{ "KICK", handleKick },
+	{ "MODE", handleMode },
 	{ "NICK", handleNick },
 	{ "NOTICE", handlePrivmsg },
 	{ "PART", handlePart },
'nohover-highlight'> 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