mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
refactor: Poke
This commit is contained in:
parent
a2c4498694
commit
eef5293ca0
@ -12,11 +12,11 @@ import {
|
||||
import { isNumeric, sleep, solveAsyncProblem } from '@/common/helper';
|
||||
import { LimitedHashTable } from '@/common/message-unique';
|
||||
import { NTEventWrapper } from '@/common/event';
|
||||
import { encodeGroupPoke } from '../proto/Poke';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { RequestUtil } from '@/common/request';
|
||||
interface recvPacket
|
||||
{
|
||||
import { NapProtoMsg } from '../proto/NapProto';
|
||||
import { OidbSvcTrpcTcp0XED3_1, OidbSvcTrpcTcpBaseProto } from '../proto/OidbBase';
|
||||
interface recvPacket {
|
||||
type: string,//仅recv
|
||||
trace_id_md5?: string,
|
||||
data: {
|
||||
@ -65,10 +65,18 @@ export class NTQQGroupApi {
|
||||
//console.log('ret: ', ret);
|
||||
}
|
||||
async sendPacketPoke(group: number, peer: number) {
|
||||
let data = encodeGroupPoke(group, peer);
|
||||
let hex = Buffer.from(data).toString('hex');
|
||||
let oidb_0xed3 = new NapProtoMsg(OidbSvcTrpcTcp0XED3_1).encode({
|
||||
uin: peer,
|
||||
groupUin: group,
|
||||
ext: 0
|
||||
});
|
||||
let oidb_packet = new NapProtoMsg(OidbSvcTrpcTcpBaseProto).encode({
|
||||
command: 0xed3,
|
||||
subCommand: 1,
|
||||
body: oidb_0xed3
|
||||
});
|
||||
let hex = Buffer.from(oidb_packet).toString('hex');
|
||||
let retdata = await this.core.apis.PacketApi.sendPacket('OidbSvcTrpcTcp.0xed3_1', hex, false);
|
||||
//console.log('sendPacketPoke', retdata);
|
||||
}
|
||||
async fetchGroupEssenceList(groupCode: string) {
|
||||
const pskey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!;
|
||||
|
@ -51,9 +51,9 @@ type ProtoMessageType = {
|
||||
[key: string]: ProtoFieldType;
|
||||
};
|
||||
|
||||
function ProtoField<T extends ScalarType, O extends boolean = false, R extends O extends true ? false : boolean = false>(no: number, type: T, repeated?: R, optional?: O): ScalarProtoFieldType<T, O, R>;
|
||||
function ProtoField<T extends () => ProtoMessageType, O extends boolean = false, R extends O extends true ? false : boolean = false>(no: number, type: T, repeated?: R, optional?: O): MessageProtoFieldType<T, O, R>;
|
||||
function ProtoField(no: number, type: ScalarType | (() => ProtoMessageType), repeated?: boolean, optional?: boolean): ProtoFieldType {
|
||||
export function ProtoField<T extends ScalarType, O extends boolean = false, R extends O extends true ? false : boolean = false>(no: number, type: T, repeated?: R, optional?: O): ScalarProtoFieldType<T, O, R>;
|
||||
export function ProtoField<T extends () => ProtoMessageType, O extends boolean = false, R extends O extends true ? false : boolean = false>(no: number, type: T, repeated?: R, optional?: O): MessageProtoFieldType<T, O, R>;
|
||||
export function ProtoField(no: number, type: ScalarType | (() => ProtoMessageType), repeated?: boolean, optional?: boolean): ProtoFieldType {
|
||||
if (typeof type === 'function') {
|
||||
return { kind: 'message', no: no, type: type, repeated: repeated ?? false, optional: optional ?? false };
|
||||
} else {
|
||||
@ -89,7 +89,7 @@ type ProtoStructType<T> = RequiredFieldsType<T> & OptionalFieldsType<T>;
|
||||
|
||||
const NapProtoMsgCache = new Map<ProtoMessageType, MessageType<ProtoStructType<ProtoMessageType>>>();
|
||||
|
||||
class NapProtoMsg<T extends ProtoMessageType> {
|
||||
export class NapProtoMsg<T extends ProtoMessageType> {
|
||||
private readonly _msg: T;
|
||||
private readonly _field: PartialFieldInfo[];
|
||||
private readonly _proto_msg: MessageType<ProtoStructType<T>>;
|
||||
|
16
src/core/proto/OidbBase.ts
Normal file
16
src/core/proto/OidbBase.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { ProtoField } from "./NapProto";
|
||||
import { ScalarType } from '@protobuf-ts/runtime';
|
||||
|
||||
export const OidbSvcTrpcTcpBaseProto = {
|
||||
command: ProtoField(1, ScalarType.UINT32),
|
||||
subCommand: ProtoField(2, ScalarType.UINT32),
|
||||
body: ProtoField(4, ScalarType.BYTES),
|
||||
isReserved: ProtoField(12, ScalarType.UINT32, false, true)
|
||||
}
|
||||
|
||||
export const OidbSvcTrpcTcp0XED3_1 = {
|
||||
uin: ProtoField(1, ScalarType.UINT32),
|
||||
groupUin: ProtoField(2, ScalarType.UINT32, false, true),
|
||||
friendUin: ProtoField(5, ScalarType.BYTES, false, true),
|
||||
ext: ProtoField(6, ScalarType.UINT32)
|
||||
}
|
@ -1,31 +1,31 @@
|
||||
import { MessageType, ScalarType, BinaryWriter } from '@protobuf-ts/runtime';
|
||||
// import { MessageType, ScalarType, BinaryWriter } from '@protobuf-ts/runtime';
|
||||
|
||||
export const OidbSvcTrpcTcpBase = new MessageType("oidb_svc_trpctcp_base", [
|
||||
{ no: 1, name: "command", kind: "scalar", T: ScalarType.UINT32 },
|
||||
{ no: 2, name: "subcommand", kind: "scalar", T: ScalarType.UINT32, opt: true },
|
||||
{ no: 4, name: "body", kind: "scalar", T: ScalarType.BYTES, opt: true },
|
||||
{ no: 12, name: "isreserved", kind: "scalar", T: ScalarType.INT32, opt: true }
|
||||
]);
|
||||
// export const OidbSvcTrpcTcpBase = new MessageType("oidb_svc_trpctcp_base", [
|
||||
// { no: 1, name: "command", kind: "scalar", T: ScalarType.UINT32 },
|
||||
// { no: 2, name: "subcommand", kind: "scalar", T: ScalarType.UINT32, opt: true },
|
||||
// { no: 4, name: "body", kind: "scalar", T: ScalarType.BYTES, opt: true },
|
||||
// { no: 12, name: "isreserved", kind: "scalar", T: ScalarType.INT32, opt: true }
|
||||
// ]);
|
||||
|
||||
export const OidbSvcTrpcTcp0XED3_1 = new MessageType("oidb_svc_trpctcp_0xed3_1", [
|
||||
{ no: 1, name: "uin", kind: "scalar", T: ScalarType.UINT32 },
|
||||
{ no: 2, name: "groupuin", kind: "scalar", T: ScalarType.UINT32, opt: true },
|
||||
{ no: 5, name: "frienduin", kind: "scalar", T: ScalarType.UINT32, opt: true },
|
||||
{ no: 6, name: "ext", kind: "scalar", T: ScalarType.UINT32 }
|
||||
]);
|
||||
// export const OidbSvcTrpcTcp0XED3_1 = new MessageType("oidb_svc_trpctcp_0xed3_1", [
|
||||
// { no: 1, name: "uin", kind: "scalar", T: ScalarType.UINT32 },
|
||||
// { no: 2, name: "groupuin", kind: "scalar", T: ScalarType.UINT32, opt: true },
|
||||
// { no: 5, name: "frienduin", kind: "scalar", T: ScalarType.UINT32, opt: true },
|
||||
// { no: 6, name: "ext", kind: "scalar", T: ScalarType.UINT32 }
|
||||
// ]);
|
||||
|
||||
export function encodeGroupPoke(groupUin: number, PeerUin: number) {
|
||||
let Body = OidbSvcTrpcTcp0XED3_1.toBinary
|
||||
({
|
||||
uin: PeerUin,
|
||||
groupuin: groupUin,
|
||||
ext: 0
|
||||
});
|
||||
//console.log(Body)
|
||||
return OidbSvcTrpcTcpBase.toBinary
|
||||
({
|
||||
command: 0xed3,
|
||||
subcommand: 1,
|
||||
body: Body
|
||||
});
|
||||
}
|
||||
// export function encodeGroupPoke(groupUin: number, PeerUin: number) {
|
||||
// let Body = OidbSvcTrpcTcp0XED3_1.toBinary
|
||||
// ({
|
||||
// uin: PeerUin,
|
||||
// groupuin: groupUin,
|
||||
// ext: 0
|
||||
// });
|
||||
// //console.log(Body)
|
||||
// return OidbSvcTrpcTcpBase.toBinary
|
||||
// ({
|
||||
// command: 0xed3,
|
||||
// subcommand: 1,
|
||||
// body: Body
|
||||
// });
|
||||
// }
|
Loading…
x
Reference in New Issue
Block a user