diff options
author | June McEnroe <june@causal.agency> | 2020-12-29 23:49:16 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-12-29 23:54:30 -0500 |
commit | 1662b01a5f616bd4babc08e1eb6fec1a3c7b44cf (patch) | |
tree | 2fba4e960bbd7cac6e55ed96cf4cd6a5f47d9fe7 /handle.c | |
parent | Handle so-called Standard Replies (diff) | |
download | test-1662b01a5f616bd4babc08e1eb6fec1a3c7b44cf.tar.gz test-1662b01a5f616bd4babc08e1eb6fec1a3c7b44cf.zip |
Add /setname command
I'm not sure about that replies check in handleStandardReply. If more of those are added the reply counter system will definitely need refactoring.
Diffstat (limited to '')
-rw-r--r-- | handle.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/handle.c b/handle.c index 96c99b7..d8f5f3d 100644 --- a/handle.c +++ b/handle.c @@ -97,6 +97,10 @@ typedef void Handler(struct Message *msg); static void handleStandardReply(struct Message *msg) { require(msg, false, 3); + if (!strcmp(msg->params[0], "SETNAME")) { + if (!replies.setname) return; + replies.setname--; + } for (uint i = 2; i < ParamCap - 1; ++i) { if (msg->params[i + 1]) continue; uiFormat( @@ -1150,6 +1154,17 @@ static void handleReplyNowAway(struct Message *msg) { replies.away--; } +static void handleSetname(struct Message *msg) { + require(msg, true, 1); + if (!replies.setname) return; + if (strcmp(msg->nick, self.nick)) return; + uiFormat( + Network, Warm, tagTime(msg), + "You update your name tag: %s", msg->params[0] + ); + replies.setname--; +} + static bool isAction(struct Message *msg) { if (strncmp(msg->params[1], "\1ACTION ", 8)) return false; msg->params[1] += 8; @@ -1343,6 +1358,7 @@ static const struct Handler { { "PING", handlePing }, { "PRIVMSG", handlePrivmsg }, { "QUIT", handleQuit }, + { "SETNAME", handleSetname }, { "TOPIC", handleTopic }, { "WARN", handleStandardReply }, }; |