1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

fix: failed get nt qq img (#343)

This commit is contained in:
MisakaTAT 2023-10-10 09:25:41 +08:00 committed by GitHub
parent a8213e127b
commit ee8edcfe32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 119 additions and 16 deletions

View File

@ -892,3 +892,31 @@ type NotOnlineImage_PbReserve struct {
Url proto.Option[string] `protobuf:"bytes,30,opt"` Url proto.Option[string] `protobuf:"bytes,30,opt"`
_ [0]func() _ [0]func()
} }
type PbMultiMediaElement struct {
Elem1 *struct {
Meta *struct {
Data *struct {
FileLen proto.Option[int32] `protobuf:"varint,1,opt"`
PicMd5 []byte `protobuf:"bytes,2,opt"`
} `protobuf:"bytes,1,opt"`
FilePath proto.Option[string] `protobuf:"bytes,2,opt"`
} `protobuf:"bytes,1,opt"`
Data *struct {
ImgURL proto.Option[string] `protobuf:"bytes,1,opt"`
Domain proto.Option[string] `protobuf:"bytes,3,opt"`
} `protobuf:"bytes,2,opt"`
} `protobuf:"bytes,1,opt"`
Elem2 *struct {
Data *struct {
Friend *struct {
RKey proto.Option[string] `protobuf:"bytes,30,opt"`
} `protobuf:"bytes,11,opt"`
Group *struct {
RKey proto.Option[string] `protobuf:"bytes,30,opt"`
} `protobuf:"bytes,12,opt"`
} `protobuf:"bytes,1,opt"`
} `protobuf:"bytes,2,opt"`
}

View File

@ -877,3 +877,41 @@ message MsgElemInfo_servtype37 {
optional bytes surpriseid = 8; optional bytes surpriseid = 8;
optional uint32 randomtype = 9; optional uint32 randomtype = 9;
} }
message PbMultiMediaElement {
message Elem1 {
message Meta {
message Data {
optional int32 FileLen = 1;
optional bytes PicMd5 = 2;
}
optional Data data = 1;
optional string FilePath = 2;
}
optional Meta meta = 1;
message Data {
optional string ImgURL = 2;
optional string Domain = 3;
}
optional Data data = 2;
}
optional Elem1 elem1 = 1;
message Elem2 {
message Data {
message Friend {
optional string RKey = 30;
}
optional Friend friend = 11;
message Group {
optional string RKey = 30;
}
optional Group group = 12;
}
optional Data data = 1;
}
optional Elem2 elem2 = 2;
}

View File

@ -387,6 +387,7 @@ func ToSrcProtoElems(elems []IMessageElement) []*msg.Elem {
func ParseMessageElems(elems []*msg.Elem) []IMessageElement { func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
var res []IMessageElement var res []IMessageElement
var newImg = false
for _, elem := range elems { for _, elem := range elems {
if elem.SrcMsg != nil && len(elem.SrcMsg.OrigSeqs) != 0 { if elem.SrcMsg != nil && len(elem.SrcMsg.OrigSeqs) != 0 {
r := &ReplyElement{ r := &ReplyElement{
@ -537,16 +538,18 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
bizType = ImageBizType(attr.ImageBizType.Unwrap()) bizType = ImageBizType(attr.ImageBizType.Unwrap())
} }
} }
res = append(res, &GroupImageElement{ if !newImg {
FileId: int64(elem.CustomFace.FileId.Unwrap()), res = append(res, &GroupImageElement{
ImageId: elem.CustomFace.FilePath.Unwrap(), FileId: int64(elem.CustomFace.FileId.Unwrap()),
Size: elem.CustomFace.Size.Unwrap(), ImageId: elem.CustomFace.FilePath.Unwrap(),
Width: elem.CustomFace.Width.Unwrap(), Size: elem.CustomFace.Size.Unwrap(),
Height: elem.CustomFace.Height.Unwrap(), Width: elem.CustomFace.Width.Unwrap(),
Url: url, Height: elem.CustomFace.Height.Unwrap(),
ImageBizType: bizType, Url: url,
Md5: elem.CustomFace.Md5, ImageBizType: bizType,
}) Md5: elem.CustomFace.Md5,
})
}
} }
if elem.MarketFace != nil { if elem.MarketFace != nil {
face := &MarketFaceElement{ face := &MarketFaceElement{
@ -582,6 +585,7 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
} }
return []IMessageElement{face} return []IMessageElement{face}
} }
if elem.NotOnlineImage != nil { if elem.NotOnlineImage != nil {
img := elem.NotOnlineImage img := elem.NotOnlineImage
@ -603,13 +607,17 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
url += downloadPath + "/0?term=3" url += downloadPath + "/0?term=3"
} }
res = append(res, &FriendImageElement{ if !newImg {
ImageId: img.FilePath.Unwrap(), res = append(res, &FriendImageElement{
Size: img.FileLen.Unwrap(), ImageId: img.FilePath.Unwrap(),
Url: url, Size: img.FileLen.Unwrap(),
Md5: img.PicMd5, Url: url,
}) Md5: img.PicMd5,
})
}
} }
if elem.QQWalletMsg != nil && elem.QQWalletMsg.AioBody != nil { if elem.QQWalletMsg != nil && elem.QQWalletMsg.AioBody != nil {
// /com/tencent/mobileqq/data/MessageForQQWalletMsg.java#L366 // /com/tencent/mobileqq/data/MessageForQQWalletMsg.java#L366
msgType := elem.QQWalletMsg.AioBody.MsgType.Unwrap() msgType := elem.QQWalletMsg.AioBody.MsgType.Unwrap()
@ -663,7 +671,36 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
Name: strings.TrimPrefix(string(animatedStickerMsg.Text), "/"), Name: strings.TrimPrefix(string(animatedStickerMsg.Text), "/"),
} }
return []IMessageElement{sticker} // sticker 永远为单独消息 return []IMessageElement{sticker} // sticker 永远为单独消息
case 48:
img := &msg.PbMultiMediaElement{}
_ = proto.Unmarshal(elem.CommonElem.PbElem, img)
domain := img.Elem1.Data.Domain.Unwrap()
imgURL := img.Elem1.Data.ImgURL.Unwrap()
if img.Elem2.Data.Friend != nil {
rKey := img.Elem2.Data.Friend.RKey.Unwrap()
url := fmt.Sprintf("https://%s%s%s&spec=0&rf=naio", domain, imgURL, rKey)
res = append(res, &FriendImageElement{
ImageId: img.Elem1.Meta.FilePath.Unwrap(),
Size: img.Elem1.Meta.Data.FileLen.Unwrap(),
Url: url,
Md5: img.Elem1.Meta.Data.PicMd5,
})
newImg = true
}
if img.Elem2.Data.Group != nil {
rKey := img.Elem2.Data.Group.RKey.Unwrap()
url := fmt.Sprintf("https://%s%s%s&spec=0&rf=naio", domain, imgURL, rKey)
res = append(res, &GroupImageElement{
ImageId: img.Elem1.Meta.FilePath.Unwrap(),
Size: img.Elem1.Meta.Data.FileLen.Unwrap(),
Url: url,
Md5: img.Elem1.Meta.Data.PicMd5,
})
newImg = true
}
} }
} }
} }
return res return res