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>
This commit is contained in:
Alisson Lauffer 2021-09-14 13:33:54 -03:00 committed by GitHub
parent fdbab8cc87
commit 02a3969101
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

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

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"]