Documentation
¶
Overview ¶
Package webhook provides an implementation of UpdateSource using Telegram webhooks.
Index ¶
- Constants
- type OptOptionsSetter
- func WithAllowedUpdates(opt []string) OptOptionsSetter
- func WithBufferSize(opt int) OptOptionsSetter
- func WithClient(opt client.ClientWithResponsesInterface) OptOptionsSetter
- func WithDropPendingUpdates(opt bool) OptOptionsSetter
- func WithMaxBodyBytes(opt int64) OptOptionsSetter
- func WithMaxConnections(opt int) OptOptionsSetter
- func WithToken(opt string) OptOptionsSetter
- func WithUrl(opt string) OptOptionsSetter
- func WithWebhookRegistrationEnabled(enabled bool) OptOptionsSetter
- type Options
- type Webhook
Constants ¶
const (
// HeaderTelegramBotAPISecretToken is the header used by Telegram to send the secret token.
HeaderTelegramBotAPISecretToken = "X-Telegram-Bot-Api-Secret-Token"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OptOptionsSetter ¶
type OptOptionsSetter func(o *Options)
func WithAllowedUpdates ¶
func WithAllowedUpdates(opt []string) OptOptionsSetter
func WithBufferSize ¶
func WithBufferSize(opt int) OptOptionsSetter
func WithClient ¶
func WithClient(opt client.ClientWithResponsesInterface) OptOptionsSetter
func WithDropPendingUpdates ¶
func WithDropPendingUpdates(opt bool) OptOptionsSetter
func WithMaxBodyBytes ¶
func WithMaxBodyBytes(opt int64) OptOptionsSetter
func WithMaxConnections ¶
func WithMaxConnections(opt int) OptOptionsSetter
func WithToken ¶
func WithToken(opt string) OptOptionsSetter
func WithUrl ¶
func WithUrl(opt string) OptOptionsSetter
func WithWebhookRegistrationEnabled ¶
func WithWebhookRegistrationEnabled(enabled bool) OptOptionsSetter
WithWebhookRegistrationEnabled controls whether Start configures the Telegram webhook.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options is the options for the Webhook handler.
func NewOptions ¶
func NewOptions( options ...OptOptionsSetter, ) Options
type Webhook ¶
type Webhook struct {
// contains filtered or unexported fields
}
Webhook implements http.Handler to receive incoming updates via an outgoing webhook.
func (*Webhook) ServeHTTP ¶
func (h *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler interface. It validates the request, decodes the update, and sends it to the updates channel.
func (*Webhook) SetWebhook ¶
SetWebhook sets the outgoing webhook for the bot.
func (*Webhook) Start ¶
Start satisfies the lifecycle.Lifecycle interface. The context is used only for the startup timeout.
func (*Webhook) Stop ¶
Stop satisfies the lifecycle.Lifecycle interface. The context is used only for the shutdown timeout.
func (*Webhook) UpdateChan ¶
UpdateChan returns the updates channel.