mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-11 17:46:27 +00:00
Update vendor (#1257)
This commit is contained in:
4
vendor/github.com/Rhymen/go-whatsapp/README.md
generated
vendored
4
vendor/github.com/Rhymen/go-whatsapp/README.md
generated
vendored
@ -74,6 +74,10 @@ func (myHandler) HandleBatteryMessage(msg whatsapp.BatteryMessage) {
|
||||
fmt.Println(message)
|
||||
}
|
||||
|
||||
func (myHandler) HandleNewContact(contact whatsapp.Contact) {
|
||||
fmt.Println(contact)
|
||||
}
|
||||
|
||||
wac.AddHandler(myHandler{})
|
||||
```
|
||||
The message handlers are all optional, you don't need to implement anything but the error handler to implement the interface. The ImageMessage, VideoMessage, AudioMessage and DocumentMessage provide a Download function to get the media data.
|
||||
|
23
vendor/github.com/Rhymen/go-whatsapp/handler.go
generated
vendored
23
vendor/github.com/Rhymen/go-whatsapp/handler.go
generated
vendored
@ -141,6 +141,14 @@ type BatteryMessageHandler interface {
|
||||
HandleBatteryMessage(battery BatteryMessage)
|
||||
}
|
||||
|
||||
/**
|
||||
The NewContactHandler interface needs to be implemented to receive the contact's name for the first time.
|
||||
*/
|
||||
type NewContactHandler interface {
|
||||
Handler
|
||||
HandleNewContact(contact Contact)
|
||||
}
|
||||
|
||||
/*
|
||||
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
|
||||
@ -304,6 +312,17 @@ func (wac *Conn) handleWithCustomHandlers(message interface{}, handlers []Handle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case Contact:
|
||||
for _, h := range handlers {
|
||||
if x, ok := h.(NewContactHandler); ok {
|
||||
if wac.shouldCallSynchronously(h) {
|
||||
x.HandleNewContact(m)
|
||||
} else {
|
||||
go x.HandleNewContact(m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case *proto.WebMessageInfo:
|
||||
for _, h := range handlers {
|
||||
@ -397,6 +416,10 @@ func (wac *Conn) dispatch(msg interface{}) {
|
||||
wac.handle(v)
|
||||
wac.handle(ParseProtoMessage(v))
|
||||
}
|
||||
|
||||
if v, ok := con[a].(binary.Node); ok {
|
||||
wac.handle(ParseNodeMessage(v))
|
||||
}
|
||||
}
|
||||
} else if con, ok := message.Content.([]binary.Node); ok {
|
||||
for a := range con {
|
||||
|
16
vendor/github.com/Rhymen/go-whatsapp/media.go
generated
vendored
16
vendor/github.com/Rhymen/go-whatsapp/media.go
generated
vendored
@ -129,7 +129,17 @@ func (wac *Conn) queryMediaConn() (hostname, auth string, ttl int, err error) {
|
||||
return "", "", 0, fmt.Errorf("query media conn responded with %d", resp.Status)
|
||||
}
|
||||
|
||||
return resp.MediaConn.Hosts[0].Hostname, resp.MediaConn.Auth, resp.MediaConn.TTL, nil
|
||||
var host string
|
||||
for _, h := range resp.MediaConn.Hosts {
|
||||
if h.Hostname!="" {
|
||||
host = h.Hostname
|
||||
break
|
||||
}
|
||||
}
|
||||
if host == "" {
|
||||
return "", "", 0, fmt.Errorf("query media conn responded with no host")
|
||||
}
|
||||
return host, resp.MediaConn.Auth, resp.MediaConn.TTL, nil
|
||||
}
|
||||
|
||||
var mediaTypeMap = map[MediaType]string{
|
||||
@ -173,6 +183,10 @@ func (wac *Conn) Upload(reader io.Reader, appInfo MediaType) (downloadURL string
|
||||
fileEncSha256 = sha.Sum(nil)
|
||||
|
||||
hostname, auth, _, err := wac.queryMediaConn()
|
||||
if err != nil {
|
||||
return "", nil, nil, nil, 0, err
|
||||
}
|
||||
|
||||
token := base64.URLEncoding.EncodeToString(fileEncSha256)
|
||||
q := url.Values{
|
||||
"auth": []string{auth},
|
||||
|
10
vendor/github.com/Rhymen/go-whatsapp/message.go
generated
vendored
10
vendor/github.com/Rhymen/go-whatsapp/message.go
generated
vendored
@ -867,11 +867,21 @@ func getBatteryMessage(msg map[string]string) BatteryMessage {
|
||||
return batteryMessage
|
||||
}
|
||||
|
||||
func getNewContact(msg map[string]string) Contact {
|
||||
contact := Contact{
|
||||
Jid: msg["jid"],
|
||||
Notify: msg["notify"],
|
||||
}
|
||||
|
||||
return contact
|
||||
}
|
||||
|
||||
func ParseNodeMessage(msg binary.Node) interface{} {
|
||||
switch msg.Description {
|
||||
case "battery":
|
||||
return getBatteryMessage(msg.Attributes)
|
||||
case "user":
|
||||
return getNewContact(msg.Attributes)
|
||||
default:
|
||||
//cannot match message
|
||||
}
|
||||
|
6
vendor/github.com/Rhymen/go-whatsapp/session.go
generated
vendored
6
vendor/github.com/Rhymen/go-whatsapp/session.go
generated
vendored
@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
//represents the WhatsAppWeb client version
|
||||
var waVersion = []int{2, 2033, 7}
|
||||
var waVersion = []int{2, 2039, 9}
|
||||
|
||||
/*
|
||||
Session contains session individual information. To be able to resume the connection without scanning the qr code
|
||||
@ -141,11 +141,11 @@ func CheckCurrentServerVersion() ([]int, error) {
|
||||
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 {
|
||||
func (wac *Conn) SetClientName(long, short string, version string) error {
|
||||
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
|
||||
wac.longClientName, wac.shortClientName, wac.clientVersion = long, short, version
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user