This commit is contained in:
idranme 2024-11-14 11:40:19 +08:00
parent 5c5105ce88
commit bb8771a5b4
No known key found for this signature in database
GPG Key ID: D0F3677546E6ECD5
6 changed files with 8 additions and 14 deletions

View File

@ -36,9 +36,6 @@ import {
} from '../ntqqapi/api' } from '../ntqqapi/api'
import { existsSync, mkdirSync } from 'node:fs' import { existsSync, mkdirSync } from 'node:fs'
import { initWrapperSession} from '@/ntqqapi/native/napcat-protocol-packet'
initWrapperSession().then()
declare module 'cordis' { declare module 'cordis' {
interface Events { interface Events {
'llob/config-updated': (input: LLOBConfig) => void 'llob/config-updated': (input: LLOBConfig) => void

View File

@ -41,12 +41,14 @@ class Core extends Service {
static inject = ['ntMsgApi', 'ntFriendApi', 'ntGroupApi', 'store'] static inject = ['ntMsgApi', 'ntFriendApi', 'ntGroupApi', 'store']
public startTime = 0 public startTime = 0
public native public native
public ntqqPacketApi: NTQQPacketApi public packet!: NTQQPacketApi
constructor(protected ctx: Context, public config: Core.Config) { constructor(protected ctx: Context, public config: Core.Config) {
super(ctx, 'app', true) super(ctx, 'app', true)
this.native = new Native(ctx) this.native = new Native(ctx)
initWrapperSession().then(session=>{this.ntqqPacketApi = new NTQQPacketApi(session)}) initWrapperSession().then(session => {
this.packet = new NTQQPacketApi(session)
})
} }
public start() { public start() {

View File

@ -1,6 +1,5 @@
import { BaseAction, Schema } from '../BaseAction' import { BaseAction, Schema } from '../BaseAction'
import { ActionName } from '../types' import { ActionName } from '../types'
import { getBuildVersion } from '@/common/utils/misc'
import { selfInfo } from '@/common/globalVars' import { selfInfo } from '@/common/globalVars'
interface Payload { interface Payload {
@ -14,7 +13,7 @@ export class SendGroupSign extends BaseAction<Payload, null> {
}) })
async _handle(payload: Payload) { async _handle(payload: Payload) {
await this.ctx.app.ntqqPacketApi.sendGroupSignPacket(selfInfo.uin, payload.group_id.toString()) await this.ctx.app.packet.sendGroupSignPacket(selfInfo.uin, payload.group_id.toString())
return null return null
} }
} }

View File

@ -1,6 +1,5 @@
import { BaseAction, Schema } from '../BaseAction' import { BaseAction, Schema } from '../BaseAction'
import { ActionName } from '../types' import { ActionName } from '../types'
import { getBuildVersion } from '@/common/utils/misc'
import { selfInfo } from '@/common/globalVars' import { selfInfo } from '@/common/globalVars'
import { GroupMemberRole } from '@/ntqqapi/types' import { GroupMemberRole } from '@/ntqqapi/types'
@ -25,7 +24,7 @@ export class SetGroupSpecialTitle extends BaseAction<Payload, null> {
if (self.role !== GroupMemberRole.Owner){ if (self.role !== GroupMemberRole.Owner){
throw new Error(`不是群${payload.group_id}的群主,无法设置群头衔`) throw new Error(`不是群${payload.group_id}的群主,无法设置群头衔`)
} }
await this.ctx.app.ntqqPacketApi.sendSetSpecialTittlePacket(payload.group_id.toString(), uid, payload.special_title || "") await this.ctx.app.packet.sendSetSpecialTittlePacket(payload.group_id.toString(), uid, payload.special_title || "")
return null return null
} }
} }

View File

@ -1,6 +1,5 @@
import { BaseAction, Schema } from '../BaseAction' import { BaseAction, Schema } from '../BaseAction'
import { ActionName } from '../types' import { ActionName } from '../types'
import { getBuildVersion } from '@/common/utils/misc'
interface Payload { interface Payload {
user_id: number | string user_id: number | string
@ -21,7 +20,7 @@ export class FriendPoke extends BaseAction<Payload, null> {
// } // }
// await this.ctx.app.native.sendFriendPoke(+payload.user_id) // await this.ctx.app.native.sendFriendPoke(+payload.user_id)
await this.ctx.app.ntqqPacketApi.sendPokePacket(+payload.user_id) await this.ctx.app.packet.sendPokePacket(+payload.user_id)
return null return null
} }
} }

View File

@ -1,7 +1,5 @@
import { BaseAction, Schema } from '../BaseAction' import { BaseAction, Schema } from '../BaseAction'
import { ActionName } from '../types' import { ActionName } from '../types'
import { getBuildVersion } from '@/common/utils/misc'
import {NTQQPacketApi} from '@/ntqqapi/native/napcat-protocol-packet'
interface Payload { interface Payload {
group_id: number | string group_id: number | string
@ -23,7 +21,7 @@ export class GroupPoke extends BaseAction<Payload, null> {
// throw new Error(`当前 QQ 版本 ${getBuildVersion()} 不支持,可尝试其他版本 27333—27597`) // throw new Error(`当前 QQ 版本 ${getBuildVersion()} 不支持,可尝试其他版本 27333—27597`)
// } // }
// await this.ctx.app.native.sendGroupPoke(+payload.group_id, +payload.user_id) // await this.ctx.app.native.sendGroupPoke(+payload.group_id, +payload.user_id)
await this.ctx.app.ntqqPacketApi.sendPokePacket(+payload.user_id, +payload.group_id) await this.ctx.app.packet.sendPokePacket(+payload.user_id, +payload.group_id)
return null return null
} }
} }