From 4f40ace9d4cf475d445678e63b3f48cc03cf7d7e Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Mon, 23 Mar 2020 16:52:24 -0400 Subject: Track MODE in replies --- chat.h | 1 + command.c | 2 ++ handle.c | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/chat.h b/chat.h index 3f93f3d..7ffcfcd 100644 --- a/chat.h +++ b/chat.h @@ -187,6 +187,7 @@ extern struct Replies { uint invex; uint join; uint list; + uint mode; uint names; uint topic; uint whois; diff --git a/command.c b/command.c index 5da8bb9..7339574 100644 --- a/command.c +++ b/command.c @@ -185,12 +185,14 @@ static void commandMode(uint id, char *params) { ircFormat("MODE %s %s\r\n", self.nick, params); } else { ircFormat("MODE %s\r\n", self.nick); + replies.mode++; } } else { if (params) { ircFormat("MODE %s %s\r\n", idNames[id], params); } else { ircFormat("MODE %s\r\n", idNames[id]); + replies.mode++; } } } diff --git a/handle.c b/handle.c index 376e722..e690caa 100644 --- a/handle.c +++ b/handle.c @@ -527,6 +527,9 @@ static const char *UserModes[256] = { static void handleReplyUserModeIs(struct Message *msg) { require(msg, false, 2); + if (!replies.mode) return; + replies.mode--; + char buf[1024] = ""; for (char *ch = msg->params[1]; *ch; ++ch) { if (*ch == '+') continue; @@ -560,6 +563,9 @@ static const char *ChanModes[256] = { static void handleReplyChannelModeIs(struct Message *msg) { require(msg, false, 3); + if (!replies.mode) return; + replies.mode--; + uint param = 3; char buf[1024] = ""; for (char *ch = msg->params[2]; *ch; ++ch) { -- cgit 1.4.1