diff options
author | June McEnroe <june@causal.agency> | 2020-02-25 02:12:35 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-02-25 02:12:35 -0500 |
commit | 3c5e1c95a4091c26de8cc47e9cf222b74cec4fb3 (patch) | |
tree | 8c3d66e9729d990f0e031a83f9f2e2e5bfacbf89 /handle.c | |
parent | Accumulate mode changes into a buffer for one message (diff) | |
download | catgirl-3c5e1c95a4091c26de8cc47e9cf222b74cec4fb3.tar.gz catgirl-3c5e1c95a4091c26de8cc47e9cf222b74cec4fb3.zip |
Add /mode, /except, /invex and handle lists replies
Diffstat (limited to 'handle.c')
-rw-r--r-- | handle.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/handle.c b/handle.c index 2dc4654..f1fc75d 100644 --- a/handle.c +++ b/handle.c @@ -606,6 +606,50 @@ static void handleReplyEndOfBanList(struct Message *msg) { if (replies.ban) replies.ban--; } +static void onList(const char *list, struct Message *msg) { + uint id = idFor(msg->params[1]); + if (msg->params[3] && msg->params[4]) { + char since[sizeof("0000-00-00 00:00:00")]; + time_t time = strtol(msg->params[4], NULL, 10); + strftime(since, sizeof(since), "%F %T", localtime(&time)); + uiFormat( + id, Cold, tagTime(msg), + "On the \3%02d%s\3 %s list since %s by \3%02d%s\3: %s", + hash(msg->params[1]), msg->params[1], list, + since, completeColor(id, msg->params[3]), msg->params[3], + msg->params[2] + ); + } else { + uiFormat( + id, Cold, tagTime(msg), + "On the \3%02d%s\3 %s list: %s", + hash(msg->params[1]), msg->params[1], list, msg->params[2] + ); + } +} + +static void handleReplyExceptList(struct Message *msg) { + require(msg, false, 3); + if (!replies.excepts) return; + onList("except", msg); +} + +static void handleReplyEndOfExceptList(struct Message *msg) { + (void)msg; + if (replies.excepts) replies.excepts--; +} + +static void handleReplyInviteList(struct Message *msg) { + require(msg, false, 3); + if (!replies.invex) return; + onList("invite", msg); +} + +static void handleReplyEndOfInviteList(struct Message *msg) { + (void)msg; + if (replies.invex) replies.invex--; +} + static void handleReplyList(struct Message *msg) { require(msg, false, 4); if (!replies.list) return; @@ -881,6 +925,10 @@ static const struct Handler { { "331", handleReplyNoTopic }, { "332", handleReplyTopic }, { "341", handleReplyInviting }, + { "346", handleReplyInviteList }, + { "347", handleReplyEndOfInviteList }, + { "348", handleReplyExceptList }, + { "349", handleReplyEndOfExceptList }, { "353", handleReplyNames }, { "366", handleReplyEndOfNames }, { "367", handleReplyBanList }, |