Documentation
¶
Overview ¶
Package telegram adapts the Telegram Bot API to the inbox Source and Sink ports. It receives messages by long-polling getUpdates and replies with sendMessage, using only the standard library so it ships in the single static binary with no extra dependencies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot is a Telegram bot adapted to the inbox ports: it is both a Source (inbound messages) and a Sink (outbound replies). Construct it with New.
func New ¶
New builds a Telegram bot for the given token. The token is required and is never logged or wrapped into an error.
func (*Bot) Receive ¶
Receive long-polls getUpdates and streams each text message as an inbox.Spec until ctx is cancelled, then closes the returned channel. Transient request failures are retried after a short backoff rather than ending the stream. The Spec's Source is left for the ingester to stamp.
type Option ¶
type Option func(*Bot)
Option configures a Bot.
func WithBaseURL ¶
WithBaseURL overrides the API root (for tests).
func WithClock ¶
WithClock sets the clock that paces reconnect backoff, so a test drives retry timing with a Manual clock instead of sleeping. Production leaves the default System clock.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client used for API calls. The default client has no timeout because getUpdates long-polls; per-request deadlines are applied internally instead.
func WithPollTimeout ¶
WithPollTimeout overrides how long each getUpdates call waits for a message.