mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: proto 整理
This commit is contained in:
parent
eef5293ca0
commit
dc168bf8b9
@ -12,10 +12,9 @@ import {
|
||||
import { isNumeric, sleep, solveAsyncProblem } from '@/common/helper';
|
||||
import { LimitedHashTable } from '@/common/message-unique';
|
||||
import { NTEventWrapper } from '@/common/event';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { RequestUtil } from '@/common/request';
|
||||
import { NapProtoMsg } from '../proto/NapProto';
|
||||
import { OidbSvcTrpcTcp0XED3_1, OidbSvcTrpcTcpBaseProto } from '../proto/OidbBase';
|
||||
import { OidbSvcTrpcTcpBase } from '../proto/oidb/OidbBase';
|
||||
import { OidbSvcTrpcTcp0XED3_1 } from '../proto/oidb/Oidb.ed3_1';
|
||||
interface recvPacket {
|
||||
type: string,//仅recv
|
||||
trace_id_md5?: string,
|
||||
@ -46,11 +45,7 @@ export class NTQQGroupApi {
|
||||
this.groupCache.set(group.groupCode, group);
|
||||
}
|
||||
this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`);
|
||||
//console.log('pid', process.pid);
|
||||
// this.session = await frida.attach(process.pid);
|
||||
// setTimeout(async () => {
|
||||
// this.sendPocketRkey();
|
||||
// }, 10000);
|
||||
// process.pid 调试点
|
||||
}
|
||||
async getCoreAndBaseInfo(uids: string[]) {
|
||||
return await this.core.eventWrapper.callNoListenerEvent(
|
||||
@ -70,7 +65,7 @@ export class NTQQGroupApi {
|
||||
groupUin: group,
|
||||
ext: 0
|
||||
});
|
||||
let oidb_packet = new NapProtoMsg(OidbSvcTrpcTcpBaseProto).encode({
|
||||
let oidb_packet = new NapProtoMsg(OidbSvcTrpcTcpBase).encode({
|
||||
command: 0xed3,
|
||||
subCommand: 1,
|
||||
body: oidb_0xed3
|
||||
|
@ -1,21 +0,0 @@
|
||||
import { MessageType, BinaryReader, ScalarType, BinaryWriter } from '@protobuf-ts/runtime';
|
||||
|
||||
export const FileId = new MessageType("FileId", [
|
||||
{ no: 2, name: "sha1", kind: "scalar", T: ScalarType.BYTES },
|
||||
{ no: 4, name: "appid", kind: "scalar", T: ScalarType.UINT32 },
|
||||
]);
|
||||
|
||||
export function encodePBFileId(message: any) {
|
||||
return FileId.internalBinaryWrite(message, new BinaryWriter(), {
|
||||
writerFactory: () => new BinaryWriter(),
|
||||
writeUnknownFields: false
|
||||
}).finish();
|
||||
}
|
||||
|
||||
export function decodePBFileId(buffer: Uint8Array): any {
|
||||
const reader = new BinaryReader(buffer);
|
||||
return FileId.internalBinaryRead(reader, reader.len, {
|
||||
readUnknownField: true,
|
||||
readerFactory: () => new BinaryReader(buffer)
|
||||
});
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
import { MessageType, ScalarType } from "@protobuf-ts/runtime";
|
||||
import { OidbSvcTrpcTcpBase } from "./Poke";
|
||||
|
||||
export const OidbSvcTrpcTcp0XFE1_2 = new MessageType("oidb_svc_trpctcp_0xfe1_2", [
|
||||
{ no: 1, name: "uin", kind: "scalar", T: ScalarType.UINT32 },
|
||||
{ no: 3, name: "key", kind: "scalar", T: ScalarType.BYTES, opt: true }
|
||||
]);
|
||||
export function encode_packet_0xfe1_2(PeerUin: string) {
|
||||
let Body = OidbSvcTrpcTcp0XFE1_2.toBinary
|
||||
({
|
||||
uin: parseInt(PeerUin),
|
||||
key: new Uint8Array([0x00, 0x00, 0x00, 0x00])
|
||||
});
|
||||
return OidbSvcTrpcTcpBase.toBinary
|
||||
({
|
||||
command: 0xfe1,
|
||||
subcommand: 2,
|
||||
body: Body,
|
||||
isreserved: 1
|
||||
});
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
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 +0,0 @@
|
||||
// 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 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
|
||||
// });
|
||||
// }
|
9
src/core/proto/oidb/Oidb.ed3_1.ts
Normal file
9
src/core/proto/oidb/Oidb.ed3_1.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { ScalarType } from "@protobuf-ts/runtime";
|
||||
import { ProtoField } from "../NapProto";
|
||||
|
||||
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)
|
||||
}
|
7
src/core/proto/oidb/Oidb.fe1_2.ts
Normal file
7
src/core/proto/oidb/Oidb.fe1_2.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { ScalarType } from "@protobuf-ts/runtime";
|
||||
import { ProtoField } from "../NapProto";
|
||||
|
||||
export const OidbSvcTrpcTcp0XEE1_2 = {
|
||||
uin: ProtoField(1, ScalarType.UINT32),
|
||||
key: ProtoField(3, ScalarType.BYTES, false, true),
|
||||
}
|
9
src/core/proto/oidb/OidbBase.ts
Normal file
9
src/core/proto/oidb/OidbBase.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { ProtoField } from "../NapProto";
|
||||
import { ScalarType } from '@protobuf-ts/runtime';
|
||||
|
||||
export const OidbSvcTrpcTcpBase = {
|
||||
command: ProtoField(1, ScalarType.UINT32),
|
||||
subCommand: ProtoField(2, ScalarType.UINT32),
|
||||
body: ProtoField(4, ScalarType.BYTES),
|
||||
isReserved: ProtoField(12, ScalarType.UINT32, false, true)
|
||||
}
|
@ -34,7 +34,7 @@ import { RequestUtil } from '@/common/request';
|
||||
import fs from 'node:fs';
|
||||
import fsPromise from 'node:fs/promises';
|
||||
import { OB11FriendAddNoticeEvent } from '@/onebot/event/notice/OB11FriendAddNoticeEvent';
|
||||
import { decodeSysMessage } from '@/core/proto/ProfileLike';
|
||||
import { decodeSysMessage } from '@/core/proto/old/ProfileLike';
|
||||
|
||||
type RawToOb11Converters = {
|
||||
[Key in keyof MessageElement as Key extends `${string}Element` ? Key : never]: (
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { NapCatCore } from '@/core';
|
||||
import { decodeProfileLikeTip } from '@/core/proto/ProfileLike';
|
||||
import { decodeProfileLikeTip } from '@/core/proto/old/ProfileLike';
|
||||
|
||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
||||
import { OB11ProfileLikeEvent } from '../event/notice/OB11ProfileLikeEvent';
|
||||
|
@ -45,7 +45,7 @@ import { OB11GroupRecallNoticeEvent } from '@/onebot/event/notice/OB11GroupRecal
|
||||
import { LRUCache } from '@/common/lru-cache';
|
||||
import { NodeIKernelRecentContactListener } from '@/core/listeners/NodeIKernelRecentContactListener';
|
||||
import { Native } from '@/native';
|
||||
import { decodeMessage, decodeRecallGroup, Message, RecallGroup } from '@/core/proto/Message';
|
||||
import { decodeMessage, decodeRecallGroup, Message, RecallGroup } from '@/core/proto/old/Message';
|
||||
|
||||
//OneBot实现类
|
||||
export class NapCatOneBot11Adapter {
|
||||
|
Loading…
x
Reference in New Issue
Block a user