mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-03 16:39:25 +01:00
Added a list command.
This commit is contained in:
parent
6287713fcd
commit
1cc62cf609
@ -1,3 +1,6 @@
|
||||
* Added BadWords.list, to list the bad words currently being
|
||||
censored by the bot.
|
||||
|
||||
* Changed Misc.help to allow plugins to specify their own help,
|
||||
and added help for several of the more confusing plugins.
|
||||
|
||||
|
@ -107,6 +107,7 @@ class BadWords(privmsgs.CapabilityCheckingPrivmsg):
|
||||
capability = 'admin'
|
||||
def __init__(self):
|
||||
privmsgs.CapabilityCheckingPrivmsg.__init__(self)
|
||||
self.filtering = True
|
||||
self.lastModified = 0
|
||||
self.words = conf.supybot.plugins.BadWords.words
|
||||
|
||||
@ -117,16 +118,19 @@ class BadWords(privmsgs.CapabilityCheckingPrivmsg):
|
||||
elif replaceMethod == 'nastyCharacters':
|
||||
return self.registryValue('nastyChars')[:len(m.group(1))]
|
||||
|
||||
def inFilter(self, irc, msg):
|
||||
self.filtering = True
|
||||
return msg
|
||||
|
||||
def outFilter(self, irc, msg):
|
||||
if msg.command == 'PRIVMSG':
|
||||
if self.filtering and msg.command == 'PRIVMSG':
|
||||
if self.lastModified < self.words.lastModified:
|
||||
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:
|
||||
msg = ircmsgs.privmsg(msg.args[0], s)
|
||||
return msg
|
||||
|
||||
def makeRegexp(self, iterable):
|
||||
@ -135,6 +139,19 @@ class BadWords(privmsgs.CapabilityCheckingPrivmsg):
|
||||
s = r'\b%s\b' % s
|
||||
self.regexp = re.compile(s, re.I)
|
||||
|
||||
def list(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
|
||||
Returns the list of words being censored.
|
||||
"""
|
||||
L = list(self.words())
|
||||
if L:
|
||||
self.filtering = False
|
||||
utils.sortBy(str.lower, L)
|
||||
irc.reply(utils.commaAndify(L))
|
||||
else:
|
||||
irc.reply('I\'m not currently censoring any bad words.')
|
||||
|
||||
def add(self, irc, msg, args):
|
||||
"""<word> [<word> ...]
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
from testsupport import *
|
||||
|
||||
class BadWordsTestCase(PluginTestCase, PluginDocumentation):
|
||||
class BadWordsTestCase(PluginTestCase):
|
||||
plugins = ('BadWords', 'Utilities')
|
||||
badwords = ('shit', 'ass')
|
||||
def tearDown(self):
|
||||
@ -64,5 +64,11 @@ class BadWordsTestCase(PluginTestCase, PluginDocumentation):
|
||||
self.assertNotError('badwords remove %s' % ' '.join(self.badwords))
|
||||
self._NegTest()
|
||||
|
||||
def testList(self):
|
||||
self.assertNotError('badwords list')
|
||||
self.assertNotError('badwords add shit')
|
||||
self.assertNotError('badwords add ass')
|
||||
self.assertResponse('badwords list', 'ass and shit')
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user