peyk.dispatcher.dispatcher

Classes

Dispatcher(*[, name, storage, fsm_strategy, ...])

Root router that feeds normalized updates from one or more bots.

class peyk.dispatcher.dispatcher.Dispatcher(*, name: str | None = None, storage: BaseStorage | None = None, fsm_strategy: FSMStrategy | str = FSMStrategy.USER_IN_CHAT, events_isolation: BaseEventIsolation | None = None, **workflow_data: object)[source]

Bases: Router

Root router that feeds normalized updates from one or more bots.

The dispatcher owns polling tasks but deliberately delegates event matching to Router; Phase 3 does not alter router matching semantics.

resolve_used_update_types() list[str][source]

Return the Telegram update types this dispatcher should receive.

Telegram remembers the allowed_updates last sent for a bot token, whether it came from getUpdates, from setWebhook or from a completely different program that used the same token earlier. If a new run does not send the parameter, the old filter silently stays in effect, so e.g. callback_query and inline_query updates never arrive even though the handlers are registered. Peyk therefore always sends an explicit list.

The list contains every update type Peyk can parse, except the three opt-in types Telegram does not deliver by default (chat_member, message_reaction and message_reaction_count); those are added only when a router in the tree has a handler that needs them.

Returns:

Update type names in Telegram’s allowed_updates spelling.

async feed_raw_update(bot: Bot[object], raw_update: object) object[source]

Normalize one raw update, inject dispatcher context, and propagate it.

async start_polling(*bots: Bot[object], polling_timeout: int = 30, allowed_updates: Sequence[str] | None = None, skip_updates: bool = False, handle_signals: bool = True, close_bots: bool = True, handle_as_tasks: bool = False, max_concurrent_updates: int = 100) None[source]

Poll all supplied bots concurrently until stopped or cancelled.

run_polling(*bots: Bot[object], **kwargs: object) None[source]

Run start_polling() through asyncio.run.

async start_webhook(*bots: Bot[object], base_url: str, host: str = '0.0.0.0', port: int = 8080, path_prefix: str = '/webhook', secrets: Sequence[str] | None = None, ssl_context: object | None = None, allowed_updates: Sequence[str] | None = None, drop_pending_updates: bool = False, manage_registration: bool = True, delete_on_shutdown: bool = False, max_connections: int | None = None, handle_in_background: bool = True) None[source]

Serve Telegram, Bale and Rubika webhooks from one aiohttp app.

Each bot receives a non-token URL of {path_prefix}/{platform}/{secret}. Rubika’s confirmed inline endpoint is registered at the additional /inline path.

run_webhook(*bots: Bot[object], **kwargs: object) None[source]

Run start_webhook() through asyncio.run for Windows-safe automation.

async stop_polling() None[source]

Request graceful polling shutdown after the current batch.