diff --git a/cmd/server/main.go b/cmd/server/main.go index 704bffe..586b18f 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -25,6 +25,7 @@ import ( "github.com/tiennm99/miti99bot-go/internal/modules/lolschedule" "github.com/tiennm99/miti99bot-go/internal/modules/misc" "github.com/tiennm99/miti99bot-go/internal/modules/semantle" + "github.com/tiennm99/miti99bot-go/internal/modules/trading" "github.com/tiennm99/miti99bot-go/internal/modules/twentyq" "github.com/tiennm99/miti99bot-go/internal/modules/util" "github.com/tiennm99/miti99bot-go/internal/modules/wordle" @@ -50,6 +51,7 @@ func factories() map[string]modules.Factory { "semantle": semantle.New, "doantu": doantu.New, "twentyq": twentyq.New, + "trading": trading.New, } } @@ -106,6 +108,7 @@ func main() { reg, err := modules.Build(cfg.Modules, factories(), provider, cfg.ModuleEnv, modules.BuildOptions{ Embedder: aiClient, Chatter: aiClient, + Bot: b, }) if err != nil { log.Fatal("module registry build failed", "err", err) diff --git a/internal/modules/module.go b/internal/modules/module.go index 2f24b71..3553fb9 100644 --- a/internal/modules/module.go +++ b/internal/modules/module.go @@ -79,6 +79,7 @@ type Deps struct { Registry *Registry // populated by Build; safe to capture but read-only at module use Embedder ai.Embedder // nil if GEMINI_API_KEY unset; semantle/doantu must check Chatter ai.Chatter // nil if GEMINI_API_KEY unset; twentyq must check + Bot *bot.Bot // nil-safe: only crons that fan-out (lolschedule daily push) need it } // Factory constructs a Module from its Deps. Spec deviation: Phase 03 plan diff --git a/internal/modules/registry.go b/internal/modules/registry.go index dba5c79..3fb1a30 100644 --- a/internal/modules/registry.go +++ b/internal/modules/registry.go @@ -5,6 +5,8 @@ import ( "regexp" "sort" + "github.com/go-telegram/bot" + "github.com/tiennm99/miti99bot-go/internal/ai" "github.com/tiennm99/miti99bot-go/internal/storage" ) @@ -83,6 +85,7 @@ func (r *Registry) Crons() []Cron { type BuildOptions struct { Embedder ai.Embedder Chatter ai.Chatter + Bot *bot.Bot } func Build(enabled []string, factories map[string]Factory, kv storage.KVProvider, env map[string]string, opts BuildOptions) (*Registry, error) { @@ -125,6 +128,7 @@ func Build(enabled []string, factories map[string]Factory, kv storage.KVProvider Registry: reg, Embedder: opts.Embedder, Chatter: opts.Chatter, + Bot: opts.Bot, } mod := factory(moduleDeps) // A factory that hardcodes its own Name is a bug: the registry key is