mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-07-08 15:18:32 +00:00
Compare commits
2 Commits
f4a63a83cd
...
9ee41fc5f9
Author | SHA1 | Date | |
---|---|---|---|
9ee41fc5f9 | |||
cd753c1953 |
@ -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)
|
||||||
}(),
|
}(),
|
||||||
}
|
}
|
||||||
|
@ -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"`
|
||||||
|
@ -671,40 +671,45 @@ 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:
|
|
||||||
bt := elem.CommonElem.BusinessType.Unwrap()
|
|
||||||
// 20 for group, 10 for friend, 22 or 12 for voice record
|
|
||||||
if bt == 20 || bt == 10 {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
switch elem.CommonElem.BusinessType.Unwrap() {
|
||||||
|
case 10, 20:
|
||||||
|
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.FileMd5,
|
||||||
|
})
|
||||||
|
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.FileMd5,
|
||||||
|
})
|
||||||
|
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
|
||||||
|
Reference in New Issue
Block a user