GitHub

TelegramChatService

API reference for TelegramChatService.

The Telegram adapter's own service.

  • bot_id is the numeric id in front of the token's colon.
  • receive runs one update, already authenticated and parsed, as both transports do, for a consumer's own transport. It needs a ChatHandler. Clicks and commands go to chat_interaction.Handler when there is one in context: without it a click is answered and dropped, and a command is an ordinary message.

Attributes

AttributeTypeDescription
bot_idstr

The numeric id in front of the token's colon.

environmentEnvironment

"production", or "test" for Telegram's test environment.

Functions

__init__

__init__(*, api, env) -> None
ParameterTypeDescription
apiTelegramBotApiService
env_receive.Environment
def __init__(self, *, api: TelegramBotApiService, env: _receive.Environment) -> None:
    self._api = api
    self._env = env

receive

receive(update, options=None) -> Effect[Outcome, Never, ChatHandler]

Runs one update; see the class.

ParameterTypeDescription
updateobject
optionsReceiveOptions | 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
            )
        )
    )