fix(onebot): 引用回复解析中 quick_reply 形参未解构导致 reply 段丢失 (#1952)
Release Tag / validate-version (push) Canceled after 0s
Release Tag / trigger-release (push) Canceled after 0s

* 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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

---------

Co-authored-by: xulang <xuxiaolang2003@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-07-08 09:46:59 +08:00
1 parent f7edbfd8d9
commit 738e272d2c
1 file changed
+10 -10
+10 -10
View File
@@ -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;