From d21da47a7d36c9cb09c0b4f8c117a27e46f209e1 Mon Sep 17 00:00:00 2001 From: pk5ls20 Date: Sun, 13 Oct 2024 16:13:34 +0800 Subject: [PATCH] feat & fix: feat proto & revert `NapProto` changes --- src/core/apis/group.ts | 4 ++-- src/core/apis/packet.ts | 10 ++++++---- src/core/proto/NapProto.ts | 6 +++--- src/core/proto/oidb/Oidb.0x9067_202.ts | 4 ++-- src/core/proto/oidb/common/Ntv2.RichMedia.ts | 8 ++++---- src/onebot/action/group/GroupPoke.ts | 4 ++-- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/core/apis/group.ts b/src/core/apis/group.ts index 47670eba..750c3c9c 100644 --- a/src/core/apis/group.ts +++ b/src/core/apis/group.ts @@ -55,8 +55,8 @@ export class NTQQGroupApi { ); } async sendPocketRkey() { - let hex = '08E7A00210CA01221D0A130A05080110CA011206A80602B006011A0208022206080A081408022A006001'; - let ret = await this.core.apis.PacketApi.sendPacket('OidbSvcTrpcTcp.0x9067_202', hex, true); + let u8 = await this.core.apis.PacketApi.buildRkeyPacket() + let ret = await this.core.apis.PacketApi.sendPacket('OidbSvcTrpcTcp.0x9067_202', Buffer.from(u8).toString('hex'), true); //console.log('ret: ', ret); } async sendPacketPoke(group: number, peer: number) { diff --git a/src/core/apis/packet.ts b/src/core/apis/packet.ts index 12990499..b3407e74 100644 --- a/src/core/apis/packet.ts +++ b/src/core/apis/packet.ts @@ -76,18 +76,20 @@ export class NTQQPacketApi { reqHead: { common: { requestId: 1, - command: 2 + command: 202 }, scene: { requestType: 2, businessType: 1, sceneType: 0 }, - clent: { + client: { agentType: 2 } }, - downloadRKeyReq: [[{ key: 10 }, { key: 20 }], { key: 2 }], + downloadRKeyReq: { + key: [10, 20, 2] + }, }); let oidb_packet = new NapProtoMsg(OidbSvcTrpcTcpBase).encode({ command: 0x9067, @@ -149,4 +151,4 @@ export class NTQQPacketApi { } return { status: status, ext_status: 0 }; } -} \ No newline at end of file +} diff --git a/src/core/proto/NapProto.ts b/src/core/proto/NapProto.ts index 2985adaf..68d06f15 100644 --- a/src/core/proto/NapProto.ts +++ b/src/core/proto/NapProto.ts @@ -1,4 +1,4 @@ -import { MessageType, RepeatType, ScalarType } from '@protobuf-ts/runtime'; +import { MessageType, PartialMessage, RepeatType, ScalarType } from '@protobuf-ts/runtime'; import { PartialFieldInfo } from "@protobuf-ts/runtime/build/types/reflection-info"; type LowerCamelCase = CamelCaseHelper; @@ -122,7 +122,7 @@ export class NapProtoMsg { no: field.no, name: key, kind: 'message', - repeat: field.repeat ? RepeatType.UNPACKED : RepeatType.NO, + repeat: field.repeat ? RepeatType.PACKED : RepeatType.NO, T: () => rt, }; } @@ -131,7 +131,7 @@ export class NapProtoMsg { } encode(data: ProtoStructType): Uint8Array { - return this._proto_msg.toBinary(data) + return this._proto_msg.toBinary(this._proto_msg.create(data as PartialMessage>)); } decode(data: Uint8Array): ProtoStructType { diff --git a/src/core/proto/oidb/Oidb.0x9067_202.ts b/src/core/proto/oidb/Oidb.0x9067_202.ts index 870fc363..f8afee44 100644 --- a/src/core/proto/oidb/Oidb.0x9067_202.ts +++ b/src/core/proto/oidb/Oidb.0x9067_202.ts @@ -4,8 +4,8 @@ import { MultiMediaReqHead } from "./common/Ntv2.RichMedia"; export const OidbSvcTrpcTcp0X9067_202 = { ReqHead: ProtoField(1, () => MultiMediaReqHead), - DownloadRKeyReq: ProtoField(4, () => OidbSvcTrpcTcp0X9067_202Key, true, false), + DownloadRKeyReq: ProtoField(4, () => OidbSvcTrpcTcp0X9067_202Key), } export const OidbSvcTrpcTcp0X9067_202Key = { - key: ProtoField(1, ScalarType.UINT32) + key: ProtoField(1, ScalarType.INT32, false, true), } diff --git a/src/core/proto/oidb/common/Ntv2.RichMedia.ts b/src/core/proto/oidb/common/Ntv2.RichMedia.ts index 0482f0e8..aa122b31 100644 --- a/src/core/proto/oidb/common/Ntv2.RichMedia.ts +++ b/src/core/proto/oidb/common/Ntv2.RichMedia.ts @@ -8,7 +8,7 @@ export const NTV2RichMediaReq = { export const MultiMediaReqHead = { Common: ProtoField(1, () => CommonHead), Scene: ProtoField(2, () => SceneInfo), - Clent: ProtoField(3, () => ClientMeta), + Client: ProtoField(3, () => ClientMeta), } export const CommonHead = { RequestId: ProtoField(1, ScalarType.UINT32), @@ -19,6 +19,9 @@ export const SceneInfo = { BusinessType: ProtoField(102, ScalarType.UINT32), SceneType: ProtoField(200, ScalarType.UINT32), } +export const ClientMeta = { + AgentType: ProtoField(1, ScalarType.UINT32), +} export const C2CUserInfo = { AccountType: ProtoField(1, ScalarType.UINT32), TargetUid: ProtoField(2, ScalarType.STRING), @@ -26,9 +29,6 @@ export const C2CUserInfo = { export const GroupInfo = { GroupUin: ProtoField(1, ScalarType.UINT32), } -export const ClientMeta = { - AgentType: ProtoField(1, ScalarType.UINT32), -} export const DownloadReq = { Node: ProtoField(1, ScalarType.BYTES), Download: ProtoField(2, ScalarType.BYTES), diff --git a/src/onebot/action/group/GroupPoke.ts b/src/onebot/action/group/GroupPoke.ts index 6f960776..bf518661 100644 --- a/src/onebot/action/group/GroupPoke.ts +++ b/src/onebot/action/group/GroupPoke.ts @@ -21,6 +21,6 @@ export class GroupPoke extends BaseAction { if (!this.core.apis.PacketApi.PacketClient?.isConnected) { throw new Error('PacketClient is not init'); } - this.core.apis.GroupApi.sendPacketPoke(+payload.group_id, +payload.user_id); + await this.core.apis.GroupApi.sendPacketPoke(+payload.group_id, +payload.user_id); } -} \ No newline at end of file +}