mirror of
https://github.com/irssi/irssi.git
synced 2026-08-19 16:42:30 +02:00
correctly separate ignore flags (no_act, hidden) from level
This commit is contained in:
parent
7f14d4d744
commit
b9a274a81d
7 changed files with 92 additions and 57 deletions
|
|
@ -82,17 +82,12 @@ static int ignore_match_pattern(IGNORE_REC *rec, const char *text)
|
|||
* 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 )
|
||||
static int ignore_match_level(IGNORE_REC *rec, int level)
|
||||
static int ignore_match_level(IGNORE_REC *rec, int level, int flags)
|
||||
{
|
||||
if (level & FLAG_MSGLEVELS) {
|
||||
int flaglevel = level & FLAG_MSGLEVELS;
|
||||
int msglevel = level & ~FLAG_MSGLEVELS;
|
||||
return (msglevel & rec->level) && (flaglevel & rec->level);
|
||||
} else if (!(rec->level & FLAG_MSGLEVELS)) {
|
||||
return (level & rec->level);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
level &= ~FLAG_MSGLEVELS;
|
||||
flags &= FLAG_MSGLEVELS;
|
||||
|
||||
return ((flags & rec->level) == flags) && ((level & rec->level) != 0);
|
||||
}
|
||||
|
||||
#define ignore_match_nickmask(rec, nick, nickmask) \
|
||||
|
|
@ -109,7 +104,7 @@ static int ignore_match_level(IGNORE_REC *rec, int level)
|
|||
((rec)->channels == NULL || ((channel) != NULL && \
|
||||
strarray_find((rec)->channels, (channel)) != -1))
|
||||
|
||||
static int ignore_check_replies(CHANNEL_REC *chanrec, const char *text, int level)
|
||||
static int ignore_check_replies(CHANNEL_REC *chanrec, const char *text, int level, int flags)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
|
|
@ -121,7 +116,7 @@ static int ignore_check_replies(CHANNEL_REC *chanrec, const char *text, int leve
|
|||
IGNORE_REC *rec = tmp->data;
|
||||
|
||||
if (rec->mask != NULL && rec->replies &&
|
||||
ignore_match_level(rec, level) &&
|
||||
ignore_match_level(rec, level, flags) &&
|
||||
ignore_match_channel(rec, chanrec->name) &&
|
||||
ignore_check_replies_rec(rec, chanrec, text))
|
||||
return TRUE;
|
||||
|
|
@ -130,8 +125,8 @@ static int ignore_check_replies(CHANNEL_REC *chanrec, const char *text, int leve
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
int ignore_check(SERVER_REC *server, const char *nick, const char *host,
|
||||
const char *channel, const char *text, int level)
|
||||
int ignore_check_flags(SERVER_REC *server, const char *nick, const char *host,
|
||||
const char *channel, const char *text, int level, int flags)
|
||||
{
|
||||
CHANNEL_REC *chanrec;
|
||||
NICK_REC *nickrec;
|
||||
|
|
@ -167,7 +162,7 @@ int ignore_check(SERVER_REC *server, const char *nick, const char *host,
|
|||
ignore_match_channel(rec, channel) &&
|
||||
ignore_match_nickmask(rec, nick, nickmask);
|
||||
if (match &&
|
||||
ignore_match_level(rec, level) &&
|
||||
ignore_match_level(rec, level, flags) &&
|
||||
ignore_match_pattern(rec, text)) {
|
||||
len = rec->mask == NULL ? 0 : strlen(rec->mask);
|
||||
if (len > best_mask) {
|
||||
|
|
@ -188,7 +183,12 @@ int ignore_check(SERVER_REC *server, const char *nick, const char *host,
|
|||
if (best_match || (level & MSGLEVEL_PUBLIC) == 0)
|
||||
return best_match;
|
||||
|
||||
return ignore_check_replies(chanrec, text, level);
|
||||
return ignore_check_replies(chanrec, text, level, flags);
|
||||
}
|
||||
|
||||
int ignore_check(SERVER_REC *server, const char *nick, const char *host,
|
||||
const char *channel, const char *text, int level) {
|
||||
return ignore_check_flags(server, nick, host, channel, text, level, 0);
|
||||
}
|
||||
|
||||
IGNORE_REC *ignore_find_full(const char *servertag, const char *mask, const char *pattern,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ extern GSList *ignores;
|
|||
|
||||
int ignore_check(SERVER_REC *server, const char *nick, const char *host,
|
||||
const char *channel, const char *text, int level);
|
||||
int ignore_check_flags(SERVER_REC *server, const char *nick, const char *host,
|
||||
const char *channel, const char *text, int level, int flags);
|
||||
|
||||
enum {
|
||||
IGNORE_FIND_PATTERN = 0x01, /* Match the pattern */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue