Documentation
¶
Overview ¶
Package telegram sends notification batches through the Telegram Bot API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidConfig indicates invalid client settings. ErrInvalidConfig = errors.New("invalid telegram configuration") // ErrInvalidChat indicates an invalid chat destination. ErrInvalidChat = errors.New("invalid telegram chat") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client[T any] struct { // contains filtered or unexported fields }
Client is a shared Telegram bot client.
func (*Client[T]) Bot ¶ added in v0.3.1
Bot returns the underlying go-telegram/bot client so callers can register their own update handlers.
func (*Client[T]) Chat ¶
func (c *Client[T]) Chat(id, chat string, renderer Renderer[T], opts ...SendOption) (notifier.Destination[T], error)
Chat creates a destination for a Telegram chat. opts customize every SendMessage call, e.g. WithParseMode(models.ParseModeMarkdown) or setting fields directly.
type Config ¶
type Config struct {
// Token is the required BotFather token. Errors do not include it.
Token string
// APIBase overrides the Bot API endpoint.
APIBase string
// WebhookURL receives updates in webhook mode.
WebhookURL string
// WebhookPattern is the ServeMux pattern returned by Routes.
WebhookPattern string
// WebhookSecret authenticates webhook callbacks.
WebhookSecret string
// Polling selects long polling instead of webhook mode.
Polling bool
// HTTPClient overrides the default HTTP client used for Bot API requests (i.e. for proxy).
// Callers must not mutate it while in use.
HTTPClient *http.Client
// ProxyCACertPath adds a trusted CA for the Bot API connection.
ProxyCACertPath string
// ClientCertPath and ClientKeyPath configure mTLS and must be set together.
ClientCertPath string
ClientKeyPath string
}
Config defines Telegram API and update-delivery settings.
type Route ¶
type Route struct {
// Pattern is a net/http ServeMux pattern.
Pattern string
// Handler serves Pattern.
Handler http.Handler
}
Route describes an HTTP endpoint required by a Client.
type SendOption ¶ added in v0.2.0
type SendOption func(*bot.SendMessageParams)
SendOption customizes the bot.SendMessageParams used for a Chat's messages.
func WithParseMode ¶ added in v0.2.0
func WithParseMode(mode models.ParseMode) SendOption
WithParseMode sets the message parse mode, e.g. models.ParseModeMarkdown or models.ParseModeHTML.
func WithoutLinkPreview ¶ added in v0.2.0
func WithoutLinkPreview() SendOption
WithoutLinkPreview disables the link preview for URLs found in the message text.
func WithoutNotification ¶ added in v0.2.0
func WithoutNotification() SendOption
WithoutNotification delivers the message silently: no sound or vibration on the recipient's device.