Compare commits

...

5 Commits

Author SHA1 Message Date
手瓜一十雪
36c2c567b7 fix: #444 2024-10-31 19:32:10 +08:00
Mlikiowa
7b1ac224f6 release: v3.4.3 2024-10-31 10:18:21 +00:00
手瓜一十雪
34d9f04f15 Merge branch 'main' of https://github.com/NapNeko/NapCatQQ 2024-10-31 18:17:53 +08:00
手瓜一十雪
be5da7cc6f fix: 正向ws异常推送事件问题 2024-10-31 18:17:41 +08:00
Mlikiowa
8d32ccb5d4 release: v3.4.2 2024-10-31 10:03:19 +00:00
7 changed files with 49 additions and 29 deletions

View File

@@ -4,7 +4,7 @@
"name": "NapCatQQ",
"slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现",
"version": "3.4.1",
"version": "3.4.3",
"icon": "./logo.png",
"authors": [
{

View File

@@ -2,7 +2,7 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "3.4.1",
"version": "3.4.3",
"scripts": {
"build:framework": "vite build --mode framework",
"build:shell": "vite build --mode shell",

View File

@@ -1 +1 @@
export const napCatVersion = '3.4.1';
export const napCatVersion = '3.4.3';

View File

@@ -822,6 +822,8 @@ export interface RawMessage {
elements: MessageElement[];
sourceType: MsgSourceType;
isOnlineMsg: boolean;
}
export interface QueryMsgsParams {
chatInfo: Peer;

View File

@@ -311,33 +311,51 @@ export class NapCatOneBot11Adapter {
}
};
const msgIdSend = new LRUCache<string, boolean>(100);
//const msgIdSend = new LRUCache<string, boolean>(100);
const recallMsgs = new LRUCache<string, boolean>(100);
msgListener.onAddSendMsg = async msg => {
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SUCCESS) {
this.apis.MsgApi.parseMessage(msg)
.then((ob11Msg) => {
if (!ob11Msg) return;
ob11Msg.target_id = parseInt(msg.peerUin);
if (this.configLoader.configData.reportSelfMessage) {
msg.id = MessageUnique.createUniqueMsgId({
chatType: msg.chatType,
peerUid: msg.peerUid,
guildId: '',
}, msg.msgId);
this.emitMsg(msg);
} else {
// logOB11Message(this.core, ob11Msg);
}
});
}
};
msgListener.onMsgInfoListUpdate = async msgList => {
this.emitRecallMsg(msgList, recallMsgs)
.catch(e => this.context.logger.logError.bind(this.context.logger)('处理消息失败', e));
for (const msg of msgList.filter(e => e.senderUin == this.core.selfInfo.uin)) {
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SUCCESS && !msgIdSend.get(msg.msgId)) {
msgIdSend.put(msg.msgId, true);
// 完成后再post
this.apis.MsgApi.parseMessage(msg)
.then((ob11Msg) => {
if (!ob11Msg) return;
ob11Msg.target_id = parseInt(msg.peerUin);
if (this.configLoader.configData.reportSelfMessage) {
msg.id = MessageUnique.createUniqueMsgId({
chatType: msg.chatType,
peerUid: msg.peerUid,
guildId: '',
}, msg.msgId);
this.emitMsg(msg);
} else {
// logOB11Message(this.core, ob11Msg);
}
});
}
}
// for (const msg of msgList.filter(e => e.senderUin == this.core.selfInfo.uin)) {
// if (msg.sendStatus == SendStatusType.KSEND_STATUS_SUCCESS && !msgIdSend.get(msg.msgId)) {
// msgIdSend.put(msg.msgId, true);
// // 完成后再post
// this.apis.MsgApi.parseMessage(msg)
// .then((ob11Msg) => {
// if (!ob11Msg) return;
// ob11Msg.target_id = parseInt(msg.peerUin);
// if (this.configLoader.configData.reportSelfMessage) {
// msg.id = MessageUnique.createUniqueMsgId({
// chatType: msg.chatType,
// peerUid: msg.peerUid,
// guildId: '',
// }, msg.msgId);
// this.emitMsg(msg);
// } else {
// // logOB11Message(this.core, ob11Msg);
// }
// });
// }
// }
};
this.context.session.getMsgService().addKernelMsgListener(
@@ -523,7 +541,7 @@ export class NapCatOneBot11Adapter {
);
}
private async emitMsg(message: RawMessage) {
private async emitMsg(message: RawMessage, parseEvent: boolean = true) {
const { debug, reportSelfMessage, messagePostFormat } = this.configLoader.configData;
this.context.logger.logDebug('收到新消息 RawMessage', message);
this.apis.MsgApi.parseMessage(message, messagePostFormat).then((ob11Msg) => {

View File

@@ -143,7 +143,7 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
private registerHeartBeat() {
this.heartbeatIntervalId = setInterval(() => {
this.wsClientsMutex.runExclusive(async () => {
this.wsClients.forEach((wsClient) => {
this.wsClientWithEvent.forEach((wsClient) => {
if (wsClient.readyState === WebSocket.OPEN) {
wsClient.send(JSON.stringify(new OB11HeartbeatEvent(this.core, this.heartbeatInterval, this.core.selfInfo.online, true)));
}

View File

@@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) {
SettingItem(
'<span id="napcat-update-title">Napcat</span>',
void 0,
SettingButton("V3.4.1", "napcat-update-button", "secondary")
SettingButton("V3.4.3", "napcat-update-button", "secondary")
)
]),
SettingList([