fix: send-proactive adapter查找 — 先按名再按平台类型回退
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
// 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
|
||||
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 {
|
||||
log.Printf("[send-proactive] 发送失败: adapter=%s err=%v", adapterName, err)
|
||||
writeJSON(w, http.StatusInternalServerError, errResp("send failed: "+err.Error()))
|
||||
|
||||
Reference in New Issue
Block a user