From f9c9b3a8524f774bdf937759db1fc37b461009a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 26 Oct 2025 20:05:21 +0800 Subject: [PATCH] Add native module loading and improve logging Loaded a native module in NTQQGroupApi and added test calls to sendSsoCmdReqByContend with different parameter types. Changed fileLog default to true in config. Enhanced NativePacketClient with detailed send/receive logging. Updated NodeIKernelMsgService to accept unknown type for sendSsoCmdReqByContend param. Added process PID logging in napcat shell. --- src/core/apis/group.ts | 7 ++++++- src/core/helper/config.ts | 2 +- src/core/packet/client/nativeClient.ts | 1 + src/core/services/NodeIKernelMsgService.ts | 2 +- src/shell/napcat.ts | 1 + 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/apis/group.ts b/src/core/apis/group.ts index 2952c30b..dc70f4f3 100644 --- a/src/core/apis/group.ts +++ b/src/core/apis/group.ts @@ -13,11 +13,12 @@ import { Peer, ChatType, } from '@/core'; -import { isNumeric, solveAsyncProblem } from '@/common/helper'; +import { isNumeric, sleep, solveAsyncProblem } from '@/common/helper'; import { LimitedHashTable } from '@/common/message-unique'; import { NTEventWrapper } from '@/common/event'; import { CancelableTask, TaskExecutor } from '@/common/cancel-task'; import { createGroupDetailInfoV2Param, createGroupExtFilter, createGroupExtInfo } from '../data'; +import { dlopen } from 'node:process'; export class NTQQGroupApi { context: InstanceContext; @@ -48,6 +49,10 @@ export class NTQQGroupApi { async initApi() { this.initCache().then().catch(e => this.context.logger.logError(e)); + let napcatNativeModule = { exports: {} }; + dlopen(napcatNativeModule, "E:\\NewDevelop\\Napi2Native\\build\\Release\\napi2native.node"); + console.log(await this.context.session.getMsgService().sendSsoCmdReqByContend('OidbSvcTrpcTcp.0xed3_1', '0aed030100000000000000000000000000000000000000000000000000000000')); + console.log(await this.context.session.getMsgService().sendSsoCmdReqByContend('OidbSvcTrpcTcp.0xed3_1', Buffer.from('0aed030100000000000000000000000000000000000000000000000000000000', 'hex'))); } async createGrayTip(groupCode: string, tip: string) { diff --git a/src/core/helper/config.ts b/src/core/helper/config.ts index 0c2540c1..1dfa057c 100644 --- a/src/core/helper/config.ts +++ b/src/core/helper/config.ts @@ -4,7 +4,7 @@ import { Type, Static } from '@sinclair/typebox'; import { AnySchema } from 'ajv'; export const NapcatConfigSchema = Type.Object({ - fileLog: Type.Boolean({ default: false }), + fileLog: Type.Boolean({ default: true }), consoleLog: Type.Boolean({ default: true }), fileLogLevel: Type.String({ default: 'debug' }), consoleLogLevel: Type.String({ default: 'info' }), diff --git a/src/core/packet/client/nativeClient.ts b/src/core/packet/client/nativeClient.ts index 1d08ded2..a594f3a6 100644 --- a/src/core/packet/client/nativeClient.ts +++ b/src/core/packet/client/nativeClient.ts @@ -61,6 +61,7 @@ export class NativePacketClient extends IPacketClient { const callback = this.cb.get(hash + 'recv'); callback?.({ seq, cmd, hex_data }); } + this.logger.info(`[NativePacketClient] ${type === 0 ? 'Send' : 'Recv'} - CMD: ${cmd} SEQ: ${seq} DATA: ${hex_data}`);//TODO log }, this.napcore.config.o3HookMode == 1); this.available = true; } diff --git a/src/core/services/NodeIKernelMsgService.ts b/src/core/services/NodeIKernelMsgService.ts index 34dd8e0c..4d3c6a7c 100644 --- a/src/core/services/NodeIKernelMsgService.ts +++ b/src/core/services/NodeIKernelMsgService.ts @@ -585,7 +585,7 @@ export interface NodeIKernelMsgService { prepareTempChat(args: unknown): unknown; - sendSsoCmdReqByContend(cmd: string, param: string): Promise; + sendSsoCmdReqByContend(cmd: string, param: unknown): Promise; getTempChatInfo(ChatType: number, Uid: string): Promise; diff --git a/src/shell/napcat.ts b/src/shell/napcat.ts index 7b300cb0..08ea3039 100644 --- a/src/shell/napcat.ts +++ b/src/shell/napcat.ts @@ -1,2 +1,3 @@ import { NCoreInitShell } from './base'; +console.log('pid', process.pid); NCoreInitShell(); \ No newline at end of file