From 73bda18110cfb52eecf7ad1089cd99d68f73e568 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Tue, 7 Apr 2020 13:18:42 -0400 Subject: Check ignores against id Otherwise they do not work correctly for QUIT and NICK. This also lets you ignore private messages only by putting the nick in the third field. --- chat.h | 2 +- handle.c | 17 +++++++++-------- ignore.c | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/chat.h b/chat.h index 764f8ec..e0266ef 100644 --- a/chat.h +++ b/chat.h @@ -269,7 +269,7 @@ extern struct Ignore { } ignore; const char *ignoreAdd(const char *pattern); bool ignoreRemove(const char *pattern); -enum Heat ignoreCheck(enum Heat heat, const struct Message *msg); +enum Heat ignoreCheck(enum Heat heat, uint id, const struct Message *msg); extern bool logEnable; void logFormat(uint id, const time_t *time, const char *format, ...) diff --git a/handle.c b/handle.c index 0719754..ef3f2b5 100644 --- a/handle.c +++ b/handle.c @@ -314,7 +314,7 @@ static void handleJoin(struct Message *msg) { msg->params[2] = NULL; } uiFormat( - id, ignoreCheck(Cold, msg), tagTime(msg), + id, ignoreCheck(Cold, id, msg), tagTime(msg), "\3%02d%s\3\t%s%s%sarrives in \3%02d%s\3", hash(msg->user), msg->nick, (msg->params[2] ? "(" : ""), @@ -346,7 +346,7 @@ static void handlePart(struct Message *msg) { completeRemove(id, msg->nick); urlScan(id, msg->nick, msg->params[1]); uiFormat( - id, ignoreCheck(Cold, msg), tagTime(msg), + id, ignoreCheck(Cold, id, msg), tagTime(msg), "\3%02d%s\3\tleaves \3%02d%s\3%s%s", hash(msg->user), msg->nick, hash(msg->params[0]), msg->params[0], (msg->params[1] ? ": " : ""), (msg->params[1] ?: "") @@ -393,7 +393,7 @@ static void handleNick(struct Message *msg) { set(&idNames[id], msg->params[0]); } uiFormat( - id, ignoreCheck(Cold, msg), tagTime(msg), + id, ignoreCheck(Cold, id, msg), tagTime(msg), "\3%02d%s\3\tis now known as \3%02d%s\3", hash(msg->user), msg->nick, hash(msg->user), msg->params[0] ); @@ -411,7 +411,7 @@ static void handleQuit(struct Message *msg) { for (uint id; (id = completeID(msg->nick));) { urlScan(id, msg->nick, msg->params[0]); uiFormat( - id, ignoreCheck(Cold, msg), tagTime(msg), + id, ignoreCheck(Cold, id, msg), tagTime(msg), "\3%02d%s\3\tleaves%s%s", hash(msg->user), msg->nick, (msg->params[0] ? ": " : ""), (msg->params[0] ?: "") @@ -430,7 +430,7 @@ static void handleInvite(struct Message *msg) { require(msg, true, 2); if (!strcmp(msg->params[0], self.nick)) { uiFormat( - Network, ignoreCheck(Hot, msg), tagTime(msg), + Network, ignoreCheck(Hot, Network, msg), tagTime(msg), "\3%02d%s\3\tinvites you to \3%02d%s\3", hash(msg->user), msg->nick, hash(msg->params[1]), msg->params[1] ); @@ -1106,12 +1106,13 @@ static void handlePrivmsg(struct Message *msg) { bool mention = !mine && isMention(msg); if (!notice && !mine) completeTouch(id, msg->nick, hash(msg->user)); urlScan(id, msg->nick, msg->params[1]); + enum Heat heat = ignoreCheck((mention || query ? Hot : Warm), id, msg); if (notice) { if (id != Network) { logFormat(id, tagTime(msg), "-%s- %s", msg->nick, msg->params[1]); } uiFormat( - id, ignoreCheck(Warm, msg), tagTime(msg), + id, ignoreCheck(Warm, id, msg), tagTime(msg), "\3%d-%s-\3%d\t%s", hash(msg->user), msg->nick, LightGray, msg->params[1] ); @@ -1119,7 +1120,7 @@ static void handlePrivmsg(struct Message *msg) { logFormat(id, tagTime(msg), "* %s %s", msg->nick, msg->params[1]); const char *mentions = colorMentions(id, msg); uiFormat( - id, ignoreCheck((mention || query ? Hot : Warm), msg), tagTime(msg), + id, heat, tagTime(msg), "%s\35\3%d* %s\17\35\t%s%s", (mention ? "\26" : ""), hash(msg->user), msg->nick, mentions, msg->params[1] @@ -1128,7 +1129,7 @@ static void handlePrivmsg(struct Message *msg) { logFormat(id, tagTime(msg), "<%s> %s", msg->nick, msg->params[1]); const char *mentions = colorMentions(id, msg); uiFormat( - id, ignoreCheck((mention || query ? Hot : Warm), msg), tagTime(msg), + id, heat, tagTime(msg), "%s\3%d<%s>\17\t%s%s", (mention ? "\26" : ""), hash(msg->user), msg->nick, mentions, msg->params[1] diff --git a/ignore.c b/ignore.c index d65c35a..8aa3e1b 100644 --- a/ignore.c +++ b/ignore.c @@ -58,11 +58,11 @@ bool ignoreRemove(const char *pattern) { return found; } -enum Heat ignoreCheck(enum Heat heat, const struct Message *msg) { +enum Heat ignoreCheck(enum Heat heat, uint id, const struct Message *msg) { char match[512]; snprintf( match, sizeof(match), "%s!%s@%s %s %s", - msg->nick, msg->user, msg->host, msg->cmd, (msg->params[0] ?: "") + msg->nick, msg->user, msg->host, msg->cmd, idNames[id] ); for (size_t i = 0; i < ignore.len; ++i) { if (fnmatch(ignore.patterns[i], match, FNM_CASEFOLD)) continue; -- cgit 1.4.1