mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
refactor(handler): rename observers
Rename observers but with backward compatibility, relevant documentation
This commit is contained in:
parent
b097680f3c
commit
4124770b0e
21 changed files with 297 additions and 110 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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): ...
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue