mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
feat: query guild service image
This commit is contained in:
parent
12e40ef1ea
commit
af9ed48cb7
@ -55,6 +55,10 @@ func (msg DynamicProtoMessage) Encode() []byte {
|
|||||||
en.uvarint(key | 0)
|
en.uvarint(key | 0)
|
||||||
en.uvarint(v[i])
|
en.uvarint(v[i])
|
||||||
}
|
}
|
||||||
|
case []byte:
|
||||||
|
en.uvarint(key | 2)
|
||||||
|
en.uvarint(uint64(len(v)))
|
||||||
|
_, _ = en.Write(v)
|
||||||
case DynamicProtoMessage:
|
case DynamicProtoMessage:
|
||||||
en.uvarint(key | 2)
|
en.uvarint(key | 2)
|
||||||
b := v.Encode()
|
b := v.Encode()
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/hex"
|
||||||
|
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x388"
|
||||||
|
"github.com/Mrs4s/MiraiGo/internal/packets"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -37,6 +40,56 @@ func (c *QQClient) parseGuildChannelMessage(msg *channel.ChannelMsgContent) *mes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *GuildService) QueryImage(guildId, channelId uint64, hash []byte, size uint64) (*message.GuildImageElement, error) {
|
||||||
|
seq := s.c.nextSeq()
|
||||||
|
payload, _ := proto.Marshal(&cmd0x388.D388ReqBody{
|
||||||
|
NetType: proto.Uint32(3),
|
||||||
|
Subcmd: proto.Uint32(1),
|
||||||
|
TryupImgReq: []*cmd0x388.TryUpImgReq{
|
||||||
|
{
|
||||||
|
GroupCode: &channelId,
|
||||||
|
SrcUin: proto.Uint64(uint64(s.c.Uin)),
|
||||||
|
FileId: proto.Uint64(0),
|
||||||
|
FileMd5: hash,
|
||||||
|
FileSize: &size,
|
||||||
|
FileName: []byte(hex.EncodeToString(hash) + ".jpg"),
|
||||||
|
SrcTerm: proto.Uint32(5),
|
||||||
|
PlatformType: proto.Uint32(9),
|
||||||
|
BuType: proto.Uint32(211),
|
||||||
|
PicType: proto.Uint32(1000),
|
||||||
|
BuildVer: []byte("8.8.38.2266"),
|
||||||
|
AppPicType: proto.Uint32(1052),
|
||||||
|
SrvUpload: proto.Uint32(0),
|
||||||
|
QqmeetGuildId: &guildId,
|
||||||
|
QqmeetChannelId: &channelId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
CommandId: proto.Uint32(83),
|
||||||
|
})
|
||||||
|
packet := packets.BuildUniPacket(s.c.Uin, seq, "ImgStore.QQMeetPicUp", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key, payload)
|
||||||
|
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "send packet error")
|
||||||
|
}
|
||||||
|
body := new(cmd0x388.D388RspBody)
|
||||||
|
if err = proto.Unmarshal(rsp, body); err != nil {
|
||||||
|
return nil, errors.Wrap(err, "failed to unmarshal protobuf message")
|
||||||
|
}
|
||||||
|
if len(body.TryupImgRsp) == 0 {
|
||||||
|
return nil, errors.New("response is empty")
|
||||||
|
}
|
||||||
|
if body.TryupImgRsp[0].GetFileExit() {
|
||||||
|
return &message.GuildImageElement{
|
||||||
|
FileId: body.TryupImgRsp[0].GetFileid(),
|
||||||
|
FilePath: hex.EncodeToString(hash) + ".jpg",
|
||||||
|
Size: int32(size),
|
||||||
|
DownloadIndex: string(body.TryupImgRsp[0].GetDownloadIndex()),
|
||||||
|
Md5: hash,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
return nil, errors.New("image is not exists")
|
||||||
|
}
|
||||||
|
|
||||||
func decodeGuildMessagePushPacket(c *QQClient, _ *incomingPacketInfo, payload []byte) (interface{}, error) {
|
func decodeGuildMessagePushPacket(c *QQClient, _ *incomingPacketInfo, payload []byte) (interface{}, error) {
|
||||||
push := new(channel.MsgOnlinePush)
|
push := new(channel.MsgOnlinePush)
|
||||||
if err := proto.Unmarshal(payload, push); err != nil {
|
if err := proto.Unmarshal(payload, push); err != nil {
|
||||||
|
@ -36,6 +36,17 @@ type FriendImageElement struct {
|
|||||||
Flash bool
|
Flash bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GuildImageElement struct {
|
||||||
|
FileId uint64
|
||||||
|
FilePath string
|
||||||
|
ImageType int32
|
||||||
|
Size int32
|
||||||
|
Width int32
|
||||||
|
Height int32
|
||||||
|
DownloadIndex string
|
||||||
|
Md5 []byte
|
||||||
|
}
|
||||||
|
|
||||||
type ImageBizType uint32
|
type ImageBizType uint32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -155,3 +166,24 @@ func (e *FriendImageElement) Pack() (r []*msg.Elem) {
|
|||||||
elem := &msg.Elem{NotOnlineImage: image}
|
elem := &msg.Elem{NotOnlineImage: image}
|
||||||
return []*msg.Elem{elem}
|
return []*msg.Elem{elem}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *GuildImageElement) Pack() (r []*msg.Elem) {
|
||||||
|
cface := &msg.CustomFace{
|
||||||
|
FileType: proto.Int32(66),
|
||||||
|
Useful: proto.Int32(1),
|
||||||
|
BizType: proto.Int32(0),
|
||||||
|
Width: &e.Width,
|
||||||
|
Height: &e.Height,
|
||||||
|
FileId: proto.Int32(int32(e.FileId)),
|
||||||
|
FilePath: &e.FilePath,
|
||||||
|
ImageType: &e.ImageType,
|
||||||
|
Size: &e.Size,
|
||||||
|
Md5: e.Md5,
|
||||||
|
PbReserve: binary.DynamicProtoMessage{
|
||||||
|
1: uint32(0), 2: uint32(0), 6: "", 10: uint32(0), 15: uint32(8),
|
||||||
|
20: e.DownloadIndex,
|
||||||
|
}.Encode(),
|
||||||
|
}
|
||||||
|
elem := &msg.Elem{CustomFace: cface}
|
||||||
|
return []*msg.Elem{elem}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user