Compare commits

...

1 Commits

Author SHA1 Message Date
手瓜一十雪
da90245f7b release: v2.6.20 2024-09-30 17:05:02 +08:00
7 changed files with 46 additions and 52 deletions

View File

@@ -4,7 +4,7 @@
"name": "NapCatQQ", "name": "NapCatQQ",
"slug": "NapCat.Framework", "slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现", "description": "高性能的 OneBot 11 协议实现",
"version": "2.6.19", "version": "2.6.20",
"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": "2.6.19", "version": "2.6.20",
"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",

View File

@@ -1 +1 @@
export const napCatVersion = '2.6.19'; export const napCatVersion = '2.6.20';

View File

@@ -7,8 +7,10 @@ export class Native {
supportedPlatforms = ['win32']; supportedPlatforms = ['win32'];
MoeHooExport: any = { exports: {} }; MoeHooExport: any = { exports: {} };
recallHookEnabled: boolean = false; recallHookEnabled: boolean = false;
inited = true;
constructor(nodePath: string, platform: string = process.platform) { constructor(nodePath: string, platform: string = process.platform) {
this.platform = platform; this.platform = platform;
try {
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`);
} }
@@ -16,12 +18,17 @@ export class Native {
if (fs.existsSync(nativeNode)) { if (fs.existsSync(nativeNode)) {
dlopen(this.MoeHooExport, nativeNode, constants.dlopen.RTLD_LAZY); dlopen(this.MoeHooExport, nativeNode, constants.dlopen.RTLD_LAZY);
} }
} catch (error) {
this.inited = false;
}
} }
isSetReCallEnabled(): boolean { isSetReCallEnabled(): boolean {
return this.recallHookEnabled; return this.recallHookEnabled && this.inited;
} }
registerRecallCallback(callback: (hex: string) => any): void { registerRecallCallback(callback: (hex: string) => any): void {
try { try {
if (!this.inited) throw new Error('Native Not Init');
if (this.MoeHooExport.exports?.registMsgPush) { if (this.MoeHooExport.exports?.registMsgPush) {
this.MoeHooExport.exports.registMsgPush(callback); this.MoeHooExport.exports.registMsgPush(callback);
this.recallHookEnabled = true; this.recallHookEnabled = true;

View File

@@ -79,7 +79,9 @@ export class NapCatOneBot11Adapter {
} }
async registerNative(core: NapCatCore, context: InstanceContext) { async registerNative(core: NapCatCore, context: InstanceContext) {
try {
this.nativeCore = new Native(context.pathWrapper.binaryPath); this.nativeCore = new Native(context.pathWrapper.binaryPath);
if (!this.nativeCore.inited) throw new Error('Native Not Init');
this.nativeCore.registerRecallCallback(async (hex: string) => { this.nativeCore.registerRecallCallback(async (hex: string) => {
try { try {
let data = decodeMessage(Buffer.from(hex, 'hex')) as any; let data = decodeMessage(Buffer.from(hex, 'hex')) as any;
@@ -96,30 +98,15 @@ export class NapCatOneBot11Adapter {
context.logger.log("[Native] 群消息撤回 Peer: " + uid.toString() + " / MsgSeq:" + seq); context.logger.log("[Native] 群消息撤回 Peer: " + uid.toString() + " / MsgSeq:" + seq);
let msgs = await core.apis.MsgApi.queryMsgsWithFilterExWithSeq(peer, seq.toString()); let msgs = await core.apis.MsgApi.queryMsgsWithFilterExWithSeq(peer, seq.toString());
this.recallMsgCache.put(msgs.msgList[0].msgId, msgs.msgList[0]); this.recallMsgCache.put(msgs.msgList[0].msgId, msgs.msgList[0]);
// let ob11 = await this.apis.MsgApi.parseMessage(msgs.msgList[0], 'array')
// .catch(e => this.context.logger.logError.bind(this.context.logger)('处理消息失败', e));
// if (ob11) {
// const { sendElements, deleteAfterSentFiles } = await this.apis.MsgApi.createSendElements(ob11.message as OB11MessageData[], peer);
// this.apis.MsgApi.sendMsgWithOb11UniqueId(peer, sendElements, deleteAfterSentFiles);
// }
// this.apis.MsgApi.sendMsg(peer, [{
// elementType: 1,
// elementId: '',
// textElement: {
// content: "[Native] 群消息撤回 Peer: " + uid.toString() + " / MsgSeq:" + seq,
// atType: 0,
// atUid: '',
// atTinyId: '',
// atNtUid: '',
// },
// }]);
} }
} catch (error: any) { } catch (error: any) {
context.logger.logWarn("[Native] Error:", (error as Error).message, ' HEX:', hex); context.logger.logWarn("[Native] Error:", (error as Error).message, ' HEX:', hex);
} }
}); });
} catch (error) {
context.logger.logWarn("[Native] Error:", (error as Error).message);
return;
}
} }
async InitOneBot() { async InitOneBot() {
const selfInfo = this.core.selfInfo; const selfInfo = this.core.selfInfo;

View File

@@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) {
SettingItem( SettingItem(
'<span id="napcat-update-title">Napcat</span>', '<span id="napcat-update-title">Napcat</span>',
undefined, undefined,
SettingButton('V2.6.19', 'napcat-update-button', 'secondary'), SettingButton('V2.6.20', 'napcat-update-button', 'secondary'),
), ),
]), ]),
SettingList([ SettingList([

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("V2.6.19", "napcat-update-button", "secondary") SettingButton("V2.6.20", "napcat-update-button", "secondary")
) )
]), ]),
SettingList([ SettingList([