Skip to content

Commit

Permalink
Adjusting to API change in Rhymen/go-whatsapp@4be474a.
Browse files Browse the repository at this point in the history
Closes #10.
  • Loading branch information
hoehermann committed May 16, 2019
1 parent a736501 commit 6acd204
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Being developed on Ubuntu 18.04.

### Building

* Have at least [go-whatsapp e51cd7d](https://github.com/Rhymen/go-whatsapp/commit/e51cd7d0bbd46ddee94a6b2115d4c8d9c2e86a33) or newer.
* Have Rhymen/go-whatsapp@4be474aa8320557ead966e74d357ca975117e360.
* Build using the supplied Makefile.
* Place the binary in your Pidgin's plugin directory (`~/.purple/plugins` on Linux).

Expand Down
12 changes: 4 additions & 8 deletions purplegwa.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ struct gowhatsapp_session {
import "C"

import (
"encoding/base64"
"encoding/hex"
"encoding/base64"
"fmt"
"os"
"time"
"strings"
"math/rand"

"github.com/Rhymen/go-whatsapp"
"github.com/skip2/go-qrcode"
Expand All @@ -71,22 +69,20 @@ func gowhatsapp_go_sendMessage(connID C.uintptr_t, who *C.char, text *C.char) *C
if remoteJid == "[email protected]" {
return nil
}
b := make([]byte, 10)
rand.Read(b) // according to https://github.com/Rhymen/go-whatsapp/issues/43
message := whatsapp.TextMessage{
Info: whatsapp.MessageInfo{
RemoteJid: remoteJid,
Id: strings.ToUpper(hex.EncodeToString(b)),
},
Text: C.GoString(text),
}
handler := waHandlers[connID]
if err := handler.wac.Send(message); err != nil {
msgId, err := handler.wac.Send(message)
if err != nil {
handler.messages <- makeConversationErrorMessage(message.Info,
fmt.Sprintf("Unable to send message: %v", err))
return nil
}
return C.CString(message.Info.Id)
return C.CString(msgId)
}

// TODO: find out how to enable C99's bool type in cgo
Expand Down

0 comments on commit 6acd204

Please sign in to comment.