-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
922 additions
and
475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,7 @@ const fs = require('fs'); | |
|
||
(async () => { | ||
let client; | ||
let checkConnect = false; | ||
// start bot service | ||
const ev = await hydraBot.initServer(); | ||
|
||
|
@@ -104,7 +105,8 @@ const fs = require('fs'); | |
} | ||
|
||
// Was connected to whatsapp chat | ||
if (conn.connect) { | ||
if (conn.connect && !checkConnect) { | ||
checkConnect = true; | ||
client = conn.client; // class client from hydra-bot | ||
const getMe = await client.getHost(); | ||
const hostNumber = getMe.id._serialized; // number host | ||
|
@@ -539,13 +541,29 @@ const contacts = await client.getAllContacts(); | |
|
||
// return whatsapp version | ||
const version = await client.getWAVersion(); | ||
|
||
// Load all messages in chat by date | ||
const listMsg = await client.loadAndGetAllMessagesInChat( | ||
'<phone Number>@c.us', | ||
'YYYY-MM-DD' | ||
); | ||
``` | ||
|
||
## Group Management | ||
|
||
Group number example `<phone Number>-<groupId>@g.us` or `<phone Number><groupId>@g.us` | ||
|
||
```javascript | ||
// get all participants in the group | ||
await client | ||
.getGroupParticipant('[email protected]') | ||
.then((result) => { | ||
console.log('Participants: ', result); | ||
}) | ||
.catch((error) => { | ||
console.log('Error Participants: ', error); | ||
}); | ||
|
||
// Get all Group | ||
const allGroups = await client.getAllChatsGroups(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ To use these functions, it is necessary to initialize the bot. | |
- [addParticipant](#addparticipant) | ||
- [setGroupDescription](#setgroupdescription) | ||
- [setGroupImage](#setgroupimage) | ||
- [getGroupParticipant](#getGroupParticipant) | ||
|
||
### Retrieve all groups | ||
|
||
|
@@ -77,4 +78,18 @@ await client.setGroupImage('[email protected]', './file.jpg') | |
}); | ||
``` | ||
|
||
### getGroupParticipant | ||
|
||
Get all participants in the group | ||
|
||
```javascript | ||
await client | ||
.getGroupParticipant('[email protected]') | ||
.then((result) => { | ||
console.log('Participants: ', result); | ||
}) | ||
.catch((error) => { | ||
console.log('Error Participants: ', error); | ||
}); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.