mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
Bot API 5.7 and some new features (#834)
* Update API, added some new features * Fixed unknown chat_action value * Separate events from dispatcher messages * Disabled cache for I18n LazyProxy * Rework events isolation * Added chat member status changed filter, update Bot API 5.7, other small changes * Improve exceptions in chat member status filter * Fixed tests, covered flags and events isolation modules * Try to fix flake8 unused type ignore * Fixed linter error * Cover chat member updated filter * Cover chat action sender * Added docs for chat action util * Try to fix tests for python <= 3.9 * Fixed headers * Added docs for flags functionality * Added docs for chat_member_updated filter * Added change notes * Update dependencies and fix mypy checks * Bump version
This commit is contained in:
parent
ac7f2dc408
commit
7776cf9cf6
77 changed files with 2485 additions and 502 deletions
56
docs/utils/chat_action.rst
Normal file
56
docs/utils/chat_action.rst
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
==================
|
||||
Chat action sender
|
||||
==================
|
||||
|
||||
Sender
|
||||
======
|
||||
|
||||
.. autoclass:: aiogram.utils.chat_action.ChatActionSender
|
||||
:members: __init__,running,typing,upload_photo,record_video,upload_video,record_voice,upload_voice,upload_document,choose_sticker,find_location,record_video_note,upload_video_note
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
async with ChatActionSender.typing(bot=bot, chat_id=message.chat.id):
|
||||
# Do something...
|
||||
# Perform some long calculations
|
||||
await message.answer(result)
|
||||
|
||||
|
||||
Middleware
|
||||
==========
|
||||
|
||||
.. autoclass:: aiogram.utils.chat_action.ChatActionMiddleware
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Before usa should be registered for the `message` event
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
<router or dispatcher>.message.middleware(ChatActionMiddleware())
|
||||
|
||||
After this action all handlers which works longer than `initial_sleep` will produce the '`typing`' chat action.
|
||||
|
||||
Also sender can be customized via flags feature for particular handler.
|
||||
|
||||
Change only action type:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@router.message(...)
|
||||
@flags.chat_action("sticker")
|
||||
async def my_handler(message: Message): ...
|
||||
|
||||
|
||||
Change sender configuration:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@router.message(...)
|
||||
@flags.chat_action(initial_sleep=2, action="upload_document", interval=3)
|
||||
async def my_handler(message: Message): ...
|
||||
Loading…
Add table
Add a link
Reference in a new issue