diff options
author | Wim <wim@42.be> | 2020-10-11 23:07:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-11 23:07:00 +0200 |
commit | 2d98df61221e23b3be557d7b1931ee3d510ac32d (patch) | |
tree | 7898a2d3c2b3003bae97d50541443072046666f3 /vendor/github.com/Rhymen/go-whatsapp | |
parent | 219a5453f9edaa87aa7aa4b9d5f9c3de9c75b38f (diff) | |
download | matterbridge-msglm-2d98df61221e23b3be557d7b1931ee3d510ac32d.tar.gz matterbridge-msglm-2d98df61221e23b3be557d7b1931ee3d510ac32d.tar.bz2 matterbridge-msglm-2d98df61221e23b3be557d7b1931ee3d510ac32d.zip |
Update vendor (#1257)
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp')
-rw-r--r-- | vendor/github.com/Rhymen/go-whatsapp/README.md | 4 | ||||
-rw-r--r-- | vendor/github.com/Rhymen/go-whatsapp/handler.go | 23 | ||||
-rw-r--r-- | vendor/github.com/Rhymen/go-whatsapp/media.go | 16 | ||||
-rw-r--r-- | vendor/github.com/Rhymen/go-whatsapp/message.go | 10 | ||||
-rw-r--r-- | vendor/github.com/Rhymen/go-whatsapp/session.go | 6 |
5 files changed, 55 insertions, 4 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/README.md b/vendor/github.com/Rhymen/go-whatsapp/README.md index f3c7ef58..7f12dd72 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/README.md +++ b/vendor/github.com/Rhymen/go-whatsapp/README.md @@ -74,6 +74,10 @@ func (myHandler) HandleBatteryMessage(msg whatsapp.BatteryMessage) { fmt.Println(message) } +func (myHandler) HandleNewContact(contact whatsapp.Contact) { + fmt.Println(contact) +} + wac.AddHandler(myHandler{}) ``` The message handlers are all optional, you don't need to implement anything but the error handler to implement the interface. The ImageMessage, VideoMessage, AudioMessage and DocumentMessage provide a Download function to get the media data. diff --git a/vendor/github.com/Rhymen/go-whatsapp/handler.go b/vendor/github.com/Rhymen/go-whatsapp/handler.go index 86ea43b1..4f8ef858 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/handler.go +++ b/vendor/github.com/Rhymen/go-whatsapp/handler.go @@ -141,6 +141,14 @@ type BatteryMessageHandler interface { HandleBatteryMessage(battery BatteryMessage) } +/** +The NewContactHandler interface needs to be implemented to receive the contact's name for the first time. +*/ +type NewContactHandler interface { + Handler + HandleNewContact(contact Contact) +} + /* AddHandler adds an handler to the list of handler that receive dispatched messages. The provided handler must at least implement the Handler interface. Additionally implemented @@ -304,6 +312,17 @@ func (wac *Conn) handleWithCustomHandlers(message interface{}, handlers []Handle } } } + + case Contact: + for _, h := range handlers { + if x, ok := h.(NewContactHandler); ok { + if wac.shouldCallSynchronously(h) { + x.HandleNewContact(m) + } else { + go x.HandleNewContact(m) + } + } + } case *proto.WebMessageInfo: for _, h := range handlers { @@ -397,6 +416,10 @@ func (wac *Conn) dispatch(msg interface{}) { wac.handle(v) wac.handle(ParseProtoMessage(v)) } + + if v, ok := con[a].(binary.Node); ok { + wac.handle(ParseNodeMessage(v)) + } } } else if con, ok := message.Content.([]binary.Node); ok { for a := range con { diff --git a/vendor/github.com/Rhymen/go-whatsapp/media.go b/vendor/github.com/Rhymen/go-whatsapp/media.go index 43ff424f..225eac8e 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/media.go +++ b/vendor/github.com/Rhymen/go-whatsapp/media.go @@ -129,7 +129,17 @@ func (wac *Conn) queryMediaConn() (hostname, auth string, ttl int, err error) { return "", "", 0, fmt.Errorf("query media conn responded with %d", resp.Status) } - return resp.MediaConn.Hosts[0].Hostname, resp.MediaConn.Auth, resp.MediaConn.TTL, nil + var host string + for _, h := range resp.MediaConn.Hosts { + if h.Hostname!="" { + host = h.Hostname + break + } + } + if host == "" { + return "", "", 0, fmt.Errorf("query media conn responded with no host") + } + return host, resp.MediaConn.Auth, resp.MediaConn.TTL, nil } var mediaTypeMap = map[MediaType]string{ @@ -173,6 +183,10 @@ func (wac *Conn) Upload(reader io.Reader, appInfo MediaType) (downloadURL string fileEncSha256 = sha.Sum(nil) hostname, auth, _, err := wac.queryMediaConn() + if err != nil { + return "", nil, nil, nil, 0, err + } + token := base64.URLEncoding.EncodeToString(fileEncSha256) q := url.Values{ "auth": []string{auth}, diff --git a/vendor/github.com/Rhymen/go-whatsapp/message.go b/vendor/github.com/Rhymen/go-whatsapp/message.go index d4bc0926..15797cb4 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/message.go +++ b/vendor/github.com/Rhymen/go-whatsapp/message.go @@ -867,11 +867,21 @@ func getBatteryMessage(msg map[string]string) BatteryMessage { return batteryMessage } +func getNewContact(msg map[string]string) Contact { + contact := Contact{ + Jid: msg["jid"], + Notify: msg["notify"], + } + + return contact +} func ParseNodeMessage(msg binary.Node) interface{} { switch msg.Description { case "battery": return getBatteryMessage(msg.Attributes) + case "user": + return getNewContact(msg.Attributes) default: //cannot match message } diff --git a/vendor/github.com/Rhymen/go-whatsapp/session.go b/vendor/github.com/Rhymen/go-whatsapp/session.go index dc3acd57..8c829c4a 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/session.go +++ b/vendor/github.com/Rhymen/go-whatsapp/session.go @@ -18,7 +18,7 @@ import ( ) //represents the WhatsAppWeb client version -var waVersion = []int{2, 2033, 7} +var waVersion = []int{2, 2039, 9} /* Session contains session individual information. To be able to resume the connection without scanning the qr code @@ -141,11 +141,11 @@ func CheckCurrentServerVersion() ([]int, error) { SetClientName sets the long and short client names that are sent to WhatsApp when logging in and displayed in the WhatsApp Web device list. As the values are only sent when logging in, changing them after logging in is not possible. */ -func (wac *Conn) SetClientName(long, short string) error { +func (wac *Conn) SetClientName(long, short string, version string) error { if wac.session != nil && (wac.session.EncKey != nil || wac.session.MacKey != nil) { return fmt.Errorf("cannot change client name after logging in") } - wac.longClientName, wac.shortClientName = long, short + wac.longClientName, wac.shortClientName, wac.clientVersion = long, short, version return nil } |