mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
group file download supported.
This commit is contained in:
parent
683ad4b6cb
commit
771f5d491d
@ -24,7 +24,7 @@ qq-android协议的golang实现 移植于mirai
|
||||
- [x] 小程序(暂只支持RAW)
|
||||
- [ ] 位置
|
||||
- [x] 合并转发
|
||||
- [x] 群文件(仅接收信息)
|
||||
- [x] 群文件(仅接受消息)
|
||||
|
||||
#### 事件
|
||||
- [x] 好友消息
|
||||
@ -55,6 +55,7 @@ qq-android协议的golang实现 移植于mirai
|
||||
- [x] 处理好友请求
|
||||
- [x] 撤回群消息
|
||||
- [ ] 群公告设置
|
||||
- [x] 获取群文件下载链接
|
||||
- [x] 群设置 (全体禁言/群名)
|
||||
- [x] 修改群成员Card
|
||||
- [x] 修改群成员头衔
|
||||
|
@ -893,3 +893,25 @@ func (c *QQClient) buildQuitGroupPacket(groupCode int64) (uint16, []byte) {
|
||||
packet := packets.BuildUniPacket(c.Uin, seq, "ProfileService.GroupMngReq", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, pkt.ToBytes())
|
||||
return seq, packet
|
||||
}
|
||||
|
||||
// OidbSvc.0x6d6_2
|
||||
func (c *QQClient) buildGroupFileDownloadReqPacket(groupCode int64, fileId string, busId int32) (uint16, []byte) {
|
||||
seq := c.nextSeq()
|
||||
body := &oidb.D6D6ReqBody{
|
||||
DownloadFileReq: &oidb.DownloadFileReqBody{
|
||||
GroupCode: groupCode,
|
||||
AppId: 3,
|
||||
BusId: busId,
|
||||
FileId: fileId,
|
||||
},
|
||||
}
|
||||
b, _ := proto.Marshal(body)
|
||||
req := &oidb.OIDBSSOPkg{
|
||||
Command: 1750,
|
||||
ServiceType: 2,
|
||||
Bodybuffer: b,
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d6_2", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
|
||||
return seq, packet
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package client
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/Mrs4s/MiraiGo/binary"
|
||||
@ -122,6 +123,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
|
||||
"ProfileService.Pb.ReqSystemMsgNew.Friend": decodeSystemMsgFriendPacket,
|
||||
"MultiMsg.ApplyUp": decodeMultiApplyUpResponse,
|
||||
"MultiMsg.ApplyDown": decodeMultiApplyDownResponse,
|
||||
"OidbSvc.0x6d6_2": decodeOIDB6d6Response,
|
||||
},
|
||||
sigInfo: &loginSigInfo{},
|
||||
requestPacketRequestId: 1921334513,
|
||||
@ -207,6 +209,16 @@ func (c *QQClient) GetFriendList() (*FriendListResponse, error) {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (c *QQClient) GetGroupFileUrl(groupCode int64, fileId string, busId int32) string {
|
||||
i, err := c.sendAndWait(c.buildGroupFileDownloadReqPacket(groupCode, fileId, busId))
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
url := i.(string)
|
||||
url += "?fname=" + hex.EncodeToString([]byte(fileId))
|
||||
return url
|
||||
}
|
||||
|
||||
func (c *QQClient) SendGroupMessage(groupCode int64, m *message.SendingMessage) *message.GroupMessage {
|
||||
imgCount := m.Count(func(e message.IMessageElement) bool { return e.Type() == message.Image })
|
||||
msgLen := message.EstimateLength(m.Elements, 703)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/Mrs4s/MiraiGo/binary"
|
||||
@ -10,6 +11,7 @@ import (
|
||||
"github.com/Mrs4s/MiraiGo/client/pb/longmsg"
|
||||
"github.com/Mrs4s/MiraiGo/client/pb/msg"
|
||||
"github.com/Mrs4s/MiraiGo/client/pb/multimsg"
|
||||
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
|
||||
"github.com/Mrs4s/MiraiGo/client/pb/structmsg"
|
||||
"github.com/Mrs4s/MiraiGo/utils"
|
||||
"github.com/golang/protobuf/proto"
|
||||
@ -750,3 +752,17 @@ func decodeMultiApplyDownResponse(c *QQClient, _ uint16, payload []byte) (interf
|
||||
}
|
||||
return &mt, nil
|
||||
}
|
||||
|
||||
func decodeOIDB6d6Response(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
|
||||
pkg := oidb.OIDBSSOPkg{}
|
||||
rsp := oidb.D6D6RspBody{}
|
||||
if err := proto.Unmarshal(payload, &pkg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := proto.Unmarshal(pkg.Bodybuffer, &rsp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ip := rsp.DownloadFileRsp.DownloadIp
|
||||
url := hex.EncodeToString(rsp.DownloadFileRsp.DownloadUrl)
|
||||
return fmt.Sprintf("http://%s/ftn_handler/%s/", ip, url), nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user