The Telegram adapter's own service.
bot_idis the numeric id in front of the token's colon.receiveruns one update, already authenticated and parsed, as both transports do, for a consumer's own transport. It needs aChatHandler. Clicks and commands go tochat_interaction.Handlerwhen there is one in context: without it a click is answered and dropped, and a command is an ordinary message.
Attributes#
| Attribute | Type | Description |
|---|---|---|
bot_id | str | The numeric id in front of the token's colon. |
environment | Environment |
|
Functions#
__init__#
__init__(*, api, env) -> None| Parameter | Type | Description |
|---|---|---|
api | TelegramBotApiService | |
env | _receive.Environment |
def __init__(self, *, api: TelegramBotApiService, env: _receive.Environment) -> None:
self._api = api
self._env = envreceive#
receive(update, options=None) -> Effect[Outcome, Never, ChatHandler]Runs one update; see the class.
| Parameter | Type | Description |
|---|---|---|
update | object | |
options | ReceiveOptions | None = None |
Returns Effect[Outcome, Never, ChatHandler]
def receive(
self, update: object, options: ReceiveOptions | None = None
) -> Effect[Outcome, Never, ChatHandler]:
"""Runs one update; see the class."""
return ChatHandler().flat_map(
lambda handler: fx.service_option(Handler).flat_map(
lambda found: self._run(
update, options, handler, None if found is None else found.value
)
)
)