Browse Source

Switch back to go-whatsapp upstream

Tulir Asokan 6 years ago
parent
commit
e4a78832ad

+ 5 - 6
Gopkg.lock

@@ -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"
-  source = "github.com/tulir/go-whatsapp"
+  revision = "c31092027237441cffba1b9cb148eadf7c83c3d2"
 
 
 [[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"
-  version = "v0.0.3"
+  revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
+  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

+ 3 - 2
Gopkg.toml

@@ -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"

+ 20 - 32
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.
 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 !ok {
-				continue
+			if x, ok := h.(JsonMessageHandler); ok {
+				go x.HandleJsonMessage(m)
 			}
 			}
-			go x.HandleJsonMessage(m)
 		}
 		}
 	case TextMessage:
 	case TextMessage:
 		for _, h := range wac.handler {
 		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:
 	case ImageMessage:
 		for _, h := range wac.handler {
 		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:
 	case VideoMessage:
 		for _, h := range wac.handler {
 		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:
 	case AudioMessage:
 		for _, h := range wac.handler {
 		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:
 	case DocumentMessage:
 		for _, h := range wac.handler {
 		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 {
 			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 {
-							x, ok := h.(RawMessageHandler)
-							if !ok {
-								continue
-							}
-							go x.HandleRawMessage(v)
-						}
+						wac.handle(v)
 						wac.handle(parseProtoMessage(v))
 						wac.handle(parseProtoMessage(v))
 					}
 					}
 				}
 				}

+ 2 - 2
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
 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

+ 4 - 0
vendor/github.com/mattn/go-isatty/.travis.yml

@@ -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

+ 1 - 1
vendor/github.com/mattn/go-isatty/isatty_others.go

@@ -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