peyk.dispatcher.middlewares¶
- class peyk.dispatcher.middlewares.BaseMiddleware(*args, **kwargs)[source]¶
Bases:
ProtocolAwaitable middleware around dispatcher execution.
Middleware receives the next callable, the normalized event, and a mutable context dictionary. It may add values to
databefore callingnext; matching handlers receive those values as keyword arguments.
- class peyk.dispatcher.middlewares.FSMContextMiddleware(storage: BaseStorage, *, strategy: str | FSMStrategy = FSMStrategy.USER_IN_CHAT, events_isolation: BaseEventIsolation | None = None)[source]¶
Bases:
BaseMiddlewareInject
stateandraw_statefor every normalized dispatcher event.
- class peyk.dispatcher.middlewares.LoggingMiddleware(logger: object | None = None)[source]¶
Bases:
objectLog normalized dispatcher events without inspecting platform raw data.
The existing transport logging hook remains the logging integration point;
log_eventis an additive hook on that same logger abstraction.
- class peyk.dispatcher.middlewares.CallbackAnswer(text: str | None = None, show_alert: bool = False)[source]¶
Bases:
objectConfiguration for automatic callback-query acknowledgement.
- show_alert: bool = False¶
- text: str | None = None¶
- class peyk.dispatcher.middlewares.CallbackAnswerMiddleware[source]¶
Bases:
objectAutomatically acknowledge callback queries after a handler succeeds.
- class peyk.dispatcher.middlewares.ChatActionMiddleware[source]¶
Bases:
objectSend the action named by
flags.chat_actionaround a handler.
- class peyk.dispatcher.middlewares.ChatActionSender(bot: _BotLike, chat_id: int | str, action: str = 'typing', interval: float = 4.0)[source]¶
Bases:
objectKeep a chat action alive while a handler is running.
- action: str = 'typing'¶
- classmethod choose_sticker(bot: _BotLike, chat_id: int | str, interval: float = 4.0) ChatActionSender[source]¶
Performs the choose sticker operation for the dispatcher client.
- Parameters:
bot – Value used by this operation.
chat_id – Identifier of the target chat.
interval – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- classmethod find_location(bot: _BotLike, chat_id: int | str, interval: float = 4.0) ChatActionSender[source]¶
Performs the find location operation for the dispatcher client.
- Parameters:
bot – Value used by this operation.
chat_id – Identifier of the target chat.
interval – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- interval: float = 4.0¶
- classmethod record_video(bot: _BotLike, chat_id: int | str, interval: float = 4.0) ChatActionSender[source]¶
Performs the record video operation for the dispatcher client.
- Parameters:
bot – Value used by this operation.
chat_id – Identifier of the target chat.
interval – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- classmethod record_video_note(bot: _BotLike, chat_id: int | str, interval: float = 4.0) ChatActionSender[source]¶
Performs the record video note operation for the dispatcher client.
- Parameters:
bot – Value used by this operation.
chat_id – Identifier of the target chat.
interval – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- classmethod record_voice(bot: _BotLike, chat_id: int | str, interval: float = 4.0) ChatActionSender[source]¶
Performs the record voice operation for the dispatcher client.
- Parameters:
bot – Value used by this operation.
chat_id – Identifier of the target chat.
interval – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- classmethod typing(bot: _BotLike, chat_id: int | str, interval: float = 4.0) ChatActionSender[source]¶
Performs the typing operation for the dispatcher client.
- Parameters:
bot – Value used by this operation.
chat_id – Identifier of the target chat.
interval – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- classmethod upload_document(bot: _BotLike, chat_id: int | str, interval: float = 4.0) ChatActionSender[source]¶
Performs the upload document operation for the dispatcher client.
- Parameters:
bot – Value used by this operation.
chat_id – Identifier of the target chat.
interval – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- classmethod upload_photo(bot: _BotLike, chat_id: int | str, interval: float = 4.0) ChatActionSender[source]¶
Performs the upload photo operation for the dispatcher client.
- Parameters:
bot – Value used by this operation.
chat_id – Identifier of the target chat.
interval – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- classmethod upload_video(bot: _BotLike, chat_id: int | str, interval: float = 4.0) ChatActionSender[source]¶
Performs the upload video operation for the dispatcher client.
- Parameters:
bot – Value used by this operation.
chat_id – Identifier of the target chat.
interval – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- classmethod upload_video_note(bot: _BotLike, chat_id: int | str, interval: float = 4.0) ChatActionSender[source]¶
Performs the upload video note operation for the dispatcher client.
- Parameters:
bot – Value used by this operation.
chat_id – Identifier of the target chat.
interval – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- bot: _BotLike¶
- chat_id: int | str¶
Modules
Base protocol for normalized-event dispatcher middleware. |
|
Compatibility import for the FSM middleware. |
|
Platform-neutral dispatcher event logging middleware. |
|