diff options
author | Tom Feist <shabble+irssi@metavore.org> | 2014-01-09 15:23:47 +0100 |
---|---|---|
committer | Ailin Nemui <ailin@esf51.localdomain> | 2014-06-18 23:40:26 +0200 |
commit | 7d87a025229d6ee4e292ad0b5492ab10a416f8d6 (patch) | |
tree | d6e7437fd940cead71db3197153f6534781a6971 | |
parent | b7c1fbd2b96a38cd1025cc353ac19cf3a5b2894c (diff) | |
download | irssi-7d87a025229d6ee4e292ad0b5492ab10a416f8d6.zip |
Add NO_ACT level
This patch adds a new NO_ACT level that can be used with /ignore to
ignore activity notifications
-rw-r--r-- | src/core/levels.c | 7 | ||||
-rw-r--r-- | src/fe-common/core/fe-messages.c | 47 |
2 files changed, 47 insertions, 7 deletions
diff --git a/src/core/levels.c b/src/core/levels.c index 3cc00e95..b47079ba 100644 --- a/src/core/levels.c +++ b/src/core/levels.c @@ -46,6 +46,7 @@ static const char *levels[] = { "HILIGHTS", "NOHILIGHT", + "NO_ACT", NULL }; @@ -59,6 +60,9 @@ int level_get(const char *level) if (g_ascii_strcasecmp(level, "NEVER") == 0) return MSGLEVEL_NEVER; + if (g_ascii_strcasecmp(level, "NO_ACT") == 0) + return MSGLEVEL_NO_ACT; + len = strlen(level); if (len == 0) return 0; @@ -139,6 +143,9 @@ char *bits2level(int bits) if (bits & MSGLEVEL_NEVER) g_string_append(str, "NEVER "); + if (bits & MSGLEVEL_NO_ACT) + g_string_append(str, "NO_ACT "); + for (n = 0; levels[n] != NULL; n++) { if (bits & (1L << n)) g_string_append_printf(str, "%s ", levels[n]); diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c index 846272fd..367863c7 100644 --- a/src/fe-common/core/fe-messages.c +++ b/src/fe-common/core/fe-messages.c @@ -190,6 +190,9 @@ static void sig_message_public(SERVER_REC *server, const char *msg, if (for_me) level |= MSGLEVEL_HILIGHT; + if (ignore_check(server, nick, address, target, msg, MSGLEVEL_NO_ACT)) + level |= MSGLEVEL_NO_ACT; + if (settings_get_bool("emphasis")) msg = freemsg = expand_emphasis((WI_ITEM_REC *) chanrec, msg); @@ -325,7 +328,12 @@ static void sig_message_own_private(SERVER_REC *server, const char *msg, static void sig_message_join(SERVER_REC *server, const char *channel, const char *nick, const char *address) { - printformat(server, channel, MSGLEVEL_JOINS, + int level = MSGLEVEL_JOINS; + + if (ignore_check(server, nick, address, channel, NULL, MSGLEVEL_NO_ACT)) + level |= MSGLEVEL_NO_ACT; + + printformat(server, channel, level, TXT_JOIN, nick, address, channel); } @@ -333,7 +341,12 @@ static void sig_message_part(SERVER_REC *server, const char *channel, const char *nick, const char *address, const char *reason) { - printformat(server, channel, MSGLEVEL_PARTS, + int level = MSGLEVEL_PARTS; + + if (ignore_check(server, nick, address, channel, NULL, MSGLEVEL_NO_ACT)) + level |= MSGLEVEL_NO_ACT; + + printformat(server, channel, level, TXT_PART, nick, address, channel, reason); } @@ -344,17 +357,21 @@ static void sig_message_quit(SERVER_REC *server, const char *nick, GString *chans; GSList *tmp, *windows; char *print_channel; - int once, count; + int once, count, level = MSGLEVEL_QUITS; if (ignore_check(server, nick, address, NULL, reason, MSGLEVEL_QUITS)) return; + if (ignore_check(server, nick, address, NULL, reason, MSGLEVEL_NO_ACT)) + level |= MSGLEVEL_NO_ACT; + print_channel = NULL; once = settings_get_bool("show_quit_once"); count = 0; windows = NULL; chans = g_string_new(NULL); for (tmp = server->channels; tmp != NULL; tmp = tmp->next) { + level = MSGLEVEL_QUITS; CHANNEL_REC *rec = tmp->data; if (!nicklist_find(rec, nick)) @@ -366,6 +383,9 @@ static void sig_message_quit(SERVER_REC *server, const char *nick, continue; } + if (ignore_check(server, nick, address, rec->visible_name, reason, MSGLEVEL_NO_ACT)) + level |= MSGLEVEL_NO_ACT; + if (print_channel == NULL || active_win->active == (WI_ITEM_REC *) rec) print_channel = rec->visible_name; @@ -377,7 +397,7 @@ static void sig_message_quit(SERVER_REC *server, const char *nick, if (g_slist_find(windows, window) == NULL) { windows = g_slist_append(windows, window); printformat(server, rec->visible_name, - MSGLEVEL_QUITS, + level, TXT_QUIT, nick, address, reason, rec->visible_name); } @@ -391,7 +411,7 @@ static void sig_message_quit(SERVER_REC *server, const char *nick, display the quit there too */ QUERY_REC *query = query_find(server, nick); if (query != NULL) { - printformat(server, nick, MSGLEVEL_QUITS, + printformat(server, nick, level, TXT_QUIT, nick, address, reason, ""); } } @@ -410,7 +430,12 @@ static void sig_message_kick(SERVER_REC *server, const char *channel, const char *nick, const char *kicker, const char *address, const char *reason) { - printformat(server, channel, MSGLEVEL_KICKS, + int level = MSGLEVEL_KICKS; + + if (ignore_check(server, kicker, address, channel, reason, MSGLEVEL_NO_ACT)) + level |= MSGLEVEL_NO_ACT; + + printformat(server, channel, level, TXT_KICK, nick, channel, kicker, reason, address); } @@ -428,6 +453,9 @@ static void print_nick_change_channel(SERVER_REC *server, const char *channel, level = MSGLEVEL_NICKS; if (ownnick) level |= MSGLEVEL_NO_ACT; + if (!(level & MSGLEVEL_NO_ACT) && ignore_check(server, oldnick, address, channel, newnick, MSGLEVEL_NO_ACT)) + level |= MSGLEVEL_NO_ACT; + printformat(server, channel, level, ownnick ? TXT_YOUR_NICK_CHANGED : TXT_NICK_CHANGED, oldnick, newnick, channel, address); @@ -502,7 +530,12 @@ static void sig_message_topic(SERVER_REC *server, const char *channel, const char *topic, const char *nick, const char *address) { - printformat(server, channel, MSGLEVEL_TOPICS, + int level = MSGLEVEL_TOPICS; + + if (ignore_check(server, nick, address, channel, topic, MSGLEVEL_NO_ACT)) + level |= MSGLEVEL_NO_ACT; + + printformat(server, channel, level, *topic != '\0' ? TXT_NEW_TOPIC : TXT_TOPIC_UNSET, nick, channel, topic, address); } |