bot

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 17 Imported by: ? modules, 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 Bot

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

func NewBot

func NewBot(token string, chatID int64, manager *engine.Manager, control *controlapi.Client) (*Bot, error)

NewBot creates a Telegram bot. manager powers read-only queries (/status, /rules, /detail). control is the control API client used for write actions (/reload, /stop, /start_rule, /toggle); when nil or without a token the bot runs in read-only mode and write commands report that control is disabled.

func (*Bot) Ready added in v0.3.0

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

Ready verifies the token with Telegram before Manager replaces a running bot.

func (*Bot) Start

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

type Manager added in v0.3.0

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

Manager implements controlapi.BotController, owning the Telegram bot goroutine lifecycle so the bot can be reconfigured at runtime without restarting the daemon.

func NewManager added in v0.3.0

func NewManager(manager *engine.Manager, controlFn func(string) *controlapi.Client, logger *slog.Logger) *Manager

NewManager creates a bot lifecycle manager. controlFn builds a control API client for a given control token (used by the bot for write actions); it may return nil when no token is configured, in which case the bot runs read-only.

func (*Manager) Apply added in v0.3.0

func (m *Manager) Apply(settings controlapi.BotSettings) error

Apply stops any running bot and starts a new one with settings. With an empty token or chat ID the bot is stopped and not restarted.

func (*Manager) Running added in v0.3.0

func (m *Manager) Running() bool

Running reports whether a bot goroutine is currently active.

func (*Manager) Stop added in v0.3.0

func (m *Manager) Stop() error

Stop stops the running bot without changing persisted configuration.

Jump to

Keyboard shortcuts

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