summaryrefslogtreecommitdiffstats
path: root/bridge/whatsapp/helpers.go
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/whatsapp/helpers.go')
-rw-r--r--bridge/whatsapp/helpers.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/bridge/whatsapp/helpers.go b/bridge/whatsapp/helpers.go
index 5268ba3e..f45d6246 100644
--- a/bridge/whatsapp/helpers.go
+++ b/bridge/whatsapp/helpers.go
@@ -2,13 +2,22 @@ package bwhatsapp
import (
"encoding/gob"
+ "encoding/json"
"errors"
+ "fmt"
"os"
qrcodeTerminal "github.com/Baozisoftware/qrcode-terminal-go"
"github.com/Rhymen/go-whatsapp"
)
+type ProfilePicInfo struct {
+ URL string `json:"eurl"`
+ Tag string `json:"tag"`
+
+ Status int16 `json:"status"`
+}
+
func qrFromTerminal(invert bool) chan string {
qr := make(chan string)
go func() {
@@ -82,3 +91,17 @@ func (b *Bwhatsapp) getSenderNotify(senderJid string) string {
}
return ""
}
+
+func (b *Bwhatsapp) GetProfilePicThumb(jid string) (*ProfilePicInfo, error) {
+ data, err := b.conn.GetProfilePicThumb(jid)
+ if err != nil {
+ return nil, fmt.Errorf("failed to get avatar: %v", err)
+ }
+ content := <-data
+ info := &ProfilePicInfo{}
+ err = json.Unmarshal([]byte(content), info)
+ if err != nil {
+ return info, fmt.Errorf("failed to unmarshal avatar info: %v", err)
+ }
+ return info, nil
+}