From 738e272d2c46bff6882751b26a742f891d95152b Mon Sep 17 00:00:00 2001 From: noobking <135508328+fayev1t@users.noreply.github.com> Date: Tue, 7 Jul 2026 21:46:59 -0400 Subject: [PATCH] =?UTF-8?q?fix(onebot):=20=E5=BC=95=E7=94=A8=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E8=A7=A3=E6=9E=90=E4=B8=AD=20quick=5Freply=20?= =?UTF-8?q?=E5=BD=A2=E5=8F=82=E6=9C=AA=E8=A7=A3=E6=9E=84=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=20reply=20=E6=AE=B5=E4=B8=A2=E5=A4=B1=20(#1952)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(onebot): destructure quick_reply in replyElement converter parseMessageSegments passes the whole RecvMessageContext object as the 4th argument to element converters, but replyElement declared the parameter as `quick_reply` without destructuring. The object is always truthy, so every reply element took the quick-reply branch and skipped lookup methods 2/3 whenever method 1 found no match, dropping the reply segment from the reported OneBot message (it degrades to at + text). Co-Authored-By: Claude Fable 5 * fix(onebot): fall back to msgSeq match when msgRandom mismatches in reply lookup All three reply lookup methods matched candidates only by msgRandom whenever records.msgRandom was present. When the recorded msgRandom is stale or inconsistent with the message database, the quoted message returned by a seq-based query was discarded even though its msgSeq matched exactly. Match by msgRandom first and fall back to an exact msgSeq match. Co-Authored-By: Claude Fable 5 --------- Co-authored-by: xulang Co-authored-by: Claude Fable 5 --- packages/napcat-onebot/api/msg.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/napcat-onebot/api/msg.ts b/packages/napcat-onebot/api/msg.ts index 004e701d8..2197b02aa 100644 --- a/packages/napcat-onebot/api/msg.ts +++ b/packages/napcat-onebot/api/msg.ts @@ -278,7 +278,7 @@ export class OneBotMsgApi { }; }, - replyElement: async (element, msg, _, quick_reply) => { + replyElement: async (element, msg, _, { quick_reply }) => { const peer = { chatType: msg.chatType, peerUid: msg.peerUid, @@ -310,9 +310,9 @@ export class OneBotMsgApi { peer, msgSeq, msgTime, [senderUid] )).msgList; - const replyMsg = msgRandom - ? replyMsgList.find(msg => msg.msgRandom === msgRandom) - : replyMsgList.find(msg => msg.msgSeq === msgSeq); + const replyMsg = replyMsgList.find(msg => + (msgRandom && msg.msgRandom === msgRandom) || msg.msgSeq === msgSeq + ); if (replyMsg) return replyMsg; if (quick_reply) { @@ -327,9 +327,9 @@ export class OneBotMsgApi { peer, msgSeq, 1, true, true )).msgList; - const replyMsg = msgRandom - ? replyMsgList.find(msg => msg.msgRandom === msgRandom) - : replyMsgList.find(msg => msg.msgSeq === msgSeq); + const replyMsg = replyMsgList.find(msg => + (msgRandom && msg.msgRandom === msgRandom) || msg.msgSeq === msgSeq + ); if (replyMsg) return replyMsg; @@ -341,9 +341,9 @@ export class OneBotMsgApi { peer, msgSeq, [senderUid] )).msgList; - const replyMsg = msgRandom - ? replyMsgList.find(msg => msg.msgRandom === msgRandom) - : replyMsgList.find(msg => msg.msgSeq === msgSeq); + const replyMsg = replyMsgList.find(msg => + (msgRandom && msg.msgRandom === msgRandom) || msg.msgSeq === msgSeq + ); if (replyMsg) return replyMsg;