mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +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,
|
* Changed Misc.help to allow plugins to specify their own help,
|
||||||
and added help for several of the more confusing plugins.
|
and added help for several of the more confusing plugins.
|
||||||
|
|
||||||
|
@ -107,6 +107,7 @@ class BadWords(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
capability = 'admin'
|
capability = 'admin'
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
privmsgs.CapabilityCheckingPrivmsg.__init__(self)
|
privmsgs.CapabilityCheckingPrivmsg.__init__(self)
|
||||||
|
self.filtering = True
|
||||||
self.lastModified = 0
|
self.lastModified = 0
|
||||||
self.words = conf.supybot.plugins.BadWords.words
|
self.words = conf.supybot.plugins.BadWords.words
|
||||||
|
|
||||||
@ -117,16 +118,19 @@ class BadWords(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
elif replaceMethod == 'nastyCharacters':
|
elif replaceMethod == 'nastyCharacters':
|
||||||
return self.registryValue('nastyChars')[:len(m.group(1))]
|
return self.registryValue('nastyChars')[:len(m.group(1))]
|
||||||
|
|
||||||
|
def inFilter(self, irc, msg):
|
||||||
|
self.filtering = True
|
||||||
|
return msg
|
||||||
|
|
||||||
def outFilter(self, irc, msg):
|
def outFilter(self, irc, msg):
|
||||||
if msg.command == 'PRIVMSG':
|
if self.filtering and msg.command == 'PRIVMSG':
|
||||||
if self.lastModified < self.words.lastModified:
|
if self.lastModified < self.words.lastModified:
|
||||||
self.makeRegexp(self.words())
|
self.makeRegexp(self.words())
|
||||||
self.lastModified = time.time()
|
self.lastModified = time.time()
|
||||||
s = msg.args[1]
|
s = msg.args[1]
|
||||||
s = ircutils.stripFormatting(s)
|
s = ircutils.stripFormatting(s)
|
||||||
s = self.regexp.sub(self.sub, s)
|
s = self.regexp.sub(self.sub, s)
|
||||||
return ircmsgs.privmsg(msg.args[0], s)
|
msg = ircmsgs.privmsg(msg.args[0], s)
|
||||||
else:
|
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
def makeRegexp(self, iterable):
|
def makeRegexp(self, iterable):
|
||||||
@ -135,6 +139,19 @@ class BadWords(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
s = r'\b%s\b' % s
|
s = r'\b%s\b' % s
|
||||||
self.regexp = re.compile(s, re.I)
|
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):
|
def add(self, irc, msg, args):
|
||||||
"""<word> [<word> ...]
|
"""<word> [<word> ...]
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
class BadWordsTestCase(PluginTestCase, PluginDocumentation):
|
class BadWordsTestCase(PluginTestCase):
|
||||||
plugins = ('BadWords', 'Utilities')
|
plugins = ('BadWords', 'Utilities')
|
||||||
badwords = ('shit', 'ass')
|
badwords = ('shit', 'ass')
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@ -64,5 +64,11 @@ class BadWordsTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertNotError('badwords remove %s' % ' '.join(self.badwords))
|
self.assertNotError('badwords remove %s' % ' '.join(self.badwords))
|
||||||
self._NegTest()
|
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:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user