diff --git a/yaboli/bot.py b/yaboli/bot.py index a728afe..0672e70 100644 --- a/yaboli/bot.py +++ b/yaboli/bot.py @@ -46,7 +46,10 @@ class Bot(Controller): self._commands.add((command, specific), callback) def register_trigger(self, regex, callback): - self._triggers.add(regex, callback) + self._triggers.add(re.compile(regex), callback) + + def register_trigger_compiled(self, comp_regex, callback): + self._triggers.add(comp_regex, callback) def add_help(self, topic, text, visible=True): info = self.TopicHelp(text, visible) @@ -132,7 +135,7 @@ class Bot(Controller): # find triggers to call (if any) for trigger in self._triggers.list(): - match = re.fullmatch(trigger, message.content) + match = trigger.fullmatch(message.content) if match: wait.append(self._triggers.call(trigger, message, match))