telegram

package
v0.30.19 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 31 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

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 platform.Platform for Telegram.

func NewAdapter

func NewAdapter(cfg config.TelegramConfig, pool *acp.SessionPool, transcriber stt.Transcriber, synthesizer tts.Synthesizer, ttsCfg config.TTSConfig, mdCfg config.MarkdownConfig, picker sessionpicker.Picker, cronStore *cronjob.Store, cronCfg config.CronjobConfig) (*Adapter, error)

func (*Adapter) Healthy

func (a *Adapter) Healthy() bool

Healthy reports whether the Telegram polling loop is operating normally. Returns false when consecutive getUpdates errors have reached the restart threshold, indicating the adapter is degraded (e.g. after a network change).

func (*Adapter) RegisterCron added in v0.30.0

func (a *Adapter) RegisterCron(registry *cronjob.Registry)

RegisterCron creates the per-platform cron Dispatcher and registers it with the prefix "tg" in the provided registry. The prefix must match buildSessionKey's output ("tg:<chat>" / "tg:<chat>:<thread>"), not the platform's full name — the scheduler routes by the substring before the first ':' in the threadKey.

func (*Adapter) Start

func (a *Adapter) Start() error

func (*Adapter) Stop

func (a *Adapter) Stop() error

type CronDispatcher added in v0.30.0

type CronDispatcher struct {
	Handler *Handler
	Bot     *bot.Bot
}

CronDispatcher implements cronjob.Dispatcher for Telegram threads.

func (*CronDispatcher) Fire added in v0.30.0

func (d *CronDispatcher) Fire(ctx context.Context, job cronjob.Job) error

Fire posts a placeholder message into the originating chat (and forum topic if applicable), builds the cron-flavoured sender_context, and streams the reply via the existing streamPrompt machinery.

func (*CronDispatcher) NotifyDropped added in v0.30.0

func (d *CronDispatcher) NotifyDropped(ctx context.Context, job cronjob.Job)

NotifyDropped posts a brief marker so the user notices a fire was lost. Best-effort; failure is logged, not returned.

type Handler

type Handler struct {
	Bot            *bot.Bot
	Pool           *acp.SessionPool
	AllowedChats   map[int64]bool
	AllowedUserIDs map[int64]bool
	// AllowAnyUser is true when allowed_user_id contains "*" — anyone can talk
	// to the bot from any chat.
	AllowAnyUser    bool
	ReactionsConfig config.ReactionsConfig
	Transcriber     stt.Transcriber
	Synthesizer     tts.Synthesizer
	TTSConfig       config.TTSConfig
	// MarkdownTableMode controls how GFM tables in agent replies are rewritten
	// before being sent to Telegram. See markdown.TableMode for options.
	MarkdownTableMode markdown.TableMode
	// BotToken is the raw Telegram bot token, kept so sendRichMessage can issue
	// the raw Bot API 10.1 call (go-telegram/bot has no binding for it yet).
	BotToken string
	// RichMessages opts into the experimental Bot API 10.1 sendRichMessage path
	// for complex replies (tables/headings/long). Off by default; falls back to
	// the parse_mode=HTML path on any failure.
	RichMessages bool
	// Picker lists historical sessions for /pick. Nil when
	// the configured agent backend is not recognised by sessionpicker.Detect.
	Picker    sessionpicker.Picker
	CronStore *cronjob.Store
	CronCfg   config.CronjobConfig
	// contains filtered or unexported fields
}

type StatusReactionController

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

func NewStatusReactionController

func NewStatusReactionController(
	enabled bool,
	b *bot.Bot,
	chatID int64,
	messageID int,
	emojis config.ReactionEmojis,
	timing config.ReactionTiming,
) *StatusReactionController

func (*StatusReactionController) Clear

func (c *StatusReactionController) Clear()

func (*StatusReactionController) SetCancelled

func (c *StatusReactionController) SetCancelled()

SetCancelled is a terminal state for user-triggered cancellation (session/cancel). Distinct from SetError so downstream UI can tell the difference between a crash and an intentional stop. Telegram requires reactions to come from a fixed allowed set — 🙊 ("speak-no-evil" monkey) matches the semantic of "agent stopped talking" within that set.

func (*StatusReactionController) SetDone

func (c *StatusReactionController) SetDone()

func (*StatusReactionController) SetError

func (c *StatusReactionController) SetError()

func (*StatusReactionController) SetQueued

func (c *StatusReactionController) SetQueued()

func (*StatusReactionController) SetThinking

func (c *StatusReactionController) SetThinking()

func (*StatusReactionController) SetTool

func (c *StatusReactionController) SetTool(toolName string)

Jump to

Keyboard shortcuts

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