From 7970f14f231fcf239d6894e14b6135c17c0a5649 Mon Sep 17 00:00:00 2001 From: Jerrypluay Date: Mon, 24 Nov 2025 16:19:28 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20fix(apps/ai.js):=20impr?= =?UTF-8?q?ove=20message=20formatting=20for=20replies=20and=20quoted=20mes?= =?UTF-8?q?sages=20in=20chat=20history?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ai.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/apps/ai.js b/apps/ai.js index 0b0086f..b7313a0 100644 --- a/apps/ai.js +++ b/apps/ai.js @@ -144,6 +144,25 @@ async function extractUserMessage(msg, nickname, e) { if (imgUrls) { returnMessage += `[${e.sender?.nickname},id:${e.user_id}]发送了一张图片(你可能暂时无法查看)\n`; } + if(e.source || e.reply_id){ + let reply; + if(e.getReply) reply = await e.getReply(); + else { + const history = await e.group.getChatHistory(e.source.seq,1); + reply = history?.pop(); + } + if(reply){ + const msgArr = Array.isArray(reply) ? reply : reply.message || []; + msgArr.forEach((msg) => { + if(msg.type === 'text'){ + returnMessage += `[${e.sender?.nickname},id:${e.user_id}]引用了一段文本:${msg.text}\n` + } + if(msg.type === 'image'){ + returnMessage += `[${e.sender?.nickname},id:${e.user_id}]引用了一张图片(你可能暂时无法查看)\n`; + } + }) + } + } return returnMessage; } logger.warn('[crystelf-ai] 字符串匹配失败');