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

Method SendPrivateFile

client/operation.go:731–753  ·  view source on GitHub ↗

SendPrivateFile 发送私聊文件

(targetUin uint32, localFilePath, filename string)

Source from the content-addressed store, hash-verified

729
730// SendPrivateFile 发送私聊文件
731func (c *QQClient) SendPrivateFile(targetUin uint32, localFilePath, filename string) error {
732 fileElement, err := message2.NewLocalFile(localFilePath, filename)
733 if err != nil {
734 return err
735 }
736 uploadedFileElement, err := c.UploadPrivateFile(c.GetUID(targetUin), fileElement)
737 if err != nil {
738 return err
739 }
740 route := &message.RoutingHead{
741 Trans0X211: &message.Trans0X211{
742 CcCmd: proto.Uint32(4),
743 Uid: proto.String(c.GetUID(targetUin)),
744 },
745 }
746 body := message2.PackElementsToBody([]message2.IMessageElement{uploadedFileElement})
747 mr := crypto.RandU32()
748 ret, _, err := c.SendRawMessage(route, body, mr)
749 if err != nil || ret.PrivateSequence == 0 {
750 return err
751 }
752 return nil
753}
754
755// SendGroupFile 发送群文件
756func (c *QQClient) SendGroupFile(groupUin uint32, localFilePath, filename, targetDirectory string) error {

Callers

nothing calls this directly

Calls 6

UploadPrivateFileMethod · 0.95
GetUIDMethod · 0.95
SendRawMessageMethod · 0.95
Uint32Function · 0.92
StringFunction · 0.92
RandU32Function · 0.92

Tested by

no test coverage detected