Switch back to go-whatsapp upstream

This commit is contained in:
Tulir Asokan 2018-08-31 11:24:27 +03:00
parent 79851a62b4
commit e4a78832ad
6 changed files with 35 additions and 43 deletions

11
Gopkg.lock generated
View file

@ -2,7 +2,7 @@
[[projects]] [[projects]]
branch = "develop" branch = "master"
name = "github.com/Rhymen/go-whatsapp" name = "github.com/Rhymen/go-whatsapp"
packages = [ packages = [
".", ".",
@ -13,8 +13,7 @@
"crypto/curve25519", "crypto/curve25519",
"crypto/hkdf" "crypto/hkdf"
] ]
revision = "00ef431f94f17f125f842d0c7d4e9b68294c6559" revision = "c31092027237441cffba1b9cb148eadf7c83c3d2"
source = "github.com/tulir/go-whatsapp"
[[projects]] [[projects]]
name = "github.com/fatih/color" name = "github.com/fatih/color"
@ -55,8 +54,8 @@
[[projects]] [[projects]]
name = "github.com/mattn/go-isatty" name = "github.com/mattn/go-isatty"
packages = ["."] packages = ["."]
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39" revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
version = "v0.0.3" version = "v0.0.4"
[[projects]] [[projects]]
name = "github.com/mattn/go-sqlite3" name = "github.com/mattn/go-sqlite3"
@ -146,6 +145,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "16c945243c327e861a6dc4fa2b43010d00453b8ee71427b95fb5dfcc6cb6ebee" inputs-digest = "9158f20cc827fadd5ed71302b767c938595986ef9e0623496eddfb4f95f75c76"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

View file

@ -26,9 +26,10 @@
[[constraint]] [[constraint]]
branch = "develop" branch = "master"
name = "github.com/Rhymen/go-whatsapp" name = "github.com/Rhymen/go-whatsapp"
source = "github.com/tulir/go-whatsapp" # branch = "develop"
# source = "github.com/tulir/go-whatsapp"
[[constraint]] [[constraint]]
name = "github.com/mattn/go-sqlite3" name = "github.com/mattn/go-sqlite3"

View file

@ -72,7 +72,7 @@ type JsonMessageHandler interface {
/** /**
The RawMessageHandler interface needs to be implemented to receive raw messages dispatched by the dispatcher. 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.. Raw messages are the raw protobuf structs instead of the easy-to-use structs in TextMessageHandler, ImageMessageHandler, etc..
*/ */
type RawMessageHandler interface { type RawMessageHandler interface {
Handler Handler
HandleRawMessage(message *proto.WebMessageInfo) HandleRawMessage(message *proto.WebMessageInfo)
@ -96,51 +96,45 @@ func (wac *Conn) handle(message interface{}) {
} }
case string: case string:
for _, h := range wac.handler { for _, h := range wac.handler {
x, ok := h.(JsonMessageHandler) if x, ok := h.(JsonMessageHandler); ok {
if !ok { go x.HandleJsonMessage(m)
continue
} }
go x.HandleJsonMessage(m)
} }
case TextMessage: case TextMessage:
for _, h := range wac.handler { for _, h := range wac.handler {
x, ok := h.(TextMessageHandler) if x, ok := h.(TextMessageHandler); ok {
if !ok { go x.HandleTextMessage(m)
continue
} }
go x.HandleTextMessage(m)
} }
case ImageMessage: case ImageMessage:
for _, h := range wac.handler { for _, h := range wac.handler {
x, ok := h.(ImageMessageHandler) if x, ok := h.(ImageMessageHandler); ok {
if !ok { go x.HandleImageMessage(m)
continue
} }
go x.HandleImageMessage(m)
} }
case VideoMessage: case VideoMessage:
for _, h := range wac.handler { for _, h := range wac.handler {
x, ok := h.(VideoMessageHandler) if x, ok := h.(VideoMessageHandler); ok {
if !ok { go x.HandleVideoMessage(m)
continue
} }
go x.HandleVideoMessage(m)
} }
case AudioMessage: case AudioMessage:
for _, h := range wac.handler { for _, h := range wac.handler {
x, ok := h.(AudioMessageHandler) if x, ok := h.(AudioMessageHandler); ok {
if !ok { go x.HandleAudioMessage(m)
continue
} }
go x.HandleAudioMessage(m)
} }
case DocumentMessage: case DocumentMessage:
for _, h := range wac.handler { for _, h := range wac.handler {
x, ok := h.(DocumentMessageHandler) if x, ok := h.(DocumentMessageHandler); ok {
if !ok { go x.HandleDocumentMessage(m)
continue }
}
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 { if con, ok := message.Content.([]interface{}); ok {
for a := range con { for a := range con {
if v, ok := con[a].(*proto.WebMessageInfo); ok { if v, ok := con[a].(*proto.WebMessageInfo); ok {
for _, h := range wac.handler { wac.handle(v)
x, ok := h.(RawMessageHandler)
if !ok {
continue
}
go x.HandleRawMessage(v)
}
wac.handle(parseProtoMessage(v)) wac.handle(parseProtoMessage(v))
} }
} }

View file

@ -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 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. 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) 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") return fmt.Errorf("cannot change client name after logging in")
} }
wac.longClientName, wac.shortClientName = long, short wac.longClientName, wac.shortClientName = long, short

View file

@ -2,6 +2,10 @@ language: go
go: go:
- tip - tip
os:
- linux
- osx
before_install: before_install:
- go get github.com/mattn/goveralls - go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover - go get golang.org/x/tools/cmd/cover

View file

@ -3,7 +3,7 @@
package isatty 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. // terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool { func IsCygwinTerminal(fd uintptr) bool {
return false return false