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:
2026-06-23 18:19:52 +08:00
parent c96bd23f83
commit 8a3236b8bb
6 changed files with 28 additions and 28 deletions
+8 -8
View File
@@ -300,14 +300,14 @@ func main() {
// Sync admin identities from config fields.
syncAdminUIDs(mapper, platform, fields, cfg.AdminNickname)
// Restart OBv11 reader when OBv11 config changes.
if platform == "qq" {
if platform == "obv11" {
startOBv11Readers(router)
}
} else {
router.RemoveAdapter(name)
fmt.Printf("Platform adapter removed: %s\n", name)
// Cancel reader goroutines for removed adapter.
if platform == "qq" {
if platform == "obv11" {
startOBv11Readers(router)
}
}
@@ -366,7 +366,7 @@ func startOBv11Readers(router *bridge.PlatformRouter) {
qqReaderCancels = make(map[string]context.CancelFunc)
qqReaderCancelsMu.Unlock()
for _, qqa := range router.GetAdaptersByPlatform("qq") {
for _, qqa := range router.GetAdaptersByPlatform("obv11") {
qqAdapter, ok := qqa.(*qqadapter.Adapter)
if !ok {
continue
@@ -485,7 +485,7 @@ func createAdapters(cfg *config.Config, store *config.Store) []bridge.PlatformAd
}
// Seed default adapters for platforms that have no stored config.
defaultPlatforms := []string{"qq", "telegram", "webhook", "wechat", "feishu", "discord"}
defaultPlatforms := []string{"obv11", "telegram", "webhook", "wechat", "feishu", "discord"}
for _, name := range defaultPlatforms {
if seen[name] {
continue
@@ -500,10 +500,10 @@ func createAdapters(cfg *config.Config, store *config.Store) []bridge.PlatformAd
}
// createSingleAdapter creates one platform adapter from config fields.
// platform is the base platform type ("qq", "telegram", etc.), configName is the instance key.
// platform is the base platform type ("obv11", "telegram", etc.), configName is the instance key.
func createSingleAdapter(cfg *config.Config, platform, configName, configID string, fields map[string]string) bridge.PlatformAdapter {
switch platform {
case "qq":
case "obv11":
port := cfg.OBv11BotPort
if p, ok := fields["bot_port"]; ok && p != "" {
port = p
@@ -565,7 +565,7 @@ func mergeFields(cfg *config.Config, platform string, stored *config.PlatformCon
if fields["webhook_url"] == "" && cfg.TelegramWebhookURL != "" && platform == "telegram" {
fields["webhook_url"] = cfg.TelegramWebhookURL
}
if fields["bot_port"] == "" && cfg.OBv11BotPort != "" && platform == "qq" {
if fields["bot_port"] == "" && cfg.OBv11BotPort != "" && platform == "obv11" {
fields["bot_port"] = cfg.OBv11BotPort
}
return fields
@@ -989,7 +989,7 @@ func seedIdentities(m *bridge.IdentityMapper, store *config.Store, adminNickname
}
// From stored platform configs (admin_uids field).
for _, name := range []string{"qq", "telegram", "webhook", "wechat", "feishu", "discord"} {
for _, name := range []string{"obv11", "telegram", "webhook", "wechat", "feishu", "discord"} {
stored, _ := store.Get(name)
if stored == nil {
continue
@@ -64,7 +64,7 @@ func NewAdapter(configID, configName, mode, port, accessToken, remoteURL string,
}
}
func (a *Adapter) PlatformName() string { return "qq" }
func (a *Adapter) PlatformName() string { return "obv11" }
func (a *Adapter) ConfigID() string { return a.configID }
func (a *Adapter) ConfigName() string { return a.configName }
func (a *Adapter) SendIntervalMs() int { return a.sendIntervalMs }
@@ -391,7 +391,7 @@ func (a *Adapter) ToUnified(rawMessage interface{}) (*bridge.UnifiedMessage, err
return &bridge.UnifiedMessage{
SenderID: senderID,
SenderName: senderName,
Platform: "qq",
Platform: "obv11",
ChannelID: channelID,
ChannelType: channelType,
Content: content,
@@ -442,7 +442,7 @@ func (a *Adapter) noticeToUnified(msg *OBv11Message) (*bridge.UnifiedMessage, er
return &bridge.UnifiedMessage{
SenderID: senderID,
SenderName: senderName,
Platform: "qq",
Platform: "obv11",
ChannelID: channelID,
ChannelType: channelType,
Content: content,
@@ -65,7 +65,7 @@ func (a *Adapter) FetchGroups() []bridge.ChannelInfo {
a.SetGroupName(g.GroupID, g.GroupName)
}
channels = append(channels, bridge.ChannelInfo{
Platform: "qq",
Platform: "obv11",
ChannelType: "group",
ChannelID: fmt.Sprintf("%d", g.GroupID),
ChannelName: g.GroupName,
@@ -124,7 +124,7 @@ func (a *Adapter) FetchFriends() []bridge.ChannelInfo {
name = f.Nickname
}
channels = append(channels, bridge.ChannelInfo{
Platform: "qq",
Platform: "obv11",
ChannelType: "private",
ChannelID: fmt.Sprintf("%d", f.UserID),
ChannelName: name,