bot

package
v0.0.3 Latest Latest
Warning

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

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

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
}

Bot represents the Telegram bot.

func New

func New(token, chatID, label string, deps *Dependencies) *Bot

New creates a new Telegram bot.

func (*Bot) IsRunning

func (b *Bot) IsRunning() bool

IsRunning returns whether the bot is active.

func (*Bot) SendMessage

func (b *Bot) SendMessage(ctx context.Context, text string) error

SendMessage sends a Markdown message to the configured chat.

func (*Bot) SendPhoto

func (b *Bot) SendPhoto(ctx context.Context, pngData []byte, caption string) error

SendPhoto sends a PNG photo with an optional caption to the configured chat.

func (*Bot) Start

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

Start begins the long-polling loop.

func (*Bot) Stop

func (b *Bot) Stop()

Stop stops the bot.

type Dependencies

type Dependencies struct {
	Settings  *store.SettingsStore
	Secrets   *store.SecretStore
	Upstreams *store.UpstreamStore
	Traffic   *store.TrafficStore
	Instances *store.InstanceStore

	// Callbacks for actions that need service layer (set by caller)
	GetPublicIP      func(ctx context.Context) string
	IsProxyRunning   func(ctx context.Context) bool
	GetUptime        func(ctx context.Context) string
	GetEngineVersion func() string
	RestartProxy     func(ctx context.Context) error
	GenerateQR       func(ctx context.Context, link string) ([]byte, error)
}

Dependencies holds the stores/services the bot needs for command execution.

type TelegramMessage

type TelegramMessage struct {
	MessageID int64  `json:"message_id"`
	Text      string `json:"text"`
	From      struct {
		ID       int64  `json:"id"`
		Username string `json:"username"`
	} `json:"from"`
}

TelegramMessage represents a message from Telegram.

type TelegramUpdate

type TelegramUpdate struct {
	UpdateID int64            `json:"update_id"`
	Message  *TelegramMessage `json:"message,omitempty"`
}

TelegramUpdate represents an incoming update.

Jump to

Keyboard shortcuts

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