From 899b6ecca86fd52b0a299d69cb51700fe53c66e6 Mon Sep 17 00:00:00 2001 From: Irene Sheen Date: Sat, 9 May 2026 17:35:01 +0200 Subject: [PATCH] Handle commands for ctx.params and add ctx.command --- src/quadnite_bot/command.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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)