Skip to content

Commit

Permalink
fix: getAllGroups return
Browse files Browse the repository at this point in the history
  • Loading branch information
orkestral committed Feb 27, 2021
1 parent 619d983 commit 7673f1e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "venom-bot",
"version": "3.0.2",
"version": "3.0.4",
"description": "Venom is a high-performance system developed with JavaScript to create a bot for WhatsApp, support for creating any interaction, such as customer service, media sending, sentence recognition based on artificial intelligence and all types of design architecture for WhatsApp. ",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
15 changes: 15 additions & 0 deletions src/api/layers/group.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ export class GroupLayer extends RetrieverLayer {
super(page, session, options);
}

/**
* Retrieve all groups
* @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);
}
}

/**
* Removes the host device from the group
* @param groupId group id
Expand Down

0 comments on commit 7673f1e

Please sign in to comment.