feat: 平台配置唯一ID — PlatformConfig.ID + adapter全链路传播
- PlatformConfig 新增 ID 字段 (8字节hex,创建时自动生成) - QQ adapter 新增 configID + ConfigID() 访问器 - ChannelInfo 新增 AdapterID + AdapterName - createSingleAdapter 接受 configID 参数 - 同一个平台类型的多个配置实例通过 ID 唯一区分 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -287,7 +287,7 @@ func main() {
|
||||
// Hot-reload: on config save/delete, dynamically replace adapters.
|
||||
ch.SetOnConfigChanged(func(name, platform string, enabled bool, fields map[string]string) {
|
||||
if enabled {
|
||||
a := createSingleAdapter(cfg, platform, name, fields)
|
||||
a := createSingleAdapter(cfg, platform, name, "", fields) // configID via Store.Set
|
||||
if a == nil {
|
||||
fmt.Printf("WARN: cannot create adapter for %s (platform=%s)\n", name, platform)
|
||||
return
|
||||
@@ -477,7 +477,7 @@ func createAdapters(cfg *config.Config, store *config.Store) []bridge.PlatformAd
|
||||
platform = stored.Name
|
||||
}
|
||||
fields := mergeFields(cfg, platform, &stored)
|
||||
a := createSingleAdapter(cfg, platform, stored.Name, fields)
|
||||
a := createSingleAdapter(cfg, platform, stored.Name, stored.ID, fields)
|
||||
if a != nil {
|
||||
adapters = append(adapters, a)
|
||||
seen[stored.Name] = true
|
||||
@@ -491,7 +491,7 @@ func createAdapters(cfg *config.Config, store *config.Store) []bridge.PlatformAd
|
||||
continue
|
||||
}
|
||||
fields := mergeFields(cfg, name, nil)
|
||||
a := createSingleAdapter(cfg, name, name, fields)
|
||||
a := createSingleAdapter(cfg, name, name, "", fields) // seed adapter, no config ID
|
||||
if a != nil {
|
||||
adapters = append(adapters, a)
|
||||
}
|
||||
@@ -501,7 +501,7 @@ 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.
|
||||
func createSingleAdapter(cfg *config.Config, platform, configName string, fields map[string]string) bridge.PlatformAdapter {
|
||||
func createSingleAdapter(cfg *config.Config, platform, configName, configID string, fields map[string]string) bridge.PlatformAdapter {
|
||||
switch platform {
|
||||
case "qq":
|
||||
port := cfg.OBv11BotPort
|
||||
@@ -528,7 +528,7 @@ func createSingleAdapter(cfg *config.Config, platform, configName string, fields
|
||||
sendIntervalMs = n
|
||||
}
|
||||
}
|
||||
return qqadapter.NewAdapter(configName, mode, port, token, remoteURL, sendIntervalMs)
|
||||
return qqadapter.NewAdapter(configID, configName, mode, port, token, remoteURL, sendIntervalMs)
|
||||
case "telegram":
|
||||
token := cfg.TelegramToken
|
||||
if t, ok := fields["bot_token"]; ok && t != "" {
|
||||
|
||||
Reference in New Issue
Block a user