diff options
author | Wim <wim@42.be> | 2020-01-09 21:02:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-09 21:02:56 +0100 |
commit | 0f708daf2d14dcca261ef98cc698a1b1f2a6aa74 (patch) | |
tree | 022eee21366d6a9a00feaeff918972d9e72632c2 /vendor/github.com/Rhymen/go-whatsapp/README.md | |
parent | b9354de8fd5e424ac2f246fff1a03b27e8094fd8 (diff) | |
download | matterbridge-msglm-0f708daf2d14dcca261ef98cc698a1b1f2a6aa74.tar.gz matterbridge-msglm-0f708daf2d14dcca261ef98cc698a1b1f2a6aa74.tar.bz2 matterbridge-msglm-0f708daf2d14dcca261ef98cc698a1b1f2a6aa74.zip |
Update dependencies (#975)
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/README.md')
-rw-r--r-- | vendor/github.com/Rhymen/go-whatsapp/README.md | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/README.md b/vendor/github.com/Rhymen/go-whatsapp/README.md index 1248b8f9..5f439d55 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/README.md +++ b/vendor/github.com/Rhymen/go-whatsapp/README.md @@ -23,7 +23,7 @@ qrChan := make(chan string) go func() { fmt.Printf("qr code: %v\n", <-qrChan) //show qr code or save it somewhere to scan -} +}() sess, err := wac.Login(qrChan) ``` The authentication process requires you to scan the qr code, that is send through the channel, with the device you are using whatsapp on. The session struct that is returned can be saved and used to restore the login without scanning the qr code again. The qr code has a ttl of 20 seconds and the login function throws a timeout err if the time has passed or any other request fails. @@ -66,6 +66,10 @@ func (myHandler) HandleJsonMessage(message string) { fmt.Println(message) } +func (myHandler) HandleContactMessage(message whatsapp.ContactMessage) { + fmt.Println(message) +} + 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. @@ -81,6 +85,21 @@ text := whatsapp.TextMessage{ err := wac.Send(text) ``` + +### Sending Contact Messages +```go +contactMessage := whatsapp.ContactMessage{ + Info: whatsapp.MessageInfo{ + RemoteJid: "0123456789@s.whatsapp.net", + }, + DisplayName: "Luke Skylwallker", + Vcard: "BEGIN:VCARD\nVERSION:3.0\nN:Skyllwalker;Luke;;\nFN:Luke Skywallker\nitem1.TEL;waid=0123456789:+1 23 456789789\nitem1.X-ABLabel:Mobile\nEND:VCARD", + } + +id, error := client.WaConn.Send(contactMessage) +``` + + The message will be send over the websocket. The attributes seen above are the required ones. All other relevant attributes (id, timestamp, fromMe, status) are set if they are missing in the struct. For the time being we only support text messages, but other types are planned for the near future. ## Legal |