mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
refactor: handle msg in parallel form
This commit is contained in:
parent
0e67ec1a6d
commit
b109414193
@ -131,13 +131,22 @@ export class NapCatEventChannel extends
|
|||||||
private initMsgListener() {
|
private initMsgListener() {
|
||||||
const msgListener = new NodeIKernelMsgListener();
|
const msgListener = new NodeIKernelMsgListener();
|
||||||
|
|
||||||
msgListener.onRecvMsg = async msgList => {
|
msgListener.onRecvMsg = msgList => {
|
||||||
for (const msg of msgList) {
|
Promise.allSettled(
|
||||||
if (msg.senderUin !== this.core.selfInfo.uin) {
|
msgList.filter(msg => msg.senderUin !== this.core.selfInfo.uin)
|
||||||
const handled = await this.parseRawMsgToEventAndEmit(msg);
|
.map(msg => {
|
||||||
|
this.parseRawMsgToEventAndEmit(msg)
|
||||||
|
.then(handled => {
|
||||||
if (!handled) this.emit('message/receive', msg);
|
if (!handled) this.emit('message/receive', msg);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
).then(callRes => {
|
||||||
|
callRes.forEach(res => {
|
||||||
|
if (res.status === 'rejected') {
|
||||||
|
this.core.context.logger.logError('处理消息失败', res.reason);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const msgIdSentCache = new LRUCache<string, boolean>(100);
|
const msgIdSentCache = new LRUCache<string, boolean>(100);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user