diff --git a/plugins/Fun.py b/plugins/Fun.py index b74e5b27a..4138fc928 100644 --- a/plugins/Fun.py +++ b/plugins/Fun.py @@ -46,9 +46,10 @@ import urllib import inspect import mimetypes -#import conf +import conf import debug import utils +import ircmsgs import ircutils import privmsgs import callbacks @@ -125,8 +126,44 @@ example = utils.wrapLines(""" @whois ohio-state.edu jemfinch: ohio-state.edu 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): + 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): + """[] + + Sets the outFilter of this plugin to be . 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): """ diff --git a/test/test_Fun.py b/test/test_Fun.py index cf3949892..b2dad1082 100644 --- a/test/test_Fun.py +++ b/test/test_Fun.py @@ -91,4 +91,15 @@ class FunTest(PluginTestCase, PluginDocumentation): s = 'the recalc1trant jam3ssan tests his scramble fun>