mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Fix duplicated commands in Message.command
Also add more test cases Related to #676
This commit is contained in:
parent
4fc4501445
commit
636ff776d6
2 changed files with 9 additions and 1 deletions
|
|
@ -789,7 +789,7 @@ def command(commands: Union[str, List[str]], prefixes: Union[str, List[str]] = "
|
|||
flags=re.IGNORECASE if not flt.case_sensitive else 0):
|
||||
continue
|
||||
|
||||
without_command = re.sub(rf"{cmd}(?:@?{username})?\s", "", without_prefix, count=1)
|
||||
without_command = re.sub(rf"{cmd}(?:@?{username})?\s?", "", without_prefix, count=1)
|
||||
|
||||
# match.groups are 1-indexed, group(1) is the quote, group(2) is the text
|
||||
# between the quotes, group(3) is unquoted, whitespace-split text
|
||||
|
|
|
|||
|
|
@ -103,6 +103,14 @@ async def test_with_mention():
|
|||
async def test_with_args():
|
||||
f = filters.command("start")
|
||||
|
||||
m = Message("/start")
|
||||
await f(c, m)
|
||||
assert m.command == ["start"]
|
||||
|
||||
m = Message("/start@username")
|
||||
await f(c, m)
|
||||
assert m.command == ["start"]
|
||||
|
||||
m = Message("/start a b c")
|
||||
await f(c, m)
|
||||
assert m.command == ["start"] + list("abc")
|
||||
|
|
|
|||
Loading…
Reference in a new issue