Switch back to go-whatsapp upstream
This commit is contained in:
52
vendor/github.com/Rhymen/go-whatsapp/handler.go
generated
vendored
52
vendor/github.com/Rhymen/go-whatsapp/handler.go
generated
vendored
@ -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))
|
||||
}
|
||||
}
|
||||
|
4
vendor/github.com/Rhymen/go-whatsapp/session.go
generated
vendored
4
vendor/github.com/Rhymen/go-whatsapp/session.go
generated
vendored
@ -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
|
||||
|
Reference in New Issue
Block a user