refactor: remove nc packet api

This commit is contained in:
linyuchen 2024-11-19 00:47:48 +08:00
parent 0fb30df1bc
commit 9453b71943
13 changed files with 5 additions and 3100 deletions

View File

@ -20,7 +20,6 @@ import { selfInfo } from '../common/globalVars'
import { version } from '../version'
import { invoke } from './ntcall'
import { Native } from './native/crychic'
import { initWrapperSession, NTQQPacketApi } from './native/napcat-protocol-packet'
declare module 'cordis' {
interface Context {
@ -41,14 +40,10 @@ class Core extends Service {
static inject = ['ntMsgApi', 'ntFriendApi', 'ntGroupApi', 'store']
public startTime = 0
public native
public packet!: NTQQPacketApi
constructor(protected ctx: Context, public config: Core.Config) {
super(ctx, 'app', true)
this.native = new Native(ctx)
initWrapperSession().then(session => {
this.packet = new NTQQPacketApi(session)
})
}
public start() {

View File

@ -1,17 +0,0 @@
import { WrapperSession } from './wrapper-session/types';
export { initWrapperSession } from './wrapper-session';
export declare function checkSupportVersion(): void;
export declare class NTQQPacketApi {
private qqVersion;
private readonly packetClient;
private readonly packer;
private logger;
private readonly wrapperSession;
constructor(wrapperSession: WrapperSession);
private InitSendPacket;
private sendPacket;
private sendOidbPacket;
sendPokePacket(peer: number, group?: number): Promise<void>;
sendGroupSignPacket(selfUin: string, groupCode: string): Promise<void>;
sendSetSpecialTittlePacket(groupCode: string, uid: string, tittle: string): Promise<void>;
}

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
export declare function initWrapperSession(): Promise<any>;

View File

@ -1,6 +0,0 @@
export interface MsgService {
sendSsoCmdReqByContend: (cmd: string, trace_id: string) => Promise<unknown>;
}
export type WrapperSession = {
getMsgService(): MsgService;
};

View File

@ -13,7 +13,7 @@ export class SendGroupSign extends BaseAction<Payload, null> {
})
async _handle(payload: Payload) {
await this.ctx.app.packet.sendGroupSignPacket(selfInfo.uin, payload.group_id.toString())
throw new Error('暂未实现群签到功能')
return null
}
}

View File

@ -24,7 +24,7 @@ export class SetGroupSpecialTitle extends BaseAction<Payload, null> {
if (self.role !== GroupMemberRole.Owner){
throw new Error(`不是群${payload.group_id}的群主,无法设置群头衔`)
}
await this.ctx.app.packet.sendSetSpecialTittlePacket(payload.group_id.toString(), uid, payload.special_title || "")
throw new Error('暂未实现设置群头衔功能')
return null
}
}

View File

@ -14,7 +14,8 @@ export class FriendPoke extends BaseAction<Payload, null> {
async _handle(payload: Payload) {
if (!this.ctx.app.native.checkPlatform() || !this.ctx.app.native.checkVersion()) {
await this.ctx.app.packet.sendPokePacket(+payload.user_id)
// await this.ctx.app.packet.sendPokePacket(+payload.user_id)
throw new Error('戳一戳暂时只支持Windows QQ 27333 ~ 275970版本')
}
else{
await this.ctx.app.native.sendFriendPoke(+payload.user_id)

View File

@ -16,7 +16,7 @@ export class GroupPoke extends BaseAction<Payload, null> {
async _handle(payload: Payload) {
if (!this.ctx.app.native.checkPlatform() || !this.ctx.app.native.checkVersion()) {
await this.ctx.app.packet.sendPokePacket(+payload.user_id, +payload.group_id)
throw new Error('戳一戳暂时只支持Windows QQ 27333 ~ 275970版本')
}
else{
await this.ctx.app.native.sendGroupPoke(+payload.group_id, +payload.user_id)