chore: type

This commit is contained in:
手瓜一十雪
2024-08-09 10:42:03 +08:00
parent 65521bd840
commit a1a28a892f
6 changed files with 44 additions and 14 deletions

View File

@@ -6,6 +6,7 @@ import { NTEventChannel } from "@/common/framework/event";
import { proxiedListenerOf } from "@/common/utils/proxy-handler";
import { MsgListener } from "./listeners";
import { sleep } from "@/common/utils/helper";
import { CoreCache, LineDevice } from "./entities";
export enum NapCatCoreWorkingEnv {
Unknown = 0,
@@ -26,22 +27,42 @@ export function loadQQWrapper(QQVersion: string): WrapperNodeApi {
export class NapCatCore {
readonly context: InstanceContext;
readonly eventChannel: NTEventChannel;
readonly cache: CoreCache;
constructor(context: InstanceContext) {
this.context = context;
this.eventChannel = new NTEventChannel(context.wrapper, context.session);
this.cache = {
selfInfo: {
uid: "",
uin: "",
nick: ""
},
DeviceList: []
}
this.initNapCatCoreListeners().then().catch(console.error);
}
// Renamed from 'InitDataListener'
async initNapCatCoreListeners() {
let msg = new MsgListener();
msg.onRecvMsg = (msg) => {
let msgListener = new MsgListener();
msgListener.onRecvMsg = (msg) => {
console.log("RecvMsg", msg);
}
msgListener.onLineDev = (Devices: LineDevice[]) => {
this.cache.DeviceList.splice(0, this.cache.DeviceList.length);
Devices.map((Device: LineDevice) => {
let DeviceData = {
app_id: Device.devUid,
device_name: Device.clientType.toString(),
device_kind: Device.clientType.toString(),
};
this.cache.DeviceList.push(DeviceData);
});
};
//await sleep(2500);
this.context.session.getMsgService().addKernelMsgListener(
new this.context.wrapper.NodeIKernelMsgListener(proxiedListenerOf(msg, this.context.logger))
new this.context.wrapper.NodeIKernelMsgListener(proxiedListenerOf(msgListener, this.context.logger))
);
}
}