diff --git a/src/quadnite_bot/command.py b/src/quadnite_bot/command.py index 44ef31f..6e2b0cf 100644 --- a/src/quadnite_bot/command.py +++ b/src/quadnite_bot/command.py @@ -15,8 +15,14 @@ class Context: self.bot = bot self.accid = accid self.event = event - if command.command: - self.params = re.sub(fr"^/{command.command}\s+", "", event.msg.text) + self.command = "" + if command.command or command.commands: + commands: list[str] = [command.command] if command.command else command.commands + commands_join = "|".join(re.escape(command) for command in commands) + commands_re = re.compile(fr"^/({commands_join})\b\s*", re.I) + self.params = commands_re.sub("", event.msg.text) + if match := commands_re.match(event.msg.text): + self.command = match.group(1) else: self.params = event.msg.text self.args = re.split(r"\s+", self.params)