style: lint
This commit is contained in:
1 parent
345e941e11
commit
dacfefe644
29 files changed
+276
-276
No files matched your search
@@ -1,8 +1,8 @@
|
||||
import * as crypto from "crypto";
|
||||
import {PushMsgBody} from "@/core/packet/proto/message/message";
|
||||
import {NapProtoEncodeStructType} from "@/core/packet/proto/NapProto";
|
||||
import {LogWrapper} from "@/common/log";
|
||||
import {PacketMsg} from "@/core/packet/msg/message";
|
||||
import { PushMsgBody } from "@/core/packet/proto/message/message";
|
||||
import { NapProtoEncodeStructType } from "@/core/packet/proto/NapProto";
|
||||
import { LogWrapper } from "@/common/log";
|
||||
import { PacketMsg } from "@/core/packet/msg/message";
|
||||
|
||||
export class PacketMsgBuilder {
|
||||
private logger: LogWrapper;
|
||||
|
||||
@@ -28,8 +28,8 @@ import {
|
||||
PacketMsgVideoElement,
|
||||
PacketMultiMsgElement
|
||||
} from "@/core/packet/msg/element";
|
||||
import {PacketMsg, PacketSendMsgElement} from "@/core/packet/msg/message";
|
||||
import {LogWrapper} from "@/common/log";
|
||||
import { PacketMsg, PacketSendMsgElement } from "@/core/packet/msg/message";
|
||||
import { LogWrapper } from "@/common/log";
|
||||
|
||||
type SendMessageElementMap = {
|
||||
textElement: SendTextElement,
|
||||
@@ -82,50 +82,50 @@ export class PacketMsgConverter {
|
||||
);
|
||||
if (key) {
|
||||
const elementData = (element as any)[key]; // TODO:
|
||||
if (elementData) return this.rawToPacketMsgConverters[key](element as any)
|
||||
if (elementData) return this.rawToPacketMsgConverters[key](element as any);
|
||||
}
|
||||
return null;
|
||||
}).filter((e) => e !== null)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private rawToPacketMsgConverters: RawToPacketMsgConverters = {
|
||||
textElement: (element: SendTextElement) => {
|
||||
if (element.textElement.atType) {
|
||||
return new PacketMsgAtElement(element)
|
||||
return new PacketMsgAtElement(element);
|
||||
}
|
||||
return new PacketMsgTextElement(element)
|
||||
return new PacketMsgTextElement(element);
|
||||
},
|
||||
picElement: (element: SendPicElement) => {
|
||||
return new PacketMsgPicElement(element)
|
||||
return new PacketMsgPicElement(element);
|
||||
},
|
||||
replyElement: (element: SendReplyElement) => {
|
||||
return new PacketMsgReplyElement(element)
|
||||
return new PacketMsgReplyElement(element);
|
||||
},
|
||||
faceElement: (element: SendFaceElement) => {
|
||||
return new PacketMsgFaceElement(element)
|
||||
return new PacketMsgFaceElement(element);
|
||||
},
|
||||
marketFaceElement: (element: SendMarketFaceElement) => {
|
||||
return new PacketMsgMarkFaceElement(element)
|
||||
return new PacketMsgMarkFaceElement(element);
|
||||
},
|
||||
videoElement: (element: SendVideoElement) => {
|
||||
return new PacketMsgVideoElement(element)
|
||||
return new PacketMsgVideoElement(element);
|
||||
},
|
||||
fileElement: (element: SendFileElement) => {
|
||||
return new PacketMsgFileElement(element)
|
||||
return new PacketMsgFileElement(element);
|
||||
},
|
||||
pttElement: (element: SendPttElement) => {
|
||||
return new PacketMsgPttElement(element)
|
||||
return new PacketMsgPttElement(element);
|
||||
},
|
||||
arkElement: (element: SendArkElement) => {
|
||||
return new PacketMsgLightAppElement(element)
|
||||
return new PacketMsgLightAppElement(element);
|
||||
},
|
||||
markdownElement: (element: SendMarkdownElement) => {
|
||||
return new PacketMsgMarkDownElement(element)
|
||||
return new PacketMsgMarkDownElement(element);
|
||||
},
|
||||
// TODO: check this logic, move it in arkElement?
|
||||
structLongMsgElement: (element: SendStructLongMsgElement) => {
|
||||
return new PacketMultiMsgElement(element)
|
||||
return new PacketMultiMsgElement(element);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import assert from "node:assert";
|
||||
import * as zlib from "node:zlib";
|
||||
import {NapProtoEncodeStructType, NapProtoMsg} from "@/core/packet/proto/NapProto";
|
||||
import { NapProtoEncodeStructType, NapProtoMsg } from "@/core/packet/proto/NapProto";
|
||||
import {
|
||||
CustomFace,
|
||||
Elem,
|
||||
@@ -25,9 +25,9 @@ import {
|
||||
SendTextElement,
|
||||
SendVideoElement
|
||||
} from "@/core";
|
||||
import {MsgInfo} from "@/core/packet/proto/oidb/common/Ntv2.RichMediaReq";
|
||||
import {PacketMsg, PacketSendMsgElement} from "@/core/packet/msg/message";
|
||||
import {ForwardMsgBuilder} from "@/common/forward-msg-builder";
|
||||
import { MsgInfo } from "@/core/packet/proto/oidb/common/Ntv2.RichMediaReq";
|
||||
import { PacketMsg, PacketSendMsgElement } from "@/core/packet/msg/message";
|
||||
import { ForwardMsgBuilder } from "@/common/forward-msg-builder";
|
||||
|
||||
// raw <-> packet
|
||||
// TODO: SendStructLongMsgElement
|
||||
@@ -84,11 +84,11 @@ export class PacketMsgAtElement extends PacketMsgTextElement {
|
||||
text: {
|
||||
str: this.text,
|
||||
pbReserve: 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,
|
||||
}
|
||||
)
|
||||
}
|
||||
}];
|
||||
@@ -101,7 +101,7 @@ export class PacketMsgAtElement extends PacketMsgTextElement {
|
||||
|
||||
export class PacketMsgPicElement extends IPacketMsgElement<SendPicElement> {
|
||||
path: string;
|
||||
name: string
|
||||
name: string;
|
||||
size: number;
|
||||
md5: string;
|
||||
width: number;
|
||||
@@ -131,7 +131,7 @@ export class PacketMsgPicElement extends IPacketMsgElement<SendPicElement> {
|
||||
pbElem: new NapProtoMsg(MsgInfo).encode(this.msgInfo),
|
||||
businessType: 10,
|
||||
}
|
||||
}]
|
||||
}];
|
||||
}
|
||||
|
||||
toPreview(): string {
|
||||
@@ -185,7 +185,7 @@ export class PacketMsgReplyElement extends IPacketMsgElement<SendReplyElement> {
|
||||
uid: String(this.targetUid),
|
||||
}),
|
||||
} : undefined,
|
||||
}]
|
||||
}];
|
||||
}
|
||||
|
||||
toPreview(): string {
|
||||
@@ -219,7 +219,7 @@ export class PacketMsgFaceElement extends IPacketMsgElement<SendFaceElement> {
|
||||
}),
|
||||
businessType: 1
|
||||
}
|
||||
}]
|
||||
}];
|
||||
} else if (this.faceId < 260) {
|
||||
return [{
|
||||
face: {
|
||||
@@ -237,7 +237,7 @@ export class PacketMsgFaceElement extends IPacketMsgElement<SendFaceElement> {
|
||||
}),
|
||||
businessType: 1
|
||||
}
|
||||
}]
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ export class PacketMsgMarkFaceElement extends IPacketMsgElement<SendMarketFaceEl
|
||||
field8: 1
|
||||
}
|
||||
}
|
||||
}]
|
||||
}];
|
||||
}
|
||||
|
||||
toPreview(): string {
|
||||
@@ -318,7 +318,7 @@ export class PacketMsgLightAppElement extends IPacketMsgElement<SendArkElement>
|
||||
zlib.deflateSync(Buffer.from(this.payload, 'utf-8'))
|
||||
])
|
||||
}
|
||||
}]
|
||||
}];
|
||||
}
|
||||
|
||||
toPreview(): string {
|
||||
@@ -343,7 +343,7 @@ export class PacketMsgMarkDownElement extends IPacketMsgElement<SendMarkdownElem
|
||||
}),
|
||||
businessType: 1
|
||||
}
|
||||
}]
|
||||
}];
|
||||
}
|
||||
|
||||
toPreview(): string {
|
||||
@@ -369,7 +369,7 @@ export class PacketMultiMsgElement extends IPacketMsgElement<SendStructLongMsgEl
|
||||
zlib.deflateSync(Buffer.from(JSON.stringify(ForwardMsgBuilder.fromPacketMsg(this.resid, this.message)), 'utf-8'))
|
||||
])
|
||||
}
|
||||
}]
|
||||
}];
|
||||
}
|
||||
|
||||
toPreview(): string {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {IPacketMsgElement} from "@/core/packet/msg/element";
|
||||
import {SendMessageElement, SendStructLongMsgElement} from "@/core";
|
||||
import { IPacketMsgElement } from "@/core/packet/msg/element";
|
||||
import { SendMessageElement, SendStructLongMsgElement } from "@/core";
|
||||
|
||||
export type PacketSendMsgElement = SendMessageElement | SendStructLongMsgElement
|
||||
|
||||
|
||||
Reference in new issue
Block a user