Skip to main content

Module service_telegram

Module service_telegram 

Source
Expand description

Telegram’s plug-in to the generic service lifecycle.

Everything in this file is Telegram-specific — scope names, the prompt for a default chat, the shape of the Telegram credential (TelegramSecrets = one bot token), and the call that validates the token against the Bot API. The generic plumbing (flag parsing, path resolution, JSON envelopes, human banners, keychain I/O sequencing) lives in src/cli/lifecycle.rs and is shared with every other service.

See docs/services.md#adding-a-new-service for the full recipe.

Structs§

CapturedChat
Snapshot of the first private-chat message we saw during capture. chat_id is the value persisted to config; the remaining fields are used only to render the confirmation prompt.
CreateArgs
TelegramLifecycle
TelegramSecrets
Telegram uses one long-lived bot token, issued by @BotFather. It carries the bot’s identity on its own — there is no separate application ID.

Constants§

CAPTURE_TIMEOUT
How long capture_self_chat will wait for the user to send a message to the bot before giving up. Picked to be long enough for a context-switch to the Telegram client, short enough to fail fast if the user never sends anything.

Functions§

capture_self_chat
Poll getUpdates for up to CAPTURE_TIMEOUT seconds, looking for the first private-chat message whose from.id differs from the bot’s own ID. Returns Some(CapturedChat) on success (and after the user confirms the detected identity), None if the user skipped or the timeout elapsed.