From f8e3cfa34673a2f6bee068f725e2044f2afbeec2 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 9 Jun 2018 16:21:41 -0700 Subject: [PATCH] antispam: strip IRC formatting by default before processing Closes #615. --- example-conf.yml | 4 ++++ plugins/antispam.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/example-conf.yml b/example-conf.yml index e21fc47..cb2db5e 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -836,6 +836,10 @@ stats: # Valid values are "voice", "halfop", and "op". This defaults to "halfop" if not set. #exempt_level: halfop + # Determines whether Antispam should strip formatting before applying filter checks. + # Defaults to true if not set. + #strip_formatting: true + #masshighlight: # This block configures options for antispam's mass highlight blocking. It can also be # overridden (as an entire block) per-network by copying its options under diff --git a/plugins/antispam.py b/plugins/antispam.py index a8f7d62..6990325 100644 --- a/plugins/antispam.py +++ b/plugins/antispam.py @@ -177,6 +177,9 @@ def handle_masshighlight(irc, source, command, args): log.debug("(%s) antispam.masshighlight: skipping processing message %r; it's too short", irc.name, text) return + if irc.get_service_option('antispam', 'strip_formatting', True): + text = utils.strip_irc_formatting(text) + # Strip :, from potential nicks words = [word.rstrip(':,') for word in text.split()] @@ -272,6 +275,9 @@ def handle_textfilter(irc, source, command, args): punishment = txf_settings.get('punishment', TEXTFILTER_DEFAULTS['punishment']).lower() reason = txf_settings.get('reason', TEXTFILTER_DEFAULTS['reason']) + if irc.get_service_option('antispam', 'strip_formatting', True): + text = utils.strip_irc_formatting(text) + punished = False for filterglob in txf_globs: if ircmatch.match(1, filterglob, text):