mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
Merge pull request #1260 from ailin-nemui/nohilight
add /IGNORE ... NOHILIGHT to ignore some hilights
This commit is contained in:
commit
f93879baff
@ -81,7 +81,7 @@ 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.
|
||||
* However we also want to allow NO_ACT combined with levels, so mask it out and
|
||||
* match levels if set. */
|
||||
#define FLAG_MSGLEVELS ( MSGLEVEL_NO_ACT | MSGLEVEL_HIDDEN )
|
||||
#define FLAG_MSGLEVELS (MSGLEVEL_NO_ACT | MSGLEVEL_HIDDEN | MSGLEVEL_NOHILIGHT)
|
||||
static int ignore_match_level(IGNORE_REC *rec, int level, int flags)
|
||||
{
|
||||
level &= ~FLAG_MSGLEVELS;
|
||||
@ -214,6 +214,9 @@ int ignore_check_plus(SERVER_REC *server, const char *nick, const char *address,
|
||||
if (ignore_check_flags(server, nick, address, target, msg, olevel, MSGLEVEL_HIDDEN))
|
||||
*level |= MSGLEVEL_HIDDEN;
|
||||
|
||||
if (ignore_check_flags(server, nick, address, target, msg, olevel, MSGLEVEL_NOHILIGHT))
|
||||
*level |= MSGLEVEL_NOHILIGHT;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -252,6 +255,12 @@ IGNORE_REC *ignore_find_full(const char *servertag, const char *mask, const char
|
||||
if (!(flags & IGNORE_FIND_HIDDEN) && (rec->level & MSGLEVEL_HIDDEN) != 0)
|
||||
continue;
|
||||
|
||||
if ((flags & IGNORE_FIND_NOHILIGHT) && (rec->level & MSGLEVEL_NOHILIGHT) == 0)
|
||||
continue;
|
||||
|
||||
if (!(flags & IGNORE_FIND_NOHILIGHT) && (rec->level & MSGLEVEL_NOHILIGHT) != 0)
|
||||
continue;
|
||||
|
||||
if ((rec->mask == NULL && mask != NULL) ||
|
||||
(rec->mask != NULL && mask == NULL))
|
||||
continue;
|
||||
@ -299,16 +308,6 @@ IGNORE_REC *ignore_find(const char *servertag, const char *mask, char **channels
|
||||
return ignore_find_full(servertag, mask, NULL, channels, 0);
|
||||
}
|
||||
|
||||
IGNORE_REC *ignore_find_noact(const char *servertag, const char *mask, char **channels, int 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)
|
||||
{
|
||||
CONFIG_NODE *node;
|
||||
|
@ -31,9 +31,10 @@ int ignore_check_plus(SERVER_REC *server, const char *nick, const char *host,
|
||||
const char *channel, const char *text, int *level, int test_ignore);
|
||||
|
||||
enum {
|
||||
IGNORE_FIND_PATTERN = 0x01, /* Match the pattern */
|
||||
IGNORE_FIND_NOACT = 0x02, /* Exclude the targets with NOACT level */
|
||||
IGNORE_FIND_HIDDEN = 0x04, /* Exclude the targets with HIDDEN level */
|
||||
IGNORE_FIND_PATTERN = 0x01, /* Match the pattern */
|
||||
IGNORE_FIND_NOACT = 0x02, /* Exclude the targets with NOACT level */
|
||||
IGNORE_FIND_HIDDEN = 0x04, /* Exclude the targets with HIDDEN level */
|
||||
IGNORE_FIND_NOHILIGHT = 0x08, /* Exclude the targets with NOHILIGHT level */
|
||||
};
|
||||
|
||||
IGNORE_REC *ignore_find_full (const char *servertag, const char *mask, const char *pattern,
|
||||
@ -42,8 +43,6 @@ IGNORE_REC *ignore_find_full (const char *servertag, const char *mask, const cha
|
||||
/* Convenience wrappers around ignore_find_full, for compatibility purpose */
|
||||
|
||||
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_hidden(const char *servertag, const char *mask, char **channels, int hidden);
|
||||
|
||||
void ignore_add_rec(IGNORE_REC *rec);
|
||||
void ignore_update_rec(IGNORE_REC *rec);
|
||||
|
@ -61,6 +61,9 @@ int level_get(const char *level)
|
||||
if (g_ascii_strcasecmp(level, "NO_ACT") == 0)
|
||||
return MSGLEVEL_NO_ACT;
|
||||
|
||||
if (g_ascii_strcasecmp(level, "NOHILIGHT") == 0)
|
||||
return MSGLEVEL_NOHILIGHT;
|
||||
|
||||
if (g_ascii_strcasecmp(level, "HIDDEN") == 0)
|
||||
return MSGLEVEL_HIDDEN;
|
||||
|
||||
@ -154,6 +157,9 @@ char *bits2level(int bits)
|
||||
}
|
||||
}
|
||||
|
||||
if (bits & MSGLEVEL_NOHILIGHT)
|
||||
g_string_append(str, "NOHILIGHT ");
|
||||
|
||||
if (bits & MSGLEVEL_HIDDEN)
|
||||
g_string_append(str, "HIDDEN ");
|
||||
|
||||
|
@ -169,6 +169,8 @@ static void cmd_ignore(const char *data)
|
||||
flags |= IGNORE_FIND_NOACT;
|
||||
if (level & MSGLEVEL_HIDDEN)
|
||||
flags |= IGNORE_FIND_HIDDEN;
|
||||
if (level & MSGLEVEL_NOHILIGHT)
|
||||
flags |= IGNORE_FIND_NOHILIGHT;
|
||||
|
||||
rec = ignore_find_full(servertag, mask, patternarg, channels, flags);
|
||||
new_ignore = rec == NULL;
|
||||
@ -198,6 +200,12 @@ static void cmd_ignore(const char *data)
|
||||
rec->level |= MSGLEVEL_ALL;
|
||||
}
|
||||
|
||||
if (rec->level == MSGLEVEL_NOHILIGHT) {
|
||||
/* If only NOHILIGHT was specified add all levels; it makes no
|
||||
* sense on its own. */
|
||||
rec->level |= MSGLEVEL_ALL;
|
||||
}
|
||||
|
||||
if (new_ignore && rec->level == 0) {
|
||||
/* tried to unignore levels from nonexisting ignore */
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||
|
@ -202,6 +202,11 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
|
||||
level |= MSGLEVEL_HILIGHT;
|
||||
|
||||
ignore_check_plus(server, nick, address, target, msg, &level, FALSE);
|
||||
if (level & MSGLEVEL_NOHILIGHT) {
|
||||
for_me = FALSE;
|
||||
g_free_and_null(color);
|
||||
level &= ~MSGLEVEL_HILIGHT;
|
||||
}
|
||||
|
||||
if (settings_get_bool("emphasis"))
|
||||
msg = freemsg = expand_emphasis((WI_ITEM_REC *) chanrec, msg);
|
||||
|
@ -114,6 +114,12 @@ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
|
||||
return;
|
||||
}
|
||||
|
||||
if (level & MSGLEVEL_NOHILIGHT) {
|
||||
for_me = FALSE;
|
||||
g_free_and_null(color);
|
||||
level &= ~MSGLEVEL_HILIGHT;
|
||||
}
|
||||
|
||||
if (settings_get_bool("emphasis"))
|
||||
msg = freemsg = expand_emphasis((WI_ITEM_REC *) chanrec, msg);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user