Skip to content

Commit

Permalink
feat: Get new messages chat
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Feb 12, 2021
1 parent 8e6c0db commit 674b1c8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
**Grupo de Suporte do Venom em português do Brasil | R$ 30 Mensais** <br> <br>
<a target="_blank" href="https://web.whatsapp.com/send?phone=556181590153&text=I%20want%20access%20to%20the%20WhatsApp%20Venom%20support%20group" target="_blank"><img title="whatzapp" height="75" width="300" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/WhatsApp_logo.svg/2000px-WhatsApp_logo.svg.png"></a>


## 🕷🕷 Functions Venom🕷🕷

| | |
Expand Down Expand Up @@ -569,6 +568,12 @@ await client.setChatState('[email protected]', 0 | 1 | 2);
## Retrieving Data
```javascript
//Retrieve all contacts new messages
const ContactNewMsg = await client.getChatContactNewMsg();

//Retrieve all groups new messages
const GroupNewMsg = await client.getChatGroupNewMsg();

// Returns a list of mute and non-mute users
// "all" List all mutes
// "toMute" List all silent chats
Expand Down
25 changes: 15 additions & 10 deletions src/api/layers/retriever.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,23 @@ export class RetrieverLayer extends SenderLayer {
}

/**
* Retrieve all groups
* Retrieve all groups new messages
* @returns array of groups
*/
public async getAllGroups(withNewMessagesOnly = false) {
if (withNewMessagesOnly) {
// prettier-ignore
const chats = await this.page.evaluate(() => WAPI.getAllChatsWithNewMsg());
return chats.filter((chat) => chat.isGroup);
} else {
const chats = await this.page.evaluate(() => WAPI.getAllChats());
return chats.filter((chat) => chat.isGroup);
}
public async getChatGroupNewMsg() {
// prettier-ignore
const chats = await this.page.evaluate(() => WAPI.getAllChatsWithNewMsg());
return chats.filter((chat) => chat.kind === 'group');
}

/**
* Retrieve all contact new messages
* @returns array of groups
*/
public async getChatContactNewMsg() {
// prettier-ignore
const chats = await this.page.evaluate(() => WAPI.getAllChatsWithNewMsg());
return chats.filter((chat) => chat.kind === 'chat');
}

/**
Expand Down

0 comments on commit 674b1c8

Please sign in to comment.