1.8 KiB
1.8 KiB
summary, read_when
| summary | read_when | |
|---|---|---|
| Telegram Bot API integration via grammY with setup notes |
|
grammY Integration (Telegram Bot API)
Updated: 2025-12-07
Why grammY
- TS-first Bot API client with built-in long-poll + webhook helpers, middleware, error handling, rate limiter.
- Cleaner media helpers than hand-rolling fetch + FormData; supports all Bot API methods.
- Extensible: proxy support via custom fetch, session middleware (optional), type-safe context.
What we shipped
- Single client path: fetch-based implementation removed; grammY is now the sole Telegram client (send + gateway) with the grammY throttler enabled by default.
- Gateway:
monitorTelegramProviderbuilds a grammYBot, wires mention/allowlist gating, media download viagetFile/download, and delivers replies withsendMessage/sendPhoto/sendVideo/sendAudio/sendDocument. Supports long-poll or webhook viawebhookCallback. - Proxy: optional
telegram.proxyusesundici.ProxyAgentthrough grammY’sclient.baseFetch. - Webhook helpers:
webhook-set.tswrapssetWebhook/deleteWebhook;webhook.tshosts the callback with health + graceful shutdown and optional--webhook-urloverride. - Sessions: direct chats map to
main; groups map togroup:<chatId>; replies route back to the same surface. - Config knobs:
telegram.botToken,requireMention,allowFrom,mediaMaxMb,proxy,webhookSecret,webhookUrl. - Tests: grammy mocks cover DM + group mention gating and outbound send; more media/webhook fixtures still welcome.
Open questions
- Optional grammY plugins (throttler) if we hit Bot API 429s.
- Add more structured media tests (stickers, voice notes).
- Expose a
--public-urlflag in CLI for webhook registration convenience (currently--webhook-url).