telegram

package
v0.182.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChannelBuiltinCommands = []channels.ChannelCommand{
	{Name: "new", Description: "Start a fresh conversation and wipe recent chat messages (previous one is kept)"},
	{Name: "conversations", Description: "List past conversations, tap one to switch"},
	{Name: "stats", Description: "Usage stats for this conversation — phone-friendly list (/stats 24h; add 'table' for tables)"},
	{Name: "help", Description: "List available commands"},
}

ChannelBuiltinCommands are the shortcuts the daemon implements natively for channels (everything else in the registry is either a custom shortcut, executed as-is, or TUI-only and answered with a pointer to `infer chat`).

Functions

This section is empty.

Types

type ChannelManagerService

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

ChannelManagerService manages pluggable messaging channels and triggers the agent as a subprocess for each inbound message.

func NewChannelManagerService

func NewChannelManagerService(cfg config.ChannelsConfig, tel *telemetry.Recorder) *ChannelManagerService

NewChannelManagerService creates a new channel manager

func (*ChannelManagerService) GetChannel

func (cm *ChannelManagerService) GetChannel(name string) chn.Channel

GetChannel returns a registered channel by name, or nil if not registered. Used by the scheduler service to deliver scheduled-job output through the in-process channel registry.

func (*ChannelManagerService) Register

func (cm *ChannelManagerService) Register(ch chn.Channel)

Register adds a channel to the manager

func (*ChannelManagerService) SetCommandSupport

SetCommandSupport enables slash-command handling for inbound channel messages. A nil registry leaves the feature disabled.

func (*ChannelManagerService) Start

func (cm *ChannelManagerService) Start(ctx context.Context) error

Start begins all registered channels and the message routing loop

func (*ChannelManagerService) Stop

func (cm *ChannelManagerService) Stop() error

Stop gracefully shuts down all channels

type FileRetention

type FileRetention struct {
	Dir    string
	Keep   int
	Prefix string
	// contains filtered or unexported fields
}

FileRetention persists a bounded number of inbound files (voice recordings, photo/video attachments) to a local directory, pruning the oldest once the count exceeds Keep. A nil *FileRetention or a Keep <= 0 disables retention (the default behavior).

save serializes on mu because the channel manager may process messages concurrently and they all share one directory.

func NewMediaRetention

func NewMediaRetention(dir string, keep int) *FileRetention

NewMediaRetention returns a retainer for inbound photo/video attachments.

func NewVoiceRetention

func NewVoiceRetention(dir string, keep int) *FileRetention

NewVoiceRetention returns a retainer for inbound voice/audio recordings.

type TelegramChannel

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

TelegramChannel implements channels.Channel for the Telegram Bot API using the go-telegram/bot SDK with long-polling.

func NewTelegramChannel

func NewTelegramChannel(cfg config.TelegramChannelConfig, transcriber VoiceTranscriber, retention *FileRetention) *TelegramChannel

NewTelegramChannel creates a new Telegram channel. transcriber may be nil, in which case inbound voice messages are ignored. retention may be nil to disable local persistence of inbound voice/audio files.

func (*TelegramChannel) ClearHistory

func (t *TelegramChannel) ClearHistory(ctx context.Context, recipientID string) error

ClearHistory best-effort deletes the tracked messages of a chat. Implements channels.HistoryCleaner. Telegram silently skips messages it can no longer delete (older than 48h), and batches that fail are logged and skipped.

func (*TelegramChannel) Name

func (t *TelegramChannel) Name() string

Name returns the channel identifier

func (*TelegramChannel) Send

Send delivers a message through the Telegram Bot API

func (*TelegramChannel) SendApproval

func (t *TelegramChannel) SendApproval(ctx context.Context, recipientID string, req *ipc.ApprovalRequest) error

SendApproval sends a tool approval prompt with inline keyboard buttons. Implements channels.ApprovalChannel.

func (*TelegramChannel) SetCommands

func (t *TelegramChannel) SetCommands(cmds []channels.ChannelCommand)

SetCommands sets the slash commands advertised to Telegram on Start.

func (*TelegramChannel) Start

func (t *TelegramChannel) Start(ctx context.Context, inbox chan<- channels.InboundMessage) error

Start begins long-polling for Telegram updates and sends inbound messages to the inbox

func (*TelegramChannel) Stop

func (t *TelegramChannel) Stop() error

Stop gracefully shuts down the Telegram channel

type VoiceTranscriber

type VoiceTranscriber interface {
	TranscribeFile(ctx context.Context, audioPath string) (string, error)
}

VoiceTranscriber transcribes a downloaded audio file (any format ffmpeg can decode) into text. It is defined here so the channel can be wired with a concrete speech-to-text implementation only when the feature is enabled, while remaining nil (and a no-op) otherwise.

Jump to

Keyboard shortcuts

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