MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / SendPrivateMessage

Method SendPrivateMessage

client/message.go:85–116  ·  view source on GitHub ↗

SendPrivateMessage 发送私聊消息,默认会对消息进行预处理

(uin uint32, elements []message2.IMessageElement, needPreprocess ...bool)

Source from the content-addressed store, hash-verified

83
84// SendPrivateMessage 发送私聊消息,默认会对消息进行预处理
85func (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
118func (c *QQClient) SendTempMessage(groupUin uint32, uin uint32, elements []message2.IMessageElement) (*message2.TempMessage, error) {
119 body := message2.PackElementsToBody(elements)

Callers 1

mainFunction · 0.80

Calls 5

GetUIDMethod · 0.95
SendRawMessageMethod · 0.95
NickNameMethod · 0.95
RandU32Function · 0.92

Tested by

no test coverage detected