feat: maybe more stable fake forwardMsg

This commit is contained in:
pk5ls20
2024-10-25 08:09:17 +08:00
parent a27c2a69c4
commit da0fad743d
2 changed files with 30 additions and 9 deletions

View File

@@ -99,7 +99,7 @@ export class ForwardMsgBuilder {
senderName: msg.senderName,
isGroupMsg: msg.groupId !== undefined,
msg: msg.msg.map(m => ({
preview: m.toPreview(),
preview: m.valid? m.toPreview() : "[该消息类型暂不支持查看]",
}))
})));
}

View File

@@ -36,6 +36,10 @@ export abstract class IPacketMsgElement<T extends PacketSendMsgElement> {
protected constructor(rawElement: T) {
}
get valid(): boolean {
return true;
}
buildContent(): Uint8Array | undefined {
return undefined;
}
@@ -265,6 +269,10 @@ export class PacketMsgPicElement extends IPacketMsgElement<SendPicElement> {
this.picType = element.picElement.picType;
}
get valid(): boolean {
return !!this.msgInfo;
}
buildElement(): NapProtoEncodeStructType<typeof Elem>[] {
if (!this.msgInfo) return [];
return [{
@@ -306,6 +314,10 @@ export class PacketMsgVideoElement extends IPacketMsgElement<SendVideoElement> {
this.thumbHeight = element.videoElement.thumbHeight;
}
get valid(): boolean {
return !!this.msgInfo;
}
buildElement(): NapProtoEncodeStructType<typeof Elem>[] {
if (!this.msgInfo) return [];
return [{
@@ -338,15 +350,20 @@ export class PacketMsgPttElement extends IPacketMsgElement<SendPttElement> {
this.fileDuration = Math.round(element.pttElement.duration); // TODO: cc
}
buildElement(): NapProtoEncodeStructType<typeof Elem>[] {
if (!this.msgInfo) return [];
return [{
commonElem: {
serviceType: 48,
pbElem: new NapProtoMsg(MsgInfo).encode(this.msgInfo),
businessType: 22,
get valid(): boolean {
return !!this.msgInfo;
}
}];
buildElement(): NapProtoEncodeStructType<typeof Elem>[] {
return []
// if (!this.msgInfo) return [];
// return [{
// commonElem: {
// serviceType: 48,
// pbElem: new NapProtoMsg(MsgInfo).encode(this.msgInfo),
// businessType: 22,
// }
// }];
}
toPreview(): string {
@@ -374,6 +391,10 @@ export class PacketMsgFileElement extends IPacketMsgElement<SendFileElement> {
this.fileSize = +element.fileElement.fileSize;
}
get valid(): boolean {
return this.isGroupFile || Boolean(this._e37_800_rsp);
}
buildContent(): Uint8Array | undefined {
if (this.isGroupFile || !this._e37_800_rsp) return undefined;
return new NapProtoMsg(FileExtra).encode({