Compare commits

...

21 Commits

Author SHA1 Message Date
pk5ls20
0f427375cb fix: sendCommand 2024-11-05 21:48:39 +08:00
Mlikiowa
4001270b93 release: v3.4.10 2024-11-05 13:34:25 +00:00
手瓜一十雪
e7f5ed3bcc Merge branch 'main' of https://github.com/NapNeko/NapCatQQ 2024-11-05 21:33:51 +08:00
手瓜一十雪
05cdc37d0a fix: qqnt 29271 最新版兼容问题 2024-11-05 21:33:36 +08:00
Mlikiowa
27920e0bee release: v3.4.9 2024-11-05 13:22:43 +00:00
手瓜一十雪
ae409b7249 Merge branch 'main' of https://github.com/NapNeko/NapCatQQ 2024-11-05 21:22:10 +08:00
手瓜一十雪
8276258348 fix: Once 2024-11-05 21:21:59 +08:00
Mlikiowa
1bf96a97a5 release: v3.4.8 2024-11-05 13:18:35 +00:00
手瓜一十雪
d672680c4c feat: 复活吧我的arm64 2024-11-05 21:17:07 +08:00
手瓜一十雪
b89f2805e7 feat: linux.x64'packet 2024-11-05 21:12:19 +08:00
手瓜一十雪
78b4aa9295 feat: linux x64 support 2024-11-05 21:11:41 +08:00
手瓜一十雪
0a06637e78 style: lint 2024-11-05 20:59:18 +08:00
手瓜一十雪
13afa2c7ab fix: 去掉开发日志 2024-11-05 20:54:39 +08:00
手瓜一十雪
51d34d17cc feat: 去掉无用日志 2024-11-05 20:52:36 +08:00
手瓜一十雪
18a99341d5 Merge pull request #494 from NapNeko/dependabot/npm_and_yarn/vite-tsconfig-paths-5.1.0
chore(deps-dev): bump vite-tsconfig-paths from 4.3.2 to 5.1.0
2024-11-05 20:50:59 +08:00
手瓜一十雪
f01c8f0110 Merge pull request #493 from NapNeko/multi-packet
refactor: automatically select the optimal packet backend
2024-11-05 20:50:36 +08:00
手瓜一十雪
d8070eee2a fix: LL 2024-11-05 20:49:16 +08:00
手瓜一十雪
8519b7f4df update: LiteLoader 2024-11-05 20:48:28 +08:00
手瓜一十雪
591ab1b1df feat: 去掉开发输出 2024-11-05 20:40:25 +08:00
手瓜一十雪
393815b11e fix 2024-11-05 20:33:55 +08:00
dependabot[bot]
341a397bc4 chore(deps-dev): bump vite-tsconfig-paths from 4.3.2 to 5.1.0
Bumps [vite-tsconfig-paths](https://github.com/aleclarson/vite-tsconfig-paths) from 4.3.2 to 5.1.0.
- [Release notes](https://github.com/aleclarson/vite-tsconfig-paths/releases)
- [Commits](https://github.com/aleclarson/vite-tsconfig-paths/compare/v4.3.2...v5.1.0)

---
updated-dependencies:
- dependency-name: vite-tsconfig-paths
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-05 08:39:26 +00:00
11 changed files with 27 additions and 30 deletions

Binary file not shown.

View File

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

View File

@@ -2,7 +2,7 @@
"name": "napcat", "name": "napcat",
"private": true, "private": true,
"type": "module", "type": "module",
"version": "3.4.7", "version": "3.4.10",
"scripts": { "scripts": {
"build:framework": "vite build --mode framework", "build:framework": "vite build --mode framework",
"build:shell": "vite build --mode shell", "build:shell": "vite build --mode shell",
@@ -40,7 +40,7 @@
"typescript": "^5.3.3", "typescript": "^5.3.3",
"vite": "^5.2.6", "vite": "^5.2.6",
"vite-plugin-cp": "^4.0.8", "vite-plugin-cp": "^4.0.8",
"vite-tsconfig-paths": "^4.3.2" "vite-tsconfig-paths": "^5.1.0"
}, },
"dependencies": { "dependencies": {
"express": "^5.0.0", "express": "^5.0.0",

View File

@@ -1 +1 @@
export const napCatVersion = '3.4.7'; export const napCatVersion = '3.4.10';

View File

@@ -53,18 +53,14 @@ export abstract class PacketClient {
private async registerCallback(trace_id: string, type: string, callback: (json: RecvPacketData) => Promise<void>): Promise<void> { private async registerCallback(trace_id: string, type: string, callback: (json: RecvPacketData) => Promise<void>): Promise<void> {
this.cb.put(createHash('md5').update(trace_id).digest('hex') + type, callback); this.cb.put(createHash('md5').update(trace_id).digest('hex') + type, callback);
console.log(this.cb.cache);
} }
private async sendCommand(cmd: string, data: string, trace_id: string, rsp: boolean = false, timeout: number = 20000, sendcb: (json: RecvPacketData) => void = () => { private async sendCommand(cmd: string, data: string, trace_id: string, rsp: boolean = false, timeout: number = 20000, sendcb: (json: RecvPacketData) => void = () => {
}): Promise<RecvPacketData> { }): Promise<RecvPacketData> {
return new Promise<RecvPacketData>((resolve, reject) => { return new Promise<RecvPacketData>((resolve, reject) => {
if (rsp) { const timeoutHandle = setTimeout(() => {
this.registerCallback(trace_id, 'recv', async (json: RecvPacketData) => { reject(new Error(`sendCommand timed out after ${timeout} ms for ${cmd} with trace_id ${trace_id}`));
clearTimeout(timeoutHandle); }, timeout);
resolve(json);
});
}
this.registerCallback(trace_id, 'send', async (json: RecvPacketData) => { this.registerCallback(trace_id, 'send', async (json: RecvPacketData) => {
sendcb(json); sendcb(json);
if (!rsp) { if (!rsp) {
@@ -72,10 +68,13 @@ export abstract class PacketClient {
resolve(json); resolve(json);
} }
}); });
if (rsp) {
this.registerCallback(trace_id, 'recv', async (json: RecvPacketData) => {
clearTimeout(timeoutHandle);
resolve(json);
});
}
this.sendCommandImpl(cmd, data, trace_id); this.sendCommandImpl(cmd, data, trace_id);
const timeoutHandle = setTimeout(() => {
reject(new Error(`sendCommand timed out after ${timeout} ms for ${cmd} with trace_id ${trace_id}`));
}, timeout);
}); });
} }
@@ -90,7 +89,7 @@ export abstract class PacketClient {
const trace_id = (this.randText(4) + md5 + data).slice(0, data.length / 2); const trace_id = (this.randText(4) + md5 + data).slice(0, data.length / 2);
this.sendCommand(cmd, data, trace_id, rsp, 20000, async () => { this.sendCommand(cmd, data, trace_id, rsp, 20000, async () => {
console.log('sendPacket:', cmd, data, trace_id); //console.log('sendPacket:', cmd, data, trace_id);
await this.napCatCore.context.session.getMsgService().sendSsoCmdReqByContend(cmd, trace_id); await this.napCatCore.context.session.getMsgService().sendSsoCmdReqByContend(cmd, trace_id);
}).then((res) => resolve(res)).catch((e: Error) => reject(e)); }).then((res) => resolve(res)).catch((e: Error) => reject(e));
}); });

View File

@@ -12,7 +12,7 @@ export interface NativePacketExportType {
SendPacket?: (cmd: string, data: string, trace_id: string) => void; SendPacket?: (cmd: string, data: string, trace_id: string) => void;
} }
export class NativePacketClient extends PacketClient { export class NativePacketClient extends PacketClient {
private readonly supportedPlatforms = ['win32.x64']; private readonly supportedPlatforms = ['win32.x64', 'linux.x64', 'linux.arm64'];
private MoeHooExport: { exports: NativePacketExportType } = { exports: {} }; private MoeHooExport: { exports: NativePacketExportType } = { exports: {} };
private sendEvent = new LRUCache<number, string>(500);//seq->trace_id private sendEvent = new LRUCache<number, string>(500);//seq->trace_id
constructor(core: NapCatCore) { constructor(core: NapCatCore) {
@@ -41,8 +41,6 @@ export class NativePacketClient extends PacketClient {
const platform = process.platform + '.' + process.arch; const platform = process.platform + '.' + process.arch;
const moehoo_path = path.join(dirname(fileURLToPath(import.meta.url)), './moehoo/MoeHoo.' + platform + '.node'); const moehoo_path = path.join(dirname(fileURLToPath(import.meta.url)), './moehoo/MoeHoo.' + platform + '.node');
process.dlopen(this.MoeHooExport, moehoo_path, constants.dlopen.RTLD_LAZY); process.dlopen(this.MoeHooExport, moehoo_path, constants.dlopen.RTLD_LAZY);
console.log('MoeHooExport:', this.MoeHooExport);
console.log('recv:', recv, 'send:',);
this.MoeHooExport.exports.InitHook?.(send, recv, (type: number, uin: string, cmd: string, seq: number, hex_data: string) => { this.MoeHooExport.exports.InitHook?.(send, recv, (type: number, uin: string, cmd: string, seq: number, hex_data: string) => {
const trace_id = createHash('md5').update(Buffer.from(hex_data, 'hex')).digest('hex'); const trace_id = createHash('md5').update(Buffer.from(hex_data, 'hex')).digest('hex');
if (type === 0 && this.cb.get(trace_id + 'recv')) { if (type === 0 && this.cb.get(trace_id + 'recv')) {
@@ -63,14 +61,14 @@ export class NativePacketClient extends PacketClient {
// } else { // } else {
// this.logger.logError(`Callback not found for hex_data: ${hex_data}`); // this.logger.logError(`Callback not found for hex_data: ${hex_data}`);
// } // }
console.log('type:', type, 'cmd:', cmd, 'trace_id:', trace_id); //console.log('type:', type, 'cmd:', cmd, 'trace_id:', trace_id);
}); });
this.isAvailable = true; this.isAvailable = true;
} }
sendCommandImpl(cmd: string, data: string, trace_id: string): void { sendCommandImpl(cmd: string, data: string, trace_id: string): void {
const trace_id_md5 = createHash('md5').update(trace_id).digest('hex'); const trace_id_md5 = createHash('md5').update(trace_id).digest('hex');
console.log('sendCommandImpl:', cmd, data, trace_id_md5); //console.log('sendCommandImpl:', cmd, data, trace_id_md5);
this.MoeHooExport.exports.SendPacket?.(cmd, data, trace_id_md5); this.MoeHooExport.exports.SendPacket?.(cmd, data, trace_id_md5);
this.cb.get(trace_id_md5 + 'send')?.({ seq: 0, cmd, hex_data: '' }); this.cb.get(trace_id_md5 + 'send')?.({ seq: 0, cmd, hex_data: '' });
} }

Binary file not shown.

Binary file not shown.

View File

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