import (
"context"
+ "crypto/sha256"
"database/sql"
"errors"
"fmt"
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)
}
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.logger, w.clock, id, chat, text, image)
}
func (w *WhatsApp) sessionPath() string {
return own
}
+// whatsappChatHash returns a short hash of chat for the daemon log, so that a
+// log line can tell chats apart without a phone number.
+func whatsappChatHash(chat types.JID) string {
+ digest := sha256.Sum256([]byte(chat.ToNonAD().String()))
+
+ return fmt.Sprintf("%x", digest[:6])
+}
+
// whatsappRedact replaces each of the own IDs own in text with OWN.
func whatsappRedact(own []string, text string) string {
for _, id := range own {