Handling eventsΒΆ
aiogram includes Dispatcher mechanism. Dispatcher is needed for handling incoming updates from Telegram.
With dispatcher you can do:
Handle incoming updates;
Filter incoming events before it will be processed by specific handler;
Modify event and related data in middlewares;
Separate bot functionality between different handlers, modules and packages
Dispatcher is also separated into two entities - Router and Dispatcher. Dispatcher is subclass of router and should be always is root router.
Telegram supports two ways of receiving updates:
Webhook - you should configure your web server to receive updates from Telegram;
Long polling - you should request updates from Telegram.
So, you can use both of them with aiogram.
- Router
- Dispatcher
- Dependency injection
- How it works in aiogram
- Injecting own dependencies
- Using type hints
- Available context data type helpers
MiddlewareData
MiddlewareData.dispatcher
MiddlewareData.bot
MiddlewareData.bots
MiddlewareData.event_update
MiddlewareData.event_router
MiddlewareData.handler
MiddlewareData.event_context
MiddlewareData.event_from_user
MiddlewareData.event_chat
MiddlewareData.event_thread_id
MiddlewareData.event_business_connection_id
MiddlewareData.fsm_storage
MiddlewareData.state
MiddlewareData.raw_state
I18nData
- Available context data type helpers
- Filtering events
- Long-polling
- Finite State Machine
- Middlewares
- Errors
- Handling errors
- ErrorEvent
- Error types
AiogramError
DetailedAiogramError
CallbackAnswerException
SceneException
UnsupportedKeywordArgument
TelegramAPIError
TelegramNetworkError
TelegramRetryAfter
TelegramMigrateToChat
TelegramBadRequest
TelegramNotFound
TelegramConflictError
TelegramUnauthorizedError
TelegramForbiddenError
TelegramServerError
RestartingTelegram
TelegramEntityTooLarge
ClientDecodeError
- Flags
- Webhook
- Class based handlers