mirror of
https://github.com/maubot/maubot.git
synced 2024-10-01 01:06:10 -04:00
Make command arguments map optional and fix optional command arguments
This commit is contained in:
parent
a4fb18038c
commit
fd14a38546
@ -31,7 +31,7 @@ class Argument(SerializableAttrs['Argument']):
|
||||
@dataclass
|
||||
class Command(SerializableAttrs['Command']):
|
||||
syntax: str
|
||||
arguments: Dict[str, Argument]
|
||||
arguments: Dict[str, Argument] = {}
|
||||
description: str = None
|
||||
|
||||
|
||||
@ -80,7 +80,9 @@ class ParsedCommand:
|
||||
arg = command.arguments.get(word, None)
|
||||
if arg is not None and len(word) > 0:
|
||||
argument_encountered = True
|
||||
regex = f"({arg.matches})" if arg.required else f"(?:{arg.matches})?"
|
||||
regex = f"({arg.matches})"
|
||||
if not arg.required:
|
||||
regex += "?"
|
||||
self.arguments.append(word)
|
||||
regex_builder.append(regex)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user