peyk.dispatcher.router¶
Classes
|
Handler collection for one event type, with filters and middleware. |
|
Aiogram-style first-match router with nested ordered subrouters. |
- class peyk.dispatcher.router.Observer(router: Router, name: str)[source]¶
Bases:
objectHandler collection for one event type, with filters and middleware.
- register(handler: Callable[[P], R], *filters: object) Callable[[P], R][source]¶
Performs the register operation for the dispatcher client.
- Parameters:
handler – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- filter(*filters: object) Observer[source]¶
Performs the filter operation for the dispatcher client.
- Returns:
Result produced by the dispatcher operation.
- middleware(middleware: BaseMiddleware) BaseMiddleware[source]¶
Performs the middleware operation for the dispatcher client.
- Parameters:
middleware – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- outer_middleware(middleware: BaseMiddleware) BaseMiddleware[source]¶
Performs the outer middleware operation for the dispatcher client.
- Parameters:
middleware – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- class peyk.dispatcher.router.Router(*, name: str | None = None)[source]¶
Bases:
objectAiogram-style first-match router with nested ordered subrouters.
- command(*names: str, prefix: str = '/') Callable[[Callable[[P], R]], Callable[[P], R]][source]¶
Register a message handler for one or more bot commands.
This is shorthand for
router.message(Command(name, prefix=prefix))and is available onRouter,Dispatcherand (throughBot.command()) on the bot’s own router. Each alias is registered independently, so all of them share the same Python callable:@router.command("start", "help") async def start(message): ...
- include_router(router: Router) Router[source]¶
Performs the include router operation for the dispatcher client.
- Parameters:
router – Value used by this operation.
- Returns:
Result produced by the dispatcher operation.
- middleware(middleware: BaseMiddleware) BaseMiddleware[source]¶
Register outer whole-subtree middleware, preserving the D3 API.
- handler_middleware(middleware: BaseMiddleware) BaseMiddleware[source]¶
Register middleware that runs after handler flags have been injected.
- has_handlers() bool[source]¶
Performs the has handlers operation for the dispatcher client.
- Returns:
Result produced by the dispatcher operation.
- async propagate_platform_event(update: object, *, platform: str, **data: object) object[source]¶
Dispatch a native platform update and its named Telegram field observer.
platform_eventreceives the complete native update object. For Telegram, a named observer receives the native model stored in the correspondingUpdatefield; other platforms currently have no named-native observer surface.