Allow for pre-compiled regex triggers
This commit is contained in:
parent
156e9088ef
commit
5952c4c6bd
1 changed files with 5 additions and 2 deletions
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue