]> git.giacomolli.uk - onechat/blobdiff - whatsapp.go
Send stored images to WhatsApp chats
[onechat] / whatsapp.go
index 97b1e857d50cebcf45a59f1d08251cfd76bbcb76..57bfab078301a01907a3c6d898421f24c37df814 100644 (file)
@@ -92,6 +92,7 @@ type WhatsAppClient interface {
        Logout(ctx context.Context) error
        GetJoinedGroups(ctx context.Context) ([]*types.GroupInfo, error)
        Download(ctx context.Context, message whatsmeow.DownloadableMessage) ([]byte, error)
+       Upload(ctx context.Context, data []byte, mediaType whatsmeow.MediaType) (whatsmeow.UploadResponse, error)
        GenerateMessageID() types.MessageID
        SendMessage(ctx context.Context, to types.JID, message *waE2E.Message, extra ...whatsmeow.SendRequestExtra) (whatsmeow.SendResponse, error)
 }
@@ -462,10 +463,10 @@ func (w *WhatsApp) Find(ctx context.Context, name string) (string, error) {
        return whatsappFind(ctx, w.link(), w.groups, name)
 }
 
-// Send returns the answer of whatsapp_send for the send id of text to chat, as
-// whatsappSend says.
-func (w *WhatsApp) Send(ctx context.Context, id, chat, text string) (string, error) {
-       return whatsappSend(ctx, w.link(), w.groups, w.state, w.clock, id, chat, text)
+// Send returns the answer of whatsapp_send for text and an optional stored
+// image to chat, with the durable send id that whatsappSend describes.
+func (w *WhatsApp) Send(ctx context.Context, id, chat, text, image string) (string, error) {
+       return whatsappSend(ctx, w.link(), w.groups, w.state, w.inbox.images, w.clock, id, chat, text, image)
 }
 
 func (w *WhatsApp) sessionPath() string {