From afae8e9dcdc14669830dceaaad5548f8a6c7fe82 Mon Sep 17 00:00:00 2001 From: Richard Darst Date: Tue, 16 Jun 2009 01:09:17 +0000 Subject: add a supybot command -> meetbot command proxier darcs-hash:20090616010917-82ea9-31ba60b01491678a317dead95e7fee8e5c1ca46a.gz --- (limited to 'plugin.py') diff --git a/plugin.py b/plugin.py index dc74456..7484e8b 100644 --- a/plugin.py +++ b/plugin.py @@ -153,6 +153,46 @@ class MeetBot(callbacks.Plugin): pingall = wrap(pingall, [optional('text', None)]) + def __getattr__(self, name): + """Proxy between proper supybot commands and # MeetBot commands. + + This allows you to use MeetBot: + instead of the typical #command version. However, it's disabled + by default as there are some possible unresolved issues with it. + + To enable this, you must comment out a line in the main code. + It may be enabled in a future version. + """ + # First, proxy to our parent classes (__parent__ set in __init__) + try: + return self.__parent.__getattr__(name) + except AttributeError: + pass + # Disabled for now. Uncomment this if you want to use this. + raise AttributeError + + if not hasattr(meeting.Meeting, "do_"+name): + raise AttributeError + + def wrapped_function(self, irc, msg, args, message): + channel = msg.args[0] + payload = msg.args[1] + + #from fitz import interactnow ; reload(interactnow) + + #print type(payload) + payload = "#%s %s"%(name,message) + #print payload + import copy + msg = copy.copy(msg) + msg.args = (channel, payload) + + self.doPrivmsg(irc, msg) + # Give it the signature we need to be a callable supybot + # command (it does check more than I'd like). Heavy Wizardry. + instancemethod = type(self.__getattr__) + wrapped_function = wrap(wrapped_function, [optional('text', '')]) + return instancemethod(wrapped_function, self, MeetBot) Class = MeetBot -- cgit v0.9.1