summaryrefslogtreecommitdiff
path: root/src/core/ignore.c
diff options
context:
space:
mode:
authorDavid Leadbeater <dgl@dgl.cx>2014-06-29 22:07:33 +0100
committerDavid Leadbeater <dgl@dgl.cx>2014-06-30 00:31:53 +0100
commit819f9d16c9fbb014f6bd4ed88b57689347674727 (patch)
treef3965125a401ceaaf9631d68660dfbb91e9be5ac /src/core/ignore.c
parent2b6bba3fd2019158990f13d9e8913fd3bbb20b61 (diff)
downloadirssi-819f9d16c9fbb014f6bd4ed88b57689347674727.zip
Change NO_ACT so it can be used in addition to other ignores
This results in a more flexible system and is less surprising as it means levels can be used in the way they normally can in an ignore. As an example the current approach to NO_ACT provides no way to let HILIGHTS be shown, with this change /set activity_hide_targets can be recreated with: /ignore #channel NO_ACT /ignore #channel -except -regexp -pattern . NO_ACT HILIGHTS (but obviously this can be configured in many more ways if desired).
Diffstat (limited to 'src/core/ignore.c')
-rw-r--r--src/core/ignore.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/core/ignore.c b/src/core/ignore.c
index a7aa106f..63b8f279 100644
--- a/src/core/ignore.c
+++ b/src/core/ignore.c
@@ -104,8 +104,15 @@ static int ignore_match_pattern(IGNORE_REC *rec, const char *text)
stristr(text, rec->pattern) != NULL;
}
+/* MSGLEVEL_NO_ACT is special in ignores, when provided to ignore_check() it's
+ * 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 ignore_match_level(rec, level) \
- ((level & (rec)->level) != 0)
+ (((level & MSGLEVEL_NO_ACT) != 0) ? \
+ ((~MSGLEVEL_NO_ACT & level) & (rec)->level) != 0 : \
+ ((rec)->level & MSGLEVEL_NO_ACT ? 0 : \
+ (level & (rec)->level) != 0))
#define ignore_match_nickmask(rec, nick, nickmask) \
((rec)->mask == NULL || \
@@ -180,7 +187,14 @@ int ignore_check(SERVER_REC *server, const char *nick, const char *host,
}
IGNORE_REC *ignore_find(const char *servertag, const char *mask,
- char **channels)
+ char **channels)
+{
+ return ignore_find_noact(servertag, mask, channels, 0);
+}
+
+
+IGNORE_REC *ignore_find_noact(const char *servertag, const char *mask,
+ char **channels, int noact)
{
GSList *tmp;
char **chan;
@@ -202,6 +216,12 @@ IGNORE_REC *ignore_find(const char *servertag, const char *mask,
continue;
}
+ if (noact && (rec->level & MSGLEVEL_NO_ACT) == 0)
+ continue;
+
+ if (!noact && (rec->level & MSGLEVEL_NO_ACT) != 0)
+ continue;
+
if ((rec->mask == NULL && mask != NULL) ||
(rec->mask != NULL && mask == NULL)) continue;