bot

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 19 Imported by: 0 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

Overview

Package bot contains Telegram command handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandName

func CommandName(text string) string

CommandName returns the lower-cased bot command without a bot suffix.

func IsAdminCallback

func IsAdminCallback(data string) bool

IsAdminCallback reports whether callback data belongs to owner commands.

Types

type AdminSyncFunc

type AdminSyncFunc func(ctx context.Context, tgID *int64) (string, error)

AdminSyncFunc runs reconciliation from an owner command.

type Button

type Button struct {
	Text         string `json:"text"`
	CallbackData string `json:"callback_data"`
}

Button is one inline keyboard button for a command reply.

type ChatRole

type ChatRole struct {
	Role   string
	ChatID int64
}

ChatRole is one configured chat shown by /chats.

type ChatTitleResolver

type ChatTitleResolver func(ctx context.Context, chatID int64) (string, bool)

ChatTitleResolver resolves a chat's live Telegram title for owner-facing diagnostics such as /chats. It returns false when the title cannot be read, letting callers fall back to the bare chat id.

type CommandDeps

type CommandDeps struct {
	Users         *store.Users
	Subscriptions *store.Subscriptions
	Grants        *store.Grants
	Audit         *store.Audit
	Whitelist     *store.Whitelist
	Revocations   *store.Revocations
	Outbox        *store.Outbox
	Alerts        *store.Alerts
	Ops           *store.Ops
	ChatRoles     []ChatRole
	ChatInfo      ChatTitleResolver
	StatusEngine  *engine.Engine
	Members       engine.MemberChecker
	Preflight     *engine.Snapshot
	AdminSync     AdminSyncFunc

	// SubscribeLinks carries the deployment-specific subscription URLs the
	// /boosty and /tribute pages render. Sourced from config via the router.
	SubscribeLinks messages.SubscribeLinks

	// OperatorLog, when set, receives durable operator events emitted in the
	// command transaction. Optional: a nil writer disables the feed.
	OperatorLog *operatorlog.Writer
}

CommandDeps are transaction-bound dependencies for bot commands.

type Reply

type Reply struct {
	ChatID    int64
	TGID      int64
	Text      string
	ParseMode string
	Plain     bool
	DM        bool
	Buttons   [][]Button
}

Reply is a post-commit Telegram message effect.

type Result

type Result struct {
	Ignored bool
	Replies []Reply
}

Result is the durable command handling result.

type UserCommands

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

UserCommands handles user and owner bot commands.

func NewCommands

func NewCommands(deps CommandDeps, ownerIDs []int64) *UserCommands

NewCommands returns command handlers bound to one handleTx dependency set.

func NewUserCommands

func NewUserCommands(users *store.Users, ownerIDs []int64) *UserCommands

NewUserCommands returns user command handlers bound to users.

func (*UserCommands) HandleCallback

func (h *UserCommands) HandleCallback(
	ctx context.Context,
	query *models.CallbackQuery,
) (Result, error)

HandleCallback routes owner confirmation callbacks.

func (*UserCommands) HandleHere

func (h *UserCommands) HandleHere(msg *models.Message) Result

HandleHere returns chat id/type for owners in non-private chats.

func (*UserCommands) HandlePrivate

func (h *UserCommands) HandlePrivate(
	ctx context.Context, msg *models.Message,
) (Result, error)

HandlePrivate routes a private message to supported commands.

type WhoisTarget

type WhoisTarget struct {
	TGID      int64
	Query     string
	NotFound  bool
	BadSyntax bool
}

WhoisTarget is a resolved /whois argument.

func ResolveWhoisTarget

func ResolveWhoisTarget(
	ctx context.Context,
	users *store.Users,
	text string,
) (WhoisTarget, error)

ResolveWhoisTarget resolves a /whois argument using only local data.

Jump to

Keyboard shortcuts

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