fix: 私聊主动消息路由修复 + 多账号自动适配
- 正则兼容 private_ 前缀: 【OBv11私聊:private_1487720750】 - prompt 显示频道时自动剥离 private_ 前缀 - extractProactiveMessage 自动查 PlatformChannel 表, 将 target.Platform 从格式key改为adapter实例名 多账号场景下自动路由到正确adapter Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user