mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
chore: type
This commit is contained in:
parent
024faa2561
commit
9fc9ed805c
@ -6,6 +6,7 @@ import { NTEventChannel } from "@/common/framework/event";
|
|||||||
import { proxiedListenerOf } from "@/common/utils/proxy-handler";
|
import { proxiedListenerOf } from "@/common/utils/proxy-handler";
|
||||||
import { MsgListener } from "./listeners";
|
import { MsgListener } from "./listeners";
|
||||||
import { sleep } from "@/common/utils/helper";
|
import { sleep } from "@/common/utils/helper";
|
||||||
|
import { CoreCache, LineDevice } from "./entities";
|
||||||
|
|
||||||
export enum NapCatCoreWorkingEnv {
|
export enum NapCatCoreWorkingEnv {
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
@ -26,22 +27,42 @@ export function loadQQWrapper(QQVersion: string): WrapperNodeApi {
|
|||||||
export class NapCatCore {
|
export class NapCatCore {
|
||||||
readonly context: InstanceContext;
|
readonly context: InstanceContext;
|
||||||
readonly eventChannel: NTEventChannel;
|
readonly eventChannel: NTEventChannel;
|
||||||
|
readonly cache: CoreCache;
|
||||||
constructor(context: InstanceContext) {
|
constructor(context: InstanceContext) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.eventChannel = new NTEventChannel(context.wrapper, context.session);
|
this.eventChannel = new NTEventChannel(context.wrapper, context.session);
|
||||||
|
this.cache = {
|
||||||
|
selfInfo: {
|
||||||
|
uid: "",
|
||||||
|
uin: "",
|
||||||
|
nick: ""
|
||||||
|
},
|
||||||
|
DeviceList: []
|
||||||
|
}
|
||||||
this.initNapCatCoreListeners().then().catch(console.error);
|
this.initNapCatCoreListeners().then().catch(console.error);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renamed from 'InitDataListener'
|
// Renamed from 'InitDataListener'
|
||||||
async initNapCatCoreListeners() {
|
async initNapCatCoreListeners() {
|
||||||
let msg = new MsgListener();
|
let msgListener = new MsgListener();
|
||||||
msg.onRecvMsg = (msg) => {
|
msgListener.onRecvMsg = (msg) => {
|
||||||
console.log("RecvMsg", 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);
|
//await sleep(2500);
|
||||||
this.context.session.getMsgService().addKernelMsgListener(
|
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))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,3 +3,4 @@ export * from './group';
|
|||||||
export * from './msg';
|
export * from './msg';
|
||||||
export * from './notify';
|
export * from './notify';
|
||||||
export * from './cache';
|
export * from './cache';
|
||||||
|
export * from './system'
|
16
src/core/entities/system.ts
Normal file
16
src/core/entities/system.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { SelfInfo } from "./user"
|
||||||
|
|
||||||
|
export interface LineDevice {
|
||||||
|
instanceId: number
|
||||||
|
clientType: number
|
||||||
|
devUid: string
|
||||||
|
}
|
||||||
|
export interface OBLineDevice {
|
||||||
|
app_id: string;
|
||||||
|
device_name: string;
|
||||||
|
device_kind: string;
|
||||||
|
}
|
||||||
|
export interface CoreCache {
|
||||||
|
selfInfo: SelfInfo,
|
||||||
|
DeviceList: OBLineDevice[]
|
||||||
|
}
|
@ -208,6 +208,7 @@ export interface QQLevel {
|
|||||||
moonNum: number;
|
moonNum: number;
|
||||||
starNum: number
|
starNum: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
uid: string; // 加密的字符串
|
uid: string; // 加密的字符串
|
||||||
uin: string; // QQ号
|
uin: string; // QQ号
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
import { SelfInfo } from "../entities";
|
|
||||||
|
|
||||||
export const selfInfo: SelfInfo = {
|
|
||||||
uid: '',
|
|
||||||
uin: '',
|
|
||||||
nick: '',
|
|
||||||
online: true
|
|
||||||
};
|
|
@ -1,4 +1,3 @@
|
|||||||
export * from './wrapper';
|
export * from './wrapper';
|
||||||
export * from './data';
|
|
||||||
export * from './helper';
|
export * from './helper';
|
||||||
export * from './context';
|
export * from './context';
|
Loading…
x
Reference in New Issue
Block a user