feat: broken highway
This commit is contained in:
17 files changed
+1352
-144
No files matched your search
@@ -1,12 +1,21 @@
|
||||
import { PushMsgBody } from "@/core/packet/proto/message/message";
|
||||
import { NapProtoEncodeStructType } from "@/core/packet/proto/NapProto";
|
||||
import * as crypto from "crypto";
|
||||
import { PacketForwardNode } from "@/core/packet/msg/entity/forward";
|
||||
import {PushMsgBody} from "@/core/packet/proto/message/message";
|
||||
import {NapProtoEncodeStructType} from "@/core/packet/proto/NapProto";
|
||||
import {PacketForwardNode} from "@/core/packet/msg/entity/forward";
|
||||
import {LogWrapper} from "@/common/log";
|
||||
|
||||
export class PacketMsgBuilder {
|
||||
private logger: LogWrapper;
|
||||
|
||||
constructor(logger: LogWrapper) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
buildFakeMsg(selfUid: string, element: PacketForwardNode[]): NapProtoEncodeStructType<typeof PushMsgBody>[] {
|
||||
return element.map((node): NapProtoEncodeStructType<typeof PushMsgBody> => {
|
||||
const avatar = `https://q.qlogo.cn/headimg_dl?dst_uin=${node.senderId}&spec=640&img_type=jpg`;
|
||||
const msgElement = node.msg.map((msg) => msg.buildElement() ?? []);
|
||||
// this.logger.logDebug(`NOW MSG ELEMENT: ${JSON.stringify(msgElement)}`);
|
||||
return {
|
||||
responseHead: {
|
||||
fromUid: "",
|
||||
@@ -41,9 +50,7 @@ export class PacketMsgBuilder {
|
||||
},
|
||||
body: {
|
||||
richText: {
|
||||
elems: node.msg.map(
|
||||
(msg) => msg.buildElement() ?? []
|
||||
)
|
||||
elems: msgElement
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { NapProtoEncodeStructType, NapProtoMsg } from "@/core/packet/proto/NapProto";
|
||||
import { Elem, MentionExtra } from "@/core/packet/proto/message/element";
|
||||
import assert from "node:assert";
|
||||
import {NapProtoEncodeStructType, NapProtoMsg} from "@/core/packet/proto/NapProto";
|
||||
import {CustomFace, Elem, MentionExtra, NotOnlineImage} from "@/core/packet/proto/message/element";
|
||||
import {
|
||||
AtType,
|
||||
PicType,
|
||||
SendArkElement,
|
||||
SendFaceElement,
|
||||
SendFileElement,
|
||||
@@ -12,6 +14,7 @@ import {
|
||||
SendTextElement,
|
||||
SendVideoElement
|
||||
} from "@/core";
|
||||
import {MsgInfo} from "@/core/packet/proto/oidb/common/Ntv2.RichMediaReq";
|
||||
|
||||
// raw <-> packet
|
||||
// TODO: check ob11 -> raw impl!
|
||||
@@ -34,7 +37,6 @@ export class PacketMsgTextElement extends IPacketMsgElement<SendTextElement> {
|
||||
|
||||
constructor(element: SendTextElement) {
|
||||
super(element);
|
||||
console.log(JSON.stringify(element));
|
||||
this.text = element.textElement.content;
|
||||
}
|
||||
|
||||
@@ -59,11 +61,11 @@ export class PacketMsgAtElement extends PacketMsgTextElement {
|
||||
|
||||
buildElement(): NapProtoEncodeStructType<typeof Elem> {
|
||||
const res = new NapProtoMsg(MentionExtra).encode({
|
||||
type: this.atAll ? 1 : 2,
|
||||
uin: 0,
|
||||
field5: 0,
|
||||
uid: this.targetUid,
|
||||
}
|
||||
type: this.atAll ? 1 : 2,
|
||||
uin: 0,
|
||||
field5: 0,
|
||||
uid: this.targetUid,
|
||||
}
|
||||
);
|
||||
return {
|
||||
text: {
|
||||
@@ -74,17 +76,48 @@ export class PacketMsgAtElement extends PacketMsgTextElement {
|
||||
}
|
||||
}
|
||||
|
||||
export class PacketMsgPicElement extends IPacketMsgElement<SendPicElement> {
|
||||
path: string;
|
||||
name: string
|
||||
size: number;
|
||||
md5: string;
|
||||
width: number;
|
||||
height: number;
|
||||
picType: PicType;
|
||||
sha1: string | null = null;
|
||||
msgInfo: NapProtoEncodeStructType<typeof MsgInfo> | null = null;
|
||||
groupPicExt: NapProtoEncodeStructType<typeof CustomFace> | null = null;
|
||||
c2cPicExt: NapProtoEncodeStructType<typeof NotOnlineImage> | null = null;
|
||||
|
||||
constructor(element: SendPicElement) {
|
||||
super(element);
|
||||
this.path = element.picElement.sourcePath;
|
||||
this.name = element.picElement.fileName;
|
||||
this.size = Number(element.picElement.fileSize);
|
||||
this.md5 = element.picElement.md5HexStr ?? '';
|
||||
this.width = element.picElement.picWidth;
|
||||
this.height = element.picElement.picHeight;
|
||||
this.picType = element.picElement.picType;
|
||||
}
|
||||
|
||||
buildElement(): NapProtoEncodeStructType<typeof Elem> {
|
||||
assert(this.msgInfo !== null, 'msgInfo is null, expected not null');
|
||||
return {
|
||||
commonElem: {
|
||||
serviceType: 48,
|
||||
pbElem: new NapProtoMsg(MsgInfo).encode(this.msgInfo),
|
||||
businessType: 10,
|
||||
}
|
||||
} as NapProtoEncodeStructType<typeof Elem>
|
||||
}
|
||||
}
|
||||
|
||||
export class PacketMsgPttElement extends IPacketMsgElement<SendPttElement> {
|
||||
constructor(element: SendPttElement) {
|
||||
super(element);
|
||||
}
|
||||
}
|
||||
|
||||
export class PacketMsgPicElement extends IPacketMsgElement<SendPicElement> {
|
||||
constructor(element: SendPicElement) {
|
||||
super(element);
|
||||
}
|
||||
}
|
||||
|
||||
export class PacketMsgReplyElement extends IPacketMsgElement<SendReplyElement> {
|
||||
constructor(element: SendReplyElement) {
|
||||
|
||||
Reference in new issue
Block a user