SendPrivateFile 发送私聊文件
(targetUin uint32, localFilePath, filename string)
| 729 | |
| 730 | // SendPrivateFile 发送私聊文件 |
| 731 | func (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 发送群文件 |
| 756 | func (c *QQClient) SendGroupFile(groupUin uint32, localFilePath, filename, targetDirectory string) error { |
nothing calls this directly
no test coverage detected