From 7732f28ca89426f4349b1fa58730f147a04f5822 Mon Sep 17 00:00:00 2001 From: Alen Date: Wed, 28 Aug 2024 22:51:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20reply=E6=B6=88=E6=81=AF=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/onebot/api/msg.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index a80d3d72..3621abee 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -207,6 +207,21 @@ export class OneBotMsgApi { this.core.context.logger.logError('获取不到引用的消息', element.replayMsgSeq); return null; } + + // 合并转发直接返回 + if (records.peerUin === '284840486') { + return { + type: OB11MessageDataType.reply, + data: { + id: MessageUnique.createUniqueMsgId({ + peerUid: msg.peerUid, + guildId: '', + chatType: msg.chatType, + }, records.msgId).toString(), + }, + }; + } + let replyMsg: RawMessage | undefined; // Attempt 1 replyMsg = (await NTQQMsgApi.getMsgsBySeqAndCount({ @@ -221,7 +236,7 @@ export class OneBotMsgApi { // Attempt 2 replyMsg = (await NTQQMsgApi.getSingleMsg(peer, element.replayMsgSeq)).msgList[0]; - if ((!replyMsg || records.msgRandom !== replyMsg.msgRandom) && msg.peerUin !== '284840486') { + if (!replyMsg || records.msgRandom !== replyMsg.msgRandom) { // Attempt 3 const replyMsgList = (await NTQQMsgApi.getMsgExBySeq(peer, records.msgSeq)).msgList; if (replyMsgList.length < 1) { From 2027da1db5832e7712c570306b787e3eb802be65 Mon Sep 17 00:00:00 2001 From: Alen Date: Wed, 28 Aug 2024 23:24:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/onebot/api/msg.ts | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index 3621abee..3b4fc0d5 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -208,27 +208,20 @@ export class OneBotMsgApi { return null; } - // 合并转发直接返回 + const createReplyData = (msgId: string): OB11MessageData => ({ + type: OB11MessageDataType.reply, + data: { + id: MessageUnique.createUniqueMsgId(peer, msgId).toString(), + }, + }); + if (records.peerUin === '284840486') { - return { - type: OB11MessageDataType.reply, - data: { - id: MessageUnique.createUniqueMsgId({ - peerUid: msg.peerUid, - guildId: '', - chatType: msg.chatType, - }, records.msgId).toString(), - }, - }; + return createReplyData(records.msgId); } let replyMsg: RawMessage | undefined; // Attempt 1 - replyMsg = (await NTQQMsgApi.getMsgsBySeqAndCount({ - peerUid: msg.peerUid, - guildId: '', - chatType: msg.chatType, - }, element.replayMsgSeq, 1, true, true)) + replyMsg = (await NTQQMsgApi.getMsgsBySeqAndCount(peer,element.replayMsgSeq, 1, true, true)) .msgList .find(msg => msg.msgRandom === records.msgRandom); @@ -248,16 +241,7 @@ export class OneBotMsgApi { } } - return { - type: OB11MessageDataType.reply, - data: { - id: MessageUnique.createUniqueMsgId({ - peerUid: msg.peerUid, - guildId: '', - chatType: msg.chatType, - }, replyMsg.msgId).toString(), - }, - }; + return createReplyData(replyMsg.msgId); }, videoElement: async (element, msg, elementWrapper) => {