fix: send-proactive adapter查找 — 先按名再按平台类型回退

This commit is contained in:
2026-06-23 19:26:12 +08:00
parent 4326f1fc02
commit 222fc5768f
@@ -200,9 +200,18 @@ func (h *BridgeHandler) sendProactive(w http.ResponseWriter, r *http.Request) {
content = fmt.Sprintf("[CQ:at,qq=%s] %s", req.AtUserID, content) content = fmt.Sprintf("[CQ:at,qq=%s] %s", req.AtUserID, content)
} }
// Find the adapter. For OBv11, use the platform name as adapter name. // Resolve adapter: try exact name first, then find by platform type.
adapterName := req.Platform adapterName := req.Platform
err := h.router.SendProactive(adapterName, msgType, userID, groupID, content) err := h.router.SendProactive(adapterName, msgType, userID, groupID, content)
if err != nil {
for _, name := range h.router.ListAdapters() {
if a, aErr := h.router.GetAdapter(name); aErr == nil && a.PlatformName() == req.Platform && a.IsConnected() {
adapterName = name
err = h.router.SendProactive(name, msgType, userID, groupID, content)
break
}
}
}
if err != nil { if err != nil {
log.Printf("[send-proactive] 发送失败: adapter=%s err=%v", adapterName, err) log.Printf("[send-proactive] 发送失败: adapter=%s err=%v", adapterName, err)
writeJSON(w, http.StatusInternalServerError, errResp("send failed: "+err.Error())) writeJSON(w, http.StatusInternalServerError, errResp("send failed: "+err.Error()))