webhook

package
v0.0.0-...-422e9ff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package webhook provides an implementation of UpdateSource using Telegram webhooks.

Index

Constants

View Source
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 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

func (*Options) Validate

func (o *Options) Validate() error

type Webhook

type Webhook struct {
	// contains filtered or unexported fields
}

Webhook implements http.Handler to receive incoming updates via an outgoing webhook.

func New

func New(opts Options) (*Webhook, error)

New creates a new Webhook handler.

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

func (h *Webhook) SetWebhook(ctx context.Context) error

SetWebhook sets the outgoing webhook for the bot.

func (*Webhook) Start

func (h *Webhook) Start(ctx context.Context) error

Start satisfies the lifecycle.Lifecycle interface. The context is used only for the startup timeout.

func (*Webhook) Stop

func (h *Webhook) Stop(_ context.Context) error

Stop satisfies the lifecycle.Lifecycle interface. The context is used only for the shutdown timeout.

func (*Webhook) UpdateChan

func (h *Webhook) UpdateChan() <-chan client.Update

UpdateChan returns the updates channel.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL