Created
May 9, 2011 23:50
-
-
Save EntityReborn/963658 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# before | |
# In plugin manager: | |
def register_trigger(self, func, *events): | |
for event in events: | |
self.triggers[event.upper()].append(func) | |
# In plugin: | |
def initialize(self, *args, **kwargs): | |
manager.register_trigger(self.on_welcome, "IRC_RPL_WELCOME") | |
def on_welcome(self, bot, command, prefix, params): | |
... | |
# now | |
# In plugin manager | |
def trigger(self, event): | |
def process(func): | |
for event in events: | |
self.triggers[event.upper()].append(func) | |
return func | |
return process | |
# In plugin: | |
@manager.trigger("IRC_RPL_WELCOME") | |
def on_welcome(self, bot, command, prefix, params): | |
... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment