docs: migration feeding updates

This commit is contained in:
Oleg A 2024-06-30 16:33:10 +03:00
parent 3baa7383c1
commit b2ecae38f2
No known key found for this signature in database
GPG key ID: 5FE046817A9657C5
3 changed files with 38 additions and 20 deletions

View file

@ -2,7 +2,7 @@
Dispatcher
##########
Dispatcher is root :obj:`Router` and in code Dispatcher can be used directly for routing updates or attach another routers into dispatcher.
Dispatcher is root :class:`~aiogram.dispatcher.router.Router` and in code Dispatcher can be used directly for routing updates or attach another routers into dispatcher.
Here is only listed base information about Dispatcher. All about writing handlers, filters and etc. you can find in next pages:
@ -39,16 +39,26 @@ Example:
router1 = Router()
dp.include_router(router1)
.. _Handling updates:
Handling updates
================
All updates can be propagated to the dispatcher by :obj:`Dispatcher.feed_update(bot=..., update=...)` method:
All updates can be propagated to the dispatcher by :meth:`~aiogram.dispatcher.dispatcher.Dispatcher.feed_update` method:
.. code-block:: python
bot = Bot(...)
dp = Dispatcher()
from aiogram import Bot, Dispatcher
...
async def update_handler(update: Update, bot: Bot, dispatcher: Dispatcher):
result = await dp.feed_update(bot, update)
result = await dp.feed_update(bot=bot, update=incoming_update)
Also you can feed raw update (dictionary) object to the dispatcher by :meth:`~aiogram.dispatcher.dispatcher.Dispatcher.feed_raw_update` method:
.. code-block:: python
from aiogram import Bot, Dispatcher
async def update_handler(raw_update: dict[str, Any], bot: Bot, dispatcher: Dispatcher):
result = await dp.feed_raw_update(bot, raw_update)