mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Added the outfilter command, great fun.
This commit is contained in:
parent
ef4efab1a8
commit
4a8b627b2d
@ -46,9 +46,10 @@ import urllib
|
|||||||
import inspect
|
import inspect
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
|
||||||
#import conf
|
import conf
|
||||||
import debug
|
import debug
|
||||||
import utils
|
import utils
|
||||||
|
import ircmsgs
|
||||||
import ircutils
|
import ircutils
|
||||||
import privmsgs
|
import privmsgs
|
||||||
import callbacks
|
import callbacks
|
||||||
@ -125,8 +126,44 @@ example = utils.wrapLines("""
|
|||||||
<jemfinch> @whois ohio-state.edu
|
<jemfinch> @whois ohio-state.edu
|
||||||
<supybot> jemfinch: ohio-state.edu <http://www.educause.edu/edudomain> is active; registered 18-aug-1987, updated 19-aug-2003, expires 18-aug-2004.
|
<supybot> jemfinch: ohio-state.edu <http://www.educause.edu/edudomain> is active; registered 18-aug-1987, updated 19-aug-2003, expires 18-aug-2004.
|
||||||
""")
|
""")
|
||||||
|
class MyFunProxy(object):
|
||||||
|
def reply(self, msg, s):
|
||||||
|
self.s = s
|
||||||
|
|
||||||
class Fun(callbacks.Privmsg):
|
class Fun(callbacks.Privmsg):
|
||||||
|
def __init__(self):
|
||||||
|
self.filtercommand = None
|
||||||
|
callbacks.Privmsg.__init__(self)
|
||||||
|
|
||||||
|
def outFilter(self, irc, msg):
|
||||||
|
if msg.command == 'PRIVMSG':
|
||||||
|
if self.filtercommand is not None:
|
||||||
|
myIrc = MyFunProxy()
|
||||||
|
self.filtercommand(myIrc, msg, [msg.args[1]])
|
||||||
|
msg = ircmsgs.IrcMsg(msg=msg, args=(msg.args[0], myIrc.s))
|
||||||
|
return msg
|
||||||
|
|
||||||
|
_filterCommands = ['jeffk', 'leet', 'rot13', 'hexlify', 'binary', 'lithp',
|
||||||
|
'scramble', 'morse', 'reverse']
|
||||||
|
def outfilter(self, irc, msg, args):
|
||||||
|
"""[<command>]
|
||||||
|
|
||||||
|
Sets the outFilter of this plugin to be <command>. If no command is
|
||||||
|
given, unsets the outFilter.
|
||||||
|
"""
|
||||||
|
command = privmsgs.getArgs(args, needed=0, optional=1)
|
||||||
|
if command:
|
||||||
|
command = callbacks.canonicalName(command)
|
||||||
|
if command in self._filterCommands:
|
||||||
|
self.filtercommand = getattr(self, command)
|
||||||
|
irc.reply(msg, conf.replySuccess)
|
||||||
|
else:
|
||||||
|
irc.error(msg, 'That\'s not a valid filter command.')
|
||||||
|
else:
|
||||||
|
self.filtercommand = None
|
||||||
|
irc.reply(msg, conf.replySuccess)
|
||||||
|
outfilter = privmsgs.checkCapability(outfilter, 'admin')
|
||||||
|
|
||||||
def hexip(self, irc, msg, args):
|
def hexip(self, irc, msg, args):
|
||||||
"""<ip>
|
"""<ip>
|
||||||
|
|
||||||
|
@ -91,4 +91,15 @@ class FunTest(PluginTestCase, PluginDocumentation):
|
|||||||
s = 'the recalc1trant jam3ssan tests his scramble fun><tion'
|
s = 'the recalc1trant jam3ssan tests his scramble fun><tion'
|
||||||
self.assertNotRegexp('scramble %s' % s, s)
|
self.assertNotRegexp('scramble %s' % s, s)
|
||||||
|
|
||||||
|
def testoutfilter(self):
|
||||||
|
self.assertNotError('outfilter rot13')
|
||||||
|
self.assertResponse('rot13 foobar', 'foobar')
|
||||||
|
self.assertNotError('outfilter')
|
||||||
|
self.assertResponse('rot13 foobar', 'sbbone')
|
||||||
|
self.assertNotError('outfilter ROT13')
|
||||||
|
self.assertResponse('rot13 foobar', 'foobar')
|
||||||
|
self.assertNotError('outfilter')
|
||||||
|
self.assertResponse('rot13 foobar', 'sbbone')
|
||||||
|
|
||||||
|
|
||||||
# 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