peyk.dispatcher.middlewares

class peyk.dispatcher.middlewares.BaseMiddleware(*args, **kwargs)[source]

Bases: Protocol

Awaitable middleware around dispatcher execution.

Middleware receives the next callable, the normalized event, and a mutable context dictionary. It may add values to data before calling next; 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: BaseMiddleware

Inject state and raw_state for every normalized dispatcher event.

class peyk.dispatcher.middlewares.LoggingMiddleware(logger: object | None = None)[source]

Bases: object

Log normalized dispatcher events without inspecting platform raw data.

The existing transport logging hook remains the logging integration point; log_event is an additive hook on that same logger abstraction.

class peyk.dispatcher.middlewares.CallbackAnswer(text: str | None = None, show_alert: bool = False)[source]

Bases: object

Configuration for automatic callback-query acknowledgement.

show_alert: bool = False
text: str | None = None
class peyk.dispatcher.middlewares.CallbackAnswerMiddleware[source]

Bases: object

Automatically acknowledge callback queries after a handler succeeds.

class peyk.dispatcher.middlewares.ChatActionMiddleware[source]

Bases: object

Send the action named by flags.chat_action around a handler.

class peyk.dispatcher.middlewares.ChatActionSender(bot: _BotLike, chat_id: int | str, action: str = 'typing', interval: float = 4.0)[source]

Bases: object

Keep 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

Base protocol for normalized-event dispatcher middleware.

fsm

Compatibility import for the FSM middleware.

logging_middleware

Platform-neutral dispatcher event logging middleware.

utils