From c2c8595012a8fa7878ddc7f48569417402736360 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 20 Feb 2020 04:18:25 -0500 Subject: Handle MODE setting channel prefix modes --- handle.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) 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 }, -- cgit 1.4.0 h>Commit message (Expand)Author 2022-09-19Publish ApologiesJune McEnroe 2022-09-19Do more "email" filteringJune McEnroe 2022-09-18Add gdbinit, hushlogin, inputrcJune McEnroe 2022-09-18Remove some filesJune McEnroe 2022-09-18Remove doc/pdfJune McEnroe 2022-09-11Reread A Closed and Common OrbitJune McEnroe 2022-09-09Add I've Got a Time BombJune McEnroe 2022-09-02Update "Care" with initial electrolysis reportJune McEnroe 2022-08-17Add The Book of Form and EmptinessJune McEnroe 2022-08-15Load dates from ~/.config/when/datesJune McEnroe 2022-08-15Allow names with prefixes of months and daysJune McEnroe 2022-08-15Add named dates to whenJune McEnroe 2022-08-14Remove tweets text fileJune McEnroe 2022-08-04Add Conversations With FriendsJune McEnroe 2022-07-30Add Normal PeopleJune McEnroe 2022-07-26Rewrite glitch from new pngoJune McEnroe 2022-07-26Update Care with time-to-ID and piercingsJune McEnroe 2022-07-26Add -w to upJune McEnroe 2022-07-13Set push.autoSetupRemoteJune McEnroe 2022-07-08Remove TOURJune McEnroe 2022-07-03Add The Bone Shard EmperorJune McEnroe 2022-06-25Bump xterm font size to 12June McEnroe 2022-06-10Handle subshells (and functions) inside substitutionsJune McEnroe 2022-06-10Switch to jorts Install scriptJune McEnroe 2022-06-08Indicate if still reading or no resultsJune McEnroe 2022-06-08Add Maiden, Mother, CroneJune McEnroe 2022-06-05FIRST SHOW IN 2.5 YEARS BABEY!!!June McEnroe 2022-06-03Set line number on File linesJune McEnroe 2022-06-03Stop polling stdin after EOFJune McEnroe 2022-06-02Set TABSIZE=4June McEnroe 2022-06-02Do basic match highlightingJune McEnroe 2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe