Make commands be processed under received.message.* at PRIORITY_LOW, eat the

event when it's done, change karma.py to use PRIORITY_MONITOR
This commit is contained in:
jesopo 2018-09-09 17:09:04 +01:00
parent 2a37e10533
commit 59912776c1
2 changed files with 8 additions and 6 deletions

View file

@ -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",

View file

@ -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]")