Louuke / WhatsJava

Implementation of the WhatsApp Web API in Java
Apache License 2.0
37 stars 16 forks source link

Adding new feature to request status information for a contact #10

Closed mynote closed 2 years ago

mynote commented 3 years ago

A function to request this information including online status would be great.

This is very helpful to see if someone is or was online. After debugging there is a data packet when a client clicked on your profile (not 100% sure).

Online status is also returned if you requested the status at least once (at least in https://github.com/Enrico204/whatsapp-decoding/blob/master/PROTOCOL.md).

Tried extending, but none of that worked.`I am not 100% sure how the json is generated.

public void loadContact(String remoteJid) {
      sendBinary("[\"query\", {type: \"Presence\", lastseen: \"" + remoteJid + "\"},  null]", WAMetric.queryStatus, WAFlag.ignore);
      sendBinary("[\"query\",  {type: \"ProfilePicThumb\"}, \""+remoteJid+"\"]", WAMetric.queryStatus, WAFlag.ignore)
}
iammert commented 3 years ago

@JicuNull any work on this?

Louuke commented 3 years ago

Hey! I have rewritten large parts of the API in the last few days, restructured it and added new functions. Among other things, there are now the methods getChatPicture(String remoteJid) and requestPresenceUpdate(String remoteJid), which do what you wanted to implement.

Your approach was not that wrong, however the messages that need to be sent in this case are not binary messages, but plain text messages. Like this:

String request = String.format("[\"query\", \"ProfilePicThumb\", \"%s\"]", content[0]);