Skip to content

Commit 02a3969

Browse files
Fix Message.command when case is different (pyrogram#757)
* Fix Message.command when case is different * Update test_command.py Co-authored-by: Dan <[email protected]>
1 parent fdbab8c commit 02a3969

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

pyrogram/filters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,8 @@ async def func(flt, client: pyrogram.Client, message: Message):
794794
flags=re.IGNORECASE if not flt.case_sensitive else 0):
795795
continue
796796

797-
without_command = re.sub(rf"{cmd}(?:@?{username})?\s?", "", without_prefix, count=1)
797+
without_command = re.sub(rf"{cmd}(?:@?{username})?\s?", "", without_prefix, count=1,
798+
flags=re.IGNORECASE if not flt.case_sensitive else 0)
798799

799800
# match.groups are 1-indexed, group(1) is the quote, group(2) is the text
800801
# between the quotes, group(3) is unquoted, whitespace-split text

tests/filters/test_command.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ async def test_with_args():
107107
await f(c, m)
108108
assert m.command == ["start"]
109109

110+
m = Message("/StArT")
111+
await f(c, m)
112+
assert m.command == ["start"]
113+
110114
m = Message("/start@username")
111115
await f(c, m)
112116
assert m.command == ["start"]

0 commit comments

Comments
 (0)