Documentation

Telegram

The telegram package wraps github.com/go-telegram/bot with long polling, synchronous reply dispatch, media helpers, and Telegram-specific interactions.

Lifecycle and input

New(token, opts...) validates a non-empty token but does not start polling. Start(ctx) calls GetMe, checks webhook state, conditionally removes an existing webhook, then starts polling. Close() cancels the loop and clears status and multi-select state.

Input includes ChatID, ChatName, MessageID, sender fields, text/caption, Photo, Document, CallbackData, CallbackPicks, and the raw update.

Messages and media

Method Behavior
Send optional reply target and MarkdownV2 or HTML parse mode
SendFile document, video, or audio uploaded by streaming a local path
SendPhoto one photo or an album of 2–10 photos
SendVoice tts.Get output uploaded as voice.ogg
Save download a file with a 20 MiB hard cap

Interactive prompts

SendInput uses ForceReply. SendSelect builds one inline button per item; the callback is acknowledged and its keyboard is cleared before Reply receives CallbackData. SendMultiSelect renders toggle buttons plus Done. Toggle presses redraw state without invoking the handler; Done clears the keyboard and invokes it once with CallbackPicks.

Status

SendStatus creates or edits one debounced message per chat. On its first flush it adds a reaction (default 🤔) to the original message. FinishStatus removes that reaction and deletes the status message.

中文