package agent import ( "github.com/patriceckhart/zot/packages/agent/modes/bot" ) // botSpec describes one bot protocol to the generic daemon CLI in // botcmd.go. Everything protocol-specific (setup flow, status text, // adapter construction, state files) hangs off this struct; the // subcommand plumbing (run/start/stop/logs) is shared. type botSpec struct { name string // "telegram", "matrix" — used in messages subcommand string // "telegram-bot", "matrix-bot" aliases []string // {"tg"}, {"mx"} pidPath func(zotHome string) string logPath func(zotHome string) string // configured reports whether setup has been completed (e.g. a // token is present), with a hint error message when it hasn't. configured func(zotHome string) (bool, error) printHelp func() setup func(tail []string) error status func() error reset func() error // newAdapter builds the protocol adapter for the standalone // daemon. Credential refresh stays generic in botRun. newAdapter func(zotHome string) (bot.BotAdapter, error) } // botSpecs is the registry the dispatcher walks. Matrix is appended // in matrixcmd.go's init. var botSpecs = []*botSpec{telegramSpec()} // specFor returns the spec matching subcommand or one of its aliases. func specFor(subcommand string) *botSpec { for _, s := range botSpecs { if s.subcommand == subcommand { return s } for _, a := range s.aliases { if a == subcommand { return s } } } return nil }