diff --git a/client/decoders.go b/client/decoders.go index 1d5ac3c9..4149e688 100644 --- a/client/decoders.go +++ b/client/decoders.go @@ -513,6 +513,9 @@ func decodeGroupImageStoreResponse(_ *QQClient, _ uint16, payload []byte) (inter }, nil } 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{ diff --git a/client/entities.go b/client/entities.go index e01ba3ba..7e137f32 100644 --- a/client/entities.go +++ b/client/entities.go @@ -194,6 +194,8 @@ type ( IsExists bool FileId int64 + Width int32 + Height int32 ResourceId string UploadKey []byte diff --git a/message/elements.go b/message/elements.go index f6f4f110..9d040e59 100644 --- a/message/elements.go +++ b/message/elements.go @@ -14,6 +14,8 @@ type TextElement struct { type ImageElement struct { Filename string Size int32 + Width int32 + Height int32 Url string Md5 []byte Data []byte @@ -22,6 +24,9 @@ type ImageElement struct { type GroupImageElement struct { ImageId string FileId int64 + Size int32 + Width int32 + Height int32 Md5 []byte 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{ ImageId: id, FileId: fid, 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", } } diff --git a/message/message.go b/message/message.go index 702c274c..e4f2ed1e 100644 --- a/message/message.go +++ b/message/message.go @@ -294,6 +294,7 @@ func ToProtoElems(elems []IMessageElement, generalFlags bool) (r []*msg.Elem) { CustomFace: &msg.CustomFace{ FilePath: e.Filename, Md5: e.Md5, + Size: e.Size, Flag: make([]byte, 4), OldData: imgOld, }, @@ -306,6 +307,7 @@ func ToProtoElems(elems []IMessageElement, generalFlags bool) (r []*msg.Elem) { Origin: 1, FileId: int32(e.FileId), FilePath: e.ImageId, + Size: e.Size, Md5: e.Md5[:], Flag: make([]byte, 4), //OldData: imgOld, @@ -522,6 +524,8 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement { res = append(res, &ImageElement{ Filename: elem.CustomFace.FilePath, Size: elem.CustomFace.Size, + Width: elem.CustomFace.Width, + Height: elem.CustomFace.Height, Url: func() string { 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"