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"`
_ [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 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 {
var res []IMessageElement
var newImg = false
for _, elem := range elems {
if elem.SrcMsg != nil && len(elem.SrcMsg.OrigSeqs) != 0 {
r := &ReplyElement{
@ -537,6 +538,7 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
bizType = ImageBizType(attr.ImageBizType.Unwrap())
}
}
if !newImg {
res = append(res, &GroupImageElement{
FileId: int64(elem.CustomFace.FileId.Unwrap()),
ImageId: elem.CustomFace.FilePath.Unwrap(),
@ -548,6 +550,7 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
Md5: elem.CustomFace.Md5,
})
}
}
if elem.MarketFace != nil {
face := &MarketFaceElement{
Name: utils.B2S(elem.MarketFace.FaceName),
@ -582,6 +585,7 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
}
return []IMessageElement{face}
}
if elem.NotOnlineImage != nil {
img := elem.NotOnlineImage
@ -603,6 +607,7 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
url += downloadPath + "/0?term=3"
}
if !newImg {
res = append(res, &FriendImageElement{
ImageId: img.FilePath.Unwrap(),
Size: img.FileLen.Unwrap(),
@ -610,6 +615,9 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
Md5: img.PicMd5,
})
}
}
if elem.QQWalletMsg != nil && elem.QQWalletMsg.AioBody != nil {
// /com/tencent/mobileqq/data/MessageForQQWalletMsg.java#L366
msgType := elem.QQWalletMsg.AioBody.MsgType.Unwrap()
@ -663,7 +671,36 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
Name: strings.TrimPrefix(string(animatedStickerMsg.Text), "/"),
}
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