1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

Merge pull request #884 from vague666/ignore_hidden

Added HIDDEN level to ignores
This commit is contained in:
ailin-nemui 2018-06-15 14:28:09 +02:00 committed by GitHub
commit b382bd1232
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 80 additions and 7 deletions

View File

@ -81,10 +81,11 @@ static int ignore_match_pattern(IGNORE_REC *rec, const char *text)
* used as a flag to indicate it should only look at ignore items with NO_ACT. * used as a flag to indicate it should only look at ignore items with NO_ACT.
* However we also want to allow NO_ACT combined with levels, so mask it out and * However we also want to allow NO_ACT combined with levels, so mask it out and
* match levels if set. */ * match levels if set. */
#define FLAG_MSGLEVELS ( MSGLEVEL_NO_ACT | MSGLEVEL_HIDDEN )
#define ignore_match_level(rec, level) \ #define ignore_match_level(rec, level) \
(((level & MSGLEVEL_NO_ACT) != 0) ? \ (((level & FLAG_MSGLEVELS) != 0) ? \
((~MSGLEVEL_NO_ACT & level) & (rec)->level) != 0 : \ ((~FLAG_MSGLEVELS & level) & (rec)->level) != 0 : \
((rec)->level & MSGLEVEL_NO_ACT ? 0 : \ ((rec)->level & FLAG_MSGLEVELS ? 0 : \
(level & (rec)->level) != 0)) (level & (rec)->level) != 0))
#define ignore_match_nickmask(rec, nick, nickmask) \ #define ignore_match_nickmask(rec, nick, nickmask) \
@ -212,6 +213,12 @@ IGNORE_REC *ignore_find_full(const char *servertag, const char *mask, const char
if (!(flags & IGNORE_FIND_NOACT) && (rec->level & MSGLEVEL_NO_ACT) != 0) if (!(flags & IGNORE_FIND_NOACT) && (rec->level & MSGLEVEL_NO_ACT) != 0)
continue; continue;
if ((flags & IGNORE_FIND_HIDDEN) && (rec->level & MSGLEVEL_HIDDEN) == 0)
continue;
if (!(flags & IGNORE_FIND_HIDDEN) && (rec->level & MSGLEVEL_HIDDEN) != 0)
continue;
if ((rec->mask == NULL && mask != NULL) || if ((rec->mask == NULL && mask != NULL) ||
(rec->mask != NULL && mask == NULL)) (rec->mask != NULL && mask == NULL))
continue; continue;
@ -264,6 +271,11 @@ IGNORE_REC *ignore_find_noact(const char *servertag, const char *mask, char **ch
return ignore_find_full(servertag, mask, NULL, channels, IGNORE_FIND_NOACT); return ignore_find_full(servertag, mask, NULL, channels, IGNORE_FIND_NOACT);
} }
IGNORE_REC *ignore_find_hidden(const char *servertag, const char *mask, char **channels, int hidden)
{
return ignore_find_full(servertag, mask, NULL, channels, IGNORE_FIND_HIDDEN);
}
static void ignore_set_config(IGNORE_REC *rec) static void ignore_set_config(IGNORE_REC *rec)
{ {
CONFIG_NODE *node; CONFIG_NODE *node;

View File

@ -29,6 +29,7 @@ int ignore_check(SERVER_REC *server, const char *nick, const char *host,
enum { enum {
IGNORE_FIND_PATTERN = 0x01, /* Match the pattern */ IGNORE_FIND_PATTERN = 0x01, /* Match the pattern */
IGNORE_FIND_NOACT = 0x02, /* Exclude the targets with NOACT level */ IGNORE_FIND_NOACT = 0x02, /* Exclude the targets with NOACT level */
IGNORE_FIND_HIDDEN = 0x04, /* Exclude the targets with HIDDEN level */
}; };
IGNORE_REC *ignore_find_full (const char *servertag, const char *mask, const char *pattern, IGNORE_REC *ignore_find_full (const char *servertag, const char *mask, const char *pattern,
@ -38,6 +39,7 @@ IGNORE_REC *ignore_find_full (const char *servertag, const char *mask, const cha
IGNORE_REC *ignore_find(const char *servertag, const char *mask, char **channels); IGNORE_REC *ignore_find(const char *servertag, const char *mask, char **channels);
IGNORE_REC *ignore_find_noact(const char *servertag, const char *mask, char **channels, int noact); IGNORE_REC *ignore_find_noact(const char *servertag, const char *mask, char **channels, int noact);
IGNORE_REC *ignore_find_hidden(const char *servertag, const char *mask, char **channels, int hidden);
void ignore_add_rec(IGNORE_REC *rec); void ignore_add_rec(IGNORE_REC *rec);
void ignore_update_rec(IGNORE_REC *rec); void ignore_update_rec(IGNORE_REC *rec);

View File

@ -118,7 +118,7 @@ static void cmd_ignore(const char *data)
char *patternarg, *chanarg, *mask, *levels, *timestr, *servertag; char *patternarg, *chanarg, *mask, *levels, *timestr, *servertag;
char **channels; char **channels;
void *free_arg; void *free_arg;
int new_ignore, msecs, level; int new_ignore, msecs, level, flags;
if (*data == '\0') { if (*data == '\0') {
cmd_ignore_show(); cmd_ignore_show();
@ -156,8 +156,13 @@ static void cmd_ignore(const char *data)
channels = (chanarg == NULL || *chanarg == '\0') ? NULL : channels = (chanarg == NULL || *chanarg == '\0') ? NULL :
g_strsplit(chanarg, ",", -1); g_strsplit(chanarg, ",", -1);
rec = ignore_find_full(servertag, mask, patternarg, channels, flags = IGNORE_FIND_PATTERN;
IGNORE_FIND_PATTERN | ((level & MSGLEVEL_NO_ACT) ? IGNORE_FIND_NOACT : 0)); if (level & MSGLEVEL_NO_ACT)
flags |= IGNORE_FIND_NOACT;
if (level & MSGLEVEL_HIDDEN)
flags |= IGNORE_FIND_HIDDEN;
rec = ignore_find_full(servertag, mask, patternarg, channels, flags);
new_ignore = rec == NULL; new_ignore = rec == NULL;
if (rec == NULL) { if (rec == NULL) {
@ -179,6 +184,12 @@ static void cmd_ignore(const char *data)
rec->level |= MSGLEVEL_ALL; rec->level |= MSGLEVEL_ALL;
} }
if (rec->level == MSGLEVEL_HIDDEN) {
/* If only HIDDEN was specified add all levels; it makes no
* sense on its own. */
rec->level |= MSGLEVEL_ALL;
}
if (new_ignore && rec->level == 0) { if (new_ignore && rec->level == 0) {
/* tried to unignore levels from nonexisting ignore */ /* tried to unignore levels from nonexisting ignore */
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,

View File

@ -204,6 +204,9 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
if (ignore_check(server, nick, address, target, msg, level | MSGLEVEL_NO_ACT)) if (ignore_check(server, nick, address, target, msg, level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(server, nick, address, target, msg, level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
if (settings_get_bool("emphasis")) if (settings_get_bool("emphasis"))
msg = freemsg = expand_emphasis((WI_ITEM_REC *) chanrec, msg); msg = freemsg = expand_emphasis((WI_ITEM_REC *) chanrec, msg);
@ -263,6 +266,9 @@ static void sig_message_private(SERVER_REC *server, const char *msg,
if (ignore_check(server, nick, address, NULL, msg, level | MSGLEVEL_NO_ACT)) if (ignore_check(server, nick, address, NULL, msg, level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(server, nick, address, NULL, msg, level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
if (own) { if (own) {
printformat(server, target, level, printformat(server, target, level,
query == NULL ? TXT_OWN_MSG_PRIVATE : query == NULL ? TXT_OWN_MSG_PRIVATE :
@ -358,6 +364,9 @@ static void sig_message_join(SERVER_REC *server, const char *channel,
if (ignore_check(server, nick, address, channel, NULL, level | MSGLEVEL_NO_ACT)) if (ignore_check(server, nick, address, channel, NULL, level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(server, nick, address, channel, NULL, level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
printformat(server, channel, level, printformat(server, channel, level,
TXT_JOIN, nick, address, channel); TXT_JOIN, nick, address, channel);
} }
@ -371,6 +380,9 @@ static void sig_message_part(SERVER_REC *server, const char *channel,
if (ignore_check(server, nick, address, channel, NULL, level | MSGLEVEL_NO_ACT)) if (ignore_check(server, nick, address, channel, NULL, level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(server, nick, address, channel, NULL, level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
printformat(server, channel, level, printformat(server, channel, level,
TXT_PART, nick, address, channel, reason); TXT_PART, nick, address, channel, reason);
} }
@ -390,6 +402,9 @@ static void sig_message_quit(SERVER_REC *server, const char *nick,
if (ignore_check(server, nick, address, NULL, reason, level | MSGLEVEL_NO_ACT)) if (ignore_check(server, nick, address, NULL, reason, level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(server, nick, address, NULL, reason, level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
print_channel = NULL; print_channel = NULL;
once = settings_get_bool("show_quit_once"); once = settings_get_bool("show_quit_once");
@ -412,6 +427,9 @@ static void sig_message_quit(SERVER_REC *server, const char *nick,
if (ignore_check(server, nick, address, rec->visible_name, reason, MSGLEVEL_NO_ACT)) if (ignore_check(server, nick, address, rec->visible_name, reason, MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(server, nick, address, rec->visible_name, reason, MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
if (print_channel == NULL || if (print_channel == NULL ||
active_win->active == (WI_ITEM_REC *) rec) active_win->active == (WI_ITEM_REC *) rec)
print_channel = rec->visible_name; print_channel = rec->visible_name;
@ -461,6 +479,9 @@ static void sig_message_kick(SERVER_REC *server, const char *channel,
if (ignore_check(server, kicker, address, channel, reason, level | MSGLEVEL_NO_ACT)) if (ignore_check(server, kicker, address, channel, reason, level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(server, kicker, address, channel, reason, level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
printformat(server, channel, level, printformat(server, channel, level,
TXT_KICK, nick, channel, kicker, reason, address); TXT_KICK, nick, channel, kicker, reason, address);
} }
@ -482,6 +503,9 @@ static void print_nick_change_channel(SERVER_REC *server, const char *channel,
if (!(level & MSGLEVEL_NO_ACT) && ignore_check(server, oldnick, address, channel, newnick, level | MSGLEVEL_NO_ACT)) if (!(level & MSGLEVEL_NO_ACT) && ignore_check(server, oldnick, address, channel, newnick, level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (!(level & MSGLEVEL_HIDDEN) && ignore_check(server, oldnick, address, channel, newnick, level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
printformat(server, channel, level, printformat(server, channel, level,
ownnick ? TXT_YOUR_NICK_CHANGED : TXT_NICK_CHANGED, ownnick ? TXT_YOUR_NICK_CHANGED : TXT_NICK_CHANGED,
oldnick, newnick, channel, address); oldnick, newnick, channel, address);
@ -561,6 +585,9 @@ static void sig_message_topic(SERVER_REC *server, const char *channel,
if (ignore_check(server, nick, address, channel, topic, level | MSGLEVEL_NO_ACT)) if (ignore_check(server, nick, address, channel, topic, level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(server, nick, address, channel, topic, level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
printformat(server, channel, level, printformat(server, channel, level,
*topic != '\0' ? TXT_NEW_TOPIC : TXT_TOPIC_UNSET, *topic != '\0' ? TXT_NEW_TOPIC : TXT_TOPIC_UNSET,
nick, channel, topic, address); nick, channel, topic, address);

View File

@ -125,7 +125,7 @@ static void read_settings(void)
hide_targets = *targets == '\0' ? NULL : hide_targets = *targets == '\0' ? NULL :
g_strsplit(targets, " ", -1); g_strsplit(targets, " ", -1);
hide_level = MSGLEVEL_NEVER | MSGLEVEL_NO_ACT | hide_level = MSGLEVEL_NEVER | MSGLEVEL_NO_ACT | MSGLEVEL_HIDDEN |
settings_get_level("activity_hide_level"); settings_get_level("activity_hide_level");
msg_level = settings_get_level("activity_msg_level"); msg_level = settings_get_level("activity_msg_level");
hilight_level = MSGLEVEL_HILIGHT | hilight_level = MSGLEVEL_HILIGHT |

View File

@ -96,6 +96,10 @@ static void sig_message_dcc(CHAT_DCC_REC *dcc, const char *msg)
level | MSGLEVEL_NO_ACT)) level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(SERVER(dcc->server), tag, dcc->addrstr, NULL, msg,
level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
format_create_dest_tag(&dest, dcc->server, dcc->servertag, tag, format_create_dest_tag(&dest, dcc->server, dcc->servertag, tag,
level, NULL); level, NULL);
@ -118,6 +122,10 @@ static void sig_message_dcc_action(CHAT_DCC_REC *dcc, const char *msg)
level | MSGLEVEL_NO_ACT)) level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(SERVER(dcc->server), tag, dcc->addrstr, NULL, msg,
level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
format_create_dest_tag(&dest, dcc->server, dcc->servertag, tag, format_create_dest_tag(&dest, dcc->server, dcc->servertag, tag,
level, NULL); level, NULL);
@ -139,6 +147,10 @@ static void sig_message_dcc_ctcp(CHAT_DCC_REC *dcc, const char *cmd,
level | MSGLEVEL_NO_ACT)) level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(SERVER(dcc->server), tag, dcc->addrstr, NULL, cmd,
level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
format_create_dest_tag(&dest, dcc->server, dcc->servertag, tag, format_create_dest_tag(&dest, dcc->server, dcc->servertag, tag,
level, NULL); level, NULL);

View File

@ -162,6 +162,10 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
level | MSGLEVEL_NO_ACT)) level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(SERVER(server), nick, address, target, msg,
level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
if (server_ischannel(SERVER(server), target)) { if (server_ischannel(SERVER(server), target)) {
item = irc_channel_find(server, target); item = irc_channel_find(server, target);
} else { } else {
@ -241,6 +245,11 @@ static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
msg, level | MSGLEVEL_NO_ACT)) msg, level | MSGLEVEL_NO_ACT))
level |= MSGLEVEL_NO_ACT; level |= MSGLEVEL_NO_ACT;
if (ignore_check(server, nick, address,
server_ischannel(SERVER(server), target) ? target : NULL,
msg, level | MSGLEVEL_HIDDEN))
level |= MSGLEVEL_HIDDEN;
if (server_ischannel(SERVER(server), target)) { if (server_ischannel(SERVER(server), target)) {
/* notice in some channel */ /* notice in some channel */
printformat(server, target, level, printformat(server, target, level,