diff options
| -rw-r--r-- | EventManager.py | 3 | ||||
| -rw-r--r-- | modules/commands.py | 10 | ||||
| -rw-r--r-- | modules/karma.py | 14 | ||||
| -rw-r--r-- | modules/to.py | 2 |
4 files changed, 18 insertions, 11 deletions
diff --git a/EventManager.py b/EventManager.py index 560c671e..604ae337 100644 --- a/EventManager.py +++ b/EventManager.py @@ -4,8 +4,9 @@ PRIORITY_URGENT = 0 PRIORITY_HIGH = 1 PRIORITY_MEDIUM = 2 PRIORITY_LOW = 3 +PRIORITY_MONITOR = 4 -DEFAULT_PRIORITY = PRIORITY_LOW +DEFAULT_PRIORITY = PRIORITY_MEDIUM DEFAULT_DELIMITER = "." class Event(object): diff --git a/modules/commands.py b/modules/commands.py index a500c75d..9b1b1aad 100644 --- a/modules/commands.py +++ b/modules/commands.py @@ -1,5 +1,5 @@ import re -import Utils +import EventManager, Utils STR_MORE = "%s (more...)" % Utils.FONT_RESET STR_CONTINUED = "(...continued) " @@ -48,8 +48,10 @@ class Module(object): def __init__(self, bot, events, exports): self.bot = bot self.events = events - events.on("received.message.channel").hook(self.channel_message) - events.on("received.message.private").hook(self.private_message) + events.on("received.message.channel").hook(self.channel_message, + priority=EventManager.PRIORITY_LOW) + events.on("received.message.private").hook(self.private_message, + priority=EventManager.PRIORITY_LOW) events.on("received.command.help").hook(self.help, help="Show help for commands", usage="<command>") @@ -153,7 +155,7 @@ class Module(object): target.last_stdout = stdout target.last_stderr = stderr buffer.skip_next() - + event.eat() def channel_message(self, event): command_prefix = event["channel"].get_setting("command-prefix", diff --git a/modules/karma.py b/modules/karma.py index 5f6e5178..c7c3a263 100644 --- a/modules/karma.py +++ b/modules/karma.py @@ -1,5 +1,5 @@ import re, time -import Utils +import EventManager, Utils REGEX_KARMA = re.compile("(.*)(\+{2,}|\-{2,})$") KARMA_DELAY_SECONDS = 3 @@ -10,7 +10,7 @@ class Module(object): self.events = events events.on("new").on("user").hook(self.new_user) events.on("received").on("message").on("channel").hook( - self.channel_message) + self.channel_message, priority=EventManager.PRIORITY_MONITOR) events.on("received").on("command").on("karma").hook( self.karma, help="Get your or someone else's karma", usage="[target]") @@ -52,10 +52,14 @@ class Module(object): event["user"].last_karma = time.time() elif verbose: if target: - self.events.on("send").on("stderr").call(module_name="Karma", - target=event["channel"], message="You cannot change your own karma") + self.events.on("send.stderr").call( + module_name="Karma", target=event["channel"], + message="You cannot change your own karma") elif verbose: - event["stderr"].write("Try again in a couple of seconds") + self.events.on("send.stderr").call(module_name="Karma", + target=event["channel"], + message="Try again in a couple of seconds") + def karma(self, event): if event["args"]: target = event["args"] diff --git a/modules/to.py b/modules/to.py index e566e4c7..849f3af6 100644 --- a/modules/to.py +++ b/modules/to.py @@ -4,7 +4,7 @@ class Module(object): def __init__(self, bot, events, exports): events.on("received").on("message").on("channel" ).hook(self.channel_message, - priority=EventManager.PRIORITY_MEDIUM) + priority=EventManager.PRIORITY_HIGH) events.on("received").on("command").on("to").hook( self.to, min_args=2, help=("Relay a message to a " "user the next time they talk in a channel"), |
