mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: by ai 简化逻辑
This commit is contained in:
@@ -349,33 +349,20 @@ export class OneBotMsgApi {
|
|||||||
guildId: '',
|
guildId: '',
|
||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
};
|
};
|
||||||
//判断是否在合并消息内
|
const multiMsgs = await this.getMultiMessages(msg, parentMsgPeer);
|
||||||
msg.parentMsgIdList = msg.parentMsgIdList ?? [];
|
// 拉取失败则跳过
|
||||||
//首次列表不存在则开始创建
|
|
||||||
msg.parentMsgIdList.push(msg.msgId);
|
|
||||||
//let parentMsgId = msg.parentMsgIdList[msg.parentMsgIdList.length - 2 < 0 ? 0 : msg.parentMsgIdList.length - 2];
|
|
||||||
//加入自身MsgId
|
|
||||||
const multiMsgs = (await this.core.apis.MsgApi.getMultiMsg(parentMsgPeer, msg.parentMsgIdList[0], msg.msgId))?.msgList;
|
|
||||||
//拉取下级消息
|
|
||||||
if (!multiMsgs) return null;
|
if (!multiMsgs) return null;
|
||||||
//拉取失败则跳过
|
const forward: OB11MessageForward = {
|
||||||
let ret = {
|
|
||||||
type: OB11MessageDataType.forward,
|
type: OB11MessageDataType.forward,
|
||||||
data: {
|
data: { id: msg.msgId }
|
||||||
id: msg.msgId
|
};
|
||||||
},
|
if (!context.parseMultMsg) return forward;
|
||||||
} as OB11MessageForward;
|
forward.data.content = await this.parseMultiMessageContent(
|
||||||
if (context.parseMultMsg) {
|
multiMsgs,
|
||||||
ret.data.content = (await Promise.all(multiMsgs.map(
|
parentMsgPeer,
|
||||||
async multiMsgItem => {
|
msg.parentMsgIdList
|
||||||
multiMsgItem.parentMsgPeer = parentMsgPeer;
|
);
|
||||||
multiMsgItem.parentMsgIdList = msg.parentMsgIdList;
|
return forward;
|
||||||
multiMsgItem.id = MessageUnique.createUniqueMsgId(parentMsgPeer, multiMsgItem.msgId); //该ID仅用查看 无法调用
|
|
||||||
return await this.parseMessage(multiMsgItem, 'array', context.parseMultMsg);
|
|
||||||
},
|
|
||||||
))).filter(item => item !== undefined)
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
arkElement: async (element) => {
|
arkElement: async (element) => {
|
||||||
@@ -694,6 +681,34 @@ export class OneBotMsgApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async getMultiMessages(msg: RawMessage, parentMsgPeer: Peer) {
|
||||||
|
//判断是否在合并消息内
|
||||||
|
msg.parentMsgIdList = msg.parentMsgIdList ?? [];
|
||||||
|
//首次列表不存在则开始创建
|
||||||
|
msg.parentMsgIdList.push(msg.msgId);
|
||||||
|
//拉取下级消息
|
||||||
|
return (await this.core.apis.MsgApi.getMultiMsg(
|
||||||
|
parentMsgPeer,
|
||||||
|
msg.parentMsgIdList[0],
|
||||||
|
msg.msgId
|
||||||
|
))?.msgList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async parseMultiMessageContent(
|
||||||
|
multiMsgs: RawMessage[],
|
||||||
|
parentMsgPeer: Peer,
|
||||||
|
parentMsgIdList: string[]
|
||||||
|
) {
|
||||||
|
const parsed = await Promise.all(multiMsgs.map(async msg => {
|
||||||
|
msg.parentMsgPeer = parentMsgPeer;
|
||||||
|
msg.parentMsgIdList = parentMsgIdList;
|
||||||
|
msg.id = MessageUnique.createUniqueMsgId(parentMsgPeer, msg.msgId);
|
||||||
|
//该ID仅用查看 无法调用
|
||||||
|
return await this.parseMessage(msg, 'array', true);
|
||||||
|
}));
|
||||||
|
return parsed.filter(item => item !== undefined);
|
||||||
|
}
|
||||||
|
|
||||||
async parseMessage(
|
async parseMessage(
|
||||||
msg: RawMessage,
|
msg: RawMessage,
|
||||||
messagePostFormat: string,
|
messagePostFormat: string,
|
||||||
|
Reference in New Issue
Block a user