BadWords will now filter words that have been formatted

This commit is contained in:
James Vega 2004-04-15 21:20:52 +00:00
parent e87c31aea4
commit b9ab839470
3 changed files with 5 additions and 0 deletions

View File

@ -1,3 +1,5 @@
* Fixed bug #863601, plugin BadWords fails on color codes.
* Added ircutils.strip{Bold,Reverse,Underline,Formatting}, which
will remove the specified formatting or all forms of formatting
in the case of stripFormatting.

View File

@ -47,6 +47,7 @@ import conf
import utils
import ircdb
import ircmsgs
import ircutils
import privmsgs
import registry
import callbacks
@ -122,6 +123,7 @@ class BadWords(privmsgs.CapabilityCheckingPrivmsg):
self.makeRegexp(self.words())
self.lastModified = time.time()
s = msg.args[1]
s = ircutils.stripFormatting(s)
s = self.regexp.sub(self.sub, s)
return ircmsgs.privmsg(msg.args[0], s)
else:

View File

@ -41,6 +41,7 @@ class BadWordsTestCase(PluginTestCase, PluginDocumentation):
def _test(self):
for word in self.badwords:
self.assertRegexp('echo %s' % word, '(?!%s)' % word)
self.assertRegexp('echo [colorize %s]' % word, '(?!%s)' % word)
self.assertRegexp('echo foo%sbar' % word, '(?!%s)' % word)
self.assertRegexp('echo [strjoin "" %s]' % ' '.join(word),
'(?!%s)' % word)