mirror of
https://gitlab.com/ceda_ei/Quadnite-Bot
synced 2026-05-12 08:40:06 +02:00
Handle commands for ctx.params and add ctx.command
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user