summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-25 02:54:15 -0500
committerJune McEnroe <june@causal.agency>2020-02-25 02:54:15 -0500
commite9524b4af39e6b83acd2a54d67dfec3c3a41d8cc (patch)
tree12addbf469a1cbf814fdb6f7a34ef3d93be87137
parentFix handling EXCEPTS and INVEX without values (diff)
downloadcatgirl-e9524b4af39e6b83acd2a54d67dfec3c3a41d8cc.tar.gz
catgirl-e9524b4af39e6b83acd2a54d67dfec3c3a41d8cc.zip
Handle changing setParamModes, paramModes and other channel modes
-rw-r--r--handle.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/handle.c b/handle.c
index 9a0be57..4cb0e94 100644
--- a/handle.c
+++ b/handle.c
@@ -488,6 +488,18 @@ static void handleTopic(struct Message *msg) {
 	}
 }
 
+static const char *ModeNames[256] = {
+	['i'] = "invite-only",
+	['k'] = "key",
+	['l'] = "client limit",
+	['m'] = "moderated",
+	['n'] = "no external messages",
+	['o'] = "operator",
+	['s'] = "secret",
+	['t'] = "protected topic",
+	['v'] = "voice",
+};
+
 static void handleMode(struct Message *msg) {
 	require(msg, true, 2);
 	if (!strchr(network.chanTypes, msg->params[0][0])) {
@@ -500,6 +512,8 @@ static void handleMode(struct Message *msg) {
 	uint param = 2;
 	char buf[1024] = "";
 	for (char *ch = msg->params[1]; *ch; ++ch) {
+		const char *name = ModeNames[(byte)*ch];
+		if (!name) name = (const char[]) { *ch, '\0' };
 		if (*ch == '+') {
 			set = true;
 		} else if (*ch == '-') {
@@ -541,11 +555,33 @@ static void handleMode(struct Message *msg) {
 			);
 
 		} else if (strchr(network.paramModes, *ch)) {
-			// TODO
+			assert(param < ParamCap);
+			catf(
+				buf, sizeof(buf), ", %ssets \3%02d%s\3 %s %s %s",
+				(set ? "" : "un"), hash(msg->params[0]), msg->params[0], name,
+				(set ? "to" : "from"), msg->params[param++]
+			);
+
 		} else if (strchr(network.setParamModes, *ch)) {
-			// TODO
+			if (set) {
+				assert(param < ParamCap);
+				catf(
+					buf, sizeof(buf), ", sets \3%02d%s\3 %s to %s",
+					hash(msg->params[0]), msg->params[0], name,
+					msg->params[param++]
+				);
+			} else {
+				catf(
+					buf, sizeof(buf), ", unsets \3%02d%s\3 %s",
+					hash(msg->params[0]), msg->params[0], name
+				);
+			}
+
 		} else {
-			// TODO
+			catf(
+				buf, sizeof(buf), ", %ssets \3%02d%s\3 %s",
+				(set ? "" : "un"), hash(msg->params[0]), msg->params[0], name
+			);
 		}
 	}
 	if (strlen(buf) < 2) return;
s='logmsg'> 2019-02-18Remove hi line numberingJune McEnroe Tags are much better for referring to specific parts of a file and line numbering is better done by a post-processing tool such as cat -n or producing a two-column HTML <table>. 2019-02-18Add Tag class to hiJune McEnroe 2019-02-17Generate HTML with hi -n -f html -o anchorJune McEnroe Running hi twice to insert stuff between the head and the content is a bit of a hack but oh well. 2019-02-17Add hi -f html -o anchor for line number linksJune McEnroe 2019-02-17Simplify temp trap in upJune McEnroe 2019-02-17Add line numbers to hiJune McEnroe Renames previous -n option to -m to stay consistent with cat -n. Prefixing lines with line numbers affects where the first tab indent ends up relative to the text above it. Not sure if it's worth fixing somehow. 2019-02-17Always split spans after newlinesJune McEnroe Simplifies ANSI and IRC output code, and prepares for line numbered output. 2019-02-15Color format specifiers light cyan in vimJune McEnroe 2019-02-15Highlight Interp as yellowJune McEnroe 2019-02-15Highlight strings in sh command substitutionsJune McEnroe 2019-02-15Add nmap gpJune McEnroe 2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe 2019-02-13Add forgotten "sixth" book of H2G2June McEnroe