From d04e8161d5eef565c9abc0fb73207c1a26c0efe6 Mon Sep 17 00:00:00 2001 From: SamStrongTalks <33920407+SamStrongTalks@users.noreply.github.com> Date: Fri, 17 Jun 2022 10:44:12 -0400 Subject: [PATCH] Add ability to exclude channel from self censoring (#1508) --- plugins/BadWords/config.py | 3 +++ plugins/BadWords/messages.pot | 10 ++++++++-- plugins/BadWords/plugin.py | 5 +++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/BadWords/config.py b/plugins/BadWords/config.py index bea4b0a33..9c9fb31ee 100644 --- a/plugins/BadWords/config.py +++ b/plugins/BadWords/config.py @@ -113,6 +113,9 @@ conf.registerGlobalValue(BadWords, 'stripFormatting', filtering. If it's True, however, it will interact poorly with other plugins that do coloring or bolding of text."""))) +conf.registerChannelValue(BadWords, 'selfCensor', + registry.Boolean(True, _("""Determines whether the bot will filter its own + messages."""))) conf.registerChannelValue(BadWords, 'kick', registry.Boolean(False, _("""Determines whether the bot will kick people with a warning when they use bad words."""))) diff --git a/plugins/BadWords/messages.pot b/plugins/BadWords/messages.pot index a2fb4818f..b67ae4adc 100644 --- a/plugins/BadWords/messages.pot +++ b/plugins/BadWords/messages.pot @@ -81,18 +81,24 @@ msgstr "" #: config.py:117 msgid "" +"Determines whether the bot will filter its own\n" +" messages." +msgstr "" + +#: config.py:120 +msgid "" "Determines whether the bot will kick people with\n" " a warning when they use bad words." msgstr "" -#: config.py:120 +#: config.py:123 msgid "" "You have been kicked for using a word\n" " prohibited in the presence of this bot. Please use more appropriate\n" " language in the future." msgstr "" -#: config.py:122 +#: config.py:125 msgid "" "Determines the kick message used by the\n" " bot when kicking users for saying bad words." diff --git a/plugins/BadWords/plugin.py b/plugins/BadWords/plugin.py index aa9a6c703..a98e59320 100644 --- a/plugins/BadWords/plugin.py +++ b/plugins/BadWords/plugin.py @@ -104,9 +104,10 @@ class BadWords(callbacks.Privmsg): self.lastModified = time.time() def outFilter(self, irc, msg): + channel = msg.channel if self.filtering and msg.command == 'PRIVMSG' \ - and (self.words() or self.phrases()): - channel = msg.channel + and (self.words() or self.phrases()) \ + and self.registryValue('selfCensor', channel, irc.network): self.updateRegexp(channel, irc.network) s = msg.args[1] if self.registryValue('stripFormatting'):