mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Made outfilters stackable, added md5 and sha as outfilters.
This commit is contained in:
parent
e50243262d
commit
13c10c899e
@ -132,19 +132,21 @@ class MyFunProxy(object):
|
|||||||
|
|
||||||
class Fun(callbacks.Privmsg):
|
class Fun(callbacks.Privmsg):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.filtercommand = None
|
self.filtercommands = []
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
|
|
||||||
def outFilter(self, irc, msg):
|
def outFilter(self, irc, msg):
|
||||||
if msg.command == 'PRIVMSG':
|
if msg.command == 'PRIVMSG':
|
||||||
if self.filtercommand is not None:
|
s = msg.args[1]
|
||||||
|
for filtercommand in self.filtercommands:
|
||||||
myIrc = MyFunProxy()
|
myIrc = MyFunProxy()
|
||||||
self.filtercommand(myIrc, msg, [msg.args[1]])
|
filtercommand(myIrc, msg, [s])
|
||||||
msg = ircmsgs.IrcMsg(msg=msg, args=(msg.args[0], myIrc.s))
|
s = myIrc.s
|
||||||
|
msg = ircmsgs.IrcMsg(msg=msg, args=(msg.args[0], s))
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
_filterCommands = ['jeffk', 'leet', 'rot13', 'hexlify', 'binary', 'lithp',
|
_filterCommands = ['jeffk', 'leet', 'rot13', 'hexlify', 'binary', 'lithp',
|
||||||
'scramble', 'morse', 'reverse']
|
'scramble', 'morse', 'reverse', 'urlquote', 'md5','sha']
|
||||||
def outfilter(self, irc, msg, args):
|
def outfilter(self, irc, msg, args):
|
||||||
"""[<command>]
|
"""[<command>]
|
||||||
|
|
||||||
@ -155,12 +157,12 @@ class Fun(callbacks.Privmsg):
|
|||||||
if command:
|
if command:
|
||||||
command = callbacks.canonicalName(command)
|
command = callbacks.canonicalName(command)
|
||||||
if command in self._filterCommands:
|
if command in self._filterCommands:
|
||||||
self.filtercommand = getattr(self, command)
|
self.filtercommands.append(getattr(self, command))
|
||||||
irc.reply(msg, conf.replySuccess)
|
irc.reply(msg, conf.replySuccess)
|
||||||
else:
|
else:
|
||||||
irc.error(msg, 'That\'s not a valid filter command.')
|
irc.error(msg, 'That\'s not a valid filter command.')
|
||||||
else:
|
else:
|
||||||
self.filtercommand = None
|
self.filtercommands = []
|
||||||
irc.reply(msg, conf.replySuccess)
|
irc.reply(msg, conf.replySuccess)
|
||||||
outfilter = privmsgs.checkCapability(outfilter, 'admin')
|
outfilter = privmsgs.checkCapability(outfilter, 'admin')
|
||||||
|
|
||||||
|
@ -94,6 +94,8 @@ class FunTest(PluginTestCase, PluginDocumentation):
|
|||||||
def testoutfilter(self):
|
def testoutfilter(self):
|
||||||
self.assertNotError('outfilter rot13')
|
self.assertNotError('outfilter rot13')
|
||||||
self.assertResponse('rot13 foobar', 'foobar')
|
self.assertResponse('rot13 foobar', 'foobar')
|
||||||
|
self.assertNotError('outfilter rot13')
|
||||||
|
self.assertResponse('rot13 foobar', 'sbbone')
|
||||||
self.assertNotError('outfilter')
|
self.assertNotError('outfilter')
|
||||||
self.assertResponse('rot13 foobar', 'sbbone')
|
self.assertResponse('rot13 foobar', 'sbbone')
|
||||||
self.assertNotError('outfilter ROT13')
|
self.assertNotError('outfilter ROT13')
|
||||||
|
Loading…
Reference in New Issue
Block a user