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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user