From 1e2b2525f4a9efc3fcc869c15399d85ca2f75817 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Tue, 23 Jun 2026 18:43:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=81=E8=81=8A=E4=B8=BB=E5=8A=A8?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=B7=AF=E7=94=B1=E4=BF=AE=E5=A4=8D=20+=20?= =?UTF-8?q?=E5=A4=9A=E8=B4=A6=E5=8F=B7=E8=87=AA=E5=8A=A8=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 正则兼容 private_ 前缀: 【OBv11私聊:private_1487720750】 - prompt 显示频道时自动剥离 private_ 前缀 - extractProactiveMessage 自动查 PlatformChannel 表, 将 target.Platform 从格式key改为adapter实例名 多账号场景下自动路由到正确adapter Co-Authored-By: Claude --- .../ai-core/internal/background/thinker.go | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/backend/ai-core/internal/background/thinker.go b/backend/ai-core/internal/background/thinker.go index 226a02d..1c910e3 100644 --- a/backend/ai-core/internal/background/thinker.go +++ b/backend/ai-core/internal/background/thinker.go @@ -73,7 +73,7 @@ func defaultPlatformFormats() map[string]*PlatformFormat { formats := make(map[string]*PlatformFormat) obv11 := &PlatformFormat{ Label: "OBv11", - TargetRegex: `【OBv11(私聊|群聊):(\d+)(?:@(\d+))?】`, + TargetRegex: `【OBv11(私聊|群聊):(?:private_)?(\d+)(?:@(\d+))?】`, GroupMarkerFmt: "【OBv11群聊:%s】", PrivateMarkerFmt: "【OBv11私聊:%s】", GroupAtMarkerFmt: "【OBv11群聊:%s@%s】", @@ -1619,8 +1619,11 @@ func (t *Thinker) buildThinkingUserPrompt( for _, ch := range qqChannels { if ch.Platform == "obv11" && ch.ChannelID == activeChID { chLabel := activeChID + displayChID := strings.TrimPrefix(activeChID, "private_") if ch.ChannelName != "" { - chLabel = fmt.Sprintf("%s(%s)", ch.ChannelName, activeChID) + chLabel = fmt.Sprintf("%s(%s)", ch.ChannelName, displayChID) + } else if displayChID != activeChID { + chLabel = displayChID } // Last message time hint. timeHint := "" @@ -1885,8 +1888,25 @@ func (t *Thinker) extractProactiveMessage(content string) (string, *ProactiveTar if m[1] == pf.GroupKeyword { chatType = "group" } + // Resolve adapter name from registered channels. + channelID := m[2] + if chatType == "private" { + channelID = "private_" + m[2] + } + adapterName := platform // fallback to format key + t.mu.Lock() + for _, ch := range t.platformChannels { + if ch.Platform == platform && ch.ChannelType == chatType && ch.ChannelID == channelID { + if ch.AdapterName != "" { + adapterName = ch.AdapterName + } + break + } + } + t.mu.Unlock() + target = &ProactiveTarget{ - Platform: platform, + Platform: adapterName, ChatType: chatType, UserID: m[2], GroupID: m[2],