commands

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is the build version string. Set via -ldflags at release time.

Functions

func AddOutputFlags

func AddOutputFlags(cmd *cobra.Command)

func Execute

func Execute() int

func ExecuteRoot

func ExecuteRoot(root *cobra.Command) int

func GetMsgRunner

func GetMsgRunner(_ context.Context, dbPath, selector string, messageID int64, includeDeleted bool) (any, error)

GetMsgRunner mirrors Python `_get_runner`.

func ListMsgsRunner

func ListMsgsRunner(_ context.Context, dbPath, selector string, since, until string, limit int, reverse, includeDeleted bool) (any, error)

ListMsgsRunner mirrors Python `_list_runner`.

func MeLiveRunner

func MeLiveRunner(ctx context.Context, dbPath, sessionPath string) (any, error)

MeLiveRunner connects to Telegram via gotd and refreshes tg_me.

func MeOfflineRunner

func MeOfflineRunner(_ context.Context, dbPath, sessionPath string) (any, error)

MeOfflineRunner returns the cached self-user envelope data, or *resolve.NotFound when the cache is empty. Connecting and closing the DB is the runner's responsibility so the dispatch chokepoint stays uniform.

func NewRootCommand

func NewRootCommand() *cobra.Command

func RegisterAll

func RegisterAll(root *cobra.Command, mgr *accounts.Manager, cfg CommandsConfig)

RegisterAll wires every command group onto root. The accounts manager is the source of truth for per-account paths and also receives accounts-* subcommand calls.

func SearchRunner

func SearchRunner(_ context.Context, dbPath, selector, query string, caseSensitive bool, limit int, includeDeleted bool) (any, error)

SearchRunner mirrors Python `_search_runner`.

func ShowRunner

func ShowRunner(_ context.Context, dbPath, selector string, limit int, reverse, includeDeleted bool) (any, error)

ShowRunner is the runner for `tg show`. Errors map to dispatch error codes.

Types

type AuthPathProvider

type AuthPathProvider interface {
	AccountPaths(account string) (db, session, audit string)
}

AuthPathProvider lets tests inject account paths without depending on the real filesystem layout. Phase 15 will provide the production implementation.

type ChatRef

type ChatRef struct {
	ChatID int64  `json:"chat_id"`
	Title  string `json:"title"`
}

ChatRef is the JSON-serializable shape used by every read command.

type ClientFactory

type ClientFactory func(ctx context.Context, sessionPath, dbPath string) (client.Client, error)

ClientFactory builds a per-command Telegram client. Production wires this to gotd/td; tests inject a *client.FakeClient. The factory receives both the session path (gotd auth state) and the per-account DB path (so the gotd client can read tg_entities to turn chat_ids into InputPeers).

type CommandsConfig

type CommandsConfig struct {
	Paths         AuthPathProvider
	ClientFactory ClientFactory
}

CommandsConfig bundles dependencies the command tree needs.

type FullMessageDTO

type FullMessageDTO struct {
	ChatID       int64   `json:"chat_id"`
	MessageID    int64   `json:"message_id"`
	SenderID     *int64  `json:"sender_id"`
	Date         string  `json:"date"`
	Text         *string `json:"text"`
	IsOutgoing   bool    `json:"is_outgoing"`
	ReplyToMsgID *int64  `json:"reply_to_msg_id"`
	HasMedia     bool    `json:"has_media"`
	MediaType    *string `json:"media_type"`
	MediaPath    *string `json:"media_path"`
	RawJSON      any     `json:"raw_json"`
}

FullMessageDTO mirrors Python `_full_message`.

type MessageSummaryDTO

type MessageSummaryDTO struct {
	MessageID  int64   `json:"message_id"`
	Date       string  `json:"date"`
	IsOutgoing bool    `json:"is_outgoing"`
	Text       *string `json:"text"`
	MediaType  *string `json:"media_type"`
}

MessageSummaryDTO is the wire shape mirroring Python `_message_summary`.

type RootConfig

type RootConfig struct {
	ReadOnly        bool
	LockWaitSeconds float64
	Full            bool
	Account         string
	// ExitCode is set by command runners that emit their own envelope so the
	// process exit matches the dispatch classification rather than cobra's
	// default exit-1-on-RunE-error.
	ExitCode int
}

func RootConfigFrom

func RootConfigFrom(cmd *cobra.Command) RootConfig

Jump to

Keyboard shortcuts

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