refactor(handler): rename observers

Rename observers but with backward compatibility, relevant documentation
This commit is contained in:
mpa 2020-05-10 03:02:31 +04:00
parent b097680f3c
commit 4124770b0e
21 changed files with 297 additions and 110 deletions

View file

@ -19,7 +19,7 @@ Works only with [Message](../../api/types/message.md) events which have the `tex
1. Handle command by regexp pattern: `#!python3 Command(commands=[re.compile(r"item_(\d+)")])`
1. Match command by multiple variants: `#!python3 Command(commands=["item", re.compile(r"item_(\d+)")])`
1. Handle commands in public chats intended for other bots: `#!python3 Command(commands=["command"], commands)`
1. As keyword argument in registerer: `#!python3 @router.message_handler(commands=["help"])`
1. As keyword argument in registerer: `#!python3 @router.message(commands=["help"])`
!!! warning
Command cannot include spaces or any whitespace

View file

@ -53,9 +53,9 @@ class MyText(BaseFilter):
return message.text == self.my_text
router.message_handler.bind_filter(MyText)
router.message.bind_filter(MyText)
@router.message_handler(my_text="hello")
@router.message(my_text="hello")
async def my_handler(message: Message): ...
```