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 { isNumeric, sleep, solveAsyncProblem } from '@/common/helper';
|
||||||
import { LimitedHashTable } from '@/common/message-unique';
|
import { LimitedHashTable } from '@/common/message-unique';
|
||||||
import { NTEventWrapper } from '@/common/event';
|
import { NTEventWrapper } from '@/common/event';
|
||||||
import { encodeGroupPoke } from '../proto/Poke';
|
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
import { RequestUtil } from '@/common/request';
|
import { RequestUtil } from '@/common/request';
|
||||||
interface recvPacket
|
import { NapProtoMsg } from '../proto/NapProto';
|
||||||
{
|
import { OidbSvcTrpcTcp0XED3_1, OidbSvcTrpcTcpBaseProto } from '../proto/OidbBase';
|
||||||
|
interface recvPacket {
|
||||||
type: string,//仅recv
|
type: string,//仅recv
|
||||||
trace_id_md5?: string,
|
trace_id_md5?: string,
|
||||||
data: {
|
data: {
|
||||||
@ -65,10 +65,18 @@ export class NTQQGroupApi {
|
|||||||
//console.log('ret: ', ret);
|
//console.log('ret: ', ret);
|
||||||
}
|
}
|
||||||
async sendPacketPoke(group: number, peer: number) {
|
async sendPacketPoke(group: number, peer: number) {
|
||||||
let data = encodeGroupPoke(group, peer);
|
let oidb_0xed3 = new NapProtoMsg(OidbSvcTrpcTcp0XED3_1).encode({
|
||||||
let hex = Buffer.from(data).toString('hex');
|
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);
|
let retdata = await this.core.apis.PacketApi.sendPacket('OidbSvcTrpcTcp.0xed3_1', hex, false);
|
||||||
//console.log('sendPacketPoke', retdata);
|
|
||||||
}
|
}
|
||||||
async fetchGroupEssenceList(groupCode: string) {
|
async fetchGroupEssenceList(groupCode: string) {
|
||||||
const pskey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!;
|
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;
|
[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>;
|
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>;
|
||||||
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<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(no: number, type: ScalarType | (() => ProtoMessageType), repeated?: boolean, optional?: boolean): ProtoFieldType {
|
||||||
if (typeof type === 'function') {
|
if (typeof type === 'function') {
|
||||||
return { kind: 'message', no: no, type: type, repeated: repeated ?? false, optional: optional ?? false };
|
return { kind: 'message', no: no, type: type, repeated: repeated ?? false, optional: optional ?? false };
|
||||||
} else {
|
} else {
|
||||||
@ -89,7 +89,7 @@ type ProtoStructType<T> = RequiredFieldsType<T> & OptionalFieldsType<T>;
|
|||||||
|
|
||||||
const NapProtoMsgCache = new Map<ProtoMessageType, MessageType<ProtoStructType<ProtoMessageType>>>();
|
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 _msg: T;
|
||||||
private readonly _field: PartialFieldInfo[];
|
private readonly _field: PartialFieldInfo[];
|
||||||
private readonly _proto_msg: MessageType<ProtoStructType<T>>;
|
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", [
|
// export const OidbSvcTrpcTcpBase = new MessageType("oidb_svc_trpctcp_base", [
|
||||||
{ no: 1, name: "command", kind: "scalar", T: ScalarType.UINT32 },
|
// { no: 1, name: "command", kind: "scalar", T: ScalarType.UINT32 },
|
||||||
{ no: 2, name: "subcommand", kind: "scalar", T: ScalarType.UINT32, opt: true },
|
// { no: 2, name: "subcommand", kind: "scalar", T: ScalarType.UINT32, opt: true },
|
||||||
{ no: 4, name: "body", kind: "scalar", T: ScalarType.BYTES, opt: true },
|
// { no: 4, name: "body", kind: "scalar", T: ScalarType.BYTES, opt: true },
|
||||||
{ no: 12, name: "isreserved", kind: "scalar", T: ScalarType.INT32, opt: true }
|
// { no: 12, name: "isreserved", kind: "scalar", T: ScalarType.INT32, opt: true }
|
||||||
]);
|
// ]);
|
||||||
|
|
||||||
export const OidbSvcTrpcTcp0XED3_1 = new MessageType("oidb_svc_trpctcp_0xed3_1", [
|
// export const OidbSvcTrpcTcp0XED3_1 = new MessageType("oidb_svc_trpctcp_0xed3_1", [
|
||||||
{ no: 1, name: "uin", kind: "scalar", T: ScalarType.UINT32 },
|
// { no: 1, name: "uin", kind: "scalar", T: ScalarType.UINT32 },
|
||||||
{ no: 2, name: "groupuin", kind: "scalar", T: ScalarType.UINT32, opt: true },
|
// { no: 2, name: "groupuin", kind: "scalar", T: ScalarType.UINT32, opt: true },
|
||||||
{ no: 5, name: "frienduin", 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 }
|
// { no: 6, name: "ext", kind: "scalar", T: ScalarType.UINT32 }
|
||||||
]);
|
// ]);
|
||||||
|
|
||||||
export function encodeGroupPoke(groupUin: number, PeerUin: number) {
|
// export function encodeGroupPoke(groupUin: number, PeerUin: number) {
|
||||||
let Body = OidbSvcTrpcTcp0XED3_1.toBinary
|
// let Body = OidbSvcTrpcTcp0XED3_1.toBinary
|
||||||
({
|
// ({
|
||||||
uin: PeerUin,
|
// uin: PeerUin,
|
||||||
groupuin: groupUin,
|
// groupuin: groupUin,
|
||||||
ext: 0
|
// ext: 0
|
||||||
});
|
// });
|
||||||
//console.log(Body)
|
// //console.log(Body)
|
||||||
return OidbSvcTrpcTcpBase.toBinary
|
// return OidbSvcTrpcTcpBase.toBinary
|
||||||
({
|
// ({
|
||||||
command: 0xed3,
|
// command: 0xed3,
|
||||||
subcommand: 1,
|
// subcommand: 1,
|
||||||
body: Body
|
// body: Body
|
||||||
});
|
// });
|
||||||
}
|
// }
|
Loading…
x
Reference in New Issue
Block a user