diff options
author | Wim <wim@42.be> | 2020-08-24 23:35:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-24 23:35:08 +0200 |
commit | 2f506425c25504662f50f49e742529195d63ff27 (patch) | |
tree | 47170c6086cee16549a695329a478fd49174c299 /vendor/github.com/Rhymen/go-whatsapp/handler.go | |
parent | e8167ee3d73c47353eea1b0bd7062bd2fc3fc127 (diff) | |
download | matterbridge-msglm-2f506425c25504662f50f49e742529195d63ff27.tar.gz matterbridge-msglm-2f506425c25504662f50f49e742529195d63ff27.tar.bz2 matterbridge-msglm-2f506425c25504662f50f49e742529195d63ff27.zip |
Update whatsapp vendor and fix a panic (#1209)
* Fix another whatsapp panic
* Update whatsapp vendor
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/handler.go')
-rw-r--r-- | vendor/github.com/Rhymen/go-whatsapp/handler.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/handler.go b/vendor/github.com/Rhymen/go-whatsapp/handler.go index 1188f794..86ea43b1 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/handler.go +++ b/vendor/github.com/Rhymen/go-whatsapp/handler.go @@ -133,6 +133,14 @@ type ChatListHandler interface { HandleChatList(contacts []Chat) } +/** +The BatteryMessageHandler interface needs to be implemented to receive percentage the device connected dispatched by the dispatcher. +*/ +type BatteryMessageHandler interface { + Handler + HandleBatteryMessage(battery BatteryMessage) +} + /* 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 @@ -285,6 +293,17 @@ func (wac *Conn) handleWithCustomHandlers(message interface{}, handlers []Handle } } } + + case BatteryMessage: + for _, h := range handlers { + if x, ok := h.(BatteryMessageHandler); ok { + if wac.shouldCallSynchronously(h) { + x.HandleBatteryMessage(m) + } else { + go x.HandleBatteryMessage(m) + } + } + } case *proto.WebMessageInfo: for _, h := range handlers { @@ -379,6 +398,10 @@ func (wac *Conn) dispatch(msg interface{}) { wac.handle(ParseProtoMessage(v)) } } + } else if con, ok := message.Content.([]binary.Node); ok { + for a := range con { + wac.handle(ParseNodeMessage(con[a])) + } } } else if message.Description == "response" && message.Attributes["type"] == "contacts" { wac.updateContacts(message.Content) |