Skip to content

Commit

Permalink
feat: 消息发送结果判断
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmomn committed Jun 17, 2024
1 parent 79ecc2a commit 15fd073
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
18 changes: 16 additions & 2 deletions client/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ func (c *QQClient) SendGroupMessage(groupUin uint32, elements []message2.IMessag
route := &message.RoutingHead{
Grp: &message.Grp{GroupCode: proto.Some(groupUin)},
}
return c.SendRawMessage(route, body)
resp, err = c.SendRawMessage(route, body)
if err != nil {
return nil, err
}
if resp.GroupSequence.IsNone() {
return resp, utils.GrpSendFailed
}
return resp, nil
}

func (c *QQClient) SendPrivateMessage(uin uint32, elements []message2.IMessageElement) (resp *action.SendMessageResponse, err error) {
Expand All @@ -60,7 +67,14 @@ func (c *QQClient) SendPrivateMessage(uin uint32, elements []message2.IMessageEl
Uid: proto.Some(c.GetUid(uin)),
},
}
return c.SendRawMessage(route, body)
resp, err = c.SendRawMessage(route, body)
if err != nil {
return nil, err
}
if resp.PrivateSequence == 0 {
return resp, utils.PrvSendFailed
}
return resp, nil
}

func (c *QQClient) SendTempMessage(groupID uint32, uin uint32, elements []message2.IMessageElement) (resp *action.SendMessageResponse, err error) {
Expand Down
8 changes: 8 additions & 0 deletions utils/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package utils

import "errors"

var (
GrpSendFailed = errors.New("group message send failed")
PrvSendFailed = errors.New("private message send failed")
)

0 comments on commit 15fd073

Please sign in to comment.