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:
2026-06-23 17:59:37 +08:00
parent 6bf59f7eee
commit 45fac267fe
8 changed files with 177 additions and 9 deletions
@@ -26,6 +26,7 @@ var upgrader = websocket.Upgrader{
// - "server" (正向 WS): adapter starts a WS server, NapCat connects as client.
// - "client" (反向 WS): adapter connects to NapCat's WS server as a client.
type Adapter struct {
configID string // immutable unique ID from PlatformConfig
configName string // instance name, e.g. "qq-home"
mode string // "client" or "server"
port string
@@ -46,11 +47,12 @@ type Adapter struct {
respMu sync.Mutex
}
func NewAdapter(configName, mode, port, accessToken, remoteURL string, sendIntervalMs int) *Adapter {
func NewAdapter(configID, configName, mode, port, accessToken, remoteURL string, sendIntervalMs int) *Adapter {
if mode == "" {
mode = "server"
}
return &Adapter{
configID: configID,
configName: configName,
mode: mode,
port: port,
@@ -63,6 +65,7 @@ func NewAdapter(configName, mode, port, accessToken, remoteURL string, sendInter
}
func (a *Adapter) PlatformName() string { return "qq" }
func (a *Adapter) ConfigID() string { return a.configID }
func (a *Adapter) ConfigName() string { return a.configName }
func (a *Adapter) SendIntervalMs() int { return a.sendIntervalMs }
func (a *Adapter) SelfID() string { return a.selfID }