diff --git a/plugins/BadWords/config.py b/plugins/BadWords/config.py index b742ed0ae..d88d0a5f4 100644 --- a/plugins/BadWords/config.py +++ b/plugins/BadWords/config.py @@ -94,8 +94,10 @@ conf.registerChannelValue(BadWords, 'kick', registry.Boolean(False, """Determines whether the bot will kick people with a warning when they use bad words.""")) conf.registerChannelValue(BadWords.kick, 'message', - registry.String("""You have been kicked for using a word prohibited on this - channel. Please use more appropriate language in the future.""")) + registry.NormalizedString("""You have been kicked for using a word + prohibited in the presence of this bot. Please use more appropriate + language in the future.""", """Determines the kick message used by the bot + when kicking users for saying bad words.""")) # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/plugins/BadWords/plugin.py b/plugins/BadWords/plugin.py index d6f566f6a..7025837ed 100644 --- a/plugins/BadWords/plugin.py +++ b/plugins/BadWords/plugin.py @@ -66,11 +66,14 @@ class BadWords(callbacks.Privmsg): self.filtering = True return msg + def updateRegexp(self): + if self.lastModified < self.words.lastModified: + self.makeRegexp(self.words()) + self.lastModified = time.time() + def outFilter(self, irc, msg): if self.filtering and msg.command == 'PRIVMSG': - if self.lastModified < self.words.lastModified: - self.makeRegexp(self.words()) - self.lastModified = time.time() + self.updateRegexp() s = msg.args[1] if self.registryValue('stripFormatting'): s = ircutils.stripFormatting(s) @@ -79,17 +82,17 @@ class BadWords(callbacks.Privmsg): return msg def doPrivmsg(self, irc, msg): + self.updateRegexp() s = ircutils.stripFormatting(msg.args[1]) channel = msg.args[0] if ircutils.isChannel(channel) and self.registryValue('kick', channel): - if self.regexp.match(s): + if self.regexp.search(s): if irc.nick in irc.state.channels[channel].ops: message = self.registryValue('kick.message', channel) irc.queueMsg(ircmsgs.kick(channel, msg.nick, message)) else: - self.log('Should kick %s from %s, but am not opped.', - msg.nick, channel) - callbacks.Privmsg.doPrivmsg(self, irc, msg) + self.log.warning('Should kick %s from %s, but not opped.', + msg.nick, channel) def makeRegexp(self, iterable): s = '(%s)' % '|'.join(map(re.escape, iterable))