telegram

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginID    = "channel/telegram"
	RuntimeName = "bot"
)

Variables

This section is empty.

Functions

func DecodeConfig

func DecodeConfig(raw map[string]any) (pkgchannel.TelegramConfig, error)

func NewManagedRuntime

func NewManagedRuntime(deps RuntimeDeps) pkgplugins.Runtime

func RedactConfig

func RedactConfig(raw map[string]any) map[string]any

func SetRuntimeFactoryForTesting

func SetRuntimeFactoryForTesting(factory func(platform pkgplugins.Platform) (pkgplugins.Runtime, error)) func()

SetRuntimeFactoryForTesting swaps the Telegram managed runtime factory for tests.

Types

type Bot

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

Bot wraps a Telegram bot with agent pool integration. It implements channel.Channel.

func New

func New(cfg Config, handler channel.Handler) (*Bot, error)

New creates a Telegram bot and registers handlers. Call Start to begin polling.

func (*Bot) Name

func (b *Bot) Name() string

Name returns the channel name. Implements channel.Channel.

func (*Bot) Notify

func (b *Bot) Notify(_ context.Context, n channel.Notification) error

Notify sends a message to the specified chat. Implements channel.Channel.

func (*Bot) Platform added in v0.10.0

func (b *Bot) Platform() string

func (*Bot) Start

func (b *Bot) Start(ctx context.Context) error

Start begins long polling. It blocks until ctx is cancelled.

func (*Bot) Stop

func (b *Bot) Stop()

Stop gracefully shuts down the Telegram bot. Implements channel.Channel.

type Config

type Config struct {
	InstanceID string // configured channel instance ID
	Token      string // bot token
	ChannelID  string // broadcast channel ID or @username
	GroupMode  string // "mention" | "always" | "disabled"
}

Config holds Telegram bot settings.

type RuntimeDeps

type RuntimeDeps struct {
	Parent        context.Context
	Handler       pkgchannel.Handler
	Notifications pkgplugins.ChannelRegistry
	Now           func() time.Time
	NewChannel    func(pkgchannel.TelegramConfig, pkgchannel.Handler) (pkgchannel.Channel, error)
}

Jump to

Keyboard shortcuts

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