SendPrivateMessage 发送私聊消息,默认会对消息进行预处理
(uin uint32, elements []message2.IMessageElement, needPreprocess ...bool)
| 83 | |
| 84 | // SendPrivateMessage 发送私聊消息,默认会对消息进行预处理 |
| 85 | func (c *QQClient) SendPrivateMessage(uin uint32, elements []message2.IMessageElement, needPreprocess ...bool) (*message2.PrivateMessage, error) { |
| 86 | if needPreprocess == nil || needPreprocess[0] { |
| 87 | elements = c.preProcessPrivateMessage(uin, elements) |
| 88 | } |
| 89 | body := message2.PackElementsToBody(elements) |
| 90 | route := &message.RoutingHead{ |
| 91 | C2C: &message.C2C{ |
| 92 | Uid: proto.Some(c.GetUID(uin)), |
| 93 | }, |
| 94 | } |
| 95 | mr := crypto.RandU32() |
| 96 | ret, clientSeq, err := c.SendRawMessage(route, body, mr) |
| 97 | if err != nil || ret.PrivateSequence == 0 { |
| 98 | return nil, err |
| 99 | } |
| 100 | resp := &message2.PrivateMessage{ |
| 101 | ID: ret.PrivateSequence, |
| 102 | InternalID: mr, |
| 103 | ClientSeq: clientSeq, |
| 104 | Self: c.Uin, |
| 105 | Target: uin, |
| 106 | Time: ret.Timestamp1, |
| 107 | Sender: &message2.Sender{ |
| 108 | Uin: c.Uin, |
| 109 | UID: c.GetUID(c.Uin), |
| 110 | Nickname: c.NickName(), |
| 111 | IsFriend: true, |
| 112 | }, |
| 113 | Elements: elements, |
| 114 | } |
| 115 | return resp, nil |
| 116 | } |
| 117 | |
| 118 | func (c *QQClient) SendTempMessage(groupUin uint32, uin uint32, elements []message2.IMessageElement) (*message2.TempMessage, error) { |
| 119 | body := message2.PackElementsToBody(elements) |
no test coverage detected