chore: 优化代码

This commit is contained in:
Alen 2024-08-28 23:24:44 +08:00
parent 7732f28ca8
commit 2027da1db5

View File

@ -208,27 +208,20 @@ export class OneBotMsgApi {
return null; return null;
} }
// 合并转发直接返回 const createReplyData = (msgId: string): OB11MessageData => ({
if (records.peerUin === '284840486') {
return {
type: OB11MessageDataType.reply, type: OB11MessageDataType.reply,
data: { data: {
id: MessageUnique.createUniqueMsgId({ id: MessageUnique.createUniqueMsgId(peer, msgId).toString(),
peerUid: msg.peerUid,
guildId: '',
chatType: msg.chatType,
}, records.msgId).toString(),
}, },
}; });
if (records.peerUin === '284840486') {
return createReplyData(records.msgId);
} }
let replyMsg: RawMessage | undefined; let replyMsg: RawMessage | undefined;
// Attempt 1 // Attempt 1
replyMsg = (await NTQQMsgApi.getMsgsBySeqAndCount({ replyMsg = (await NTQQMsgApi.getMsgsBySeqAndCount(peer,element.replayMsgSeq, 1, true, true))
peerUid: msg.peerUid,
guildId: '',
chatType: msg.chatType,
}, element.replayMsgSeq, 1, true, true))
.msgList .msgList
.find(msg => msg.msgRandom === records.msgRandom); .find(msg => msg.msgRandom === records.msgRandom);
@ -248,16 +241,7 @@ export class OneBotMsgApi {
} }
} }
return { return createReplyData(replyMsg.msgId);
type: OB11MessageDataType.reply,
data: {
id: MessageUnique.createUniqueMsgId({
peerUid: msg.peerUid,
guildId: '',
chatType: msg.chatType,
}, replyMsg.msgId).toString(),
},
};
}, },
videoElement: async (element, msg, elementWrapper) => { videoElement: async (element, msg, elementWrapper) => {