telegram

package
v0.68.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: AGPL-3.0 Imports: 26 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) Finalize added in v0.63.0

func (b *Bot) Finalize()

Finalize removes routing registrations after accepted work has drained.

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

func (b *Bot) Platform() string

func (*Bot) Publish added in v0.43.0

func (b *Bot) Publish(ctx context.Context, req internalchannel.GroupPublishRequest) (err error)

Publish renders the dispatcher-owned ChatStream as one Telegram message. It deliberately has no session or agent logic: a failed platform request is returned so the existing at-least-once group dispatcher owns the retry.

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
	Token           string
	ChannelID       string
	AllowGroup      bool
	AllowedChatIDs  []string
	AllowedTopicIDs []string
	AllowDM         bool
	RequireMention  bool
}

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