Browse Source

Fix Message.command when case is different (#757)

* Fix Message.command when case is different

* Update test_command.py

Co-authored-by: Dan <14043624+delivrance@users.noreply.github.com>
pull/758/head
Alisson Lauffer 1 month ago
committed by GitHub
parent
commit
02a3969101
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions
  1. +2
    -1
      pyrogram/filters.py
  2. +4
    -0
      tests/filters/test_command.py

+ 2
- 1
pyrogram/filters.py View File

@ -794,7 +794,8 @@ 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,
flags=re.IGNORECASE if not flt.case_sensitive else 0)
# 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

+ 4
- 0
tests/filters/test_command.py View File

@ -107,6 +107,10 @@ async def test_with_args():
await f(c, m)
assert m.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"]

Loading…
Cancel
Save