1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

fix recall error.

This commit is contained in:
Mrs4s 2020-11-26 10:00:36 +08:00
parent 37bfcb6971
commit b5cce86b4d
2 changed files with 27 additions and 6 deletions

View File

@ -144,6 +144,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
"MessageSvc.PbGetMsg": decodeMessageSvcPacket,
"MessageSvc.PbSendMsg": decodeMsgSendResponse,
"MessageSvc.PushForceOffline": decodeForceOfflinePacket,
"PbMessageSvc.PbMsgWithDraw": decodeMsgWithDrawResponse,
"friendlist.getFriendGroupList": decodeFriendGroupListResponse,
"friendlist.GetTroopListReqV2": decodeGroupListResponse,
"friendlist.GetTroopMemberListReq": decodeGroupMemberListResponse,

View File

@ -1,6 +1,8 @@
package client
import (
"errors"
"fmt"
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/protocol/packets"
"google.golang.org/protobuf/proto"
@ -8,14 +10,14 @@ import (
// 撤回相关处理逻辑
func (c *QQClient) RecallGroupMessage(groupCode int64, msgId, msgInternalId int32) {
_, pkt := c.buildGroupRecallPacket(groupCode, msgId, msgInternalId)
_ = c.send(pkt)
func (c *QQClient) RecallGroupMessage(groupCode int64, msgId, msgInternalId int32) error {
_, err := c.sendAndWait(c.buildGroupRecallPacket(groupCode, msgId, msgInternalId))
return err
}
func (c *QQClient) RecallPrivateMessage(uin, ts int64, msgId, msgInternalId int32) {
_, pkt := c.buildPrivateRecallPacket(uin, ts, msgId, msgInternalId)
_ = c.send(pkt)
func (c *QQClient) RecallPrivateMessage(uin, ts int64, msgId, msgInternalId int32) error {
_, err := c.sendAndWait(c.buildPrivateRecallPacket(uin, ts, msgId, msgInternalId))
return err
}
// PbMessageSvc.PbMsgWithDraw
@ -64,3 +66,21 @@ func (c *QQClient) buildPrivateRecallPacket(uin, ts int64, msgSeq, random int32)
packet := packets.BuildUniPacket(c.Uin, seq, "PbMessageSvc.PbMsgWithDraw", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
func decodeMsgWithDrawResponse(_ *QQClient, _ uint16, payload []byte) (interface{}, error) {
rsp := msg.MsgWithDrawResp{}
if err := proto.Unmarshal(payload, &rsp); err != nil {
return nil, err
}
if len(rsp.C2CWithDraw) > 0 {
if rsp.C2CWithDraw[0].GetResult() != 0 {
return nil, errors.New(fmt.Sprintf("recall error: %v msg: %v", rsp.C2CWithDraw[0].GetResult(), rsp.C2CWithDraw[0].GetErrMsg()))
}
}
if len(rsp.GroupWithDraw) > 0 {
if rsp.GroupWithDraw[0].GetResult() != 0 {
return nil, errors.New(fmt.Sprintf("recall error: %v msg: %v", rsp.C2CWithDraw[0].GetResult(), rsp.C2CWithDraw[0].GetErrMsg()))
}
}
return nil, nil
}