From 6b5ba9f9c4ac1e735d198f0b6169816ca21ceb06 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Fri, 17 Dec 2021 23:50:30 +0800 Subject: [PATCH] refactor: move `c.nextSeq` to `c.uniPacket` --- client/builders.go | 82 ++++++++++++------------------------------ client/decoders.go | 2 +- client/face.go | 4 +-- client/group_file.go | 40 ++++++--------------- client/group_info.go | 8 ++--- client/group_msg.go | 16 +++------ client/guild.go | 54 ++++++++++++---------------- client/guild_msg.go | 14 +++----- client/image.go | 12 ++----- client/multimsg.go | 8 ++--- client/offline_file.go | 2 +- client/packet.go | 4 +-- client/private_msg.go | 12 ++----- client/ptt.go | 6 ++-- client/qidian.go | 8 ++--- client/recall.go | 8 ++--- client/richmsg.go | 4 +-- client/security.go | 4 +-- client/sync.go | 20 +++-------- client/system_msg.go | 12 ++----- client/translate.go | 4 +-- client/web.go | 3 +- 22 files changed, 97 insertions(+), 230 deletions(-) diff --git a/client/builders.go b/client/builders.go index e86f3b28..fe6c72d5 100644 --- a/client/builders.go +++ b/client/builders.go @@ -509,7 +509,7 @@ func (c *QQClient) buildStatusSetPacket(status, extStatus int32) (uint16, []byte Context: make(map[string]string), Status: make(map[string]string), } - return c.uniPacketWithSeq("StatSvc.SetStatusFromClient", pkt.ToBytes()) + return c.uniPacket("StatSvc.SetStatusFromClient", pkt.ToBytes()) } // ConfigPushSvc.PushResp @@ -529,7 +529,7 @@ func (c *QQClient) buildConfPushRespPacket(t int32, pktSeq int64, jceBuf []byte) Context: make(map[string]string), Status: make(map[string]string), } - return c.uniPacketWithSeq("ConfigPushSvc.PushResp", pkt.ToBytes()) + return c.uniPacket("ConfigPushSvc.PushResp", pkt.ToBytes()) } // friendlist.getFriendGroupList @@ -585,7 +585,7 @@ func (c *QQClient) buildFriendGroupListRequestPacket(friendStartIndex, friendLis Context: make(map[string]string), Status: make(map[string]string), } - return c.uniPacketWithSeq("friendlist.getFriendGroupList", pkt.ToBytes()) + return c.uniPacket("friendlist.getFriendGroupList", pkt.ToBytes()) } // SummaryCard.ReqSummaryCard @@ -669,12 +669,11 @@ func (c *QQClient) buildSummaryCardRequestPacket(target int64) (uint16, []byte) Context: make(map[string]string), Status: make(map[string]string), } - return seq, c.uniPacket(seq, "SummaryCard.ReqSummaryCard", pkt.ToBytes()) + return seq, c.uniPacketWithSeq(seq, "SummaryCard.ReqSummaryCard", pkt.ToBytes()) } // friendlist.delFriend func (c *QQClient) buildFriendDeletePacket(target int64) (uint16, []byte) { - seq := c.nextSeq() req := &jce.DelFriendReq{ Uin: c.Uin, DelUin: target, @@ -693,13 +692,11 @@ func (c *QQClient) buildFriendDeletePacket(target int64) (uint16, []byte) { Context: make(map[string]string), Status: make(map[string]string), } - packet := c.uniPacket(seq, "friendlist.delFriend", pkt.ToBytes()) - return seq, packet + return c.uniPacket("friendlist.delFriend", pkt.ToBytes()) } // friendlist.GetTroopListReqV2 func (c *QQClient) buildGroupListRequestPacket(vecCookie []byte) (uint16, []byte) { - seq := c.nextSeq() req := &jce.TroopListRequest{ Uin: c.Uin, GetMSFMsgFlag: 1, @@ -724,13 +721,11 @@ func (c *QQClient) buildGroupListRequestPacket(vecCookie []byte) (uint16, []byte Context: make(map[string]string), Status: make(map[string]string), } - packet := c.uniPacket(seq, "friendlist.GetTroopListReqV2", pkt.ToBytes()) - return seq, packet + return c.uniPacket("friendlist.GetTroopListReqV2", pkt.ToBytes()) } // friendlist.GetTroopMemberListReq func (c *QQClient) buildGroupMemberListRequestPacket(groupUin, groupCode, nextUin int64) (uint16, []byte) { - seq := c.nextSeq() req := &jce.TroopMemberListRequest{ Uin: c.Uin, GroupCode: groupCode, @@ -752,13 +747,11 @@ func (c *QQClient) buildGroupMemberListRequestPacket(groupUin, groupCode, nextUi Context: make(map[string]string), Status: make(map[string]string), } - packet := c.uniPacket(seq, "friendlist.GetTroopMemberListReq", pkt.ToBytes()) - return seq, packet + return c.uniPacket("friendlist.GetTroopMemberListReq", pkt.ToBytes()) } // group_member_card.get_group_member_card_info func (c *QQClient) buildGroupMemberInfoRequestPacket(groupCode, uin int64) (uint16, []byte) { - seq := c.nextSeq() req := &pb.GroupMemberReqBody{ GroupCode: groupCode, Uin: uin, @@ -767,13 +760,11 @@ func (c *QQClient) buildGroupMemberInfoRequestPacket(groupCode, uin int64) (uint RichCardNameVer: 1, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "group_member_card.get_group_member_card_info", payload) - return seq, packet + return c.uniPacket("group_member_card.get_group_member_card_info", payload) } // MessageSvc.PbGetMsg func (c *QQClient) buildGetMessageRequestPacket(flag msg.SyncFlag, msgTime int64) (uint16, []byte) { - seq := c.nextSeq() cook := c.syncCookie if cook == nil { cook, _ = proto.Marshal(&msg.SyncCookie{ @@ -798,17 +789,14 @@ func (c *QQClient) buildGetMessageRequestPacket(flag msg.SyncFlag, msgTime int64 ServerBuf: EmptyBytes, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "MessageSvc.PbGetMsg", payload) - return seq, packet + return c.uniPacket("MessageSvc.PbGetMsg", payload) } // MessageSvc.PbDeleteMsg func (c *QQClient) buildDeleteMessageRequestPacket(msg []*pb.MessageItem) (uint16, []byte) { - seq := c.nextSeq() req := &pb.DeleteMessageRequest{Items: msg} payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "MessageSvc.PbDeleteMsg", payload) - return seq, packet + return c.uniPacket("MessageSvc.PbDeleteMsg", payload) } // OnlinePush.RespPush @@ -835,12 +823,11 @@ func (c *QQClient) buildDeleteOnlinePushPacket(uin int64, svrip int32, pushToken Context: make(map[string]string), Status: make(map[string]string), } - return c.uniPacket(seq, "OnlinePush.RespPush", pkt.ToBytes()) + return c.uniPacketWithSeq(seq, "OnlinePush.RespPush", pkt.ToBytes()) } // LongConn.OffPicUp func (c *QQClient) buildOffPicUpPacket(target int64, md5 []byte, size int32) (uint16, []byte) { - seq := c.nextSeq() req := &cmd0x352.ReqBody{ Subcmd: proto.Uint32(1), TryupImgReq: []*cmd0x352.D352TryUpImgReq{ @@ -863,13 +850,11 @@ func (c *QQClient) buildOffPicUpPacket(target int64, md5 []byte, size int32) (ui }, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "LongConn.OffPicUp", payload) - return seq, packet + return c.uniPacket("LongConn.OffPicUp", payload) } // ProfileService.Pb.ReqSystemMsgNew.Friend func (c *QQClient) buildSystemMsgNewFriendPacket() (uint16, []byte) { - seq := c.nextSeq() req := &structmsg.ReqSystemMsgNew{ MsgNum: 20, Version: 1000, @@ -884,13 +869,11 @@ func (c *QQClient) buildSystemMsgNewFriendPacket() (uint16, []byte) { FriendMsgTypeFlag: 1, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "ProfileService.Pb.ReqSystemMsgNew.Friend", payload) - return seq, packet + return c.uniPacket("ProfileService.Pb.ReqSystemMsgNew.Friend", payload) } // friendlist.ModifyGroupCardReq func (c *QQClient) buildEditGroupTagPacket(groupCode, memberUin int64, newTag string) (uint16, []byte) { - seq := c.nextSeq() req := &jce.ModifyGroupCardRequest{ GroupCode: groupCode, UinInfo: []jce.IJceStruct{ @@ -911,13 +894,11 @@ func (c *QQClient) buildEditGroupTagPacket(groupCode, memberUin int64, newTag st Context: map[string]string{}, Status: map[string]string{}, } - packet := c.uniPacket(seq, "friendlist.ModifyGroupCardReq", pkt.ToBytes()) - return seq, packet + return c.uniPacket("friendlist.ModifyGroupCardReq", pkt.ToBytes()) } // OidbSvc.0x8fc_2 func (c *QQClient) buildEditSpecialTitlePacket(groupCode, memberUin int64, newTitle string) (uint16, []byte) { - seq := c.nextSeq() body := &oidb.D8FCReqBody{ GroupCode: &groupCode, MemLevelInfo: []*oidb.D8FCMemberInfo{ @@ -931,17 +912,14 @@ func (c *QQClient) buildEditSpecialTitlePacket(groupCode, memberUin int64, newTi } b, _ := proto.Marshal(body) payload := c.packOIDBPackage(2300, 2, b) - packet := c.uniPacket(seq, "OidbSvc.0x8fc_2", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x8fc_2", payload) } // OidbSvc.0x89a_0 func (c *QQClient) buildGroupOperationPacket(body *oidb.D89AReqBody) (uint16, []byte) { - seq := c.nextSeq() b, _ := proto.Marshal(body) payload := c.packOIDBPackage(2202, 0, b) - packet := c.uniPacket(seq, "OidbSvc.0x89a_0", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x89a_0", payload) } // OidbSvc.0x89a_0 @@ -982,7 +960,6 @@ func (c *QQClient) buildGroupMuteAllPacket(groupCode int64, mute bool) (uint16, // OidbSvc.0x8a0_0 func (c *QQClient) buildGroupKickPacket(groupCode, memberUin int64, kickMsg string, block bool) (uint16, []byte) { - seq := c.nextSeq() flagBlock := 0 if block { flagBlock = 1 @@ -1000,13 +977,11 @@ func (c *QQClient) buildGroupKickPacket(groupCode, memberUin int64, kickMsg stri } b, _ := proto.Marshal(body) payload := c.packOIDBPackage(2208, 0, b) - packet := c.uniPacket(seq, "OidbSvc.0x8a0_0", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x8a0_0", payload) } // OidbSvc.0x570_8 func (c *QQClient) buildGroupMutePacket(groupCode, memberUin int64, time uint32) (uint16, []byte) { - seq := c.nextSeq() b, cl := binary.OpenWriterF(func(w *binary.Writer) { w.WriteUInt32(uint32(groupCode)) w.WriteByte(32) @@ -1016,39 +991,33 @@ func (c *QQClient) buildGroupMutePacket(groupCode, memberUin int64, time uint32) }) payload := c.packOIDBPackage(1392, 8, b) cl() - packet := c.uniPacket(seq, "OidbSvc.0x570_8", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x570_8", payload) } // OidbSvc.0xed3 func (c *QQClient) buildGroupPokePacket(groupCode, target int64) (uint16, []byte) { - seq := c.nextSeq() body := &oidb.DED3ReqBody{ ToUin: target, GroupCode: groupCode, } b, _ := proto.Marshal(body) payload := c.packOIDBPackage(3795, 1, b) - packet := c.uniPacket(seq, "OidbSvc.0xed3", payload) - return seq, packet + return c.uniPacket("OidbSvc.0xed3", payload) } // OidbSvc.0xed3 func (c *QQClient) buildFriendPokePacket(target int64) (uint16, []byte) { - seq := c.nextSeq() body := &oidb.DED3ReqBody{ ToUin: target, AioUin: target, } b, _ := proto.Marshal(body) payload := c.packOIDBPackage(3795, 1, b) - packet := c.uniPacket(seq, "OidbSvc.0xed3", payload) - return seq, packet + return c.uniPacket("OidbSvc.0xed3", payload) } // OidbSvc.0x55c_1 func (c *QQClient) buildGroupAdminSetPacket(groupCode, member int64, flag bool) (uint16, []byte) { - seq := c.nextSeq() b, cl := binary.OpenWriterF(func(w *binary.Writer) { w.WriteUInt32(uint32(groupCode)) w.WriteUInt32(uint32(member)) @@ -1061,13 +1030,11 @@ func (c *QQClient) buildGroupAdminSetPacket(groupCode, member int64, flag bool) }) payload := c.packOIDBPackage(1372, 1, b) cl() - packet := c.uniPacket(seq, "OidbSvc.0x55c_1", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x55c_1", payload) } // ProfileService.GroupMngReq func (c *QQClient) buildQuitGroupPacket(groupCode int64) (uint16, []byte) { - seq := c.nextSeq() jw := jce.NewJceWriter() jw.WriteInt32(2, 0) jw.WriteInt64(c.Uin, 1) @@ -1087,8 +1054,7 @@ func (c *QQClient) buildQuitGroupPacket(groupCode int64) (uint16, []byte) { Context: map[string]string{}, Status: map[string]string{}, } - packet := c.uniPacket(seq, "ProfileService.GroupMngReq", pkt.ToBytes()) - return seq, packet + return c.uniPacket("ProfileService.GroupMngReq", pkt.ToBytes()) } /* this function is unused @@ -1114,12 +1080,10 @@ func (c *QQClient) buildAppInfoRequestPacket(id string) (uint16, []byte) { */ func (c *QQClient) buildWordSegmentationPacket(data []byte) (uint16, []byte) { - seq := c.nextSeq() payload := c.packOIDBPackageProto(3449, 1, &oidb.D79ReqBody{ Uin: uint64(c.Uin), Content: data, Qua: []byte("and_537065262_8.4.5"), }) - packet := c.uniPacket(seq, "OidbSvc.0xd79", payload) - return seq, packet + return c.uniPacket("OidbSvc.0xd79", payload) } diff --git a/client/decoders.go b/client/decoders.go index 895638c9..7bab79da 100644 --- a/client/decoders.go +++ b/client/decoders.go @@ -802,7 +802,7 @@ func decodeSidExpiredPacket(c *QQClient, i *incomingPacketInfo, _ []byte) (inter if err = c.registerClient(); err != nil { return nil, errors.Wrap(err, "register error") } - _ = c.sendPacket(c.uniPacket(i.SequenceId, "OnlinePush.SidTicketExpired", EmptyBytes)) + _ = c.sendPacket(c.uniPacketWithSeq(i.SequenceId, "OnlinePush.SidTicketExpired", EmptyBytes)) return nil, nil } diff --git a/client/face.go b/client/face.go index 3e1e8cc6..674ec9e6 100644 --- a/client/face.go +++ b/client/face.go @@ -27,7 +27,6 @@ func (c *QQClient) GetCustomFaces() ([]*CustomFace, error) { } func (c *QQClient) buildFaceroamRequestPacket() (uint16, []byte) { - seq := c.nextSeq() payload, _ := proto.Marshal(&faceroam.FaceroamReqBody{ Comm: &faceroam.PlatInfo{ Implat: proto.Int64(109), @@ -38,8 +37,7 @@ func (c *QQClient) buildFaceroamRequestPacket() (uint16, []byte) { SubCmd: proto.Uint32(1), ReqUserInfo: &faceroam.ReqUserInfo{}, }) - packet := c.uniPacket(seq, "Faceroam.OpReq", payload) - return seq, packet + return c.uniPacket("Faceroam.OpReq", payload) } func decodeFaceroamResponse(c *QQClient, _ *incomingPacketInfo, payload []byte) (interface{}, error) { diff --git a/client/group_file.go b/client/group_file.go index 09382ad6..d72d955a 100644 --- a/client/group_file.go +++ b/client/group_file.go @@ -275,7 +275,6 @@ func (fs *GroupFileSystem) DeleteFile(parentFolderID, fileId string, busId int32 } func (c *QQClient) buildGroupFileUploadReqPacket(parentFolderID, fileName string, groupCode, fileSize int64, md5, sha1 []byte) (uint16, []byte) { - seq := c.nextSeq() b, _ := proto.Marshal(&oidb.D6D6ReqBody{UploadFileReq: &oidb.UploadFileReqBody{ GroupCode: &groupCode, AppId: proto.Int32(3), @@ -296,12 +295,10 @@ func (c *QQClient) buildGroupFileUploadReqPacket(parentFolderID, fileName string ClientVersion: "android 8.4.8", } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "OidbSvc.0x6d6_0", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x6d6_0", payload) } func (c *QQClient) buildGroupFileFeedsRequest(groupCode int64, fileID string, busId, msgRand int32) (uint16, []byte) { - seq := c.nextSeq() req := c.packOIDBPackageProto(1753, 4, &oidb.D6D9ReqBody{FeedsInfoReq: &oidb.FeedsReqBody{ GroupCode: proto.Uint64(uint64(groupCode)), AppId: proto.Uint32(3), @@ -312,13 +309,11 @@ func (c *QQClient) buildGroupFileFeedsRequest(groupCode int64, fileID string, bu MsgRandom: proto.Uint32(uint32(msgRand)), }}, }}) - packet := c.uniPacket(seq, "OidbSvc.0x6d9_4", req) - return seq, packet + return c.uniPacket("OidbSvc.0x6d9_4", req) } // OidbSvc.0x6d8_1 func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderID string, startIndex uint32) (uint16, []byte) { - seq := c.nextSeq() body := &oidb.D6D8ReqBody{FileListInfoReq: &oidb.GetFileListReqBody{ GroupCode: proto.Uint64(uint64(groupCode)), AppId: proto.Uint32(3), @@ -340,12 +335,10 @@ func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderID str ClientVersion: "android 8.4.8", } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "OidbSvc.0x6d8_1", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x6d8_1", payload) } func (c *QQClient) buildGroupFileCountRequestPacket(groupCode int64) (uint16, []byte) { - seq := c.nextSeq() body := &oidb.D6D8ReqBody{GroupFileCountReq: &oidb.GetFileCountReqBody{ GroupCode: proto.Uint64(uint64(groupCode)), AppId: proto.Uint32(3), @@ -359,12 +352,10 @@ func (c *QQClient) buildGroupFileCountRequestPacket(groupCode int64) (uint16, [] ClientVersion: "android 8.4.8", } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "OidbSvc.0x6d8_1", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x6d8_1", payload) } func (c *QQClient) buildGroupFileSpaceRequestPacket(groupCode int64) (uint16, []byte) { - seq := c.nextSeq() body := &oidb.D6D8ReqBody{GroupSpaceReq: &oidb.GetSpaceReqBody{ GroupCode: proto.Uint64(uint64(groupCode)), AppId: proto.Uint32(3), @@ -377,48 +368,40 @@ func (c *QQClient) buildGroupFileSpaceRequestPacket(groupCode int64) (uint16, [] ClientVersion: "android 8.4.8", } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "OidbSvc.0x6d8_1", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x6d8_1", payload) } func (c *QQClient) buildGroupFileCreateFolderPacket(groupCode int64, parentFolder, name string) (uint16, []byte) { - seq := c.nextSeq() payload := c.packOIDBPackageProto(1751, 0, &oidb.D6D7ReqBody{CreateFolderReq: &oidb.CreateFolderReqBody{ GroupCode: proto.Uint64(uint64(groupCode)), AppId: proto.Uint32(3), ParentFolderId: &parentFolder, FolderName: &name, }}) - packet := c.uniPacket(seq, "OidbSvc.0x6d7_0", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x6d7_0", payload) } func (c *QQClient) buildGroupFileRenameFolderPacket(groupCode int64, folderId, newName string) (uint16, []byte) { - seq := c.nextSeq() payload := c.packOIDBPackageProto(1751, 2, &oidb.D6D7ReqBody{RenameFolderReq: &oidb.RenameFolderReqBody{ GroupCode: proto.Uint64(uint64(groupCode)), AppId: proto.Uint32(3), FolderId: proto.String(folderId), NewFolderName: proto.String(newName), }}) - packet := c.uniPacket(seq, "OidbSvc.0x6d7_2", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x6d7_2", payload) } func (c *QQClient) buildGroupFileDeleteFolderPacket(groupCode int64, folderId string) (uint16, []byte) { - seq := c.nextSeq() payload := c.packOIDBPackageProto(1751, 1, &oidb.D6D7ReqBody{DeleteFolderReq: &oidb.DeleteFolderReqBody{ GroupCode: proto.Uint64(uint64(groupCode)), AppId: proto.Uint32(3), FolderId: proto.String(folderId), }}) - packet := c.uniPacket(seq, "OidbSvc.0x6d7_1", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x6d7_1", payload) } // 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, @@ -434,12 +417,10 @@ func (c *QQClient) buildGroupFileDownloadReqPacket(groupCode int64, fileId strin Bodybuffer: b, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "OidbSvc.0x6d6_2", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x6d6_2", payload) } 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: proto.Int32(3), @@ -455,8 +436,7 @@ func (c *QQClient) buildGroupFileDeleteReqPacket(groupCode int64, parentFolderId ClientVersion: "android 8.4.8", } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "OidbSvc.0x6d6_3", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x6d6_3", payload) } func decodeOIDB6d81Response(_ *QQClient, _ *incomingPacketInfo, payload []byte) (interface{}, error) { diff --git a/client/group_info.go b/client/group_info.go index 02146a2b..da71e9fd 100644 --- a/client/group_info.go +++ b/client/group_info.go @@ -79,7 +79,6 @@ func (c *QQClient) GetGroupInfo(groupCode int64) (*GroupInfo, error) { // OidbSvc.0x88d_0 func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) (uint16, []byte) { - seq := c.nextSeq() body := &oidb.D88DReqBody{ AppId: proto.Uint32(c.version.AppId), ReqGroupInfo: []*oidb.ReqGroupInfo{ @@ -122,8 +121,7 @@ func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) (uint16, []byte) Bodybuffer: b, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "OidbSvc.0x88d_0", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x88d_0", payload) } // SearchGroupByKeyword 通过关键词搜索陌生群组 @@ -137,7 +135,6 @@ func (c *QQClient) SearchGroupByKeyword(keyword string) ([]GroupSearchInfo, erro // SummaryCard.ReqSearch func (c *QQClient) buildGroupSearchPacket(keyword string) (uint16, []byte) { - seq := c.nextSeq() comm, _ := proto.Marshal(&profilecard.BusiComm{ Ver: proto.Int32(1), Seq: proto.Int32(rand.Int31()), @@ -186,8 +183,7 @@ func (c *QQClient) buildGroupSearchPacket(keyword string) (uint16, []byte) { Context: make(map[string]string), Status: make(map[string]string), } - packet := c.uniPacket(seq, "SummaryCard.ReqSearch", pkt.ToBytes()) - return seq, packet + return c.uniPacket("SummaryCard.ReqSearch", pkt.ToBytes()) } // SummaryCard.ReqSearch diff --git a/client/group_msg.go b/client/group_msg.go index b91f5276..f00b6dbd 100644 --- a/client/group_msg.go +++ b/client/group_msg.go @@ -237,7 +237,6 @@ func (c *QQClient) multiMsgApplyUp(groupCode int64, data []byte, hash []byte, bu // MessageSvc.PbSendMsg func (c *QQClient) buildGroupSendingPacket(groupCode int64, r, pkgNum, pkgIndex, pkgDiv int32, forward bool, m []message.IMessageElement) (uint16, []byte) { - seq := c.nextSeq() var ptt *message.GroupVoiceElement if len(m) > 0 { if p, ok := m[0].(*message.GroupVoiceElement); ok { @@ -271,12 +270,10 @@ func (c *QQClient) buildGroupSendingPacket(groupCode int64, r, pkgNum, pkgIndex, }(), } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "MessageSvc.PbSendMsg", payload) - return seq, packet + return c.uniPacket("MessageSvc.PbSendMsg", payload) } func (c *QQClient) buildGetGroupMsgRequest(groupCode, beginSeq, endSeq int64) (uint16, []byte) { - seq := c.nextSeq() req := &msg.GetGroupMsgReq{ GroupCode: proto.Uint64(uint64(groupCode)), BeginSeq: proto.Uint64(uint64(beginSeq)), @@ -284,12 +281,10 @@ func (c *QQClient) buildGetGroupMsgRequest(groupCode, beginSeq, endSeq int64) (u PublicGroup: proto.Bool(false), } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "MessageSvc.PbGetGroupMsg", payload) - return seq, packet + return c.uniPacket("MessageSvc.PbGetGroupMsg", payload) } func (c *QQClient) buildAtAllRemainRequestPacket(groupCode int64) (uint16, []byte) { - seq := c.nextSeq() payload := c.packOIDBPackageProto(2215, 0, &oidb.D8A7ReqBody{ SubCmd: proto.Uint32(1), LimitIntervalTypeForUin: proto.Uint32(2), @@ -297,8 +292,7 @@ func (c *QQClient) buildAtAllRemainRequestPacket(groupCode int64) (uint16, []byt Uin: proto.Uint64(uint64(c.Uin)), GroupCode: proto.Uint64(uint64(groupCode)), }) - packet := c.uniPacket(seq, "OidbSvc.0x8a7_0", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x8a7_0", payload) } // OnlinePush.PbPushGroupMsg @@ -593,15 +587,13 @@ func (c *QQClient) DeleteEssenceMessage(groupCode int64, msgID, msgInternalId in } func (c *QQClient) buildEssenceMsgOperatePacket(groupCode int64, msgSeq, msgRand, opType uint32) (uint16, []byte) { - seq := c.nextSeq() commandName := "OidbSvc.0xeac_" + strconv.FormatInt(int64(opType), 10) payload := c.packOIDBPackageProto(3756, int32(opType), &oidb.EACReqBody{ // serviceType 2 取消 GroupCode: proto.Uint64(uint64(groupCode)), Seq: proto.Uint32(msgSeq), Random: proto.Uint32(msgRand), }) - packet := c.uniPacket(seq, commandName, payload) - return seq, packet + return c.uniPacket(commandName, payload) } // OidbSvc.0xeac_1/2 diff --git a/client/guild.go b/client/guild.go index 0d33b1e8..7cb76426 100644 --- a/client/guild.go +++ b/client/guild.go @@ -175,7 +175,6 @@ func (g *GuildInfo) removeChannel(id uint64) { } func (s *GuildService) GetUserProfile(tinyId uint64) (*GuildUserProfile, error) { - seq := s.c.nextSeq() flags := binary.DynamicProtoMessage{} for i := 3; i <= 29; i++ { flags[uint64(i)] = uint32(1) @@ -187,8 +186,7 @@ func (s *GuildService) GetUserProfile(tinyId uint64) (*GuildUserProfile, error) 3: tinyId, 4: uint32(0), }) - packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xfc9_1", payload) - rsp, err := s.c.sendAndWaitDynamic(seq, packet) + rsp, err := s.c.sendAndWaitDynamic(s.c.uniPacket("OidbSvcTrpcTcp.0xfc9_1", payload)) if err != nil { return nil, errors.Wrap(err, "send packet error") } @@ -226,7 +224,7 @@ func (s *GuildService) FetchGuildMemberListWithRole(guildId, channelId uint64, s m[13] = param } m[14] = roleIdIndex - packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xf5b_1", s.c.packOIDBPackageDynamically(3931, 1, m)) + packet := s.c.uniPacketWithSeq(seq, "OidbSvcTrpcTcp.0xf5b_1", s.c.packOIDBPackageDynamically(3931, 1, m)) rsp, err := s.c.sendAndWaitDynamic(seq, packet) if err != nil { return nil, errors.Wrap(err, "send packet error") @@ -281,7 +279,7 @@ func (s *GuildService) FetchGuildMemberProfileInfo(guildId, tinyId uint64) (*Gui 3: tinyId, 4: guildId, }) - packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xf88_1", payload) + packet := s.c.uniPacketWithSeq(seq, "OidbSvcTrpcTcp.0xf88_1", payload) rsp, err := s.c.sendAndWaitDynamic(seq, packet) if err != nil { return nil, errors.Wrap(err, "send packet error") @@ -305,8 +303,8 @@ func (s *GuildService) FetchGuildMemberProfileInfo(guildId, tinyId uint64) (*Gui } func (s *GuildService) GetGuildRoles(guildId uint64) ([]*GuildRole, error) { - seq := s.c.nextSeq() - packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x1019_1", s.c.packOIDBPackageDynamically(4121, 1, binary.DynamicProtoMessage{1: guildId})) + seq, packet := s.c.uniPacket("OidbSvcTrpcTcp.0x1019_1", + s.c.packOIDBPackageDynamically(4121, 1, binary.DynamicProtoMessage{1: guildId})) rsp, err := s.c.sendAndWaitDynamic(seq, packet) if err != nil { return nil, errors.Wrap(err, "send packet error") @@ -332,9 +330,8 @@ func (s *GuildService) GetGuildRoles(guildId uint64) ([]*GuildRole, error) { } func (s *GuildService) CreateGuildRole(guildId uint64, name string, color uint32, independent bool, initialUsers []uint64) (uint64, error) { - seq := s.c.nextSeq() u1 := uint32(1) - packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x1016_1", s.c.packOIDBPackageDynamically(4118, 1, binary.DynamicProtoMessage{ + seq, packet := s.c.uniPacket("OidbSvcTrpcTcp.0x1016_1", s.c.packOIDBPackageDynamically(4118, 1, binary.DynamicProtoMessage{ 1: guildId, 2: binary.DynamicProtoMessage{ // todo: 未知参数 1: u1, @@ -360,8 +357,7 @@ func (s *GuildService) CreateGuildRole(guildId uint64, name string, color uint32 } func (s *GuildService) DeleteGuildRole(guildId uint64, roleId uint64) error { - seq := s.c.nextSeq() - packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x100e_1", s.c.packOIDBPackageDynamically(4110, 1, binary.DynamicProtoMessage{ + seq, packet := s.c.uniPacket("OidbSvcTrpcTcp.0x100e_1", s.c.packOIDBPackageDynamically(4110, 1, binary.DynamicProtoMessage{ 1: guildId, 2: roleId, })) @@ -373,7 +369,6 @@ func (s *GuildService) DeleteGuildRole(guildId uint64, roleId uint64) error { } func (s *GuildService) SetUserRoleInGuild(guildId uint64, set bool, roleId uint64, user []uint64) error { // remove => p2 = false - seq := s.c.nextSeq() setOrRemove := binary.DynamicProtoMessage{ 1: roleId, } @@ -382,7 +377,7 @@ func (s *GuildService) SetUserRoleInGuild(guildId uint64, set bool, roleId uint6 } else { setOrRemove[3] = user } - packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x101a_1", s.c.packOIDBPackageDynamically(4122, 1, binary.DynamicProtoMessage{ + seq, packet := s.c.uniPacket("OidbSvcTrpcTcp.0x101a_1", s.c.packOIDBPackageDynamically(4122, 1, binary.DynamicProtoMessage{ 1: guildId, 2: setOrRemove, })) @@ -394,10 +389,8 @@ func (s *GuildService) SetUserRoleInGuild(guildId uint64, set bool, roleId uint6 } func (s *GuildService) ModifyRoleInGuild(guildId uint64, roleId uint64, name string, color uint32, indepedent bool) error { - seq := s.c.nextSeq() - var packet []byte u1 := uint32(1) - packet = s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x100d_1", s.c.packOIDBPackageDynamically(4109, 1, binary.DynamicProtoMessage{ + seq, packet := s.c.uniPacket("OidbSvcTrpcTcp.0x100d_1", s.c.packOIDBPackageDynamically(4109, 1, binary.DynamicProtoMessage{ 1: guildId, 2: roleId, 3: binary.DynamicProtoMessage{ @@ -419,7 +412,6 @@ func (s *GuildService) ModifyRoleInGuild(guildId uint64, roleId uint64, name str } func (s *GuildService) FetchGuestGuild(guildId uint64) (*GuildMeta, error) { - seq := s.c.nextSeq() u1 := uint32(1) payload := s.c.packOIDBPackageDynamically(3927, 9, binary.DynamicProtoMessage{ 1: binary.DynamicProtoMessage{ @@ -435,7 +427,7 @@ func (s *GuildService) FetchGuestGuild(guildId uint64) (*GuildMeta, error) { 1: guildId, }, }) - packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xf57_9", payload) + seq, packet := s.c.uniPacket("OidbSvcTrpcTcp.0xf57_9", payload) rsp, err := s.c.sendAndWaitDynamic(seq, packet) if err != nil { return nil, errors.Wrap(err, "send packet error") @@ -457,8 +449,14 @@ func (s *GuildService) FetchGuestGuild(guildId uint64) (*GuildMeta, error) { } func (s *GuildService) FetchChannelList(guildId uint64) (r []*ChannelInfo, e error) { - seq := s.c.nextSeq() - packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xf5d_1", s.c.packOIDBPackageDynamically(3933, 1, binary.DynamicProtoMessage{1: guildId, 3: binary.DynamicProtoMessage{1: uint32(1)}})) + seq, packet := s.c.uniPacket("OidbSvcTrpcTcp.0xf5d_1", + s.c.packOIDBPackageDynamically(3933, 1, + binary.DynamicProtoMessage{ + 1: guildId, + 3: binary.DynamicProtoMessage{ + 1: uint32(1), + }, + })) rsp, err := s.c.sendAndWaitDynamic(seq, packet) if err != nil { return nil, errors.Wrap(err, "send packet error") @@ -474,8 +472,7 @@ func (s *GuildService) FetchChannelList(guildId uint64) (r []*ChannelInfo, e err } func (s *GuildService) FetchChannelInfo(guildId, channelId uint64) (*ChannelInfo, error) { - seq := s.c.nextSeq() - packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0xf55_1", s.c.packOIDBPackageDynamically(3925, 1, binary.DynamicProtoMessage{1: guildId, 2: channelId})) + seq, packet := s.c.uniPacket("OidbSvcTrpcTcp.0xf55_1", s.c.packOIDBPackageDynamically(3925, 1, binary.DynamicProtoMessage{1: guildId, 2: channelId})) rsp, err := s.c.sendAndWaitDynamic(seq, packet) if err != nil { return nil, errors.Wrap(err, "send packet error") @@ -529,8 +526,7 @@ func (s *GuildService) GetTopicChannelFeeds(guildId, channelId uint64) ([]*topic }, }, }) - seq := s.c.nextSeq() - packet := s.c.uniPacket(seq, "QChannelSvr.trpc.qchannel.commreader.ComReader.GetChannelTimelineFeeds", payload) + seq, packet := s.c.uniPacket("QChannelSvr.trpc.qchannel.commreader.ComReader.GetChannelTimelineFeeds", payload) rsp, err := s.c.sendAndWaitDynamic(seq, packet) if err != nil { return nil, errors.New("send packet error") @@ -600,8 +596,7 @@ func (s *GuildService) PostTopicChannelFeed(guildId, channelId uint64, feed *top }, }, }) - seq := s.c.nextSeq() - packet := s.c.uniPacket(seq, "QChannelSvr.trpc.qchannel.commwriter.ComWriter.PublishFeed", payload) + seq, packet := s.c.uniPacket("QChannelSvr.trpc.qchannel.commwriter.ComWriter.PublishFeed", payload) rsp, err := s.c.sendAndWaitDynamic(seq, packet) if err != nil { return errors.New("send packet error") @@ -621,9 +616,8 @@ func (s *GuildService) PostTopicChannelFeed(guildId, channelId uint64, feed *top } func (s *GuildService) fetchMemberRoles(guildId uint64, tinyId uint64) ([]*GuildRole, error) { - seq := s.c.nextSeq() u1 := uint32(1) - packet := s.c.uniPacket(seq, "OidbSvcTrpcTcp.0x1017_1", s.c.packOIDBPackageDynamically(4119, 1, binary.DynamicProtoMessage{ + seq, packet := s.c.uniPacket("OidbSvcTrpcTcp.0x1017_1", s.c.packOIDBPackageDynamically(4119, 1, binary.DynamicProtoMessage{ 1: guildId, 2: tinyId, 4: binary.DynamicProtoMessage{ @@ -734,15 +728,13 @@ func (c *QQClient) syncChannelFirstView() { } func (c *QQClient) buildSyncChannelFirstViewPacket() (uint16, []byte) { - seq := c.nextSeq() req := &channel.FirstViewReq{ LastMsgTime: proto.Uint64(0), Seq: proto.Uint32(0), DirectMessageFlag: proto.Uint32(1), } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "trpc.group_pro.synclogic.SyncLogic.SyncFirstView", payload) - return seq, packet + return c.uniPacket("trpc.group_pro.synclogic.SyncLogic.SyncFirstView", payload) } func decodeGuildPushFirstView(c *QQClient, _ *incomingPacketInfo, payload []byte) (interface{}, error) { diff --git a/client/guild_msg.go b/client/guild_msg.go index dc978f10..61ab8120 100644 --- a/client/guild_msg.go +++ b/client/guild_msg.go @@ -66,9 +66,8 @@ func (s *GuildService) SendGuildChannelMessage(guildId, channelId uint64, m *mes }, }, }} - seq := s.c.nextSeq() payload, _ := proto.Marshal(req) - packet := s.c.uniPacket(seq, "MsgProxy.SendMsg", payload) + seq, packet := s.c.uniPacket("MsgProxy.SendMsg", payload) rsp, err := s.c.sendAndWaitDynamic(seq, packet) if err != nil { return nil, errors.Wrap(err, "send packet error") @@ -215,8 +214,7 @@ func (s *GuildService) pullChannelMessages(guildId, channelId, beginSeq, endSeq, WithVersionFlag: &withVersionFlag, DirectMessageFlag: &directFlag, }) - seq := s.c.nextSeq() - packet := s.c.uniPacket(seq, "trpc.group_pro.synclogic.SyncLogic.GetChannelMsg", payload) + seq, packet := s.c.uniPacket("trpc.group_pro.synclogic.SyncLogic.GetChannelMsg", payload) rsp, err := s.c.sendAndWaitDynamic(seq, packet) if err != nil { return nil, errors.Wrap(err, "send packet error") @@ -229,7 +227,6 @@ func (s *GuildService) pullChannelMessages(guildId, channelId, beginSeq, endSeq, } func (c *QQClient) buildGuildImageStorePacket(guildId, channelId uint64, hash []byte, size uint64) (uint16, []byte) { - seq := c.nextSeq() payload, _ := proto.Marshal(&cmd0x388.D388ReqBody{ NetType: proto.Uint32(3), Subcmd: proto.Uint32(1), @@ -254,8 +251,7 @@ func (c *QQClient) buildGuildImageStorePacket(guildId, channelId uint64, hash [] }, CommandId: proto.Uint32(83), }) - packet := c.uniPacket(seq, "ImgStore.QQMeetPicUp", payload) - return seq, packet + return c.uniPacket("ImgStore.QQMeetPicUp", payload) } func decodeGuildMessageEmojiReactions(content *channel.ChannelMsgContent) (r []*message.GuildMessageEmojiReaction) { @@ -349,14 +345,12 @@ func (s *GuildService) parseGuildChannelMessage(msg *channel.ChannelMsgContent) // PttCenterSvr.GroupShortVideoUpReq func (c *QQClient) buildPttGuildVideoUpReq(videoHash, thumbHash []byte, guildId, channelId int64, videoSize, thumbSize int64) (uint16, []byte) { - seq := c.nextSeq() pb := c.buildPttGroupShortVideoProto(videoHash, thumbHash, guildId, videoSize, thumbSize, 4) pb.PttShortVideoUploadReq.BusinessType = 4601 pb.PttShortVideoUploadReq.ToUin = channelId pb.ExtensionReq[0].SubBusiType = 4601 payload, _ := proto.Marshal(pb) - packet := c.uniPacket(seq, "PttCenterSvr.GroupShortVideoUpReq", payload) - return seq, packet + return c.uniPacket("PttCenterSvr.GroupShortVideoUpReq", payload) } func (c *QQClient) UploadGuildShortVideo(guildId, channelId uint64, video, thumb io.ReadSeeker) (*message.ShortVideoElement, error) { diff --git a/client/image.go b/client/image.go index ae2ab360..e473a147 100644 --- a/client/image.go +++ b/client/image.go @@ -239,7 +239,6 @@ func (c *QQClient) QueryFriendImage(target int64, hash []byte, size int32) (*mes // ImgStore.GroupPicUp func (c *QQClient) buildGroupImageStorePacket(groupCode int64, md5 []byte, size int32) (uint16, []byte) { - seq := c.nextSeq() name := utils.RandomString(16) + ".gif" req := &cmd0x388.D388ReqBody{ NetType: proto.Uint32(3), @@ -264,12 +263,10 @@ func (c *QQClient) buildGroupImageStorePacket(groupCode int64, md5 []byte, size Extension: EmptyBytes, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "ImgStore.GroupPicUp", payload) - return seq, packet + return c.uniPacket("ImgStore.GroupPicUp", payload) } func (c *QQClient) buildGroupImageDownloadPacket(fileId, groupCode int64, fileMd5 []byte) (uint16, []byte) { - seq := c.nextSeq() req := &cmd0x388.D388ReqBody{ NetType: proto.Uint32(3), Subcmd: proto.Uint32(2), @@ -290,8 +287,7 @@ func (c *QQClient) buildGroupImageDownloadPacket(fileId, groupCode int64, fileMd }, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "ImgStore.GroupPicDown", payload) - return seq, packet + return c.uniPacket("ImgStore.GroupPicDown", payload) } func (c *QQClient) uploadOcrImage(img io.Reader) (string, error) { @@ -322,7 +318,6 @@ func (c *QQClient) uploadOcrImage(img io.Reader) (string, error) { // OidbSvc.0xe07_0 func (c *QQClient) buildImageOcrRequestPacket(url, md5 string, size, weight, height int32) (uint16, []byte) { - seq := c.nextSeq() body := &oidb.DE07ReqBody{ Version: 1, Entrance: 3, @@ -338,8 +333,7 @@ func (c *QQClient) buildImageOcrRequestPacket(url, md5 string, size, weight, hei } b, _ := proto.Marshal(body) payload := c.packOIDBPackage(3591, 0, b) - packet := c.uniPacket(seq, "OidbSvc.0xe07_0", payload) - return seq, packet + return c.uniPacket("OidbSvc.0xe07_0", payload) } // ImgStore.GroupPicUp diff --git a/client/multimsg.go b/client/multimsg.go index 59a47044..beace7d4 100644 --- a/client/multimsg.go +++ b/client/multimsg.go @@ -23,7 +23,6 @@ func init() { // MultiMsg.ApplyUp func (c *QQClient) buildMultiApplyUpPacket(data, hash []byte, buType int32, groupUin int64) (uint16, []byte) { - seq := c.nextSeq() req := &multimsg.MultiReqBody{ Subcmd: 1, TermType: 5, @@ -41,8 +40,7 @@ func (c *QQClient) buildMultiApplyUpPacket(data, hash []byte, buType int32, grou BuType: buType, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "MultiMsg.ApplyUp", payload) - return seq, packet + return c.uniPacket("MultiMsg.ApplyUp", payload) } // MultiMsg.ApplyUp @@ -66,7 +64,6 @@ func decodeMultiApplyUpResponse(_ *QQClient, _ *incomingPacketInfo, payload []by // MultiMsg.ApplyDown func (c *QQClient) buildMultiApplyDownPacket(resID string) (uint16, []byte) { - seq := c.nextSeq() req := &multimsg.MultiReqBody{ Subcmd: 2, TermType: 5, @@ -83,8 +80,7 @@ func (c *QQClient) buildMultiApplyDownPacket(resID string) (uint16, []byte) { ReqChannelType: 2, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "MultiMsg.ApplyDown", payload) - return seq, packet + return c.uniPacket("MultiMsg.ApplyDown", payload) } // MultiMsg.ApplyDown diff --git a/client/offline_file.go b/client/offline_file.go index 813fee9e..ca4986c2 100644 --- a/client/offline_file.go +++ b/client/offline_file.go @@ -28,7 +28,7 @@ func (c *QQClient) buildOfflineFileDownloadRequestPacket(uuid []byte) (uint16, [ }, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "OfflineFilleHandleSvr.pb_ftn_CMD_REQ_APPLY_DOWNLOAD-1200", payload) + packet := c.uniPacketWithSeq(seq, "OfflineFilleHandleSvr.pb_ftn_CMD_REQ_APPLY_DOWNLOAD-1200", payload) return seq, packet } diff --git a/client/packet.go b/client/packet.go index f28c50a7..e7b28a09 100644 --- a/client/packet.go +++ b/client/packet.go @@ -17,7 +17,7 @@ func (c *QQClient) buildOicqRequestPacket(uin int64, command uint16, body []byte } //go:noinline -func (c *QQClient) uniPacketWithSeq(command string, body []byte) (uint16, []byte) { +func (c *QQClient) uniPacket(command string, body []byte) (uint16, []byte) { seq := c.nextSeq() req := codec.Uni{ Uin: c.Uin, @@ -33,7 +33,7 @@ func (c *QQClient) uniPacketWithSeq(command string, body []byte) (uint16, []byte } //go:noinline -func (c *QQClient) uniPacket(seq uint16, command string, body []byte) []byte { +func (c *QQClient) uniPacketWithSeq(seq uint16, command string, body []byte) []byte { req := codec.Uni{ Uin: c.Uin, Seq: seq, diff --git a/client/private_msg.go b/client/private_msg.go index 6583509b..45e567de 100644 --- a/client/private_msg.go +++ b/client/private_msg.go @@ -146,7 +146,6 @@ func (c *QQClient) buildGetOneDayRoamMsgRequest(target, lastMsgTime, random int6 // MessageSvc.PbSendMsg func (c *QQClient) buildFriendSendingPacket(target int64, msgSeq, r, pkgNum, pkgIndex, pkgDiv int32, time int64, m []message.IMessageElement) (uint16, []byte) { - seq := c.nextSeq() var ptt *msg.Ptt if len(m) > 0 { if p, ok := m[0].(*message.PrivateVoiceElement); ok { @@ -179,13 +178,11 @@ func (c *QQClient) buildFriendSendingPacket(target int64, msgSeq, r, pkgNum, pkg }(), } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "MessageSvc.PbSendMsg", payload) - return seq, packet + return c.uniPacket("MessageSvc.PbSendMsg", payload) } // MessageSvc.PbSendMsg func (c *QQClient) buildGroupTempSendingPacket(groupUin, target int64, msgSeq, r int32, time int64, m *message.SendingMessage) (uint16, []byte) { - seq := c.nextSeq() req := &msg.SendMessageRequest{ RoutingHead: &msg.RoutingHead{GrpTmp: &msg.GrpTmp{ GroupUin: &groupUin, @@ -213,12 +210,10 @@ func (c *QQClient) buildGroupTempSendingPacket(groupUin, target int64, msgSeq, r }(), } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "MessageSvc.PbSendMsg", payload) - return seq, packet + return c.uniPacket("MessageSvc.PbSendMsg", payload) } func (c *QQClient) buildWPATempSendingPacket(uin int64, sig []byte, msgSeq, r int32, time int64, m *message.SendingMessage) (uint16, []byte) { - seq := c.nextSeq() req := &msg.SendMessageRequest{ RoutingHead: &msg.RoutingHead{WpaTmp: &msg.WPATmp{ ToUin: proto.Uint64(uint64(uin)), @@ -246,6 +241,5 @@ func (c *QQClient) buildWPATempSendingPacket(uin int64, sig []byte, msgSeq, r in }(), } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "MessageSvc.PbSendMsg", payload) - return seq, packet + return c.uniPacket("MessageSvc.PbSendMsg", payload) } diff --git a/client/ptt.go b/client/ptt.go index aafc20f8..ef99a214 100644 --- a/client/ptt.go +++ b/client/ptt.go @@ -247,7 +247,7 @@ func (c *QQClient) buildPttShortVideoDownReqPacket(uuid, md5 []byte) (uint16, [] }, } payload, _ := proto.Marshal(body) - packet := c.uniPacket(seq, "PttCenterSvr.ShortVideoDownReq", payload) + packet := c.uniPacketWithSeq(seq, "PttCenterSvr.ShortVideoDownReq", payload) return seq, packet } @@ -286,10 +286,8 @@ func (c *QQClient) buildPttGroupShortVideoProto(videoHash, thumbHash []byte, toU // PttCenterSvr.GroupShortVideoUpReq func (c *QQClient) buildPttGroupShortVideoUploadReqPacket(videoHash, thumbHash []byte, toUin, videoSize, thumbSize int64) (uint16, []byte) { - seq := c.nextSeq() payload, _ := proto.Marshal(c.buildPttGroupShortVideoProto(videoHash, thumbHash, toUin, videoSize, thumbSize, 1)) - packet := c.uniPacket(seq, "PttCenterSvr.GroupShortVideoUpReq", payload) - return seq, packet + return c.uniPacket("PttCenterSvr.GroupShortVideoUpReq", payload) } // PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_UPLOAD-500 diff --git a/client/qidian.go b/client/qidian.go index 25e4809f..70f8f4fe 100644 --- a/client/qidian.go +++ b/client/qidian.go @@ -63,7 +63,6 @@ func (c *QQClient) getQiDianAddressDetailList() ([]*FriendInfo, error) { } func (c *QQClient) buildLoginExtraPacket() (uint16, []byte) { - seq := c.nextSeq() req := &cmd0x3f6.C3F6ReqBody{ SubCmd: proto.Uint32(69), CrmCommonHead: &cmd0x3f6.C3F6CRMMsgHead{ @@ -86,12 +85,10 @@ func (c *QQClient) buildLoginExtraPacket() (uint16, []byte) { }, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "qidianservice.69", payload) - return seq, packet + return c.uniPacket("qidianservice.69", payload) } func (c *QQClient) buildConnKeyRequestPacket() (uint16, []byte) { - seq := c.nextSeq() req := &cmd0x6ff.C501ReqBody{ ReqBody: &cmd0x6ff.SubCmd0X501ReqBody{ Uin: proto.Uint64(uint64(c.Uin)), @@ -103,8 +100,7 @@ func (c *QQClient) buildConnKeyRequestPacket() (uint16, []byte) { }, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "HttpConn.0x6ff_501", payload) - return seq, packet + return c.uniPacket("HttpConn.0x6ff_501", payload) } func (c *QQClient) bigDataRequest(subCmd uint32, req proto.Message) ([]byte, error) { diff --git a/client/recall.go b/client/recall.go index c26ddfe0..2567be6e 100644 --- a/client/recall.go +++ b/client/recall.go @@ -44,7 +44,6 @@ func (c *QQClient) RecallPrivateMessage(uin, ts int64, msgID, msgInternalId int3 // PbMessageSvc.PbMsgWithDraw func (c *QQClient) buildGroupRecallPacket(groupCode int64, msgSeq, msgRan int32) (uint16, []byte) { - seq := c.nextSeq() req := &msg.MsgWithDrawReq{ GroupWithDraw: []*msg.GroupMsgWithDrawReq{ { @@ -62,12 +61,10 @@ func (c *QQClient) buildGroupRecallPacket(groupCode int64, msgSeq, msgRan int32) }, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "PbMessageSvc.PbMsgWithDraw", payload) - return seq, packet + return c.uniPacket("PbMessageSvc.PbMsgWithDraw", payload) } func (c *QQClient) buildPrivateRecallPacket(uin, ts int64, msgSeq, random int32) (uint16, []byte) { - seq := c.nextSeq() req := &msg.MsgWithDrawReq{C2CWithDraw: []*msg.C2CMsgWithDrawReq{ { MsgInfo: []*msg.C2CMsgInfo{ @@ -91,8 +88,7 @@ func (c *QQClient) buildPrivateRecallPacket(uin, ts int64, msgSeq, random int32) }, }} payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "PbMessageSvc.PbMsgWithDraw", payload) - return seq, packet + return c.uniPacket("PbMessageSvc.PbMsgWithDraw", payload) } func decodeMsgWithDrawResponse(_ *QQClient, _ *incomingPacketInfo, payload []byte) (interface{}, error) { diff --git a/client/richmsg.go b/client/richmsg.go index 1f78f772..efa3ba69 100644 --- a/client/richmsg.go +++ b/client/richmsg.go @@ -98,7 +98,6 @@ func (c *QQClient) SendGuildMusicShare(guildID, channelID uint64, msg *message.M // OidbSvc.0xb77_9 func (c *QQClient) buildRichMsgSendingPacket(guild uint64, target int64, msg *message.MusicShareElement, sendType uint32) (uint16, []byte) { - seq := c.nextSeq() tp := musicType[msg.MusicType] // MusicType msgStyle := uint32(0) if msg.MusicUrl != "" { @@ -129,6 +128,5 @@ func (c *QQClient) buildRichMsgSendingPacket(guild uint64, target int64, msg *me } b, _ := proto.Marshal(body) payload := c.packOIDBPackage(2935, 9, b) - packet := c.uniPacket(seq, "OidbSvc.0xb77_9", payload) - return seq, packet + return c.uniPacket("OidbSvc.0xb77_9", payload) } diff --git a/client/security.go b/client/security.go index 031da55a..bb3c6ca9 100644 --- a/client/security.go +++ b/client/security.go @@ -29,7 +29,6 @@ func (c *QQClient) CheckUrlSafely(url string) UrlSecurityLevel { } func (c *QQClient) buildUrlCheckRequest(url string) (uint16, []byte) { - seq := c.nextSeq() payload := c.packOIDBPackageProto(3019, 0, &oidb.DBCBReqBody{ CheckUrlReq: &oidb.CheckUrlReq{ Url: []string{url}, @@ -45,8 +44,7 @@ func (c *QQClient) buildUrlCheckRequest(url string) (uint16, []byte) { Qua: proto.String("AQQ_2013 4.6/2013 8.4.184945&NA_0/000000&ADR&null18&linux&2017&C2293D02BEE31158&7.1.2&V3"), }, }) - packet := c.uniPacket(seq, "OidbSvc.0xbcb_0", payload) - return seq, packet + return c.uniPacket("OidbSvc.0xbcb_0", payload) } func decodeUrlCheckResponse(_ *QQClient, _ *incomingPacketInfo, payload []byte) (interface{}, error) { diff --git a/client/sync.go b/client/sync.go index 66490d1e..4703de77 100644 --- a/client/sync.go +++ b/client/sync.go @@ -119,7 +119,6 @@ func (c *QQClient) MarkPrivateMessageReaded(uin, time int64) { // StatSvc.GetDevLoginInfo func (c *QQClient) buildDeviceListRequestPacket() (uint16, []byte) { - seq := c.nextSeq() req := &jce.SvcReqGetDevLoginInfo{ Guid: c.deviceInfo.Guid, LoginType: 1, @@ -136,13 +135,11 @@ func (c *QQClient) buildDeviceListRequestPacket() (uint16, []byte) { Context: make(map[string]string), Status: make(map[string]string), } - packet := c.uniPacket(seq, "StatSvc.GetDevLoginInfo", pkt.ToBytes()) - return seq, packet + return c.uniPacket("StatSvc.GetDevLoginInfo", pkt.ToBytes()) } // RegPrxySvc.getOffMsg func (c *QQClient) buildGetOfflineMsgRequestPacket() (uint16, []byte) { - seq := c.nextSeq() regReq := &jce.SvcReqRegisterNew{ RequestOptional: 0x101C2 | 32, C2CMsg: &jce.SvcReqGetMsgV2{ @@ -192,13 +189,11 @@ func (c *QQClient) buildGetOfflineMsgRequestPacket() (uint16, []byte) { Context: make(map[string]string), Status: make(map[string]string), } - packet := c.uniPacket(seq, "RegPrxySvc.getOffMsg", pkt.ToBytes()) - return seq, packet + return c.uniPacket("RegPrxySvc.getOffMsg", pkt.ToBytes()) } // RegPrxySvc.PbSyncMsg func (c *QQClient) buildSyncMsgRequestPacket() (uint16, []byte) { - seq := c.nextSeq() oidbReq, _ := proto.Marshal(&oidb.D769RspBody{ ConfigList: []*oidb.D769ConfigSeq{ { @@ -266,31 +261,26 @@ func (c *QQClient) buildSyncMsgRequestPacket() (uint16, []byte) { Context: make(map[string]string), Status: make(map[string]string), } - packet := c.uniPacket(seq, "RegPrxySvc.infoSync", pkt.ToBytes()) - return seq, packet + return c.uniPacket("RegPrxySvc.infoSync", pkt.ToBytes()) } // PbMessageSvc.PbMsgReadedReport func (c *QQClient) buildGroupMsgReadedPacket(groupCode, msgSeq int64) (uint16, []byte) { - seq := c.nextSeq() req, _ := proto.Marshal(&msg.PbMsgReadedReportReq{GrpReadReport: []*msg.PbGroupReadedReportReq{{ GroupCode: proto.Uint64(uint64(groupCode)), LastReadSeq: proto.Uint64(uint64(msgSeq)), }}}) - packet := c.uniPacket(seq, "PbMessageSvc.PbMsgReadedReport", req) - return seq, packet + return c.uniPacket("PbMessageSvc.PbMsgReadedReport", req) } func (c *QQClient) buildPrivateMsgReadedPacket(uin, time int64) (uint16, []byte) { - seq := c.nextSeq() req, _ := proto.Marshal(&msg.PbMsgReadedReportReq{C2CReadReport: &msg.PbC2CReadedReportReq{PairInfo: []*msg.UinPairReadInfo{ { PeerUin: proto.Uint64(uint64(uin)), LastReadTime: proto.Uint32(uint32(time)), }, }, SyncCookie: c.syncCookie}}) - packet := c.uniPacket(seq, "PbMessageSvc.PbMsgReadedReport", req) - return seq, packet + return c.uniPacket("PbMessageSvc.PbMsgReadedReport", req) } // StatSvc.GetDevLoginInfo diff --git a/client/system_msg.go b/client/system_msg.go index 5c8fd44d..5f782dc6 100644 --- a/client/system_msg.go +++ b/client/system_msg.go @@ -98,7 +98,6 @@ func (c *QQClient) exceptAndDispatchGroupSysMsg() { // ProfileService.Pb.ReqSystemMsgNew.Group func (c *QQClient) buildSystemMsgNewGroupPacket(suspicious bool) (uint16, []byte) { - seq := c.nextSeq() req := &structmsg.ReqSystemMsgNew{ MsgNum: 100, Version: 1000, @@ -130,13 +129,11 @@ func (c *QQClient) buildSystemMsgNewGroupPacket(suspicious bool) (uint16, []byte }(), } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "ProfileService.Pb.ReqSystemMsgNew.Group", payload) - return seq, packet + return c.uniPacket("ProfileService.Pb.ReqSystemMsgNew.Group", payload) } // ProfileService.Pb.ReqSystemMsgAction.Group func (c *QQClient) buildSystemMsgGroupActionPacket(reqID, requester, group int64, msgType int32, isInvite, accept, block bool, reason string) (uint16, []byte) { - seq := c.nextSeq() subSrcId := int32(31) groupMsgType := int32(1) if isInvite { @@ -165,13 +162,11 @@ func (c *QQClient) buildSystemMsgGroupActionPacket(reqID, requester, group int64 Language: 1000, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "ProfileService.Pb.ReqSystemMsgAction.Group", payload) - return seq, packet + return c.uniPacket("ProfileService.Pb.ReqSystemMsgAction.Group", payload) } // ProfileService.Pb.ReqSystemMsgAction.Friend func (c *QQClient) buildSystemMsgFriendActionPacket(reqID, requester int64, accept bool) (uint16, []byte) { - seq := c.nextSeq() infoType := int32(3) if accept { infoType = 2 @@ -190,8 +185,7 @@ func (c *QQClient) buildSystemMsgFriendActionPacket(reqID, requester int64, acce }, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "ProfileService.Pb.ReqSystemMsgAction.Friend", payload) - return seq, packet + return c.uniPacket("ProfileService.Pb.ReqSystemMsgAction.Friend", payload) } // ProfileService.Pb.ReqSystemMsgNew.Group diff --git a/client/translate.go b/client/translate.go index dcdb7e8d..a27f9032 100644 --- a/client/translate.go +++ b/client/translate.go @@ -8,7 +8,6 @@ import ( ) func (c *QQClient) buildTranslatePacket(src, dst, text string) (uint16, []byte) { - seq := c.nextSeq() body := &oidb.TranslateReqBody{ BatchTranslateReq: &oidb.BatchTranslateReq{ SrcLanguage: src, @@ -23,8 +22,7 @@ func (c *QQClient) buildTranslatePacket(src, dst, text string) (uint16, []byte) Bodybuffer: b, } payload, _ := proto.Marshal(req) - packet := c.uniPacket(seq, "OidbSvc.0x990", payload) - return seq, packet + return c.uniPacket("OidbSvc.0x990", payload) } func (c *QQClient) Translate(src, dst, text string) (string, error) { diff --git a/client/web.go b/client/web.go index 17e6edcf..47b13f7c 100644 --- a/client/web.go +++ b/client/web.go @@ -90,8 +90,7 @@ func (c *QQClient) webSsoRequest(host, webCmd, data string) (string, error) { Type: proto.Uint32(0), Data: &data, }) - seq := c.nextSeq() - rspData, err := c.sendAndWaitDynamic(seq, c.uniPacket(seq, cmd, req)) + rspData, err := c.sendAndWaitDynamic(c.uniPacket(cmd, req)) if err != nil { return "", errors.Wrap(err, "send web sso request error") }