telegram

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package telegram implements the gateway.NotificationAdapter for Telegram Bot API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter implements gateway.NotificationAdapter for Telegram. It also supports outbound messaging via the Send method.

func New

func New(token, mode string) *Adapter

New creates a new Telegram adapter with the default name "telegram".

func NewNamed added in v0.2.0

func NewNamed(name, token, mode string) *Adapter

NewNamed creates a Telegram adapter with a custom name (e.g. "telegram:trade_research"). This allows registering multiple Telegram bots in the same gateway manager.

func (*Adapter) AddChat

func (a *Adapter) AddChat(chatID int64, name string)

AddChat manually registers a chat ID → name mapping.

func (*Adapter) Channels

func (a *Adapter) Channels() []gateway.ChannelInfo

Channels returns discovered channels.

func (*Adapter) DiscoverViaUpdate

func (a *Adapter) DiscoverViaUpdate() error

DiscoverViaUpdate processes a single getUpdates call to discover groups the bot has been added to. Called before Start to populate initial channels.

func (*Adapter) HTTPHandler added in v0.2.1

func (a *Adapter) HTTPHandler() http.Handler

HTTPHandler returns nil since Telegram uses polling, not webhooks.

func (*Adapter) Health

func (a *Adapter) Health(_ context.Context) error

Health returns nil if the adapter is connected and operational.

func (*Adapter) Name

func (a *Adapter) Name() string

func (*Adapter) Send

func (a *Adapter) Send(_ context.Context, channelID, sender, content string) error

Send delivers a message to a Telegram chat.

func (*Adapter) Start

func (a *Adapter) Start(ctx context.Context, handler func(gateway.Notification)) error

Start connects to Telegram and forwards events as Notifications.

func (*Adapter) Status

func (a *Adapter) Status() gateway.AdapterStatus

Status returns the current connection state.

func (*Adapter) Stop

func (a *Adapter) Stop() error

Stop gracefully disconnects.

func (*Adapter) Type added in v0.2.1

func (a *Adapter) Type() gateway.AdapterType

Type returns AdapterSocket since Telegram uses long-polling that blocks like a socket.

Jump to

Keyboard shortcuts

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