Telegram Provider¶
TelegramBotProvider ¶
Bases: TelegramProvider
Send messages via the Telegram Bot API.
verify_signature ¶
Verify a Telegram webhook secret token.
Telegram's setWebhook accepts a secret_token parameter.
On each webhook request Telegram sends the token in the
X-Telegram-Bot-Api-Secret-Token header. Verification is a
constant-time comparison of that header value against the
configured :attr:TelegramConfig.webhook_secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
bytes
|
Raw request body bytes (unused). |
required |
signature
|
str
|
Value of the |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the token matches, False otherwise. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TelegramConfig ¶
Bases: BaseModel
Telegram Bot API provider configuration.
MockTelegramProvider ¶
Bases: TelegramProvider
Records sent messages for verification in tests.
parse_telegram_webhook ¶
Convert a Telegram Update payload into InboundMessages.
Telegram sends one update at a time (unless using getUpdates).
Only message updates are processed; edits, channel posts, and
callback queries are silently skipped.
For photo messages the largest available file_id is stored in
metadata under "file_id"; callers must resolve it to a download
URL via the Bot API getFile endpoint.