mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +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
@ -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 New Issue
Block a user