mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: nativeNode
This commit is contained in:
parent
f51ffc091d
commit
3007a0c00e
@ -1,6 +1,7 @@
|
|||||||
import { constants } from "node:os";
|
import { constants } from "node:os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { dlopen } from "process";
|
import { dlopen } from "process";
|
||||||
|
import fs from "fs";
|
||||||
export class Native {
|
export class Native {
|
||||||
platform: string;
|
platform: string;
|
||||||
supportedPlatforms = ['win32'];
|
supportedPlatforms = ['win32'];
|
||||||
@ -11,13 +12,22 @@ export class Native {
|
|||||||
if (!this.supportedPlatforms.includes(this.platform)) {
|
if (!this.supportedPlatforms.includes(this.platform)) {
|
||||||
throw new Error(`Platform ${this.platform} is not supported`);
|
throw new Error(`Platform ${this.platform} is not supported`);
|
||||||
}
|
}
|
||||||
dlopen(this.MoeHooExport, path.join(nodePath, './native/MoeHoo.win32.node'), constants.dlopen.RTLD_LAZY);
|
let nativeNode = path.join(nodePath, './native/MoeHoo.win32.node');
|
||||||
|
if (fs.existsSync(nativeNode)) {
|
||||||
|
dlopen(this.MoeHooExport, nativeNode, constants.dlopen.RTLD_LAZY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
isSetReCallEnabled(): boolean {
|
isSetReCallEnabled(): boolean {
|
||||||
return this.recallHookEnabled;
|
return this.recallHookEnabled;
|
||||||
}
|
}
|
||||||
registerRecallCallback(callback: (hex: string) => any): void {
|
registerRecallCallback(callback: (hex: string) => any): void {
|
||||||
|
try {
|
||||||
|
if (this.MoeHooExport.exports?.registMsgPush) {
|
||||||
|
this.MoeHooExport.exports.registMsgPush(callback);
|
||||||
this.recallHookEnabled = true;
|
this.recallHookEnabled = true;
|
||||||
return this.MoeHooExport.exports.registMsgPush(callback);
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this.recallHookEnabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user