From ab3c0bfd2dd18fe84e1c06cfcade019799211f49 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Jul 2026 15:33:41 +0800 Subject: [PATCH] fix(qq): use file_id instead of file field for group file download NapCat file messages have file_id in data["file_id"], not data["file"]. data["file"] is the filename, causing get_file API to return empty. Also pass url field to downloadFile for URL-direct fallback. --- example/qq/plugin.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/example/qq/plugin.go b/example/qq/plugin.go index 3ecfc07..99af5d7 100644 --- a/example/qq/plugin.go +++ b/example/qq/plugin.go @@ -1535,15 +1535,19 @@ func (p *Plugin) processMessageSegments(segments []interface{}) string { parts = append(parts, "[表情]") } case "file": - fid, _ := data["file"].(string) + fid, _ := data["file_id"].(string) + if fid == "" { + fid, _ = data["file"].(string) + } name, _ := data["name"].(string) + fileURL, _ := data["url"].(string) size, _ := data["size"].(string) sizeDesc := "" if s, err := strconv.ParseInt(size, 10, 64); err == nil && s > 0 { sizeDesc = fmt.Sprintf(" (%.1f MB)", float64(s)/1048576) } - if fid != "" { - dlQueue = append(dlQueue, dlItem{fileID: fid, name: name}) + if fid != "" || fileURL != "" { + dlQueue = append(dlQueue, dlItem{fileID: fid, name: name, url: fileURL}) } if name != "" { parts = append(parts, fmt.Sprintf("[文件:%s%s]", name, sizeDesc))