refactor: packet x1

This commit is contained in:
pk5ls20 committed 2024-11-12 04:02:19 +08:00
1 parent af29c17814
commit 7fd94a03b7
105 files changed
+2286 -1962

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
import { NapCatCore } from "@/core";
export interface NapCoreCompatBasicInfo {
readonly uin: number;
readonly uid: string;
readonly uin2uid: (uin: number) => Promise<string>;
readonly uid2uin: (uid: string) => Promise<number>;
readonly sendSsoCmdReqByContend: (cmd: string, trace_id: string) => Promise<void>;
}
export class NapCoreContext {
private readonly core: NapCatCore;
constructor(core: NapCatCore) {
this.core = core;
}
get logger() {
return this.core.context.logger;
}
get basicInfo() {
return {
uin: +this.core.selfInfo.uin,
uid: this.core.selfInfo.uid,
uin2uid: (uin: number) => this.core.apis.UserApi.getUidByUinV2(String(uin)).then(res => res ?? ''),
uid2uin: (uid: string) => this.core.apis.UserApi.getUinByUidV2(uid).then(res => +res),
} as NapCoreCompatBasicInfo;
}
get config() {
return this.core.configLoader.configData;
}
sendSsoCmdReqByContend = (cmd: string, trace_id: string) => this.core.context.session.getMsgService().sendSsoCmdReqByContend(cmd, trace_id);
}