Skip to content

Commit

Permalink
CR fix: add isinstance check
Browse files Browse the repository at this point in the history
  • Loading branch information
bomzheg committed Jul 8, 2022
1 parent 4aac637 commit e8b09d3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions aiogram/dispatcher/filters/builtin.py
Expand Up @@ -68,8 +68,14 @@ def __init__(self, commands: Union[Iterable[Union[str, BotCommand]], str, BotCom
"""
if isinstance(commands, (str, BotCommand)):
commands = (commands,)
if isinstance(commands, Iterable):
commands = [cmd.command if isinstance(cmd, BotCommand) else cmd for cmd in commands]
elif isinstance(commands, Iterable):
pass
else:
raise ValueError(
"Command filter doesn't support {} as input. "
"It only supports str, BotCommand object or their Iterable"
)
commands = [cmd.command if isinstance(cmd, BotCommand) else cmd for cmd in commands]

self.commands = list(map(str.lower, commands)) if ignore_case else commands
self.prefixes = prefixes
Expand Down

0 comments on commit e8b09d3

Please sign in to comment.