refactor: 彻底消除硬编码 qq — 平台标识统一为 obv11
- PlatformName() 返回 "obv11" - platformFormats key: "obv11" - 所有 platform == "qq" 检查 → "obv11" - session prefix: platform_qq_ → platform_obv11_ - env var PLATFORM_CHANNELS: obv11:group:xxx - ethend 平台标识同步更新 - 注释和测试用例同步 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -33,7 +33,7 @@ type PendingThought struct {
|
||||
// ProactiveTarget describes the target for proactive platform messages (OBv11, etc.).
|
||||
// When nil, the message goes through the existing Web push path.
|
||||
type ProactiveTarget struct {
|
||||
Platform string // "qq"
|
||||
Platform string // "obv11"
|
||||
ChatType string // "private" or "group"
|
||||
UserID string // OBv11 user number
|
||||
GroupID string // OBv11 group number (group chat)
|
||||
@@ -71,7 +71,7 @@ type PlatformFormat struct {
|
||||
// defaultPlatformFormats returns the built-in platform format registry.
|
||||
func defaultPlatformFormats() map[string]*PlatformFormat {
|
||||
formats := make(map[string]*PlatformFormat)
|
||||
qq := &PlatformFormat{
|
||||
obv11 := &PlatformFormat{
|
||||
Label: "OBv11",
|
||||
TargetRegex: `【OBv11(私聊|群聊):(\d+)(?:@(\d+))?】`,
|
||||
GroupMarkerFmt: "【OBv11群聊:%s】",
|
||||
@@ -80,14 +80,14 @@ func defaultPlatformFormats() map[string]*PlatformFormat {
|
||||
GroupKeyword: "群聊",
|
||||
PrivateKeyword: "私聊",
|
||||
}
|
||||
qq.compiled = regexp.MustCompile(qq.TargetRegex)
|
||||
formats["qq"] = qq
|
||||
obv11.compiled = regexp.MustCompile(obv11.TargetRegex)
|
||||
formats["obv11"] = obv11
|
||||
return formats
|
||||
}
|
||||
|
||||
// ParsePlatformChannels parses PLATFORM_CHANNELS env var.
|
||||
// Format: "qq:group:123456,telegram:group:789012"
|
||||
// Optional 4th field for display name: "qq:group:123456:群名称"
|
||||
// Format: "obv11:group:123456,telegram:group:789012"
|
||||
// Optional 4th field for display name: "obv11:group:123456:群名称"
|
||||
func ParsePlatformChannels(raw string) []PlatformChannel {
|
||||
if raw == "" {
|
||||
return nil
|
||||
@@ -228,7 +228,7 @@ type Thinker struct {
|
||||
platformChannels []PlatformChannel
|
||||
platformThinkInterval time.Duration
|
||||
|
||||
// 平台 Bot UID (platform -> bot's own UID, e.g. "qq" -> "123456789")
|
||||
// 平台 Bot UID (platform -> bot's own UID, e.g. "obv11" -> "123456789")
|
||||
botUIDs map[string]string
|
||||
|
||||
// 平台格式注册表 (platform -> format)
|
||||
@@ -1609,15 +1609,15 @@ func (t *Thinker) buildThinkingUserPrompt(
|
||||
sb.WriteString("\n\n【你的平台身份与可用频道】\n")
|
||||
|
||||
// Bot's own identity.
|
||||
if qqBotUID, ok := botUIDs["qq"]; ok && qqBotUID != "" {
|
||||
if qqBotUID, ok := botUIDs["obv11"]; ok && qqBotUID != "" {
|
||||
sb.WriteString(fmt.Sprintf("你在OBv11上的账号是: %s(昔涟),这就是你。\n", qqBotUID))
|
||||
}
|
||||
|
||||
// Active session context with time, group name, and trigger-aware guidance.
|
||||
if strings.HasPrefix(activeSID, "platform_qq_") {
|
||||
activeChID := strings.TrimPrefix(activeSID, "platform_qq_")
|
||||
if strings.HasPrefix(activeSID, "platform_obv11_") {
|
||||
activeChID := strings.TrimPrefix(activeSID, "platform_obv11_")
|
||||
for _, ch := range qqChannels {
|
||||
if ch.Platform == "qq" && ch.ChannelID == activeChID {
|
||||
if ch.Platform == "obv11" && ch.ChannelID == activeChID {
|
||||
chLabel := activeChID
|
||||
if ch.ChannelName != "" {
|
||||
chLabel = fmt.Sprintf("%s(%s)", ch.ChannelName, activeChID)
|
||||
@@ -1665,7 +1665,7 @@ func (t *Thinker) buildThinkingUserPrompt(
|
||||
sb.WriteString("- OBv11群聊@某人: 【主动消息】【OBv11群聊:群号@账号】消息内容\n")
|
||||
sb.WriteString("\n可用的平台频道列表:\n")
|
||||
for _, ch := range qqChannels {
|
||||
if ch.Platform != "qq" {
|
||||
if ch.Platform != "obv11" {
|
||||
continue
|
||||
}
|
||||
label := ch.ChannelID
|
||||
|
||||
Reference in New Issue
Block a user