1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

client: use packOIDBPackageProto

This commit is contained in:
wdvxdr 2022-03-01 22:03:08 +08:00
parent ef65fd67e6
commit a7098f6000
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
3 changed files with 22 additions and 75 deletions

View File

@ -276,7 +276,7 @@ func (fs *GroupFileSystem) DeleteFile(parentFolderID, fileId string, busId int32
} }
func (c *QQClient) buildGroupFileUploadReqPacket(parentFolderID, fileName string, groupCode, fileSize int64, md5, sha1 []byte) (uint16, []byte) { func (c *QQClient) buildGroupFileUploadReqPacket(parentFolderID, fileName string, groupCode, fileSize int64, md5, sha1 []byte) (uint16, []byte) {
b, _ := proto.Marshal(&oidb.D6D6ReqBody{UploadFileReq: &oidb.UploadFileReqBody{ body := &oidb.D6D6ReqBody{UploadFileReq: &oidb.UploadFileReqBody{
GroupCode: &groupCode, GroupCode: &groupCode,
AppId: proto.Int32(3), AppId: proto.Int32(3),
BusId: proto.Int32(102), BusId: proto.Int32(102),
@ -288,14 +288,8 @@ func (c *QQClient) buildGroupFileUploadReqPacket(parentFolderID, fileName string
Sha: sha1, Sha: sha1,
Md5: md5, Md5: md5,
SupportMultiUpload: proto.Bool(true), SupportMultiUpload: proto.Bool(true),
}}) }}
req := &oidb.OIDBSSOPkg{ payload := c.packOIDBPackageProto(1750, 0, body)
Command: 1750,
ServiceType: 0,
Bodybuffer: b,
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
return c.uniPacket("OidbSvc.0x6d6_0", payload) return c.uniPacket("OidbSvc.0x6d6_0", payload)
} }
@ -328,31 +322,19 @@ func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderID str
StartIndex: &startIndex, StartIndex: &startIndex,
Context: EmptyBytes, Context: EmptyBytes,
}} }}
b, _ := proto.Marshal(body) payload := c.packOIDBPackageProto(1752, 1, body)
req := &oidb.OIDBSSOPkg{
Command: 1752,
ServiceType: 1,
Bodybuffer: b,
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
return c.uniPacket("OidbSvc.0x6d8_1", payload) return c.uniPacket("OidbSvc.0x6d8_1", payload)
} }
func (c *QQClient) buildGroupFileCountRequestPacket(groupCode int64) (uint16, []byte) { func (c *QQClient) buildGroupFileCountRequestPacket(groupCode int64) (uint16, []byte) {
body := &oidb.D6D8ReqBody{GroupFileCountReq: &oidb.GetFileCountReqBody{ body := &oidb.D6D8ReqBody{
GroupFileCountReq: &oidb.GetFileCountReqBody{
GroupCode: proto.Uint64(uint64(groupCode)), GroupCode: proto.Uint64(uint64(groupCode)),
AppId: proto.Uint32(3), AppId: proto.Uint32(3),
BusId: proto.Uint32(0), BusId: proto.Uint32(0),
}} },
b, _ := proto.Marshal(body)
req := &oidb.OIDBSSOPkg{
Command: 1752,
ServiceType: 2,
Bodybuffer: b,
ClientVersion: "android 8.4.8",
} }
payload, _ := proto.Marshal(req) payload := c.packOIDBPackageProto(1752, 2, body)
return c.uniPacket("OidbSvc.0x6d8_1", payload) return c.uniPacket("OidbSvc.0x6d8_1", payload)
} }
@ -361,14 +343,7 @@ func (c *QQClient) buildGroupFileSpaceRequestPacket(groupCode int64) (uint16, []
GroupCode: proto.Uint64(uint64(groupCode)), GroupCode: proto.Uint64(uint64(groupCode)),
AppId: proto.Uint32(3), AppId: proto.Uint32(3),
}} }}
b, _ := proto.Marshal(body) payload := c.packOIDBPackageProto(1752, 3, body)
req := &oidb.OIDBSSOPkg{
Command: 1752,
ServiceType: 3,
Bodybuffer: b,
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
return c.uniPacket("OidbSvc.0x6d8_1", payload) return c.uniPacket("OidbSvc.0x6d8_1", payload)
} }
@ -411,13 +386,7 @@ func (c *QQClient) buildGroupFileDownloadReqPacket(groupCode int64, fileId strin
FileId: &fileId, FileId: &fileId,
}, },
} }
b, _ := proto.Marshal(body) payload := c.packOIDBPackageProto(1750, 2, body)
req := &oidb.OIDBSSOPkg{
Command: 1750,
ServiceType: 2,
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
return c.uniPacket("OidbSvc.0x6d6_2", payload) return c.uniPacket("OidbSvc.0x6d6_2", payload)
} }
@ -429,14 +398,7 @@ func (c *QQClient) buildGroupFileDeleteReqPacket(groupCode int64, parentFolderId
ParentFolderId: &parentFolderId, ParentFolderId: &parentFolderId,
FileId: &fileId, FileId: &fileId,
}} }}
b, _ := proto.Marshal(body) payload := c.packOIDBPackageProto(1750, 3, body)
req := &oidb.OIDBSSOPkg{
Command: 1750,
ServiceType: 3,
Bodybuffer: b,
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
return c.uniPacket("OidbSvc.0x6d6_3", payload) return c.uniPacket("OidbSvc.0x6d6_3", payload)
} }
@ -470,9 +432,6 @@ func decodeOIDB6d63Response(_ *QQClient, _ *network.IncomingPacketInfo, payload
if err != nil { if err != nil {
return nil, err return nil, err
} }
if rsp.DeleteFileRsp == nil {
return "", nil
}
return rsp.DeleteFileRsp.GetClientWording(), nil return rsp.DeleteFileRsp.GetClientWording(), nil
} }
@ -491,14 +450,14 @@ func decodeOIDB6d7Response(_ *QQClient, _ *network.IncomingPacketInfo, payload [
if err != nil { if err != nil {
return nil, err return nil, err
} }
if rsp.CreateFolderRsp != nil && rsp.CreateFolderRsp.GetRetCode() != 0 { if retCode := rsp.CreateFolderRsp.GetRetCode(); retCode != 0 {
return nil, errors.Errorf("create folder error: %v", rsp.CreateFolderRsp.GetRetCode()) return nil, errors.Errorf("create folder error: %v", retCode)
} }
if rsp.RenameFolderRsp != nil && rsp.RenameFolderRsp.GetRetCode() != 0 { if retCode := rsp.RenameFolderRsp.GetRetCode(); retCode != 0 {
return nil, errors.Errorf("rename folder error: %v", rsp.CreateFolderRsp.GetRetCode()) return nil, errors.Errorf("rename folder error: %v", retCode)
} }
if rsp.DeleteFolderRsp != nil && rsp.DeleteFolderRsp.GetRetCode() != 0 { if retCode := rsp.DeleteFolderRsp.GetRetCode(); retCode != 0 {
return nil, errors.Errorf("delete folder error: %v", rsp.CreateFolderRsp.GetRetCode()) return nil, errors.Errorf("delete folder error: %v", retCode)
} }
return nil, nil return nil, nil
} }

View File

@ -116,12 +116,7 @@ func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) (uint16, []byte)
}, },
PcClientVersion: proto.Uint32(0), PcClientVersion: proto.Uint32(0),
} }
b, _ := proto.Marshal(body) payload := c.packOIDBPackageProto(2189, 0, body)
req := &oidb.OIDBSSOPkg{
Command: 2189,
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
return c.uniPacket("OidbSvc.0x88d_0", payload) return c.uniPacket("OidbSvc.0x88d_0", payload)
} }

View File

@ -5,7 +5,6 @@ import (
"github.com/Mrs4s/MiraiGo/client/internal/network" "github.com/Mrs4s/MiraiGo/client/internal/network"
"github.com/Mrs4s/MiraiGo/client/pb/oidb" "github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/internal/proto"
) )
func (c *QQClient) buildTranslatePacket(src, dst, text string) (uint16, []byte) { func (c *QQClient) buildTranslatePacket(src, dst, text string) (uint16, []byte) {
@ -16,13 +15,7 @@ func (c *QQClient) buildTranslatePacket(src, dst, text string) (uint16, []byte)
SrcTextList: []string{text}, SrcTextList: []string{text},
}, },
} }
b, _ := proto.Marshal(body) payload := c.packOIDBPackageProto(2448, 2, body)
req := &oidb.OIDBSSOPkg{
Command: 2448,
ServiceType: 2,
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
return c.uniPacket("OidbSvc.0x990", payload) return c.uniPacket("OidbSvc.0x990", payload)
} }