mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-16 09:11:03 +08:00
feat: Add smart trading assistant with context awareness
- Add SmartAgent with automatic context injection - Real-time portfolio/position data in every prompt - AI knows current state before responding - Add TradingContext builder - Aggregates balance, positions, P&L across all traders - Auto-generates alerts (liquidation risk, large loss, etc.) - Add background Monitor - Proactive position monitoring every 30s - Detects new positions, closed positions - Forwards alerts to Telegram - Enhanced system prompts - Professional trading assistant persona - Risk assessment guidelines - Clear response formatting rules Features: ✅ Context-aware responses ✅ Proactive risk alerts ✅ Background monitoring ✅ Alert broadcasting to Telegram
This commit is contained in:
@@ -408,6 +408,25 @@ func (b *Bot) AddAllowedUser(userID int64) {
|
||||
b.allowedUsers[userID] = true
|
||||
}
|
||||
|
||||
// BroadcastAlert sends an alert to all admin users
|
||||
func (b *Bot) BroadcastAlert(message string) {
|
||||
for _, adminID := range b.config.AdminUserIDs {
|
||||
chat := &tele.Chat{ID: adminID}
|
||||
_, err := b.bot.Send(chat, "🚨 "+message)
|
||||
if err != nil {
|
||||
logger.Errorf("Failed to send alert to admin %d: %v", adminID, err)
|
||||
}
|
||||
}
|
||||
|
||||
// If no admins configured, send to allowed users
|
||||
if len(b.config.AdminUserIDs) == 0 {
|
||||
for userID := range b.allowedUsers {
|
||||
chat := &tele.Chat{ID: userID}
|
||||
_, _ = b.bot.Send(chat, "🚨 "+message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RemoveAllowedUser removes a user from the allowlist
|
||||
func (b *Bot) RemoveAllowedUser(userID int64) {
|
||||
b.allowedUsersLock.Lock()
|
||||
|
||||
Reference in New Issue
Block a user