refactor: packet x1
This commit is contained in:
105 files changed
+2286
-1962
No files matched your search
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user