From 8d0dbeba1efb7dca79019e51c1d9b1be465b41cf Mon Sep 17 00:00:00 2001 From: Andrei Date: Wed, 11 Jan 2017 21:00:04 -0600 Subject: [PATCH] bugfix - properly combine multiple triggers (fixes #14) --- disco/bot/command.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/disco/bot/command.py b/disco/bot/command.py index 7e9f5ef..80f6929 100644 --- a/disco/bot/command.py +++ b/disco/bot/command.py @@ -5,7 +5,6 @@ from holster.enum import Enum from disco.bot.parser import ArgumentSet, ArgumentError from disco.util.functional import cached_property -REGEX_FMT = '{}' ARGS_REGEX = '(?: ((?:\n|.)*)$|$)' USER_MENTION_RE = re.compile('<@!?([0-9]+)>') @@ -225,7 +224,7 @@ class Command(object): The regex string that defines/triggers this command. """ if self.is_regex: - return REGEX_FMT.format('|'.join(self.triggers)) + return '|'.join(self.triggers) else: group = '' if self.group: @@ -233,7 +232,7 @@ class Command(object): group = '{}(?:\w+)? '.format(self.plugin.bot.group_abbrev.get(self.group)) else: group = self.group + ' ' - return REGEX_FMT.format('|'.join(['^' + group + trigger for trigger in self.triggers]) + ARGS_REGEX) + return '^{}(?:{})'.format(group, '|'.join(self.triggers)) + ARGS_REGEX def execute(self, event): """