mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
refactor: handle decode func in Request
This commit is contained in:
parent
f5b16b19c2
commit
6a71884235
@ -98,6 +98,7 @@ func (c *QQClient) buildLoginRequest() *network.Request {
|
||||
Uin: c.Uin,
|
||||
CommandName: "wtlogin.login",
|
||||
Body: req,
|
||||
Decode: bindDecoder(c, decodeLoginResponse),
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,6 +120,7 @@ func (c *QQClient) buildDeviceLockLoginRequest() *network.Request {
|
||||
Uin: c.Uin,
|
||||
CommandName: "wtlogin.login",
|
||||
Body: req,
|
||||
Decode: bindDecoder(c, decodeLoginResponse),
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,6 +154,7 @@ func (c *QQClient) buildQRCodeFetchRequest(size, margin, ecLevel uint32) *networ
|
||||
Uin: 0,
|
||||
CommandName: "wtlogin.trans_emp",
|
||||
Body: req,
|
||||
Decode: bindDecoder(c, decodeTransEmpResponse),
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,6 +183,7 @@ func (c *QQClient) buildQRCodeResultQueryRequest(sig []byte) *network.Request {
|
||||
Uin: 0,
|
||||
CommandName: "wtlogin.trans_emp",
|
||||
Body: req,
|
||||
Decode: bindDecoder(c, decodeTransEmpResponse),
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,6 +257,7 @@ func (c *QQClient) buildQRCodeLoginRequest(t106, t16a, t318 []byte) *network.Req
|
||||
Uin: c.Uin,
|
||||
CommandName: "wtlogin.login",
|
||||
Body: req,
|
||||
Decode: bindDecoder(c, decodeLoginResponse),
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,6 +280,7 @@ func (c *QQClient) buildCaptchaRequest(result string, sign []byte) *network.Requ
|
||||
Uin: c.Uin,
|
||||
CommandName: "wtlogin.login",
|
||||
Body: req,
|
||||
Decode: bindDecoder(c, decodeLoginResponse),
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,6 +305,7 @@ func (c *QQClient) buildSMSRequest() *network.Request {
|
||||
Uin: c.Uin,
|
||||
CommandName: "wtlogin.login",
|
||||
Body: req,
|
||||
Decode: bindDecoder(c, decodeLoginResponse),
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,6 +331,7 @@ func (c *QQClient) buildSMSCodeSubmitRequest(code string) *network.Request {
|
||||
Uin: c.Uin,
|
||||
CommandName: "wtlogin.login",
|
||||
Body: req,
|
||||
Decode: bindDecoder(c, decodeLoginResponse),
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,6 +354,7 @@ func (c *QQClient) buildTicketSubmitRequest(ticket string) *network.Request {
|
||||
Uin: c.Uin,
|
||||
CommandName: "wtlogin.login",
|
||||
Body: req,
|
||||
Decode: bindDecoder(c, decodeLoginResponse),
|
||||
}
|
||||
}
|
||||
|
||||
@ -416,6 +425,7 @@ func (c *QQClient) buildRequestTgtgtNopicsigRequest() *network.Request {
|
||||
Uin: c.Uin,
|
||||
SequenceID: int32(seq),
|
||||
CommandName: "wtlogin.exchange_emp",
|
||||
Decode: bindDecoder(c, decodeExchangeEmpResponse),
|
||||
Body: c.oicq.Marshal(&m),
|
||||
}
|
||||
}
|
||||
@ -470,6 +480,7 @@ func (c *QQClient) buildRequestChangeSigRequest(mainSigMap uint32) *network.Requ
|
||||
Uin: c.Uin,
|
||||
CommandName: "wtlogin.exchange_emp",
|
||||
Body: req,
|
||||
Decode: bindDecoder(c, decodeExchangeEmpResponse),
|
||||
}
|
||||
}
|
||||
|
||||
@ -524,6 +535,7 @@ func (c *QQClient) buildClientRegisterPacket() *network.Request {
|
||||
Uin: c.Uin,
|
||||
CommandName: "StatSvc.register",
|
||||
Body: pkt.ToBytes(),
|
||||
Decode: bindDecoder(c, decodeClientRegisterResponse),
|
||||
}
|
||||
}
|
||||
|
||||
@ -560,7 +572,7 @@ func (c *QQClient) buildStatusSetPacket(status, extStatus int32) *network.Reques
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.uniRequest("StatSvc.SetStatusFromClient", pkt.ToBytes())
|
||||
return c.uniRequest("StatSvc.SetStatusFromClient", pkt.ToBytes(), nil)
|
||||
}
|
||||
|
||||
// ConfigPushSvc.PushResp
|
||||
@ -580,7 +592,7 @@ func (c *QQClient) buildConfPushRespPacket(t int32, pktSeq int64, jceBuf []byte)
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.uniRequest("ConfigPushSvc.PushResp", pkt.ToBytes())
|
||||
return c.uniRequest("ConfigPushSvc.PushResp", pkt.ToBytes(), nil)
|
||||
}
|
||||
|
||||
// friendlist.getFriendGroupList
|
||||
@ -636,7 +648,7 @@ func (c *QQClient) buildFriendGroupListRequest(friendStartIndex, friendListCount
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.uniRequest("friendlist.getFriendGroupList", pkt.ToBytes())
|
||||
return c.uniRequest("friendlist.getFriendGroupList", pkt.ToBytes(), decodeFriendGroupListResponse)
|
||||
}
|
||||
|
||||
// SummaryCard.ReqSummaryCard
|
||||
@ -720,7 +732,7 @@ func (c *QQClient) buildSummaryCardRequest(target int64) *network.Request {
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.uniPacketWithSeq(seq, "SummaryCard.ReqSummaryCard", pkt.ToBytes())
|
||||
return c.uniPacketWithSeq(seq, "SummaryCard.ReqSummaryCard", pkt.ToBytes(), decodeSummaryCardResponse)
|
||||
}
|
||||
|
||||
// friendlist.delFriend
|
||||
@ -743,7 +755,7 @@ func (c *QQClient) buildFriendDeletePacket(target int64) *network.Request {
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.uniRequest("friendlist.delFriend", pkt.ToBytes())
|
||||
return c.uniRequest("friendlist.delFriend", pkt.ToBytes(), decodeFriendDeleteResponse)
|
||||
}
|
||||
|
||||
// friendlist.GetTroopListReqV2
|
||||
@ -772,7 +784,7 @@ func (c *QQClient) buildGroupListRequest(vecCookie []byte) *network.Request {
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.uniRequest("friendlist.GetTroopListReqV2", pkt.ToBytes())
|
||||
return c.uniRequest("friendlist.GetTroopListReqV2", pkt.ToBytes(), decodeGroupListResponse)
|
||||
}
|
||||
|
||||
// friendlist.GetTroopMemberListReq
|
||||
@ -798,7 +810,7 @@ func (c *QQClient) buildGroupMemberListRequest(groupUin, groupCode, nextUin int6
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.uniRequest("friendlist.GetTroopMemberListReq", pkt.ToBytes())
|
||||
return c.uniRequest("friendlist.GetTroopMemberListReq", pkt.ToBytes(), decodeGroupMemberListResponse)
|
||||
}
|
||||
|
||||
// group_member_card.get_group_member_card_info
|
||||
@ -811,7 +823,7 @@ func (c *QQClient) buildGroupMemberInfoRequest(groupCode, uin int64) *network.Re
|
||||
RichCardNameVer: 1,
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("group_member_card.get_group_member_card_info", payload)
|
||||
return c.uniRequest("group_member_card.get_group_member_card_info", payload, decodeGroupMemberInfoResponse)
|
||||
}
|
||||
|
||||
// MessageSvc.PbGetMsg
|
||||
@ -840,14 +852,14 @@ func (c *QQClient) buildGetMessageRequest(flag msg.SyncFlag, msgTime int64) *net
|
||||
ServerBuf: EmptyBytes,
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("MessageSvc.PbGetMsg", payload)
|
||||
return c.uniRequest("MessageSvc.PbGetMsg", payload, decodeMessageSvcPacket)
|
||||
}
|
||||
|
||||
// MessageSvc.PbDeleteMsg
|
||||
func (c *QQClient) buildDeleteMessageRequestPacket(msg []*pb.MessageItem) *network.Request {
|
||||
req := &pb.DeleteMessageRequest{Items: msg}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("MessageSvc.PbDeleteMsg", payload)
|
||||
return c.uniRequest("MessageSvc.PbDeleteMsg", payload, nil)
|
||||
}
|
||||
|
||||
// OnlinePush.RespPush
|
||||
@ -874,7 +886,7 @@ func (c *QQClient) buildDeleteOnlinePushPacket(uin int64, svrip int32, pushToken
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.transport.PackPacket(c.uniPacketWithSeq(seq, "OnlinePush.RespPush", pkt.ToBytes()))
|
||||
return c.transport.PackPacket(c.uniPacketWithSeq(seq, "OnlinePush.RespPush", pkt.ToBytes(), nil))
|
||||
}
|
||||
|
||||
// LongConn.OffPicUp
|
||||
@ -901,7 +913,7 @@ func (c *QQClient) buildOffPicUpRequest(target int64, md5 []byte, size int32) *n
|
||||
},
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("LongConn.OffPicUp", payload)
|
||||
return c.uniRequest("LongConn.OffPicUp", payload, decodeOffPicUpResponse)
|
||||
}
|
||||
|
||||
// ProfileService.Pb.ReqSystemMsgNew.Friend
|
||||
@ -920,7 +932,7 @@ func (c *QQClient) buildSystemMsgNewFriendRequest() *network.Request {
|
||||
FriendMsgTypeFlag: 1,
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("ProfileService.Pb.ReqSystemMsgNew.Friend", payload)
|
||||
return c.uniRequest("ProfileService.Pb.ReqSystemMsgNew.Friend", payload, decodeSystemMsgFriendPacket)
|
||||
}
|
||||
|
||||
// friendlist.ModifyGroupCardReq
|
||||
@ -945,7 +957,7 @@ func (c *QQClient) buildEditGroupTagPacket(groupCode, memberUin int64, newTag st
|
||||
Context: map[string]string{},
|
||||
Status: map[string]string{},
|
||||
}
|
||||
return c.uniRequest("friendlist.ModifyGroupCardReq", pkt.ToBytes())
|
||||
return c.uniRequest("friendlist.ModifyGroupCardReq", pkt.ToBytes(), nil)
|
||||
}
|
||||
|
||||
// OidbSvc.0x8fc_2
|
||||
@ -963,14 +975,14 @@ func (c *QQClient) buildEditSpecialTitlePacket(groupCode, memberUin int64, newTi
|
||||
}
|
||||
b, _ := proto.Marshal(body)
|
||||
payload := c.packOIDBPackage(2300, 2, b)
|
||||
return c.uniRequest("OidbSvc.0x8fc_2", payload)
|
||||
return c.uniRequest("OidbSvc.0x8fc_2", payload, nil)
|
||||
}
|
||||
|
||||
// OidbSvc.0x89a_0
|
||||
func (c *QQClient) buildGroupOperationPacket(body *oidb.D89AReqBody) *network.Request {
|
||||
b, _ := proto.Marshal(body)
|
||||
payload := c.packOIDBPackage(2202, 0, b)
|
||||
return c.uniRequest("OidbSvc.0x89a_0", payload)
|
||||
return c.uniRequest("OidbSvc.0x89a_0", payload, nil)
|
||||
}
|
||||
|
||||
// OidbSvc.0x89a_0
|
||||
@ -1028,7 +1040,7 @@ func (c *QQClient) buildGroupKickPacket(groupCode, memberUin int64, kickMsg stri
|
||||
}
|
||||
b, _ := proto.Marshal(body)
|
||||
payload := c.packOIDBPackage(2208, 0, b)
|
||||
return c.uniRequest("OidbSvc.0x8a0_0", payload)
|
||||
return c.uniRequest("OidbSvc.0x8a0_0", payload, nil)
|
||||
}
|
||||
|
||||
// OidbSvc.0x570_8
|
||||
@ -1042,7 +1054,7 @@ func (c *QQClient) buildGroupMutePacket(groupCode, memberUin int64, time uint32)
|
||||
})
|
||||
payload := c.packOIDBPackage(1392, 8, b)
|
||||
cl()
|
||||
return c.uniRequest("OidbSvc.0x570_8", payload)
|
||||
return c.uniRequest("OidbSvc.0x570_8", payload, nil)
|
||||
}
|
||||
|
||||
// OidbSvc.0xed3
|
||||
@ -1053,7 +1065,7 @@ func (c *QQClient) buildGroupPokeRequest(groupCode, target int64) *network.Reque
|
||||
}
|
||||
b, _ := proto.Marshal(body)
|
||||
payload := c.packOIDBPackage(3795, 1, b)
|
||||
return c.uniRequest("OidbSvc.0xed3", payload)
|
||||
return c.uniRequest("OidbSvc.0xed3", payload, nil)
|
||||
}
|
||||
|
||||
// OidbSvc.0xed3
|
||||
@ -1064,7 +1076,7 @@ func (c *QQClient) buildFriendPokeRequest(target int64) *network.Request {
|
||||
}
|
||||
b, _ := proto.Marshal(body)
|
||||
payload := c.packOIDBPackage(3795, 1, b)
|
||||
return c.uniRequest("OidbSvc.0xed3", payload)
|
||||
return c.uniRequest("OidbSvc.0xed3", payload, nil)
|
||||
}
|
||||
|
||||
// OidbSvc.0x55c_1
|
||||
@ -1076,7 +1088,7 @@ func (c *QQClient) buildGroupAdminSetPacket(groupCode, member int64, flag bool)
|
||||
})
|
||||
payload := c.packOIDBPackage(1372, 1, b)
|
||||
cl()
|
||||
return c.uniRequest("OidbSvc.0x55c_1", payload)
|
||||
return c.uniRequest("OidbSvc.0x55c_1", payload, nil)
|
||||
}
|
||||
|
||||
// ProfileService.GroupMngReq
|
||||
@ -1100,7 +1112,7 @@ func (c *QQClient) buildQuitGroupPacket(groupCode int64) *network.Request {
|
||||
Context: map[string]string{},
|
||||
Status: map[string]string{},
|
||||
}
|
||||
return c.uniRequest("ProfileService.GroupMngReq", pkt.ToBytes())
|
||||
return c.uniRequest("ProfileService.GroupMngReq", pkt.ToBytes(), nil)
|
||||
}
|
||||
|
||||
/* this function is unused
|
||||
@ -1131,5 +1143,5 @@ func (c *QQClient) buildWordSegmentationPacket(data []byte) *network.Request {
|
||||
Content: data,
|
||||
Qua: []byte("and_537065262_8.4.5"),
|
||||
})
|
||||
return c.uniRequest("OidbSvc.0xd79", payload)
|
||||
return c.uniRequest("OidbSvc.0xd79", payload, decodeWordSegmentation)
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func (c *QQClient) c2cMessageSyncProcessor(rsp *msg.GetMessageResponse, resp *ne
|
||||
c.Debug("continue sync with flag: %v", rsp.SyncFlag)
|
||||
req := c.buildGetMessageRequest(rsp.GetSyncFlag(), time.Now().Unix())
|
||||
req.Params = resp.Params
|
||||
_, _ = c.callAndDecode(req, decodeMessageSvcPacket)
|
||||
_, _ = c.callAndDecode(req)
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,8 +257,7 @@ func msgType0x211Decoder(c *QQClient, pMsg *msg.Message, info *network.Response)
|
||||
return
|
||||
}
|
||||
if sub4.NotOnlineFile != nil && sub4.NotOnlineFile.GetSubcmd() == 1 { // subcmd: 1 -> sendPacket, 2-> recv
|
||||
rsp, err := c.callAndDecode(c.buildOfflineFileDownloadRequestPacket(sub4.NotOnlineFile.FileUuid),
|
||||
decodeOfflineFileDownloadResponse) // offline_file.go
|
||||
rsp, err := c.callAndDecode(c.buildOfflineFileDownloadRequestPacket(sub4.NotOnlineFile.FileUuid)) // offline_file.go
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ type QQClient struct {
|
||||
|
||||
// todo: combine net conn, transport, pending into one struct
|
||||
pendingMu sync.Mutex
|
||||
pending map[uint16]*network.Call
|
||||
pending map[int32]*network.Call
|
||||
// TCP *network.TCPListener
|
||||
transport *network.Transport
|
||||
oicq *oicq.Codec
|
||||
@ -143,7 +143,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
|
||||
alive: true,
|
||||
highwaySession: new(highway.Session),
|
||||
|
||||
pending: make(map[uint16]*network.Call),
|
||||
pending: make(map[int32]*network.Call),
|
||||
version: new(auth.AppVersion),
|
||||
deviceInfo: new(auth.Device),
|
||||
}
|
||||
@ -239,7 +239,7 @@ func (c *QQClient) Login() (*LoginResponse, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rsp, err := c.callAndDecode(c.buildLoginRequest(), decodeLoginResponse)
|
||||
rsp, err := c.callAndDecode(c.buildLoginRequest())
|
||||
if err != nil {
|
||||
c.Disconnect()
|
||||
return nil, err
|
||||
@ -270,7 +270,7 @@ func (c *QQClient) ReLogin() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = c.callAndDecode(c.buildRequestChangeSigRequest(c.version.MainSigMap), decodeExchangeEmpResponse)
|
||||
_, err = c.callAndDecode(c.buildRequestChangeSigRequest(c.version.MainSigMap))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -397,7 +397,7 @@ func (c *QQClient) FetchQRCodeCustomSize(size, margin, ecLevel uint32) (*QRCodeL
|
||||
return nil, err
|
||||
}
|
||||
c.transport.Version = auth.AndroidWatch.Version()
|
||||
i, err := c.callAndDecode(c.buildQRCodeFetchRequest(size, margin, ecLevel), decodeTransEmpResponse)
|
||||
i, err := c.callAndDecode(c.buildQRCodeFetchRequest(size, margin, ecLevel))
|
||||
c.transport.Version = c.version
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "fetch qrcode error")
|
||||
@ -407,7 +407,7 @@ func (c *QQClient) FetchQRCodeCustomSize(size, margin, ecLevel uint32) (*QRCodeL
|
||||
|
||||
func (c *QQClient) QueryQRCodeStatus(sig []byte) (*QRCodeLoginResponse, error) {
|
||||
c.transport.Version = auth.AndroidWatch.Version()
|
||||
i, err := c.callAndDecode(c.buildQRCodeResultQueryRequest(sig), decodeTransEmpResponse)
|
||||
i, err := c.callAndDecode(c.buildQRCodeResultQueryRequest(sig))
|
||||
c.transport.Version = c.version
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "query result error")
|
||||
@ -416,7 +416,7 @@ func (c *QQClient) QueryQRCodeStatus(sig []byte) (*QRCodeLoginResponse, error) {
|
||||
}
|
||||
|
||||
func (c *QQClient) QRCodeLogin(info *QRCodeLoginInfo) (*LoginResponse, error) {
|
||||
i, err := c.callAndDecode(c.buildQRCodeLoginRequest(info.tmpPwd, info.tmpNoPicSig, info.tgtQR), decodeLoginResponse)
|
||||
i, err := c.callAndDecode(c.buildQRCodeLoginRequest(info.tmpPwd, info.tmpNoPicSig, info.tgtQR))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "qrcode login error")
|
||||
}
|
||||
@ -430,7 +430,7 @@ func (c *QQClient) QRCodeLogin(info *QRCodeLoginInfo) (*LoginResponse, error) {
|
||||
// SubmitCaptcha send captcha to server
|
||||
func (c *QQClient) SubmitCaptcha(result string, sign []byte) (*LoginResponse, error) {
|
||||
req := c.buildCaptchaRequest(result, sign)
|
||||
rsp, err := c.callAndDecode(req, decodeLoginResponse)
|
||||
rsp, err := c.callAndDecode(req)
|
||||
if err != nil {
|
||||
c.Disconnect()
|
||||
return nil, err
|
||||
@ -444,7 +444,7 @@ func (c *QQClient) SubmitCaptcha(result string, sign []byte) (*LoginResponse, er
|
||||
|
||||
func (c *QQClient) SubmitTicket(ticket string) (*LoginResponse, error) {
|
||||
req := c.buildTicketSubmitRequest(ticket)
|
||||
rsp, err := c.callAndDecode(req, decodeLoginResponse)
|
||||
rsp, err := c.callAndDecode(req)
|
||||
if err != nil {
|
||||
c.Disconnect()
|
||||
return nil, err
|
||||
@ -457,7 +457,7 @@ func (c *QQClient) SubmitTicket(ticket string) (*LoginResponse, error) {
|
||||
}
|
||||
|
||||
func (c *QQClient) SubmitSMS(code string) (*LoginResponse, error) {
|
||||
rsp, err := c.callAndDecode(c.buildSMSCodeSubmitRequest(code), decodeLoginResponse)
|
||||
rsp, err := c.callAndDecode(c.buildSMSCodeSubmitRequest(code))
|
||||
if err != nil {
|
||||
c.Disconnect()
|
||||
return nil, err
|
||||
@ -470,7 +470,7 @@ func (c *QQClient) SubmitSMS(code string) (*LoginResponse, error) {
|
||||
}
|
||||
|
||||
func (c *QQClient) RequestSMS() bool {
|
||||
rsp, err := c.callAndDecode(c.buildSMSRequest(), decodeLoginResponse)
|
||||
rsp, err := c.callAndDecode(c.buildSMSRequest())
|
||||
if err != nil {
|
||||
c.Error("request sms error: %v", err)
|
||||
return false
|
||||
@ -507,13 +507,13 @@ func (c *QQClient) init(tokenLogin bool) error {
|
||||
go c.doHeartbeat()
|
||||
_ = c.RefreshStatus()
|
||||
if c.version.Protocol == auth.QiDian {
|
||||
_, _ = c.callAndDecode(c.buildLoginExtraPacket(), decodeLoginExtraResponse) // 小登录
|
||||
_, _ = c.callAndDecode(c.buildConnKeyRequestPacket(), decodeConnKeyResponse) // big data key 如果等待 config push 的话时间来不及
|
||||
_, _ = c.callAndDecode(c.buildLoginExtraPacket()) // 小登录
|
||||
_, _ = c.callAndDecode(c.buildConnKeyRequestPacket()) // big data key 如果等待 config push 的话时间来不及
|
||||
}
|
||||
c.groupSysMsgCache, _ = c.GetGroupSystemMessages()
|
||||
req := c.buildGetMessageRequest(msg.SyncFlag_START, time.Now().Unix())
|
||||
req.Params = network.Params{"used_reg_proxy": true, "init": true}
|
||||
_, _ = c.callAndDecode(req, decodeMessageSvcPacket)
|
||||
_, _ = c.callAndDecode(req)
|
||||
c.syncChannelFirstView()
|
||||
return nil
|
||||
}
|
||||
@ -542,7 +542,7 @@ func (c *QQClient) SetOnlineStatus(s UserOnlineStatus) {
|
||||
}
|
||||
|
||||
func (c *QQClient) GetWordSegmentation(text string) ([]string, error) {
|
||||
rsp, err := c.callAndDecode(c.buildWordSegmentationPacket([]byte(text)), decodeWordSegmentation)
|
||||
rsp, err := c.callAndDecode(c.buildWordSegmentationPacket([]byte(text)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -557,7 +557,7 @@ func (c *QQClient) GetWordSegmentation(text string) ([]string, error) {
|
||||
}
|
||||
|
||||
func (c *QQClient) GetSummaryInfo(target int64) (*SummaryCardInfo, error) {
|
||||
rsp, err := c.callAndDecode(c.buildSummaryCardRequest(target), decodeSummaryCardResponse)
|
||||
rsp, err := c.callAndDecode(c.buildSummaryCardRequest(target))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -589,7 +589,7 @@ func (c *QQClient) GetFriendList() (*FriendListResponse, error) {
|
||||
r := &FriendListResponse{}
|
||||
for {
|
||||
call := c.buildFriendGroupListRequest(int16(curFriendCount), 150, 0, 0)
|
||||
rsp, err := c.callAndDecode(call, decodeFriendGroupListResponse)
|
||||
rsp, err := c.callAndDecode(call)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -624,7 +624,7 @@ func (c *QQClient) ReloadGroupList() error {
|
||||
}
|
||||
|
||||
func (c *QQClient) GetGroupList() ([]*GroupInfo, error) {
|
||||
rsp, err := c.callAndDecode(c.buildGroupListRequest(EmptyBytes), decodeGroupListResponse)
|
||||
rsp, err := c.callAndDecode(c.buildGroupListRequest(EmptyBytes))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -656,7 +656,7 @@ func (c *QQClient) GetGroupMembers(group *GroupInfo) ([]*GroupMemberInfo, error)
|
||||
var nextUin int64
|
||||
var list []*GroupMemberInfo
|
||||
for {
|
||||
data, err := c.callAndDecode(c.buildGroupMemberListRequest(group.Uin, group.Code, nextUin), decodeGroupMemberListResponse)
|
||||
data, err := c.callAndDecode(c.buildGroupMemberListRequest(group.Uin, group.Code, nextUin))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -682,7 +682,7 @@ func (c *QQClient) GetGroupMembers(group *GroupInfo) ([]*GroupMemberInfo, error)
|
||||
}
|
||||
|
||||
func (c *QQClient) GetMemberInfo(groupCode, memberUin int64) (*GroupMemberInfo, error) {
|
||||
info, err := c.callAndDecode(c.buildGroupMemberInfoRequest(groupCode, memberUin), decodeGroupMemberInfoResponse)
|
||||
info, err := c.callAndDecode(c.buildGroupMemberInfoRequest(groupCode, memberUin))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -703,7 +703,7 @@ func (c *QQClient) DeleteFriend(uin int64) error {
|
||||
if c.FindFriend(uin) == nil {
|
||||
return errors.New("friend not found")
|
||||
}
|
||||
_, err := c.callAndDecode(c.buildFriendDeletePacket(uin), decodeFriendDeleteResponse)
|
||||
_, err := c.callAndDecode(c.buildFriendDeletePacket(uin))
|
||||
return errors.Wrap(err, "delete friend error")
|
||||
}
|
||||
|
||||
@ -755,7 +755,7 @@ func (c *QQClient) SolveFriendRequest(req *NewFriendRequest, accept bool) {
|
||||
func (c *QQClient) getSKey() string {
|
||||
if c.sig.SKeyExpiredTime < time.Now().Unix() && len(c.sig.G) > 0 {
|
||||
c.Debug("skey expired. refresh...")
|
||||
_, _ = c.callAndDecode(c.buildRequestTgtgtNopicsigRequest(), decodeExchangeEmpResponse)
|
||||
_, _ = c.callAndDecode(c.buildRequestTgtgtNopicsigRequest())
|
||||
}
|
||||
return string(c.sig.SKey)
|
||||
}
|
||||
@ -835,7 +835,7 @@ func (c *QQClient) SetCustomServer(servers []*net.TCPAddr) {
|
||||
}
|
||||
|
||||
func (c *QQClient) registerClient() error {
|
||||
_, err := c.callAndDecode(c.buildClientRegisterPacket(), decodeClientRegisterResponse)
|
||||
_, err := c.callAndDecode(c.buildClientRegisterPacket())
|
||||
if err == nil {
|
||||
c.Online.Store(true)
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ func decodeLoginResponse(c *QQClient, resp *network.Response) (interface{}, erro
|
||||
if t == 204 {
|
||||
c.sig.T104 = m[0x104]
|
||||
c.sig.RandSeed = m[0x403]
|
||||
return c.callAndDecode(c.buildDeviceLockLoginRequest(), decodeLoginResponse)
|
||||
return c.callAndDecode(c.buildDeviceLockLoginRequest())
|
||||
} // drive lock
|
||||
|
||||
if t149, ok := m[0x149]; ok {
|
||||
@ -387,7 +387,7 @@ func decodeSvcNotify(c *QQClient, resp *network.Response) (interface{}, error) {
|
||||
data := &jce.RequestDataVersion2{}
|
||||
data.ReadFrom(jce.NewJceReader(request.SBuffer))
|
||||
if len(data.Map) == 0 {
|
||||
_, err := c.callAndDecode(c.buildGetMessageRequest(msg.SyncFlag_START, time.Now().Unix()), decodeMessageSvcPacket)
|
||||
_, err := c.callAndDecode(c.buildGetMessageRequest(msg.SyncFlag_START, time.Now().Unix()))
|
||||
return nil, err
|
||||
}
|
||||
notify := &jce.RequestPushNotify{}
|
||||
@ -399,11 +399,11 @@ func decodeSvcNotify(c *QQClient, resp *network.Response) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
if typ == sysMsgDecoders {
|
||||
_, err := c.callAndDecode(c.buildSystemMsgNewFriendRequest(), decodeSystemMsgFriendPacket)
|
||||
_, err := c.callAndDecode(c.buildSystemMsgNewFriendRequest())
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
_, err := c.callAndDecode(c.buildGetMessageRequest(msg.SyncFlag_START, time.Now().Unix()), decodeMessageSvcPacket)
|
||||
_, err := c.callAndDecode(c.buildGetMessageRequest(msg.SyncFlag_START, time.Now().Unix()))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -516,7 +516,7 @@ func decodeGroupListResponse(c *QQClient, resp *network.Response) (interface{},
|
||||
})
|
||||
}
|
||||
if len(vecCookie) > 0 {
|
||||
rsp, err := c.callAndDecode(c.buildGroupListRequest(vecCookie), decodeGroupListResponse)
|
||||
rsp, err := c.callAndDecode(c.buildGroupListRequest(vecCookie))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -796,14 +796,14 @@ func decodeWordSegmentation(_ *QQClient, resp *network.Response) (interface{}, e
|
||||
}
|
||||
|
||||
func decodeSidExpiredPacket(c *QQClient, resp *network.Response) (interface{}, error) {
|
||||
_, err := c.callAndDecode(c.buildRequestChangeSigRequest(3554528), decodeExchangeEmpResponse)
|
||||
_, err := c.callAndDecode(c.buildRequestChangeSigRequest(3554528))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "resign client error")
|
||||
}
|
||||
if err = c.registerClient(); err != nil {
|
||||
return nil, errors.Wrap(err, "register error")
|
||||
}
|
||||
_, _ = c.call(c.uniPacketWithSeq(uint16(resp.SequenceID), "OnlinePush.SidTicketExpired", EmptyBytes))
|
||||
_, _ = c.call(c.uniPacketWithSeq(uint16(resp.SequenceID), "OnlinePush.SidTicketExpired", EmptyBytes, nil))
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ type CustomFace struct {
|
||||
}
|
||||
|
||||
func (c *QQClient) GetCustomFaces() ([]*CustomFace, error) {
|
||||
i, err := c.callAndDecode(c.buildFaceroamRequestPacket(), decodeFaceroamResponse)
|
||||
i, err := c.callAndDecode(c.buildFaceroamRequestPacket())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get faces error")
|
||||
}
|
||||
@ -34,7 +34,7 @@ func (c *QQClient) buildFaceroamRequestPacket() *network.Request {
|
||||
SubCmd: proto.Uint32(1),
|
||||
ReqUserInfo: &faceroam.ReqUserInfo{},
|
||||
})
|
||||
return c.uniRequest("Faceroam.OpReq", payload)
|
||||
return c.uniRequest("Faceroam.OpReq", payload, decodeFaceroamResponse)
|
||||
}
|
||||
|
||||
func decodeFaceroamResponse(c *QQClient, resp *network.Response) (interface{}, error) {
|
||||
|
@ -68,7 +68,7 @@ func (c *QQClient) GetGroupFileSystem(groupCode int64) (fs *GroupFileSystem, err
|
||||
if g == nil {
|
||||
return nil, errors.New("group not found")
|
||||
}
|
||||
rsp, e := c.callAndDecode(c.buildGroupFileCountRequest(groupCode), decodeOIDB6d81Response)
|
||||
rsp, e := c.callAndDecode(c.buildGroupFileCountRequest(groupCode))
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
@ -78,7 +78,7 @@ func (c *QQClient) GetGroupFileSystem(groupCode int64) (fs *GroupFileSystem, err
|
||||
GroupCode: groupCode,
|
||||
client: c,
|
||||
}
|
||||
rsp, err = c.callAndDecode(c.buildGroupFileSpaceRequest(groupCode), decodeOIDB6d81Response)
|
||||
rsp, err = c.callAndDecode(c.buildGroupFileSpaceRequest(groupCode))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -88,7 +88,7 @@ func (c *QQClient) GetGroupFileSystem(groupCode int64) (fs *GroupFileSystem, err
|
||||
}
|
||||
|
||||
func (c *QQClient) GetGroupFileUrl(groupCode int64, fileId string, busId int32) string {
|
||||
i, err := c.callAndDecode(c.buildGroupFileDownloadReq(groupCode, fileId, busId), decodeOIDB6d62Response)
|
||||
i, err := c.callAndDecode(c.buildGroupFileDownloadReq(groupCode, fileId, busId))
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
@ -107,7 +107,7 @@ func (fs *GroupFileSystem) GetFilesByFolder(folderID string) ([]*GroupFile, []*G
|
||||
var folders []*GroupFolder
|
||||
for {
|
||||
req := fs.client.buildGroupFileListRequest(fs.GroupCode, folderID, startIndex)
|
||||
i, err := fs.client.callAndDecode(req, decodeOIDB6d81Response)
|
||||
i, err := fs.client.callAndDecode(req)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -168,7 +168,7 @@ func (fs *GroupFileSystem) UploadFile(p, name, folderId string) error {
|
||||
sha1Hash := sha1H.Sum(nil)
|
||||
_, _ = file.Seek(0, io.SeekStart)
|
||||
req := fs.client.buildGroupFileUploadReq(folderId, name, fs.GroupCode, size, md5Hash, sha1Hash)
|
||||
i, err := fs.client.callAndDecode(req, decodeOIDB6d60Response)
|
||||
i, err := fs.client.callAndDecode(req)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "query upload failed")
|
||||
}
|
||||
@ -238,21 +238,21 @@ func (fs *GroupFileSystem) GetDownloadUrl(file *GroupFile) string {
|
||||
}
|
||||
|
||||
func (fs *GroupFileSystem) CreateFolder(parentFolder, name string) error {
|
||||
if _, err := fs.client.callAndDecode(fs.client.buildGroupFileCreateFolderRequest(fs.GroupCode, parentFolder, name), decodeOIDB6d7Response); err != nil {
|
||||
if _, err := fs.client.callAndDecode(fs.client.buildGroupFileCreateFolderRequest(fs.GroupCode, parentFolder, name)); err != nil {
|
||||
return errors.Wrap(err, "create folder error")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fs *GroupFileSystem) RenameFolder(folderId, newName string) error {
|
||||
if _, err := fs.client.callAndDecode(fs.client.buildGroupFileRenameFolderRequest(fs.GroupCode, folderId, newName), decodeOIDB6d7Response); err != nil {
|
||||
if _, err := fs.client.callAndDecode(fs.client.buildGroupFileRenameFolderRequest(fs.GroupCode, folderId, newName)); err != nil {
|
||||
return errors.Wrap(err, "rename folder error")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fs *GroupFileSystem) DeleteFolder(folderId string) error {
|
||||
if _, err := fs.client.callAndDecode(fs.client.buildGroupFileDeleteFolderRequest(fs.GroupCode, folderId), decodeOIDB6d7Response); err != nil {
|
||||
if _, err := fs.client.callAndDecode(fs.client.buildGroupFileDeleteFolderRequest(fs.GroupCode, folderId)); err != nil {
|
||||
return errors.Wrap(err, "rename folder error")
|
||||
}
|
||||
return nil
|
||||
@ -261,7 +261,7 @@ func (fs *GroupFileSystem) DeleteFolder(folderId string) error {
|
||||
// DeleteFile 删除群文件,需要管理权限.
|
||||
// 返回错误, 空为删除成功
|
||||
func (fs *GroupFileSystem) DeleteFile(parentFolderID, fileId string, busId int32) string {
|
||||
i, err := fs.client.callAndDecode(fs.client.buildGroupFileDeleteReq(fs.GroupCode, parentFolderID, fileId, busId), decodeOIDB6d63Response)
|
||||
i, err := fs.client.callAndDecode(fs.client.buildGroupFileDeleteReq(fs.GroupCode, parentFolderID, fileId, busId))
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
@ -289,7 +289,7 @@ func (c *QQClient) buildGroupFileUploadReq(parentFolderID, fileName string, grou
|
||||
ClientVersion: "android 8.4.8",
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("OidbSvc.0x6d6_0", payload)
|
||||
return c.uniRequest("OidbSvc.0x6d6_0", payload, decodeOIDB6d60Response)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildGroupFileFeedsRequest(groupCode int64, fileID string, busId, msgRand int32) *network.Request {
|
||||
@ -303,7 +303,7 @@ func (c *QQClient) buildGroupFileFeedsRequest(groupCode int64, fileID string, bu
|
||||
MsgRandom: proto.Uint32(uint32(msgRand)),
|
||||
}},
|
||||
}})
|
||||
return c.uniRequest("OidbSvc.0x6d9_4", req)
|
||||
return c.uniRequest("OidbSvc.0x6d9_4", req, nil)
|
||||
}
|
||||
|
||||
// OidbSvc.0x6d8_1
|
||||
@ -329,7 +329,7 @@ func (c *QQClient) buildGroupFileListRequest(groupCode int64, folderID string, s
|
||||
ClientVersion: "android 8.4.8",
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("OidbSvc.0x6d8_1", payload)
|
||||
return c.uniRequest("OidbSvc.0x6d8_1", payload, decodeOIDB6d81Response)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildGroupFileCountRequest(groupCode int64) *network.Request {
|
||||
@ -346,7 +346,7 @@ func (c *QQClient) buildGroupFileCountRequest(groupCode int64) *network.Request
|
||||
ClientVersion: "android 8.4.8",
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("OidbSvc.0x6d8_1", payload)
|
||||
return c.uniRequest("OidbSvc.0x6d8_1", payload, decodeOIDB6d81Response)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildGroupFileSpaceRequest(groupCode int64) *network.Request {
|
||||
@ -362,7 +362,7 @@ func (c *QQClient) buildGroupFileSpaceRequest(groupCode int64) *network.Request
|
||||
ClientVersion: "android 8.4.8",
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("OidbSvc.0x6d8_1", payload)
|
||||
return c.uniRequest("OidbSvc.0x6d8_1", payload, decodeOIDB6d81Response)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildGroupFileCreateFolderRequest(groupCode int64, parentFolder, name string) *network.Request {
|
||||
@ -372,7 +372,7 @@ func (c *QQClient) buildGroupFileCreateFolderRequest(groupCode int64, parentFold
|
||||
ParentFolderId: &parentFolder,
|
||||
FolderName: &name,
|
||||
}})
|
||||
return c.uniRequest("OidbSvc.0x6d7_0", payload)
|
||||
return c.uniRequest("OidbSvc.0x6d7_0", payload, decodeOIDB6d7Response)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildGroupFileRenameFolderRequest(groupCode int64, folderId, newName string) *network.Request {
|
||||
@ -382,7 +382,7 @@ func (c *QQClient) buildGroupFileRenameFolderRequest(groupCode int64, folderId,
|
||||
FolderId: proto.String(folderId),
|
||||
NewFolderName: proto.String(newName),
|
||||
}})
|
||||
return c.uniRequest("OidbSvc.0x6d7_2", payload)
|
||||
return c.uniRequest("OidbSvc.0x6d7_2", payload, decodeOIDB6d7Response)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildGroupFileDeleteFolderRequest(groupCode int64, folderId string) *network.Request {
|
||||
@ -391,7 +391,7 @@ func (c *QQClient) buildGroupFileDeleteFolderRequest(groupCode int64, folderId s
|
||||
AppId: proto.Uint32(3),
|
||||
FolderId: proto.String(folderId),
|
||||
}})
|
||||
return c.uniRequest("OidbSvc.0x6d7_1", payload)
|
||||
return c.uniRequest("OidbSvc.0x6d7_1", payload, decodeOIDB6d7Response)
|
||||
}
|
||||
|
||||
// OidbSvc.0x6d6_2
|
||||
@ -411,7 +411,7 @@ func (c *QQClient) buildGroupFileDownloadReq(groupCode int64, fileId string, bus
|
||||
Bodybuffer: b,
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("OidbSvc.0x6d6_2", payload)
|
||||
return c.uniRequest("OidbSvc.0x6d6_2", payload, decodeOIDB6d62Response)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildGroupFileDeleteReq(groupCode int64, parentFolderId, fileId string, busId int32) *network.Request {
|
||||
@ -430,7 +430,7 @@ func (c *QQClient) buildGroupFileDeleteReq(groupCode int64, parentFolderId, file
|
||||
ClientVersion: "android 8.4.8",
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("OidbSvc.0x6d6_3", payload)
|
||||
return c.uniRequest("OidbSvc.0x6d6_3", payload, decodeOIDB6d63Response)
|
||||
}
|
||||
|
||||
func decodeOIDB6d81Response(_ *QQClient, resp *network.Response) (interface{}, error) {
|
||||
|
@ -66,7 +66,7 @@ type (
|
||||
)
|
||||
|
||||
func (c *QQClient) GetGroupInfo(groupCode int64) (*GroupInfo, error) {
|
||||
i, err := c.callAndDecode(c.buildGroupInfoRequestPacket(groupCode), decodeGroupInfoResponse)
|
||||
i, err := c.callAndDecode(c.buildGroupInfoRequestPacket(groupCode))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -117,12 +117,12 @@ func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) *network.Request
|
||||
Bodybuffer: b,
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("OidbSvc.0x88d_0", payload)
|
||||
return c.uniRequest("OidbSvc.0x88d_0", payload, decodeGroupInfoResponse)
|
||||
}
|
||||
|
||||
// SearchGroupByKeyword 通过关键词搜索陌生群组
|
||||
func (c *QQClient) SearchGroupByKeyword(keyword string) ([]GroupSearchInfo, error) {
|
||||
rsp, err := c.callAndDecode(c.buildGroupSearchPacket(keyword), decodeGroupSearchResponse)
|
||||
rsp, err := c.callAndDecode(c.buildGroupSearchPacket(keyword))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "group search failed")
|
||||
}
|
||||
@ -179,7 +179,7 @@ func (c *QQClient) buildGroupSearchPacket(keyword string) *network.Request {
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.uniRequest("SummaryCard.ReqSearch", pkt.ToBytes())
|
||||
return c.uniRequest("SummaryCard.ReqSearch", pkt.ToBytes(), decodeGroupSearchResponse)
|
||||
}
|
||||
|
||||
// SummaryCard.ReqSearch
|
||||
|
@ -77,7 +77,7 @@ func (c *QQClient) SendGroupForwardMessage(groupCode int64, m *message.ForwardEl
|
||||
func (c *QQClient) GetGroupMessages(groupCode, beginSeq, endSeq int64) ([]*message.GroupMessage, error) {
|
||||
req := c.buildGetGroupMsgRequest(groupCode, beginSeq, endSeq)
|
||||
req.Params = network.Params{"raw": false}
|
||||
i, err := c.callAndDecode(req, decodeGetGroupMsgResponse)
|
||||
i, err := c.callAndDecode(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -85,7 +85,7 @@ func (c *QQClient) GetGroupMessages(groupCode, beginSeq, endSeq int64) ([]*messa
|
||||
}
|
||||
|
||||
func (c *QQClient) GetAtAllRemain(groupCode int64) (*AtAllRemainInfo, error) {
|
||||
i, err := c.callAndDecode(c.buildAtAllRemainRequestPacket(groupCode), decodeAtAllRemainResponse)
|
||||
i, err := c.callAndDecode(c.buildAtAllRemainRequestPacket(groupCode))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -210,7 +210,7 @@ func (c *QQClient) UploadGroupForwardMessage(groupCode int64, m *message.Forward
|
||||
}
|
||||
|
||||
func (c *QQClient) multiMsgApplyUp(groupCode int64, data []byte, hash []byte, buType int32) (*multimsg.MultiMsgApplyUpRsp, []byte, error) {
|
||||
i, err := c.callAndDecode(c.buildMultiApplyUpPacket(data, hash, buType, utils.ToGroupUin(groupCode)), decodeMultiApplyUpResponse)
|
||||
i, err := c.callAndDecode(c.buildMultiApplyUpPacket(data, hash, buType, utils.ToGroupUin(groupCode)))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -267,7 +267,7 @@ func (c *QQClient) buildGroupSendingReq(groupCode int64, r, pkgNum, pkgIndex, pk
|
||||
}(),
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("MessageSvc.PbSendMsg", payload)
|
||||
return c.uniRequest("MessageSvc.PbSendMsg", payload, nil)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildGetGroupMsgRequest(groupCode, beginSeq, endSeq int64) *network.Request {
|
||||
@ -278,7 +278,7 @@ func (c *QQClient) buildGetGroupMsgRequest(groupCode, beginSeq, endSeq int64) *n
|
||||
PublicGroup: proto.Bool(false),
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("MessageSvc.PbGetGroupMsg", payload)
|
||||
return c.uniRequest("MessageSvc.PbGetGroupMsg", payload, decodeGetGroupMsgResponse)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildAtAllRemainRequestPacket(groupCode int64) *network.Request {
|
||||
@ -289,7 +289,7 @@ func (c *QQClient) buildAtAllRemainRequestPacket(groupCode int64) *network.Reque
|
||||
Uin: proto.Uint64(uint64(c.Uin)),
|
||||
GroupCode: proto.Uint64(uint64(groupCode)),
|
||||
})
|
||||
return c.uniRequest("OidbSvc.0x8a7_0", payload)
|
||||
return c.uniRequest("OidbSvc.0x8a7_0", payload, decodeAtAllRemainResponse)
|
||||
}
|
||||
|
||||
// OnlinePush.PbPushGroupMsg
|
||||
@ -357,7 +357,7 @@ func decodeGetGroupMsgResponse(c *QQClient, resp *network.Response) (interface{}
|
||||
end := int32(math.Min(float64(i+19), float64(m.Head.GetMsgSeq()+m.Content.GetPkgNum())))
|
||||
req := c.buildGetGroupMsgRequest(m.Head.GroupInfo.GetGroupCode(), int64(i), int64(end))
|
||||
req.Params = network.Params{"raw": true}
|
||||
data, err := c.callAndDecode(req, decodeGetGroupMsgResponse)
|
||||
data, err := c.callAndDecode(req)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "build fragmented message error")
|
||||
}
|
||||
@ -545,7 +545,7 @@ func (c *QQClient) parseGroupMessage(m *msg.Message) *message.GroupMessage {
|
||||
|
||||
// SetEssenceMessage 设为群精华消息
|
||||
func (c *QQClient) SetEssenceMessage(groupCode int64, msgID, msgInternalId int32) error {
|
||||
r, err := c.callAndDecode(c.buildEssenceMsgOperatePacket(groupCode, uint32(msgID), uint32(msgInternalId), 1), decodeEssenceMsgResponse)
|
||||
r, err := c.callAndDecode(c.buildEssenceMsgOperatePacket(groupCode, uint32(msgID), uint32(msgInternalId), 1))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "set essence msg network")
|
||||
}
|
||||
@ -558,7 +558,7 @@ func (c *QQClient) SetEssenceMessage(groupCode int64, msgID, msgInternalId int32
|
||||
|
||||
// DeleteEssenceMessage 移出群精华消息
|
||||
func (c *QQClient) DeleteEssenceMessage(groupCode int64, msgID, msgInternalId int32) error {
|
||||
r, err := c.callAndDecode(c.buildEssenceMsgOperatePacket(groupCode, uint32(msgID), uint32(msgInternalId), 2), decodeEssenceMsgResponse)
|
||||
r, err := c.callAndDecode(c.buildEssenceMsgOperatePacket(groupCode, uint32(msgID), uint32(msgInternalId), 2))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "set essence msg networ")
|
||||
}
|
||||
@ -576,7 +576,7 @@ func (c *QQClient) buildEssenceMsgOperatePacket(groupCode int64, msgSeq, msgRand
|
||||
Seq: proto.Uint32(msgSeq),
|
||||
Random: proto.Uint32(msgRand),
|
||||
})
|
||||
return c.uniRequest(commandName, payload)
|
||||
return c.uniRequest(commandName, payload, decodeEssenceMsgResponse)
|
||||
}
|
||||
|
||||
// OidbSvc.0xeac_1/2
|
||||
|
@ -301,7 +301,7 @@ func (s *GuildService) FetchGuildMemberProfileInfo(guildId, tinyId uint64) (*Gui
|
||||
|
||||
func (s *GuildService) GetGuildRoles(guildId uint64) ([]*GuildRole, error) {
|
||||
req := s.c.uniRequest("OidbSvcTrpcTcp.0x1019_1",
|
||||
s.c.packOIDBPackageDynamically(4121, 1, binary.DynamicProtoMessage{1: guildId}))
|
||||
s.c.packOIDBPackageDynamically(4121, 1, binary.DynamicProtoMessage{1: guildId}), nil)
|
||||
rsp, err := s.c.call(req)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "send packet error")
|
||||
@ -341,7 +341,7 @@ func (s *GuildService) CreateGuildRole(guildId uint64, name string, color uint32
|
||||
3: independent,
|
||||
},
|
||||
4: initialUsers,
|
||||
}))
|
||||
}), nil)
|
||||
rsp, err := s.c.call(req)
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "send packet error")
|
||||
@ -357,7 +357,7 @@ func (s *GuildService) DeleteGuildRole(guildId uint64, roleId uint64) error {
|
||||
req := s.c.uniRequest("OidbSvcTrpcTcp.0x100e_1", s.c.packOIDBPackageDynamically(4110, 1, binary.DynamicProtoMessage{
|
||||
1: guildId,
|
||||
2: roleId,
|
||||
}))
|
||||
}), nil)
|
||||
_, err := s.c.call(req)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "send packet error")
|
||||
@ -377,7 +377,7 @@ func (s *GuildService) SetUserRoleInGuild(guildId uint64, set bool, roleId uint6
|
||||
req := s.c.uniRequest("OidbSvcTrpcTcp.0x101a_1", s.c.packOIDBPackageDynamically(4122, 1, binary.DynamicProtoMessage{
|
||||
1: guildId,
|
||||
2: setOrRemove,
|
||||
}))
|
||||
}), nil)
|
||||
_, err := s.c.call(req)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "send packet error")
|
||||
@ -400,7 +400,7 @@ func (s *GuildService) ModifyRoleInGuild(guildId uint64, roleId uint64, name str
|
||||
2: color,
|
||||
3: indepedent,
|
||||
},
|
||||
}))
|
||||
}), nil)
|
||||
_, err := s.c.call(req)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "send packet error")
|
||||
@ -424,7 +424,7 @@ func (s *GuildService) FetchGuestGuild(guildId uint64) (*GuildMeta, error) {
|
||||
1: guildId,
|
||||
},
|
||||
})
|
||||
req := s.c.uniRequest("OidbSvcTrpcTcp.0xf57_9", payload)
|
||||
req := s.c.uniRequest("OidbSvcTrpcTcp.0xf57_9", payload, nil)
|
||||
rsp, err := s.c.call(req)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "send packet error")
|
||||
@ -453,7 +453,7 @@ func (s *GuildService) FetchChannelList(guildId uint64) (r []*ChannelInfo, e err
|
||||
3: binary.DynamicProtoMessage{
|
||||
1: uint32(1),
|
||||
},
|
||||
}))
|
||||
}), nil)
|
||||
rsp, err := s.c.call(req)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "send packet error")
|
||||
@ -469,7 +469,11 @@ func (s *GuildService) FetchChannelList(guildId uint64) (r []*ChannelInfo, e err
|
||||
}
|
||||
|
||||
func (s *GuildService) FetchChannelInfo(guildId, channelId uint64) (*ChannelInfo, error) {
|
||||
req := s.c.uniRequest("OidbSvcTrpcTcp.0xf55_1", s.c.packOIDBPackageDynamically(3925, 1, binary.DynamicProtoMessage{1: guildId, 2: channelId}))
|
||||
req := s.c.uniRequest("OidbSvcTrpcTcp.0xf55_1",
|
||||
s.c.packOIDBPackageDynamically(3925, 1, binary.DynamicProtoMessage{
|
||||
1: guildId,
|
||||
2: channelId,
|
||||
}), nil)
|
||||
rsp, err := s.c.call(req)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "send packet error")
|
||||
@ -523,7 +527,7 @@ func (s *GuildService) GetTopicChannelFeeds(guildId, channelId uint64) ([]*topic
|
||||
},
|
||||
},
|
||||
})
|
||||
call := s.c.uniRequest("QChannelSvr.trpc.qchannel.commreader.ComReader.GetChannelTimelineFeeds", payload)
|
||||
call := s.c.uniRequest("QChannelSvr.trpc.qchannel.commreader.ComReader.GetChannelTimelineFeeds", payload, nil)
|
||||
rsp, err := s.c.call(call)
|
||||
if err != nil {
|
||||
return nil, errors.New("send packet error")
|
||||
@ -593,7 +597,7 @@ func (s *GuildService) PostTopicChannelFeed(guildId, channelId uint64, feed *top
|
||||
},
|
||||
},
|
||||
})
|
||||
rsp, err := s.c.call(s.c.uniRequest("QChannelSvr.trpc.qchannel.commwriter.ComWriter.PublishFeed", payload))
|
||||
rsp, err := s.c.call(s.c.uniRequest("QChannelSvr.trpc.qchannel.commwriter.ComWriter.PublishFeed", payload, nil))
|
||||
if err != nil {
|
||||
return errors.New("send packet error")
|
||||
}
|
||||
@ -621,7 +625,7 @@ func (s *GuildService) fetchMemberRoles(guildId uint64, tinyId uint64) ([]*Guild
|
||||
2: u1,
|
||||
3: u1,
|
||||
},
|
||||
}))
|
||||
}), nil)
|
||||
rsp, err := s.c.call(req)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "send packet error")
|
||||
@ -730,7 +734,7 @@ func (c *QQClient) buildSyncChannelFirstViewPacket() *network.Request {
|
||||
DirectMessageFlag: proto.Uint32(1),
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("trpc.group_pro.synclogic.SyncLogic.SyncFirstView", payload)
|
||||
return c.uniRequest("trpc.group_pro.synclogic.SyncLogic.SyncFirstView", payload, nil)
|
||||
}
|
||||
|
||||
func decodeGuildPushFirstView(c *QQClient, resp *network.Response) (interface{}, error) {
|
||||
|
@ -94,7 +94,7 @@ func (s *GuildService) SendGuildChannelMessage(guildId, channelId uint64, m *mes
|
||||
}
|
||||
|
||||
func (s *GuildService) QueryImage(guildId, channelId uint64, hash []byte, size uint64) (*message.GuildImageElement, error) {
|
||||
rsp, err := s.c.callAndDecode(s.c.buildGuildImageStorePacket(guildId, channelId, hash, size), decodeGuildImageStoreResponse)
|
||||
rsp, err := s.c.callAndDecode(s.c.buildGuildImageStorePacket(guildId, channelId, hash, size))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "send packet error")
|
||||
}
|
||||
@ -117,7 +117,7 @@ func (s *GuildService) UploadGuildImage(guildId, channelId uint64, img io.ReadSe
|
||||
_, _ = img.Seek(0, io.SeekStart) // safe
|
||||
fh, length := utils.ComputeMd5AndLength(img)
|
||||
_, _ = img.Seek(0, io.SeekStart)
|
||||
rsp, err := s.c.callAndDecode(s.c.buildGuildImageStorePacket(guildId, channelId, fh, uint64(length)), decodeGuildImageStoreResponse)
|
||||
rsp, err := s.c.callAndDecode(s.c.buildGuildImageStorePacket(guildId, channelId, fh, uint64(length)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -246,7 +246,7 @@ func (c *QQClient) buildGuildImageStorePacket(guildId, channelId uint64, hash []
|
||||
},
|
||||
CommandId: proto.Uint32(83),
|
||||
})
|
||||
return c.uniRequest("ImgStore.QQMeetPicUp", payload)
|
||||
return c.uniRequest("ImgStore.QQMeetPicUp", payload, decodeGuildImageStoreResponse)
|
||||
}
|
||||
|
||||
func decodeGuildMessageEmojiReactions(content *channel.ChannelMsgContent) (r []*message.GuildMessageEmojiReaction) {
|
||||
@ -349,7 +349,7 @@ func (c *QQClient) buildPttGuildVideoUpReq(videoHash, thumbHash []byte, guildId,
|
||||
pb.PttShortVideoUploadReq.ToUin = channelId
|
||||
pb.ExtensionReq[0].SubBusiType = 4601
|
||||
payload, _ := proto.Marshal(pb)
|
||||
return c.uniRequest("PttCenterSvr.GroupShortVideoUpReq", payload)
|
||||
return c.uniRequest("PttCenterSvr.GroupShortVideoUpReq", payload, decodeGroupShortVideoUploadResponse)
|
||||
}
|
||||
|
||||
func (c *QQClient) UploadGuildShortVideo(guildId, channelId uint64, video, thumb io.ReadSeeker) (*message.ShortVideoElement, error) {
|
||||
@ -361,7 +361,7 @@ func (c *QQClient) UploadGuildShortVideo(guildId, channelId uint64, video, thumb
|
||||
pttWaiter.Wait(key)
|
||||
defer pttWaiter.Done(key)
|
||||
|
||||
i, err := c.callAndDecode(c.buildPttGuildVideoUpReq(videoHash, thumbHash, int64(guildId), int64(channelId), videoLen, thumbLen), decodeGroupShortVideoUploadResponse)
|
||||
i, err := c.callAndDecode(c.buildPttGuildVideoUpReq(videoHash, thumbHash, int64(guildId), int64(channelId), videoLen, thumbLen))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "upload req error")
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func (c *QQClient) UploadGroupImage(groupCode int64, img io.ReadSeeker) (*messag
|
||||
defer imgWaiter.Done(key)
|
||||
|
||||
req := c.buildGroupImageStoreRequest(groupCode, fh, int32(length))
|
||||
r, err := c.callAndDecode(req, decodeGroupImageStoreResponse)
|
||||
r, err := c.callAndDecode(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -100,7 +100,7 @@ func (c *QQClient) UploadGroupImageByFile(groupCode int64, path string) (*messag
|
||||
defer imgWaiter.Done(key)
|
||||
|
||||
req := c.buildGroupImageStoreRequest(groupCode, fh, int32(length))
|
||||
r, err := c.callAndDecode(req, decodeGroupImageStoreResponse)
|
||||
r, err := c.callAndDecode(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -145,7 +145,7 @@ func (c *QQClient) UploadPrivateImage(target int64, img io.ReadSeeker) (*message
|
||||
}
|
||||
|
||||
func (c *QQClient) GetGroupImageDownloadUrl(fileId, groupCode int64, fileMd5 []byte) (string, error) {
|
||||
i, err := c.callAndDecode(c.buildGroupImageDownloadRequest(fileId, groupCode, fileMd5), decodeGroupImageDownloadResponse)
|
||||
i, err := c.callAndDecode(c.buildGroupImageDownloadRequest(fileId, groupCode, fileMd5))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -186,7 +186,7 @@ func (c *QQClient) ImageOcr(img interface{}) (*OcrResponse, error) {
|
||||
_ = b.Close()
|
||||
}
|
||||
call := c.buildImageOcrRequestPacket(url, strings.ToUpper(hex.EncodeToString(e.Md5)), e.Size, e.Width, e.Height)
|
||||
rsp, err := c.callAndDecode(call, decodeImageOcrResponse)
|
||||
rsp, err := c.callAndDecode(call)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -196,7 +196,7 @@ func (c *QQClient) ImageOcr(img interface{}) (*OcrResponse, error) {
|
||||
}
|
||||
|
||||
func (c *QQClient) QueryGroupImage(groupCode int64, hash []byte, size int32) (*message.GroupImageElement, error) {
|
||||
r, err := c.callAndDecode(c.buildGroupImageStoreRequest(groupCode, hash, size), decodeGroupImageStoreResponse)
|
||||
r, err := c.callAndDecode(c.buildGroupImageStoreRequest(groupCode, hash, size))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -211,7 +211,7 @@ func (c *QQClient) QueryGroupImage(groupCode int64, hash []byte, size int32) (*m
|
||||
}
|
||||
|
||||
func (c *QQClient) QueryFriendImage(target int64, hash []byte, size int32) (*message.FriendImageElement, error) {
|
||||
i, err := c.callAndDecode(c.buildOffPicUpRequest(target, hash, size), decodeOffPicUpResponse)
|
||||
i, err := c.callAndDecode(c.buildOffPicUpRequest(target, hash, size))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -259,7 +259,7 @@ func (c *QQClient) buildGroupImageStoreRequest(groupCode int64, md5 []byte, size
|
||||
Extension: EmptyBytes,
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("ImgStore.GroupPicUp", payload)
|
||||
return c.uniRequest("ImgStore.GroupPicUp", payload, decodeGroupImageStoreResponse)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildGroupImageDownloadRequest(fileId, groupCode int64, fileMd5 []byte) *network.Request {
|
||||
@ -283,7 +283,7 @@ func (c *QQClient) buildGroupImageDownloadRequest(fileId, groupCode int64, fileM
|
||||
},
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("ImgStore.GroupPicDown", payload)
|
||||
return c.uniRequest("ImgStore.GroupPicDown", payload, decodeGroupImageDownloadResponse)
|
||||
}
|
||||
|
||||
func (c *QQClient) uploadOcrImage(img io.Reader) (string, error) {
|
||||
@ -329,7 +329,7 @@ func (c *QQClient) buildImageOcrRequestPacket(url, md5 string, size, weight, hei
|
||||
}
|
||||
b, _ := proto.Marshal(body)
|
||||
payload := c.packOIDBPackage(3591, 0, b)
|
||||
return c.uniRequest("OidbSvc.0xe07_0", payload)
|
||||
return c.uniRequest("OidbSvc.0xe07_0", payload, decodeImageOcrResponse)
|
||||
}
|
||||
|
||||
// ImgStore.GroupPicUp
|
||||
|
@ -26,4 +26,5 @@ type Request struct {
|
||||
Body []byte
|
||||
|
||||
Params Params
|
||||
Decode func(*Response) (interface{}, error) // callAndDecode use this function to decode response
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ func (c *QQClient) buildMultiApplyUpPacket(data, hash []byte, buType int32, grou
|
||||
BuType: buType,
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("MultiMsg.ApplyUp", payload)
|
||||
return c.uniRequest("MultiMsg.ApplyUp", payload, decodeMultiApplyUpResponse)
|
||||
}
|
||||
|
||||
// MultiMsg.ApplyUp
|
||||
@ -76,7 +76,7 @@ func (c *QQClient) buildMultiApplyDownPacket(resID string) *network.Request {
|
||||
ReqChannelType: 2,
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("MultiMsg.ApplyDown", payload)
|
||||
return c.uniRequest("MultiMsg.ApplyDown", payload, decodeMultiApplyDownResponse)
|
||||
}
|
||||
|
||||
// MultiMsg.ApplyDown
|
||||
@ -177,7 +177,7 @@ func (c *QQClient) GetForwardMessage(resID string) *message.ForwardMessage {
|
||||
}
|
||||
|
||||
func (c *QQClient) DownloadForwardMessage(resId string) *message.ForwardElement {
|
||||
i, err := c.callAndDecode(c.buildMultiApplyDownPacket(resId), decodeMultiApplyDownResponse)
|
||||
i, err := c.callAndDecode(c.buildMultiApplyDownPacket(resId))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"github.com/Mrs4s/MiraiGo/message"
|
||||
"net"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/Mrs4s/MiraiGo/message"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/Mrs4s/MiraiGo/client/internal/network"
|
||||
@ -169,12 +170,13 @@ func (c *QQClient) send(call *network.Call) {
|
||||
if call.Done == nil {
|
||||
call.Done = make(chan *network.Call, 3) // use buffered channel
|
||||
}
|
||||
seq := uint16(call.Request.SequenceID)
|
||||
seq := call.Request.SequenceID
|
||||
c.pendingMu.Lock()
|
||||
c.pending[seq] = call
|
||||
c.pendingMu.Unlock()
|
||||
|
||||
err := c.sendPacket(c.transport.PackPacket(call.Request))
|
||||
c.Debug("send pkt: %v seq: %d", call.Request.CommandName, call.Request.SequenceID)
|
||||
if err != nil {
|
||||
c.pendingMu.Lock()
|
||||
call = c.pending[seq]
|
||||
@ -203,12 +205,12 @@ func (c *QQClient) call(req *network.Request) (*network.Response, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *QQClient) callAndDecode(req *network.Request, decoder func(*QQClient, *network.Response) (interface{}, error)) (interface{}, error) {
|
||||
func (c *QQClient) callAndDecode(req *network.Request) (interface{}, error) {
|
||||
resp, err := c.call(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return decoder(c, resp)
|
||||
return req.Decode(resp)
|
||||
}
|
||||
|
||||
// sendPacket 向服务器发送一个数据包
|
||||
@ -313,7 +315,7 @@ func (c *QQClient) pktProc(req *network.Request, netErr error) {
|
||||
|
||||
// snapshot of read call
|
||||
c.pendingMu.Lock()
|
||||
call := c.pending[uint16(req.SequenceID)]
|
||||
call := c.pending[req.SequenceID]
|
||||
if call != nil {
|
||||
call.Response = &network.Response{
|
||||
SequenceID: req.SequenceID,
|
||||
|
@ -25,7 +25,7 @@ func (c *QQClient) buildOfflineFileDownloadRequestPacket(uuid []byte) *network.R
|
||||
},
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniPacketWithSeq(seq, "OfflineFilleHandleSvr.pb_ftn_CMD_REQ_APPLY_DOWNLOAD-1200", payload)
|
||||
return c.uniPacketWithSeq(seq, "OfflineFilleHandleSvr.pb_ftn_CMD_REQ_APPLY_DOWNLOAD-1200", payload, decodeOfflineFileDownloadResponse)
|
||||
}
|
||||
|
||||
func decodeOfflineFileDownloadResponse(c *QQClient, resp *network.Response) (interface{}, error) {
|
||||
|
@ -16,9 +16,21 @@ func (c *QQClient) buildOicqRequestPacket(uin int64, command uint16, body []byte
|
||||
return c.oicq.Marshal(&req)
|
||||
}
|
||||
|
||||
type decoderFunc = func(*QQClient, *network.Response) (interface{}, error)
|
||||
|
||||
func bindDecoder(c *QQClient, decoder decoderFunc) func(*network.Response) (interface{}, error) {
|
||||
return func(response *network.Response) (interface{}, error) {
|
||||
return decoder(c, response)
|
||||
}
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func (c *QQClient) uniRequest(command string, body []byte) *network.Request {
|
||||
func (c *QQClient) uniRequest(command string, body []byte, decoder decoderFunc) *network.Request {
|
||||
seq := c.nextSeq()
|
||||
var decode func(*network.Response) (interface{}, error)
|
||||
if decoder != nil {
|
||||
decode = bindDecoder(c, decoder)
|
||||
}
|
||||
return &network.Request{
|
||||
Type: network.RequestTypeSimple,
|
||||
EncryptType: network.EncryptTypeD2Key,
|
||||
@ -26,6 +38,7 @@ func (c *QQClient) uniRequest(command string, body []byte) *network.Request {
|
||||
SequenceID: int32(seq),
|
||||
CommandName: command,
|
||||
Body: body,
|
||||
Decode: decode,
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +57,11 @@ func (c *QQClient) uniCall(command string, body []byte) (*network.Response, erro
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func (c *QQClient) uniPacketWithSeq(seq uint16, command string, body []byte) *network.Request {
|
||||
func (c *QQClient) uniPacketWithSeq(seq uint16, command string, body []byte, decoder decoderFunc) *network.Request {
|
||||
var decode func(*network.Response) (interface{}, error)
|
||||
if decoder != nil {
|
||||
decode = bindDecoder(c, decoder)
|
||||
}
|
||||
req := network.Request{
|
||||
Type: network.RequestTypeSimple,
|
||||
EncryptType: network.EncryptTypeD2Key,
|
||||
@ -52,6 +69,7 @@ func (c *QQClient) uniPacketWithSeq(seq uint16, command string, body []byte) *ne
|
||||
SequenceID: int32(seq),
|
||||
CommandName: command,
|
||||
Body: body,
|
||||
Decode: decode,
|
||||
}
|
||||
return &req
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ func (c *QQClient) buildFriendSendingPacket(target int64, msgSeq, r, pkgNum, pkg
|
||||
}(),
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("MessageSvc.PbSendMsg", payload)
|
||||
return c.uniRequest("MessageSvc.PbSendMsg", payload, nil)
|
||||
}
|
||||
|
||||
// MessageSvc.PbSendMsg
|
||||
@ -211,7 +211,7 @@ func (c *QQClient) buildGroupTempSendingPacket(groupUin, target int64, msgSeq, r
|
||||
}(),
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("MessageSvc.PbSendMsg", payload)
|
||||
return c.uniRequest("MessageSvc.PbSendMsg", payload, nil)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildWPATempSendingPacket(uin int64, sig []byte, msgSeq, r int32, time int64, m *message.SendingMessage) *network.Request {
|
||||
@ -242,5 +242,5 @@ func (c *QQClient) buildWPATempSendingPacket(uin int64, sig []byte, msgSeq, r in
|
||||
}(),
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("MessageSvc.PbSendMsg", payload)
|
||||
return c.uniRequest("MessageSvc.PbSendMsg", payload, nil)
|
||||
}
|
||||
|
@ -147,8 +147,7 @@ func (c *QQClient) UploadGroupShortVideo(groupCode int64, video, thumb io.ReadSe
|
||||
pttWaiter.Wait(key)
|
||||
defer pttWaiter.Done(key)
|
||||
|
||||
i, err := c.callAndDecode(c.buildPttGroupShortVideoUploadReq(videoHash, thumbHash, groupCode, videoLen, thumbLen),
|
||||
decodeGroupShortVideoUploadResponse)
|
||||
i, err := c.callAndDecode(c.buildPttGroupShortVideoUploadReq(videoHash, thumbHash, groupCode, videoLen, thumbLen))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "upload req error")
|
||||
}
|
||||
@ -211,7 +210,7 @@ func (c *QQClient) UploadGroupShortVideo(groupCode int64, video, thumb io.ReadSe
|
||||
}
|
||||
|
||||
func (c *QQClient) GetShortVideoUrl(uuid, md5 []byte) string {
|
||||
i, err := c.callAndDecode(c.buildPttShortVideoDownReq(uuid, md5), decodePttShortVideoDownResponse)
|
||||
i, err := c.callAndDecode(c.buildPttShortVideoDownReq(uuid, md5))
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
@ -266,7 +265,7 @@ func (c *QQClient) buildPttShortVideoDownReq(uuid, md5 []byte) *network.Request
|
||||
},
|
||||
}
|
||||
payload, _ := proto.Marshal(body)
|
||||
return c.uniPacketWithSeq(seq, "PttCenterSvr.ShortVideoDownReq", payload)
|
||||
return c.uniPacketWithSeq(seq, "PttCenterSvr.ShortVideoDownReq", payload, decodePttShortVideoDownResponse)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildPttGroupShortVideoProto(videoHash, thumbHash []byte, toUin, videoSize, thumbSize int64, chattype int32) *pttcenter.ShortVideoReqBody {
|
||||
@ -305,7 +304,7 @@ func (c *QQClient) buildPttGroupShortVideoProto(videoHash, thumbHash []byte, toU
|
||||
// PttCenterSvr.GroupShortVideoUpReq
|
||||
func (c *QQClient) buildPttGroupShortVideoUploadReq(videoHash, thumbHash []byte, toUin, videoSize, thumbSize int64) *network.Request {
|
||||
payload, _ := proto.Marshal(c.buildPttGroupShortVideoProto(videoHash, thumbHash, toUin, videoSize, thumbSize, 1))
|
||||
return c.uniRequest("PttCenterSvr.GroupShortVideoUpReq", payload)
|
||||
return c.uniRequest("PttCenterSvr.GroupShortVideoUpReq", payload, decodeGroupShortVideoUploadResponse)
|
||||
}
|
||||
|
||||
// PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_UPLOAD-500
|
||||
|
@ -86,7 +86,7 @@ func (c *QQClient) buildLoginExtraPacket() *network.Request {
|
||||
},
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("qidianservice.69", payload)
|
||||
return c.uniRequest("qidianservice.69", payload, nil)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildConnKeyRequestPacket() *network.Request {
|
||||
@ -101,7 +101,7 @@ func (c *QQClient) buildConnKeyRequestPacket() *network.Request {
|
||||
},
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("HttpConn.0x6ff_501", payload)
|
||||
return c.uniRequest("HttpConn.0x6ff_501", payload, nil)
|
||||
}
|
||||
|
||||
func (c *QQClient) bigDataRequest(subCmd uint32, req proto.Message) ([]byte, error) {
|
||||
|
@ -22,7 +22,7 @@ func (c *QQClient) RecallGroupMessage(groupCode int64, msgID, msgInternalId int3
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err := c.callAndDecode(c.buildGroupRecallPacket(groupCode, msgID, msgInternalId), decodeMsgWithDrawResponse)
|
||||
_, err := c.callAndDecode(c.buildGroupRecallPacket(groupCode, msgID, msgInternalId))
|
||||
return err
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ func (c *QQClient) internalGroupRecall(groupCode int64, msgInternalID int32, m [
|
||||
for _, item := range m {
|
||||
if item.InternalId == msgInternalID {
|
||||
flag = true
|
||||
if _, err := c.callAndDecode(c.buildGroupRecallPacket(groupCode, item.Id, item.InternalId), decodeMsgWithDrawResponse); err != nil {
|
||||
if _, err := c.callAndDecode(c.buildGroupRecallPacket(groupCode, item.Id, item.InternalId)); err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,7 @@ func (c *QQClient) internalGroupRecall(groupCode int64, msgInternalID int32, m [
|
||||
}
|
||||
|
||||
func (c *QQClient) RecallPrivateMessage(uin, ts int64, msgID, msgInternalId int32) error {
|
||||
_, err := c.callAndDecode(c.buildPrivateRecallPacket(uin, ts, msgID, msgInternalId), decodeMsgWithDrawResponse)
|
||||
_, err := c.callAndDecode(c.buildPrivateRecallPacket(uin, ts, msgID, msgInternalId))
|
||||
return err
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ func (c *QQClient) buildGroupRecallPacket(groupCode int64, msgSeq, msgRan int32)
|
||||
},
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("PbMessageSvc.PbMsgWithDraw", payload)
|
||||
return c.uniRequest("PbMessageSvc.PbMsgWithDraw", payload, decodeMsgWithDrawResponse)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildPrivateRecallPacket(uin, ts int64, msgSeq, random int32) *network.Request {
|
||||
@ -89,7 +89,7 @@ func (c *QQClient) buildPrivateRecallPacket(uin, ts int64, msgSeq, random int32)
|
||||
},
|
||||
}}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("PbMessageSvc.PbMsgWithDraw", payload)
|
||||
return c.uniRequest("PbMessageSvc.PbMsgWithDraw", payload, decodeMsgWithDrawResponse)
|
||||
}
|
||||
|
||||
func decodeMsgWithDrawResponse(_ *QQClient, resp *network.Response) (interface{}, error) {
|
||||
|
@ -77,7 +77,7 @@ func (c *QQClient) SendGroupMusicShare(target int64, msg *message.MusicShareElem
|
||||
}
|
||||
})
|
||||
defer c.onGroupMessageReceipt(eid)
|
||||
_, _ = c.call(c.buildRichMsgSendingPacket(0, target, msg, 1)) // rsp is empty chunk
|
||||
_, _ = c.call(c.buildRichMsgSendingReq(0, target, msg, 1)) // rsp is empty chunk
|
||||
select {
|
||||
case ret := <-ch:
|
||||
return ret, nil
|
||||
@ -88,17 +88,17 @@ func (c *QQClient) SendGroupMusicShare(target int64, msg *message.MusicShareElem
|
||||
|
||||
// SendFriendMusicShare 发送好友音乐卡片
|
||||
func (c *QQClient) SendFriendMusicShare(target int64, msg *message.MusicShareElement) {
|
||||
_, _ = c.call(c.buildRichMsgSendingPacket(0, target, msg, 0))
|
||||
_, _ = c.call(c.buildRichMsgSendingReq(0, target, msg, 0))
|
||||
}
|
||||
|
||||
// SendGuildMusicShare 发送频道音乐卡片
|
||||
func (c *QQClient) SendGuildMusicShare(guildID, channelID uint64, msg *message.MusicShareElement) {
|
||||
// todo(wdvxdr): message receipt?
|
||||
_, _ = c.call(c.buildRichMsgSendingPacket(guildID, int64(channelID), msg, 3))
|
||||
_, _ = c.call(c.buildRichMsgSendingReq(guildID, int64(channelID), msg, 3))
|
||||
}
|
||||
|
||||
// OidbSvc.0xb77_9
|
||||
func (c *QQClient) buildRichMsgSendingPacket(guild uint64, target int64, msg *message.MusicShareElement, sendType uint32) *network.Request {
|
||||
func (c *QQClient) buildRichMsgSendingReq(guild uint64, target int64, msg *message.MusicShareElement, sendType uint32) *network.Request {
|
||||
tp := musicType[msg.MusicType] // MusicType
|
||||
msgStyle := uint32(0)
|
||||
if msg.MusicUrl != "" {
|
||||
@ -129,5 +129,5 @@ func (c *QQClient) buildRichMsgSendingPacket(guild uint64, target int64, msg *me
|
||||
}
|
||||
b, _ := proto.Marshal(body)
|
||||
payload := c.packOIDBPackage(2935, 9, b)
|
||||
return c.uniRequest("OidbSvc.0xb77_9", payload)
|
||||
return c.uniRequest("OidbSvc.0xb77_9", payload, nil)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ const (
|
||||
|
||||
// CheckUrlSafely 通过TX服务器检查URL安全性
|
||||
func (c *QQClient) CheckUrlSafely(url string) UrlSecurityLevel {
|
||||
i, err := c.callAndDecode(c.buildUrlCheckRequest(url), decodeUrlCheckResponse)
|
||||
i, err := c.callAndDecode(c.buildUrlCheckRequest(url))
|
||||
if err != nil {
|
||||
return Unknown
|
||||
}
|
||||
@ -41,7 +41,7 @@ func (c *QQClient) buildUrlCheckRequest(url string) *network.Request {
|
||||
Qua: proto.String("AQQ_2013 4.6/2013 8.4.184945&NA_0/000000&ADR&null18&linux&2017&C2293D02BEE31158&7.1.2&V3"),
|
||||
},
|
||||
})
|
||||
return c.uniRequest("OidbSvc.0xbcb_0", payload)
|
||||
return c.uniRequest("OidbSvc.0xbcb_0", payload, decodeUrlCheckResponse)
|
||||
}
|
||||
|
||||
func decodeUrlCheckResponse(_ *QQClient, resp *network.Response) (interface{}, error) {
|
||||
|
@ -45,7 +45,7 @@ type (
|
||||
|
||||
// GetAllowedClients 获取已允许的其他客户端
|
||||
func (c *QQClient) GetAllowedClients() ([]*OtherClientInfo, error) {
|
||||
i, err := c.callAndDecode(c.buildDeviceListRequestPacket(), decodeDevListResponse)
|
||||
i, err := c.callAndDecode(c.buildDeviceListRequestPacket())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -104,11 +104,11 @@ func (c *QQClient) SyncSessions() (*SessionSyncResponse, error) {
|
||||
|
||||
// MarkGroupMessageReaded 标记群消息已读, 适当调用应该能减少风控
|
||||
func (c *QQClient) MarkGroupMessageReaded(groupCode, seq int64) {
|
||||
_, _ = c.callAndDecode(c.buildGroupMsgReadedPacket(groupCode, seq), decodeMsgReadedResponse)
|
||||
_, _ = c.callAndDecode(c.buildGroupMsgReadedPacket(groupCode, seq))
|
||||
}
|
||||
|
||||
func (c *QQClient) MarkPrivateMessageReaded(uin, time int64) {
|
||||
_, _ = c.callAndDecode(c.buildPrivateMsgReadedPacket(uin, time), decodeMsgReadedResponse)
|
||||
_, _ = c.callAndDecode(c.buildPrivateMsgReadedPacket(uin, time))
|
||||
}
|
||||
|
||||
// StatSvc.GetDevLoginInfo
|
||||
@ -129,7 +129,7 @@ func (c *QQClient) buildDeviceListRequestPacket() *network.Request {
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.uniRequest("StatSvc.GetDevLoginInfo", pkt.ToBytes())
|
||||
return c.uniRequest("StatSvc.GetDevLoginInfo", pkt.ToBytes(), decodeDevListResponse)
|
||||
}
|
||||
|
||||
// RegPrxySvc.getOffMsg
|
||||
@ -183,7 +183,7 @@ func (c *QQClient) buildGetOfflineMsgRequestPacket() *network.Request {
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.uniRequest("RegPrxySvc.getOffMsg", pkt.ToBytes())
|
||||
return c.uniRequest("RegPrxySvc.getOffMsg", pkt.ToBytes(), nil)
|
||||
}
|
||||
|
||||
// RegPrxySvc.PbSyncMsg
|
||||
@ -255,7 +255,7 @@ func (c *QQClient) buildSyncMsgRequestPacket() *network.Request {
|
||||
Context: make(map[string]string),
|
||||
Status: make(map[string]string),
|
||||
}
|
||||
return c.uniRequest("RegPrxySvc.infoSync", pkt.ToBytes())
|
||||
return c.uniRequest("RegPrxySvc.infoSync", pkt.ToBytes(), nil)
|
||||
}
|
||||
|
||||
// PbMessageSvc.PbMsgReadedReport
|
||||
@ -264,7 +264,7 @@ func (c *QQClient) buildGroupMsgReadedPacket(groupCode, msgSeq int64) *network.R
|
||||
GroupCode: proto.Uint64(uint64(groupCode)),
|
||||
LastReadSeq: proto.Uint64(uint64(msgSeq)),
|
||||
}}})
|
||||
return c.uniRequest("PbMessageSvc.PbMsgReadedReport", req)
|
||||
return c.uniRequest("PbMessageSvc.PbMsgReadedReport", req, decodeMsgReadedResponse)
|
||||
}
|
||||
|
||||
func (c *QQClient) buildPrivateMsgReadedPacket(uin, time int64) *network.Request {
|
||||
@ -274,7 +274,7 @@ func (c *QQClient) buildPrivateMsgReadedPacket(uin, time int64) *network.Request
|
||||
LastReadTime: proto.Uint32(uint32(time)),
|
||||
},
|
||||
}, SyncCookie: c.sig.SyncCookie}})
|
||||
return c.uniRequest("PbMessageSvc.PbMsgReadedReport", req)
|
||||
return c.uniRequest("PbMessageSvc.PbMsgReadedReport", req, decodeMsgReadedResponse)
|
||||
}
|
||||
|
||||
// StatSvc.GetDevLoginInfo
|
||||
|
@ -44,12 +44,12 @@ type (
|
||||
)
|
||||
|
||||
func (c *QQClient) GetGroupSystemMessages() (*GroupSystemMessages, error) {
|
||||
i, err := c.callAndDecode(c.buildSystemMsgNewGroupPacket(false), decodeSystemMsgGroupPacket)
|
||||
i, err := c.callAndDecode(c.buildSystemMsgNewGroupPacket(false))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
msg := i.(*GroupSystemMessages)
|
||||
i, err = c.callAndDecode(c.buildSystemMsgNewGroupPacket(true), decodeSystemMsgGroupPacket)
|
||||
i, err = c.callAndDecode(c.buildSystemMsgNewGroupPacket(true))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -130,7 +130,7 @@ func (c *QQClient) buildSystemMsgNewGroupPacket(suspicious bool) *network.Reques
|
||||
}(),
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("ProfileService.Pb.ReqSystemMsgNew.Group", payload)
|
||||
return c.uniRequest("ProfileService.Pb.ReqSystemMsgNew.Group", payload, decodeSystemMsgGroupPacket)
|
||||
}
|
||||
|
||||
// ProfileService.Pb.ReqSystemMsgAction.Group
|
||||
@ -163,7 +163,7 @@ func (c *QQClient) buildSystemMsgGroupActionPacket(reqID, requester, group int64
|
||||
Language: 1000,
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("ProfileService.Pb.ReqSystemMsgAction.Group", payload)
|
||||
return c.uniRequest("ProfileService.Pb.ReqSystemMsgAction.Group", payload, nil)
|
||||
}
|
||||
|
||||
// ProfileService.Pb.ReqSystemMsgAction.Friend
|
||||
@ -186,7 +186,7 @@ func (c *QQClient) buildSystemMsgFriendActionPacket(reqID, requester int64, acce
|
||||
},
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("ProfileService.Pb.ReqSystemMsgAction.Friend", payload)
|
||||
return c.uniRequest("ProfileService.Pb.ReqSystemMsgAction.Friend", payload, nil)
|
||||
}
|
||||
|
||||
// ProfileService.Pb.ReqSystemMsgNew.Group
|
||||
|
@ -23,11 +23,11 @@ func (c *QQClient) buildTranslatePacket(src, dst, text string) *network.Request
|
||||
Bodybuffer: b,
|
||||
}
|
||||
payload, _ := proto.Marshal(req)
|
||||
return c.uniRequest("OidbSvc.0x990", payload)
|
||||
return c.uniRequest("OidbSvc.0x990", payload, decodeTranslateResponse)
|
||||
}
|
||||
|
||||
func (c *QQClient) Translate(src, dst, text string) (string, error) {
|
||||
rsp, err := c.callAndDecode(c.buildTranslatePacket(src, dst, text), decodeTranslateResponse)
|
||||
rsp, err := c.callAndDecode(c.buildTranslatePacket(src, dst, text))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ func (c *QQClient) webSsoRequest(host, webCmd, data string) (string, error) {
|
||||
Type: proto.Uint32(0),
|
||||
Data: &data,
|
||||
})
|
||||
rspData, err := c.call(c.uniRequest(cmd, req))
|
||||
rspData, err := c.call(c.uniRequest(cmd, req, nil))
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "send web sso request error")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user