Skip to content

Commit

Permalink
fix: failed get nt qq img (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
MisakaTAT authored Oct 10, 2023
1 parent a8213e1 commit ee8edcf
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 16 deletions.
28 changes: 28 additions & 0 deletions client/pb/msg/msg.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions client/pb/msg/msg.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


69 changes: 53 additions & 16 deletions message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -537,16 +538,18 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
bizType = ImageBizType(attr.ImageBizType.Unwrap())
}
}
res = append(res, &GroupImageElement{
FileId: int64(elem.CustomFace.FileId.Unwrap()),
ImageId: elem.CustomFace.FilePath.Unwrap(),
Size: elem.CustomFace.Size.Unwrap(),
Width: elem.CustomFace.Width.Unwrap(),
Height: elem.CustomFace.Height.Unwrap(),
Url: url,
ImageBizType: bizType,
Md5: elem.CustomFace.Md5,
})
if !newImg {
res = append(res, &GroupImageElement{
FileId: int64(elem.CustomFace.FileId.Unwrap()),
ImageId: elem.CustomFace.FilePath.Unwrap(),
Size: elem.CustomFace.Size.Unwrap(),
Width: elem.CustomFace.Width.Unwrap(),
Height: elem.CustomFace.Height.Unwrap(),
Url: url,
ImageBizType: bizType,
Md5: elem.CustomFace.Md5,
})
}
}
if elem.MarketFace != nil {
face := &MarketFaceElement{
Expand Down Expand Up @@ -582,6 +585,7 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
}
return []IMessageElement{face}
}

if elem.NotOnlineImage != nil {
img := elem.NotOnlineImage

Expand All @@ -603,13 +607,17 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
url += downloadPath + "/0?term=3"
}

res = append(res, &FriendImageElement{
ImageId: img.FilePath.Unwrap(),
Size: img.FileLen.Unwrap(),
Url: url,
Md5: img.PicMd5,
})
if !newImg {
res = append(res, &FriendImageElement{
ImageId: img.FilePath.Unwrap(),
Size: img.FileLen.Unwrap(),
Url: url,
Md5: img.PicMd5,
})
}

}

if elem.QQWalletMsg != nil && elem.QQWalletMsg.AioBody != nil {
// /com/tencent/mobileqq/data/MessageForQQWalletMsg.java#L366
msgType := elem.QQWalletMsg.AioBody.MsgType.Unwrap()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ee8edcf

Please sign in to comment.