From 119915ab2f0e1106e8db934b30320fb160325cdd Mon Sep 17 00:00:00 2001 From: Desom-fu Date: Thu, 14 Aug 2025 13:41:02 +0800 Subject: [PATCH] =?UTF-8?q?ai=E6=94=B9=E7=9A=84=EF=BC=8C=E5=B0=9D=E8=AF=95?= =?UTF-8?q?=E4=BF=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coolq/cqcode.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 4b69087..22d6f1f 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -1070,9 +1070,21 @@ func (bot *CQBot) readImageCache(elem msg.Element, record *database.DatabaseReco size := int32(record.Image.Size) imageURL := bot.Client.GetDatabaseImageUrl(record.Image) if imageURL != "" { - elem.Type = "image" - elem.Data = append(elem.Data, msg.Pair{K: "url", V: imageURL}) - rsp, err = bot.makeImageOrVideoElem(elem, sourceType) + // 修复:创建一个只包含 URL 的新元素,以避免无限递归。 + // 不重用旧的“elem”,因为它包含触发问题的“.image”文件路径。 + newElem := msg.Element{ + Type: "image", + Data: []msg.Pair{ + {K: "url", V: imageURL}, + }, + } + // 从原始元素复制其他相关字段(如 flash, type 等),但排除 'file' 和 'url' 字段。 + for _, pair := range elem.Data { + if pair.K != "file" && pair.K != "url" { + newElem.Data = append(newElem.Data, pair) + } + } + rsp, err = bot.makeImageOrVideoElem(newElem, sourceType) if err == nil { return rsp, nil }