1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

update image.

This commit is contained in:
Mrs4s 2020-09-21 20:27:30 +08:00
parent d4f8583488
commit 1fe17da712
4 changed files with 18 additions and 1 deletions

View File

@ -513,6 +513,9 @@ func decodeGroupImageStoreResponse(_ *QQClient, _ uint16, payload []byte) (inter
}, nil }, nil
} }
if rsp.BoolFileExit { if rsp.BoolFileExit {
if rsp.MsgImgInfo != nil {
return imageUploadResponse{IsExists: true, FileId: rsp.FileId, Width: rsp.MsgImgInfo.FileWidth, Height: rsp.MsgImgInfo.FileHeight}, nil
}
return imageUploadResponse{IsExists: true, FileId: rsp.Fid}, nil return imageUploadResponse{IsExists: true, FileId: rsp.Fid}, nil
} }
return imageUploadResponse{ return imageUploadResponse{

View File

@ -194,6 +194,8 @@ type (
IsExists bool IsExists bool
FileId int64 FileId int64
Width int32
Height int32
ResourceId string ResourceId string
UploadKey []byte UploadKey []byte

View File

@ -14,6 +14,8 @@ type TextElement struct {
type ImageElement struct { type ImageElement struct {
Filename string Filename string
Size int32 Size int32
Width int32
Height int32
Url string Url string
Md5 []byte Md5 []byte
Data []byte Data []byte
@ -22,6 +24,9 @@ type ImageElement struct {
type GroupImageElement struct { type GroupImageElement struct {
ImageId string ImageId string
FileId int64 FileId int64
Size int32
Width int32
Height int32
Md5 []byte Md5 []byte
Url string Url string
} }
@ -119,11 +124,14 @@ func NewImage(data []byte) *ImageElement {
} }
} }
func NewGroupImage(id string, md5 []byte, fid int64) *GroupImageElement { func NewGroupImage(id string, md5 []byte, fid int64, size, width, height int32) *GroupImageElement {
return &GroupImageElement{ return &GroupImageElement{
ImageId: id, ImageId: id,
FileId: fid, FileId: fid,
Md5: md5, Md5: md5,
Size: size,
Width: width,
Height: height,
Url: "http://gchat.qpic.cn/gchatpic_new/1/0-0-" + strings.ReplaceAll(id[1:36], "-", "") + "/0?term=2", Url: "http://gchat.qpic.cn/gchatpic_new/1/0-0-" + strings.ReplaceAll(id[1:36], "-", "") + "/0?term=2",
} }
} }

View File

@ -294,6 +294,7 @@ func ToProtoElems(elems []IMessageElement, generalFlags bool) (r []*msg.Elem) {
CustomFace: &msg.CustomFace{ CustomFace: &msg.CustomFace{
FilePath: e.Filename, FilePath: e.Filename,
Md5: e.Md5, Md5: e.Md5,
Size: e.Size,
Flag: make([]byte, 4), Flag: make([]byte, 4),
OldData: imgOld, OldData: imgOld,
}, },
@ -306,6 +307,7 @@ func ToProtoElems(elems []IMessageElement, generalFlags bool) (r []*msg.Elem) {
Origin: 1, Origin: 1,
FileId: int32(e.FileId), FileId: int32(e.FileId),
FilePath: e.ImageId, FilePath: e.ImageId,
Size: e.Size,
Md5: e.Md5[:], Md5: e.Md5[:],
Flag: make([]byte, 4), Flag: make([]byte, 4),
//OldData: imgOld, //OldData: imgOld,
@ -522,6 +524,8 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
res = append(res, &ImageElement{ res = append(res, &ImageElement{
Filename: elem.CustomFace.FilePath, Filename: elem.CustomFace.FilePath,
Size: elem.CustomFace.Size, Size: elem.CustomFace.Size,
Width: elem.CustomFace.Width,
Height: elem.CustomFace.Height,
Url: func() string { Url: func() string {
if elem.CustomFace.OrigUrl == "" { if elem.CustomFace.OrigUrl == "" {
return "http://gchat.qpic.cn/gchatpic_new/0/0-0-" + strings.ReplaceAll(binary.CalculateImageResourceId(elem.CustomFace.Md5)[1:37], "-", "") + "/0?term=2" return "http://gchat.qpic.cn/gchatpic_new/0/0-0-" + strings.ReplaceAll(binary.CalculateImageResourceId(elem.CustomFace.Md5)[1:37], "-", "") + "/0?term=2"