fix: 主动消息同步推送到平台适配器(QQ)

This commit is contained in:
2026-06-28 11:52:43 +08:00
parent 2b3aa45547
commit a47c8be77b
2 changed files with 22 additions and 2 deletions
+17 -1
View File
@@ -1987,8 +1987,24 @@ func (t *Thinker) storeThought(content string, toolCallsJSON string, toolCallCou
t.convStore.AddMessage(pushSessionID, model.LLMMessage{Role: model.RoleAssistant, Content: proactiveMsg})
}
} else {
log.Printf("[后台思考] 推送主动消息: %%s", proactiveMsg)
log.Printf("[后台思考] 推送主动消息: %s", proactiveMsg)
pusher(t.adminUserID, pushSessionID, proactiveMsg)
// 同步推送到 QQ 私聊
if platformPusher != nil {
t.mu.Lock()
channels := t.platformChannels
t.mu.Unlock()
for _, ch := range channels {
if ch.ChannelType == "direct" {
uid := strings.TrimPrefix(ch.ChannelID, "private_")
target := ProactiveTarget{Platform: ch.AdapterName, ChatType: "private", UserID: uid}
if target.Platform == "" { target.Platform = ch.Platform }
log.Printf("[后台思考] 同步推送主动消息到平台: %s/%s user=%s", target.Platform, target.ChatType, target.UserID)
platformPusher(target, proactiveMsg)
break
}
}
}
if t.convStore != nil && pushSessionID != "" {
t.convStore.AddMessage(pushSessionID, model.LLMMessage{Role: model.RoleAssistant, Content: proactiveMsg})
}
+5 -1
View File
@@ -91,7 +91,11 @@ func (cs *ConversationStore) saveToDB(sessionID string, msg model.LLMMessage) {
sessionID, string(msg.Role), msg.Content, msg.Timestamp,
)
if err != nil {
logger.Printf("[context] saveToDB insert error: %v", err)
logger.Printf("[context] saveToDB insert error: %v (session=%s)", err, sessionID)
}
// 只对非心跳消息打日志
if len(msg.Content) > 5 {
logger.Printf("[context] saveToDB ok: session=%s role=%s len=%d", sessionID, msg.Role, len(msg.Content))
}
}