From e4a78832ad941563df07e4ffb7b6f0ecbb7edf0c Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 31 Aug 2018 11:24:27 +0300 Subject: [PATCH] Switch back to go-whatsapp upstream --- Gopkg.lock | 11 ++-- Gopkg.toml | 5 +- .../github.com/Rhymen/go-whatsapp/handler.go | 52 +++++++------------ .../github.com/Rhymen/go-whatsapp/session.go | 4 +- vendor/github.com/mattn/go-isatty/.travis.yml | 4 ++ .../mattn/go-isatty/isatty_others.go | 2 +- 6 files changed, 35 insertions(+), 43 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 5bca2ba..7960368 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,7 +2,7 @@ [[projects]] - branch = "develop" + branch = "master" name = "github.com/Rhymen/go-whatsapp" packages = [ ".", @@ -13,8 +13,7 @@ "crypto/curve25519", "crypto/hkdf" ] - revision = "00ef431f94f17f125f842d0c7d4e9b68294c6559" - source = "github.com/tulir/go-whatsapp" + revision = "c31092027237441cffba1b9cb148eadf7c83c3d2" [[projects]] name = "github.com/fatih/color" @@ -55,8 +54,8 @@ [[projects]] name = "github.com/mattn/go-isatty" packages = ["."] - revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39" - version = "v0.0.3" + revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c" + version = "v0.0.4" [[projects]] name = "github.com/mattn/go-sqlite3" @@ -146,6 +145,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "16c945243c327e861a6dc4fa2b43010d00453b8ee71427b95fb5dfcc6cb6ebee" + inputs-digest = "9158f20cc827fadd5ed71302b767c938595986ef9e0623496eddfb4f95f75c76" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 6d31530..7a5e75f 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -26,9 +26,10 @@ [[constraint]] - branch = "develop" + branch = "master" name = "github.com/Rhymen/go-whatsapp" - source = "github.com/tulir/go-whatsapp" +# branch = "develop" +# source = "github.com/tulir/go-whatsapp" [[constraint]] name = "github.com/mattn/go-sqlite3" diff --git a/vendor/github.com/Rhymen/go-whatsapp/handler.go b/vendor/github.com/Rhymen/go-whatsapp/handler.go index 586a0ff..62522bd 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/handler.go +++ b/vendor/github.com/Rhymen/go-whatsapp/handler.go @@ -72,7 +72,7 @@ type JsonMessageHandler interface { /** The RawMessageHandler interface needs to be implemented to receive raw messages dispatched by the dispatcher. Raw messages are the raw protobuf structs instead of the easy-to-use structs in TextMessageHandler, ImageMessageHandler, etc.. - */ +*/ type RawMessageHandler interface { Handler HandleRawMessage(message *proto.WebMessageInfo) @@ -96,51 +96,45 @@ func (wac *Conn) handle(message interface{}) { } case string: for _, h := range wac.handler { - x, ok := h.(JsonMessageHandler) - if !ok { - continue + if x, ok := h.(JsonMessageHandler); ok { + go x.HandleJsonMessage(m) } - go x.HandleJsonMessage(m) } case TextMessage: for _, h := range wac.handler { - x, ok := h.(TextMessageHandler) - if !ok { - continue + if x, ok := h.(TextMessageHandler); ok { + go x.HandleTextMessage(m) } - go x.HandleTextMessage(m) } case ImageMessage: for _, h := range wac.handler { - x, ok := h.(ImageMessageHandler) - if !ok { - continue + if x, ok := h.(ImageMessageHandler); ok { + go x.HandleImageMessage(m) } - go x.HandleImageMessage(m) } case VideoMessage: for _, h := range wac.handler { - x, ok := h.(VideoMessageHandler) - if !ok { - continue + if x, ok := h.(VideoMessageHandler); ok { + go x.HandleVideoMessage(m) } - go x.HandleVideoMessage(m) } case AudioMessage: for _, h := range wac.handler { - x, ok := h.(AudioMessageHandler) - if !ok { - continue + if x, ok := h.(AudioMessageHandler); ok { + go x.HandleAudioMessage(m) } - go x.HandleAudioMessage(m) } case DocumentMessage: for _, h := range wac.handler { - x, ok := h.(DocumentMessageHandler) - if !ok { - continue + if x, ok := h.(DocumentMessageHandler); ok { + go x.HandleDocumentMessage(m) + } + } + case *proto.WebMessageInfo: + for _, h := range wac.handler { + if x, ok := h.(RawMessageHandler); ok { + go x.HandleRawMessage(m) } - go x.HandleDocumentMessage(m) } } @@ -157,13 +151,7 @@ func (wac *Conn) dispatch(msg interface{}) { if con, ok := message.Content.([]interface{}); ok { for a := range con { if v, ok := con[a].(*proto.WebMessageInfo); ok { - for _, h := range wac.handler { - x, ok := h.(RawMessageHandler) - if !ok { - continue - } - go x.HandleRawMessage(v) - } + wac.handle(v) wac.handle(parseProtoMessage(v)) } } diff --git a/vendor/github.com/Rhymen/go-whatsapp/session.go b/vendor/github.com/Rhymen/go-whatsapp/session.go index 1a8c8f3..8b46431 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/session.go +++ b/vendor/github.com/Rhymen/go-whatsapp/session.go @@ -87,9 +87,9 @@ func newInfoFromReq(info map[string]interface{}) *Info { /* 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 { - if wac.session != nil && (wac.session.EncKey != nil || wac.session.MacKey != nil) { + 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 diff --git a/vendor/github.com/mattn/go-isatty/.travis.yml b/vendor/github.com/mattn/go-isatty/.travis.yml index b9f8b23..5597e02 100644 --- a/vendor/github.com/mattn/go-isatty/.travis.yml +++ b/vendor/github.com/mattn/go-isatty/.travis.yml @@ -2,6 +2,10 @@ language: go go: - tip +os: + - linux + - osx + before_install: - go get github.com/mattn/goveralls - go get golang.org/x/tools/cmd/cover diff --git a/vendor/github.com/mattn/go-isatty/isatty_others.go b/vendor/github.com/mattn/go-isatty/isatty_others.go index ff4de3d..9d8b4a5 100644 --- a/vendor/github.com/mattn/go-isatty/isatty_others.go +++ b/vendor/github.com/mattn/go-isatty/isatty_others.go @@ -3,7 +3,7 @@ package isatty -// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 +// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 // terminal. This is also always false on this environment. func IsCygwinTerminal(fd uintptr) bool { return false