From a8986651e7c3b0ddb8a5293b605dbcfc866c8f9d Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Tue, 10 Nov 2020 23:14:01 +0800 Subject: [PATCH] feature: group file delete. --- client/client.go | 3 ++- client/group_file.go | 48 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/client/client.go b/client/client.go index 1c4c1674..963631a0 100644 --- a/client/client.go +++ b/client/client.go @@ -151,7 +151,8 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient { "ProfileService.Pb.ReqSystemMsgNew.Friend": decodeSystemMsgFriendPacket, "MultiMsg.ApplyUp": decodeMultiApplyUpResponse, "MultiMsg.ApplyDown": decodeMultiApplyDownResponse, - "OidbSvc.0x6d6_2": decodeOIDB6d6Response, + "OidbSvc.0x6d6_2": decodeOIDB6d62Response, + "OidbSvc.0x6d6_3": decodeOIDB6d63Response, "OidbSvc.0x6d8_1": decodeOIDB6d81Response, "OidbSvc.0x88d_0": decodeGroupInfoResponse, "OidbSvc.0xe07_0": decodeImageOcrResponse, diff --git a/client/group_file.go b/client/group_file.go index 68155f58..fe873408 100644 --- a/client/group_file.go +++ b/client/group_file.go @@ -142,6 +142,16 @@ func (fs *GroupFileSystem) GetDownloadUrl(file *GroupFile) string { return fs.client.GetGroupFileUrl(file.GroupCode, file.FileId, file.BusId) } +// DeleteFile 删除群文件,需要管理权限. +// 返回错误, 空为删除成功 +func (fs *GroupFileSystem) DeleteFile(parentFolderId, fileId string, busId int32) string { + i, err := fs.client.sendAndWait(fs.client.buildGroupFileDeleteReqPacket(fs.GroupCode, parentFolderId, fileId, busId)) + if err != nil { + return err.Error() + } + return i.(string) +} + // OidbSvc.0x6d8_1 func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderId string, startIndex uint32) (uint16, []byte) { seq := c.nextSeq() @@ -229,6 +239,27 @@ func (c *QQClient) buildGroupFileDownloadReqPacket(groupCode int64, fileId strin return seq, packet } +func (c *QQClient) buildGroupFileDeleteReqPacket(groupCode int64, parentFolderId, fileId string, busId int32) (uint16, []byte) { + seq := c.nextSeq() + body := &oidb.D6D6ReqBody{DeleteFileReq: &oidb.DeleteFileReqBody{ + GroupCode: groupCode, + AppId: 3, + BusId: busId, + ParentFolderId: parentFolderId, + FileId: fileId, + }} + b, _ := proto.Marshal(body) + req := &oidb.OIDBSSOPkg{ + Command: 1750, + ServiceType: 3, + Bodybuffer: b, + ClientVersion: "android 8.4.8", + } + payload, _ := proto.Marshal(req) + packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d6_3", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload) + return seq, packet +} + func decodeOIDB6d81Response(c *QQClient, _ uint16, payload []byte) (interface{}, error) { pkg := oidb.OIDBSSOPkg{} rsp := oidb.D6D8RspBody{} @@ -242,7 +273,7 @@ func decodeOIDB6d81Response(c *QQClient, _ uint16, payload []byte) (interface{}, } // OidbSvc.0x6d6_2 -func decodeOIDB6d6Response(_ *QQClient, _ uint16, payload []byte) (interface{}, error) { +func decodeOIDB6d62Response(_ *QQClient, _ uint16, payload []byte) (interface{}, error) { pkg := oidb.OIDBSSOPkg{} rsp := oidb.D6D6RspBody{} if err := proto.Unmarshal(payload, &pkg); err != nil { @@ -258,3 +289,18 @@ func decodeOIDB6d6Response(_ *QQClient, _ uint16, payload []byte) (interface{}, url := hex.EncodeToString(rsp.DownloadFileRsp.DownloadUrl) return fmt.Sprintf("http://%s/ftn_handler/%s/", ip, url), nil } + +func decodeOIDB6d63Response(_ *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 + } + if rsp.DeleteFileRsp == nil { + return "", nil + } + return rsp.DeleteFileRsp.ClientWording, nil +}