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

3 Commits

Author SHA1 Message Date
9ee41fc5f9 update 2024-09-04 21:05:51 +08:00
cd753c1953 update 2024-09-04 20:55:17 +08:00
f4a63a83cd fix: panic occurred when receive voice record in group message 2024-09-03 15:11:22 +08:00
3 changed files with 27 additions and 16 deletions

View File

@ -195,16 +195,16 @@ func (c *QQClient) parsePrivateMessage(msg *msg.Message) *message.PrivateMessage
Sender: sender, Sender: sender,
Self: c.Uin, Self: c.Uin,
Elements: func() []message.IMessageElement { Elements: func() []message.IMessageElement {
if msg.Body.RichText.Ptt != nil { // if msg.Body.RichText.Ptt != nil {
return []message.IMessageElement{ // return []message.IMessageElement{
&message.VoiceElement{ // &message.VoiceElement{
Name: msg.Body.RichText.Ptt.FileName.Unwrap(), // Name: msg.Body.RichText.Ptt.FileName.Unwrap(),
Md5: msg.Body.RichText.Ptt.FileMd5, // Md5: msg.Body.RichText.Ptt.FileMd5,
Size: msg.Body.RichText.Ptt.FileSize.Unwrap(), // Size: msg.Body.RichText.Ptt.FileSize.Unwrap(),
Url: string(msg.Body.RichText.Ptt.DownPara), // Url: string(msg.Body.RichText.Ptt.DownPara),
}, // },
} // }
} // }
return message.ParseMessageElems(msg.Body.RichText.Elems) return message.ParseMessageElems(msg.Body.RichText.Elems)
}(), }(),
} }

View File

@ -898,7 +898,9 @@ type PbMultiMediaElement struct {
Meta *struct { Meta *struct {
Data *struct { Data *struct {
FileLen proto.Option[int32] `protobuf:"varint,1,opt"` FileLen proto.Option[int32] `protobuf:"varint,1,opt"`
PicMd5 []byte `protobuf:"bytes,2,opt"` FileMd5 []byte `protobuf:"bytes,2,opt"`
FileSha1 proto.Option[string] `protobuf:"bytes,3,opt"`
FileName proto.Option[string] `protobuf:"bytes,4,opt"`
} `protobuf:"bytes,1,opt"` } `protobuf:"bytes,1,opt"`
FilePath proto.Option[string] `protobuf:"bytes,2,opt"` FilePath proto.Option[string] `protobuf:"bytes,2,opt"`
} `protobuf:"bytes,1,opt"` } `protobuf:"bytes,1,opt"`

View File

@ -671,12 +671,13 @@ 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: }
switch elem.CommonElem.BusinessType.Unwrap() {
case 10, 20:
img := &msg.PbMultiMediaElement{} img := &msg.PbMultiMediaElement{}
_ = proto.Unmarshal(elem.CommonElem.PbElem, img) _ = proto.Unmarshal(elem.CommonElem.PbElem, img)
domain := img.Elem1.Data.Domain.Unwrap() domain := img.Elem1.Data.Domain.Unwrap()
imgURL := img.Elem1.Data.ImgURL.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)
@ -684,7 +685,7 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
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.FileMd5,
}) })
newImg = true newImg = true
} }
@ -695,12 +696,20 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
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.FileMd5,
}) })
newImg = true newImg = true
} }
case 12, 22:
audio := &msg.PbMultiMediaElement{}
_ = proto.Unmarshal(elem.CommonElem.PbElem, audio)
res = append(res, &VoiceElement{
Name: audio.Elem1.Meta.Data.FileName.Unwrap(),
Md5: audio.Elem1.Meta.Data.FileMd5,
Size: audio.Elem1.Meta.Data.FileLen.Unwrap(),
Url: audio.Elem1.Meta.FilePath.Unwrap(), // url is wrong TODO:get url with rkey
})
} }
} }
} }
return res return res