about summary refs log tree commit diff
path: root/command.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-03-31 14:30:42 -0400
committerJune McEnroe <june@causal.agency>2020-03-31 14:30:42 -0400
commit25f419465f019feedb7266cb68232d1b32a66957 (patch)
tree67dffcc716ad457967f884cb25f448de27634f64 /command.c
parentSave and load buffer line heat (diff)
downloadcatgirl-25f419465f019feedb7266cb68232d1b32a66957.tar.gz
catgirl-25f419465f019feedb7266cb68232d1b32a66957.zip
Add /ignore message filtering patterns
Diffstat (limited to 'command.c')
-rw-r--r--command.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/command.c b/command.c
index 8782ee6..5872bdc 100644
--- a/command.c
+++ b/command.c
@@ -348,6 +348,35 @@ static void commandCopy(uint id, char *params) {
 	urlCopyMatch(id, params);
 }
 
+static void commandIgnore(uint id, char *params) {
+	if (params) {
+		const char *pattern = ignoreAdd(params);
+		uiFormat(
+			id, Cold, NULL, "Ignoring \3%02d%s\3",
+			Brown, pattern
+		);
+	} else {
+		for (size_t i = 0; i < ignore.len; ++i) {
+			uiFormat(
+				Network, Warm, NULL, "Ignoring \3%02d%s\3",
+				Brown, ignore.patterns[i]
+			);
+		}
+	}
+}
+
+static void commandUnignore(uint id, char *params) {
+	if (!params) return;
+	if (ignoreRemove(params)) {
+		uiFormat(
+			id, Cold, NULL, "No longer ignoring \3%02d%s\3",
+			Brown, params
+		);
+	} else {
+		uiFormat(id, Cold, NULL, "Not ignoring \3%02d%s\3", Brown, params);
+	}
+}
+
 static void commandExec(uint id, char *params) {
 	execID = id;
 
@@ -404,6 +433,7 @@ static const struct Handler {
 	{ "/except", commandExcept, 0 },
 	{ "/exec", commandExec, Multiline | Restricted },
 	{ "/help", commandHelp, 0 },
+	{ "/ignore", commandIgnore, 0 },
 	{ "/invex", commandInvex, 0 },
 	{ "/invite", commandInvite, 0 },
 	{ "/join", commandJoin, Restricted },
@@ -428,6 +458,7 @@ static const struct Handler {
 	{ "/topic", commandTopic, 0 },
 	{ "/unban", commandUnban, 0 },
 	{ "/unexcept", commandUnexcept, 0 },
+	{ "/unignore", commandUnignore, 0 },
 	{ "/uninvex", commandUninvex, 0 },
 	{ "/voice", commandVoice, 0 },
 	{ "/whois", commandWhois, 0 },