From 04f2200af27fb1f0fab4487b6b017c6937b9bc3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3nalan=20de=20Lima?= Date: Sat, 27 Feb 2021 13:03:21 -0300 Subject: [PATCH] feat: getChatGroupNewMsg --- README.md | 3 +++ src/api/layers/group.layer.ts | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index 18fb8218b..c8e183086 100644 --- a/README.md +++ b/README.md @@ -515,6 +515,9 @@ const chats = await client.getAllChats(); // Retrieve all groups const chats = await client.getAllChatsGroups(); +//Retrieve all groups new messages +const groupNewMsg = await client.getChatGroupNewMsg(); + // Retrieve profile fic (as url) const url = await client.getProfilePicFromServer('000000000000@c.us'); diff --git a/src/api/layers/group.layer.ts b/src/api/layers/group.layer.ts index c8edcbd44..4d6994947 100644 --- a/src/api/layers/group.layer.ts +++ b/src/api/layers/group.layer.ts @@ -73,6 +73,17 @@ export class GroupLayer extends RetrieverLayer { }); } + /** + * Retrieve all groups new messages + * @returns array of groups + */ + public async getChatGroupNewMsg() { + return await this.page.evaluate(() => { + let chats = WAPI.getAllChatsWithNewMsg(); + return chats.filter((chat) => chat.kind === 'group'); + }); + } + /** * Removes the host device from the group * @param groupId group id