webhook

package
v0.0.0-...-889dc0d Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 7 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 WithBufferSize

func WithBufferSize(opt int) OptOptionsSetter

func WithToken

func WithToken(opt string) OptOptionsSetter

func WithUrl

func WithUrl(opt string) OptOptionsSetter

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