mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Fixed tests for BadWords.
This commit is contained in:
parent
5f18d57262
commit
605129991d
@ -66,15 +66,16 @@ class LastModifiedSetOfStrings(registry.SpaceSeparatedListOfStrings):
|
||||
lastModified = 0
|
||||
def setValue(self, v):
|
||||
self.lastModified = time.time()
|
||||
registry.SpaceSeparatedSetOfStrings.setValue(self, v)
|
||||
registry.SpaceSeparatedListOfStrings.setValue(self, v)
|
||||
|
||||
conf.registerPlugin('BadWords')
|
||||
conf.registerChannelValue(conf.supybot.plugins.BadWords, 'words',
|
||||
registry.SpaceSeparatedListOfStrings([], """Determines what words are
|
||||
LastModifiedSetOfStrings([], """Determines what words are
|
||||
considered to be 'bad' so the bot won't say them."""))
|
||||
|
||||
class BadWords(privmsgs.CapabilityCheckingPrivmsg):
|
||||
priority = 1
|
||||
capability = 'admin'
|
||||
def __init__(self):
|
||||
privmsgs.CapabilityCheckingPrivmsg.__init__(self)
|
||||
self.lastModified = 0
|
||||
@ -94,6 +95,27 @@ class BadWords(privmsgs.CapabilityCheckingPrivmsg):
|
||||
def makeRegexp(self, iterable):
|
||||
self.regexp = re.compile(r'\b('+'|'.join(iterable)+r')\b', re.I)
|
||||
|
||||
def add(self, irc, msg, args):
|
||||
"""<word> [<word> ...]
|
||||
|
||||
Adds all <word>s to the list of words the bot isn't to say.
|
||||
"""
|
||||
set = self.words()
|
||||
set.update(args)
|
||||
self.words.setValue(set)
|
||||
irc.replySuccess()
|
||||
|
||||
def remove(self, irc, msg, args):
|
||||
"""<word> [<word> ...]
|
||||
|
||||
Removes a <word>s from the list of words the bot isn't to say.
|
||||
"""
|
||||
set = self.words()
|
||||
for word in args:
|
||||
set.discard(word)
|
||||
self.words.setValue(set)
|
||||
irc.replySuccess()
|
||||
|
||||
|
||||
Class = BadWords
|
||||
|
||||
|
@ -34,6 +34,10 @@ from testsupport import *
|
||||
class BadWordsTestCase(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('BadWords', 'Utilities')
|
||||
badwords = ('shit', 'ass')
|
||||
def tearDown(self):
|
||||
default = conf.supybot.plugins.BadWords.words.default
|
||||
conf.supybot.plugins.BadWords.words.setValue(default)
|
||||
|
||||
def _test(self):
|
||||
for word in self.badwords:
|
||||
self.assertRegexp('echo %s' % word, '(?!%s)' % word)
|
||||
|
Loading…
Reference in New Issue
Block a user