You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+87-53Lines changed: 87 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,6 @@ WhatsJava is a reimplementation of the WhatsApp Web API and provides a direct in
3
3
4
4
Big thanks to [@Sigalor](https://github.com/sigalor) and all participants of the [whatsapp-web-reveng project](https://github.com/sigalor/whatsapp-web-reveng) and [@adiwajshing](https://github.com/adiwajshing/Baileys) for the Typescript/Javascript implementation.
5
5
6
-
This project is **WIP** and things could break in the future.
7
-
8
6
### Gradle
9
7
```java
10
8
allprojects {
@@ -22,26 +20,33 @@ dependencies {
22
20
Find more options here: **[Jitpack](https://jitpack.io/#JicuNull/WhatsJava)**
23
21
24
22
## How to use it
25
-
**Note**: The project is tested and compiled with Java 11
23
+
**Note**: The project is tested with Java 11
26
24
27
-
###Connect and login
25
+
## Connect and login
28
26
`WAClient` connects to the WhatsApp backend server and is used for all interactions with the server. Therefore, a new `WAClient` instance needs to be created first.
29
27
30
-
A path to a storage location is also required to store the keys needed to reestablish a session.
31
28
```java
32
-
WAClient client =newWAClient("auth.json");
29
+
WAClient client =newWAClient();
33
30
```
34
31
The session is opened by calling `openConnection()`.
35
32
```java
36
-
WAClient client =newWAClient("auth.json");
33
+
WAClient client =newWAClient();
37
34
client.openConnection();
38
35
```
39
-
After a session has been successfully initialized, a qr code must be scanned from the device where WhatsApp is running on. To learn how to receive the qr code please refer to "Message handlers".
36
+
You can also define a path to a storage location to store keys needed to reestablish a session.
37
+
```java
38
+
client.setCredentialsPath("credentials.json"); // Optional - It defaults to "credentials.json"
39
+
```
40
+
After a session has been successfully initialized, a qr code must be scanned from the device where WhatsApp is running on. To print a QR code in the console, call the setPrintQRCode() method:
41
+
```java
42
+
client.setPrintQRCode(true);
43
+
```
44
+
To learn how to receive the qr code as BufferedImage please refer to "Message handlers".
40
45
41
-
###Message handlers
46
+
## Message handlers
42
47
After a WAClient instance is initialized, the `addClientActionListener` method can be called to register a `ClientActionInterface` and receive a number of callbacks. `ClientActionListener` is an empty implementation of `ClientActionInterface` interface.
43
48
44
-
- Called when a new qr code has been generated and has to be scanned for login. A qr code has a lifetime of 20 seconds, which is why it can be generated up to five times.
49
+
- Called when a new qr code has been generated and has to be scanned for login. A qr code has a lifetime of 20 second sand up to 5 five new ones can be created.
When you query the messages of a chat, you get an array of WAMessage objects, which in turn can contain different types of message types. To determine which type it is, the methods ```waMessage.hasImageMessage()```, ```waMessage.hasVideoMessage()```, ```waMessage.hasConversationMessage()``` and ```waMessage.hasStubMessage()``` can be used.
0 commit comments