1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-07-08 23:28:31 +00:00

1 Commits

Author SHA1 Message Date
f4a63a83cd fix: panic occurred when receive voice record in group message 2024-09-03 15:11:22 +08:00

View File

@ -672,32 +672,36 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
} }
return []IMessageElement{sticker} // sticker 永远为单独消息 return []IMessageElement{sticker} // sticker 永远为单独消息
case 48: case 48:
img := &msg.PbMultiMediaElement{} bt := elem.CommonElem.BusinessType.Unwrap()
_ = proto.Unmarshal(elem.CommonElem.PbElem, img) // 20 for group, 10 for friend, 22 or 12 for voice record
domain := img.Elem1.Data.Domain.Unwrap() if bt == 20 || bt == 10 {
imgURL := img.Elem1.Data.ImgURL.Unwrap() 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 { if img.Elem2.Data.Friend != nil {
rKey := img.Elem2.Data.Friend.RKey.Unwrap() rKey := img.Elem2.Data.Friend.RKey.Unwrap()
url := fmt.Sprintf("https://%s%s%s&spec=0&rf=naio", domain, imgURL, rKey) url := fmt.Sprintf("https://%s%s%s&spec=0&rf=naio", domain, imgURL, rKey)
res = append(res, &FriendImageElement{ res = append(res, &FriendImageElement{
ImageId: img.Elem1.Meta.FilePath.Unwrap(), ImageId: img.Elem1.Meta.FilePath.Unwrap(),
Size: img.Elem1.Meta.Data.FileLen.Unwrap(), Size: img.Elem1.Meta.Data.FileLen.Unwrap(),
Url: url, Url: url,
Md5: img.Elem1.Meta.Data.PicMd5, Md5: img.Elem1.Meta.Data.PicMd5,
}) })
newImg = true newImg = true
} }
if img.Elem2.Data.Group != nil { if img.Elem2.Data.Group != nil {
rKey := img.Elem2.Data.Group.RKey.Unwrap() rKey := img.Elem2.Data.Group.RKey.Unwrap()
url := fmt.Sprintf("https://%s%s%s&spec=0&rf=naio", domain, imgURL, rKey) url := fmt.Sprintf("https://%s%s%s&spec=0&rf=naio", domain, imgURL, rKey)
res = append(res, &GroupImageElement{ res = append(res, &GroupImageElement{
ImageId: img.Elem1.Meta.FilePath.Unwrap(), ImageId: img.Elem1.Meta.FilePath.Unwrap(),
Size: img.Elem1.Meta.Data.FileLen.Unwrap(), Size: img.Elem1.Meta.Data.FileLen.Unwrap(),
Url: url, Url: url,
Md5: img.Elem1.Meta.Data.PicMd5, Md5: img.Elem1.Meta.Data.PicMd5,
}) })
newImg = true newImg = true
}
} }
} }