Comments (6)
Hi,
As I said without calling contacts() I do not get anything.
When I call contacts() I see the printouts from your package, and it panics few times (I have panic recovery) while printing the contacts, and before each panic I see this print out (with broadcast):
**{user map[jid:status@broadcast] <nil>}**
echo: http: panic serving [::1]:51429: runtime error: slice bounds out of range
goroutine 712 [running]:
net/http.(*conn).serve.func1(0xc042207540)
C:/Go/src/net/http/server.go:1726 +0xd7
panic(0x8f0240, 0xc5a950)
C:/Go/src/runtime/panic.go:502 +0x237
github.com/Rhymen/go-whatsapp.(*Conn).decryptBinaryMessage(0xc0421de1c0, 0xc8ab78, 0x0, 0x0, 0x0, 0x0, 0x800a)
C:/workspaces/src/github.com/Rhymen/go-whatsapp/conn.go:246 +0x3d2
github.com/Rhymen/go-whatsapp.(*Conn).query(0xc0421de1c0, 0x98a5fa, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
C:/workspaces/src/github.com/Rhymen/go-whatsapp/contact.go:155 +0x40c
github.com/Rhymen/go-whatsapp.(*Conn).Contacts(0xc0421de1c0, 0x0, 0x0, 0xc8ab78)
C:/workspaces/src/github.com/Rhymen/go-whatsapp/contact.go:103 +0x7d
I was able to fix this issue when I added this code, I'm not sure this is the correct fix:
func (wac *Conn) decryptBinaryMessage(msg []byte) (*binary.Node, error) {
//message validation
//---------------- MY CODE STARTS HERE
if len(msg) == 0 {
fmt.Println("Got empty msg to decrypt [%s]", msg)
return nil, nil
}
//---------------- MY CODE FINISH HERE
h2 := hmac.New(sha256.New, wac.session.MacKey)
h2.Write([]byte(msg[32:]))
....
from go-whatsapp.
Hi, I try to download the latest version and reinstall it, I am able to normally extract the user name through Contact with the following command wac.Store.Contacts [message.Info.RemoteJid] .Notify
from go-whatsapp.
I tried to debug it aswell, but I couldn't reproduce the error. As @jhow2892 mentioned, you can get the contact by looking into wac.Store.Contacts[jid]
. The wac.Contacts()
function is used to update the local store with the values from your phone. You don't need to do this when you start your program, because whatsapp syncs the contacts once after every login.
What does the wac.Contacts()
func respond for you? Watch out to not expose any phone numbers or names. As for me it responds with {response map[type:contacts duplicate:true] <nil>}
.
from go-whatsapp.
Hi,
Thanks guys for the quick response.
I'm looking to get all contacts, not only one by jid.
When I call wac.Contacts() from last week the code, I used to get this result {response map[type:contacts duplicate:true] }, but since I update to the new code, that stores the contact is wac.Store and I call wac.Contacts() I get the above panic.
I tried your suggestion, and now I'm not calling wac.Contacts(), I do login, I get a session with no errors, few seconds later I print out the wac.Store.Contacts, and I get empty map.
Here is my code: is there anything I'm doing wrong:
func (ws *waSession) GetContacts() (waContacts []WaContact, err error) {
waContacts = make([]WaContact, 0)
//_, err = ws.wac.Contacts()
//if err != nil {
// return waContacts, fmt.Errorf("error loading contacts %s", err)
//}
contacts := ws.wac.Store.Contacts
for key, contact := range contacts {
fmt.Printf("contact (%s): %#v\n", key, contact)
waContacts = append(waContacts, WaContact{
Name: contact.Name,
Phone: key,
ShortName: contact.Short,
})
}
return waContacts,nil
}
from go-whatsapp.
The stacktrace obove shows that the error got invoked in
C:/workspaces/src/github.com/Rhymen/go-whatsapp/contact.go:103 +0x7d
This line contains the wac.writeBinary(...)
call inside the Presence(...)
function. I don´t know why it fails, but this function call does not correspond to your described error for calling Contacts()
. Maybe comment out the call of Presence(...)
for testing purposes.
from go-whatsapp.
Fixed in 955ab6f
from go-whatsapp.
Related Issues (20)
- How to encrypt chats data
- Any way to update client's status through api HOT 5
- invalid media hmac for audio messages, sended with drag-n-drop HOT 1
- cannot unmarshal array into Go value of type map[string]interface {} HOT 2
- Imposible scan the api qrcode from Whatsapp Bussines after today updates HOT 6
- Error after scan QR Code HOT 6
- I created an api but it has an error
- error creating connection: couldn't dial whatsapp web websocket: websocket: bad handshake HOT 3
- multidevice support HOT 1
- qrcode scan issue from Whatsapp Bussines after today update HOT 4
- I understand the code was abandoned ? HOT 1
- Use this API to send messages
- > error logging in: error during login: error decoding login resp: json: cannot unmarshal array into Go value of type map[string]interface {} HOT 2
- Is it possible to make the instance occupied 30-50mb RAM?
- Error try login
- websocket bad handsake HOT 3
- I also have a new version,And update in real-time
- new function Check is whatsapp number or not HOT 1
- is whatsapp registeration available?
- connection problem HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-whatsapp.