feat: wire NOFXi Agent into Telegram bot

- Add NOFXiAgent interface and SetNOFXiAgent() in telegram/bot.go
- Telegram messages now route through the unified agent.Agent
  instead of the legacy telegram/agent package
- Language hint injected from Telegram config for proper i18n
- Legacy telegram/agent path preserved as fallback
- Agent created before Telegram bot starts in main.go
- Build verified, API tested
This commit is contained in:
shinchan-zhai
2026-03-23 02:39:02 +08:00
parent 0fa8c48b84
commit 4cba7edd19
2 changed files with 72 additions and 22 deletions

12
main.go
View File

@@ -142,10 +142,7 @@ func main() {
}
}()
// Start Telegram bot (if TELEGRAM_BOT_TOKEN is configured)
go telegram.Start(cfg, st, telegramReloadCh)
// Start NOFXi Agent (proactive intelligence layer)
// Start NOFXi Agent (proactive intelligence layer) — must be created BEFORE Telegram bot
nofxiAgent := nofxiagent.New(traderManager, st, nil, slog.Default())
// Try to get an AI client from existing trader configs
@@ -164,6 +161,13 @@ func main() {
agentWeb := nofxiagent.NewWebHandler(nofxiAgent, slog.Default())
server.RegisterAgentHandler(agentWeb)
// Wire NOFXi Agent into Telegram bot — messages route through the unified agent
telegram.SetNOFXiAgent(nofxiAgent)
logger.Info("🔗 NOFXi Agent connected to Telegram bot")
// Start Telegram bot (if token is configured)
go telegram.Start(cfg, st, telegramReloadCh)
logger.Info("🧠 NOFXi Agent started (sentinel + brain + scheduler + web:8900)")
// Wait for interrupt signal