mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
add func QueryGroupImage()
This commit is contained in:
parent
23e8acafb1
commit
223e464c94
@ -395,7 +395,7 @@ func (c *QQClient) buildGroupSendingPacket(groupCode int64, r int32, m *message.
|
||||
}
|
||||
|
||||
// ImgStore.GroupPicUp
|
||||
func (c *QQClient) buildGroupImageStorePacket(groupCode int64, md5 [16]byte, size int32) (uint16, []byte) {
|
||||
func (c *QQClient) buildGroupImageStorePacket(groupCode int64, md5 []byte, size int32) (uint16, []byte) {
|
||||
seq := c.nextSeq()
|
||||
name := utils.RandomString(16) + ".gif"
|
||||
req := &pb.D388ReqBody{
|
||||
@ -405,7 +405,7 @@ func (c *QQClient) buildGroupImageStorePacket(groupCode int64, md5 [16]byte, siz
|
||||
{
|
||||
GroupCode: groupCode,
|
||||
SrcUin: c.Uin,
|
||||
FileMd5: md5[:],
|
||||
FileMd5: md5,
|
||||
FileSize: int64(size),
|
||||
FileName: name,
|
||||
SrcTerm: 5,
|
||||
|
@ -214,9 +214,9 @@ func (c *QQClient) SendGroupMessage(groupCode int64, m *message.SendingMessage)
|
||||
return mid
|
||||
}
|
||||
|
||||
func (c *QQClient) UploadGroupImage(groupUin int64, img []byte) (*message.GroupImageElement, error) {
|
||||
func (c *QQClient) UploadGroupImage(groupCode int64, img []byte) (*message.GroupImageElement, error) {
|
||||
h := md5.Sum(img)
|
||||
seq, pkt := c.buildGroupImageStorePacket(utils.ToGroupCode(groupUin), h, int32(len(img)))
|
||||
seq, pkt := c.buildGroupImageStorePacket(groupCode, h[:], int32(len(img)))
|
||||
r, err := c.sendAndWait(seq, pkt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -266,6 +266,21 @@ func (c *QQClient) UploadGroupImage(groupUin int64, img []byte) (*message.GroupI
|
||||
return nil, errors.New("upload failed")
|
||||
}
|
||||
|
||||
func (c *QQClient) QueryGroupImage(groupCode int64, hash []byte, size int32) (*message.GroupImageElement, error) {
|
||||
r, err := c.sendAndWait(c.buildGroupImageStorePacket(groupCode, hash, size))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rsp := r.(groupImageUploadResponse)
|
||||
if rsp.ResultCode != 0 {
|
||||
return nil, errors.New(rsp.Message)
|
||||
}
|
||||
if rsp.IsExists {
|
||||
return message.NewGroupImage(binary.CalculateImageResourceId(hash), hash), nil
|
||||
}
|
||||
return nil, errors.New("image not exists")
|
||||
}
|
||||
|
||||
func (c *QQClient) ReloadGroupList() error {
|
||||
c.groupListLock.Lock()
|
||||
defer c.groupListLock.Unlock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user