Deprecate filters factory (#976)

* Deprecate filters factory

* Added changelog

* Update filters usage in docs and examples
This commit is contained in:
Alex Root Junior 2022-08-14 18:40:41 +03:00 committed by GitHub
parent c1341ba2df
commit 0e0dbe7e59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 67 additions and 23 deletions

View file

@ -86,10 +86,10 @@ Handle user leave or join events
from aiogram.filters import IS_MEMBER, IS_NOT_MEMBER
@router.chat_member(member_status_changed=IS_MEMBER >> IS_NOT_MEMBER)
@router.chat_member(ChatMemberUpdatedFilter(member_status_changed=IS_MEMBER >> IS_NOT_MEMBER))
async def on_user_leave(event: ChatMemberUpdated): ...
@router.chat_member(member_status_changed=IS_NOT_MEMBER >> IS_MEMBER)
@router.chat_member(ChatMemberUpdatedFilter(member_status_changed=IS_NOT_MEMBER >> IS_MEMBER))
async def on_user_join(event: ChatMemberUpdated): ...
Or construct your own terms via using pre-defined set of statuses and transitions.

View file

@ -21,8 +21,7 @@ Usage
1. Filter single variant of commands: :code:`Command(commands=["start"])` or :code:`Command(commands="start")`
2. Handle command by regexp pattern: :code:`Command(commands=[re.compile(r"item_(\d+)")])`
3. Match command by multiple variants: :code:`Command(commands=["item", re.compile(r"item_(\d+)")])`
4. Handle commands in public chats intended for other bots: :code:`Command(commands=["command"], commands)`
5. As keyword argument in registerer: :code:`@router.message(commands=["help"])`
4. Handle commands in public chats intended for other bots: :code:`Command(commands=["command"], commands_ignore_mention=True)`
.. warning::

View file

@ -2,6 +2,13 @@
Filtering events
================
.. danger::
Note that the design of filters will be changed in 3.0b5
`Read more >> <https://github.com/aiogram/aiogram/issues/942>`_
Filters is needed for routing updates to the specific handler.
Searching of handler is always stops on first match set of filters are pass.

View file

@ -17,7 +17,7 @@ Or used from filters factory by passing corresponding arguments to handler regis
Usage
=====
#. :code:`magic_data=F.event.from_user.id == F.config.admin_id` (Note that :code:`config` should be passed from middleware)
#. :code:`MagicData(magic_data=F.event.from_user.id == F.config.admin_id)` (Note that :code:`config` should be passed from middleware)
Allowed handlers