BadWords: Fix commit 123c176637.

This commit is contained in:
Valentin Lorentz 2012-02-25 14:02:02 +01:00
parent e2c1adda7f
commit 99ad2d193e
2 changed files with 8 additions and 7 deletions

View File

@ -73,9 +73,9 @@ class BadWords(callbacks.Privmsg):
# We need to check for bad words here rather than in doPrivmsg because # We need to check for bad words here rather than in doPrivmsg because
# messages don't get to doPrivmsg if the user is ignored. # messages don't get to doPrivmsg if the user is ignored.
if msg.command == 'PRIVMSG': if msg.command == 'PRIVMSG':
self.updateRegexp()
s = ircutils.stripFormatting(msg.args[1])
channel = msg.args[0] channel = msg.args[0]
self.updateRegexp(channel)
s = ircutils.stripFormatting(msg.args[1])
if ircutils.isChannel(channel) and self.registryValue('kick', channel): if ircutils.isChannel(channel) and self.registryValue('kick', channel):
if self.regexp.search(s): if self.regexp.search(s):
if irc.nick in irc.state.channels[channel].ops: if irc.nick in irc.state.channels[channel].ops:
@ -86,14 +86,15 @@ class BadWords(callbacks.Privmsg):
msg.nick, channel) msg.nick, channel)
return msg return msg
def updateRegexp(self): def updateRegexp(self, channel):
if self.lastModified < self.words.lastModified: if self.lastModified < self.words.lastModified:
self.makeRegexp(self.words()) self.makeRegexp(self.words(), channel)
self.lastModified = time.time() self.lastModified = time.time()
def outFilter(self, irc, msg): def outFilter(self, irc, msg):
if self.filtering and msg.command == 'PRIVMSG' and self.words(): if self.filtering and msg.command == 'PRIVMSG' and self.words():
self.updateRegexp() channel = msg.args[0]
self.updateRegexp(channel)
s = msg.args[1] s = msg.args[1]
if self.registryValue('stripFormatting'): if self.registryValue('stripFormatting'):
s = ircutils.stripFormatting(s) s = ircutils.stripFormatting(s)
@ -102,7 +103,7 @@ class BadWords(callbacks.Privmsg):
msg = ircmsgs.privmsg(msg.args[0], t, msg=msg) msg = ircmsgs.privmsg(msg.args[0], t, msg=msg)
return msg return msg
def makeRegexp(self, iterable): def makeRegexp(self, iterable, channel):
s = '(%s)' % '|'.join(map(re.escape, iterable)) s = '(%s)' % '|'.join(map(re.escape, iterable))
if self.registryValue('requireWordBoundaries', channel): if self.registryValue('requireWordBoundaries', channel):
s = r'\b%s\b' % s s = r'\b%s\b' % s

View File

@ -1,3 +1,3 @@
"""stick the various versioning attributes in here, so we only have to change """stick the various versioning attributes in here, so we only have to change
them once.""" them once."""
version = '0.83.4.1+limnoria (2012-02-17T21:59:23+0000)' version = '0.83.4.1+limnoria (2012-02-25T13:02:02+0000)'