Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion telegram/ext/_commandhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(
self.command = [x.lower() for x in command]
for comm in self.command:
if not re.match(r'^[\da-z_]{1,32}$', comm):
raise ValueError('Command is not a valid bot command')
raise ValueError(f'Command `{comm}` is not a valid bot command')

self.filters = filters if filters is not None else filters_module.UpdateType.MESSAGES

Expand Down
4 changes: 3 additions & 1 deletion tests/test_commandhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ def test_basic(self, dp, command):
ids=['too long', 'invalid letter', 'invalid characters'],
)
def test_invalid_commands(self, cmd):
with pytest.raises(ValueError, match='not a valid bot command'):
with pytest.raises(
ValueError, match=f'`{re.escape(cmd.lower())}` is not a valid bot command'
):
CommandHandler(cmd, self.callback_basic)

def test_command_list(self):
Expand Down