From 71dbe990237e8ef7a569ea7b04d84e82afcb430a Mon Sep 17 00:00:00 2001 From: "Pedro S. Lopez" Date: Fri, 25 Dec 2020 19:52:50 -0400 Subject: [PATCH] feat: get Contact's "About" text (close #491) --- index.d.ts | 4 ++++ src/structures/Contact.js | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/index.d.ts b/index.d.ts index 1775aff..799d6a6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -679,6 +679,10 @@ declare namespace WAWebJS { block: () => Promise, /** Unlocks this contact from WhatsApp */ unblock: () => Promise, + + /** Gets the Contact's current "about" info. Returns null if you don't have permission to read their status. */ + getAbout: () => Promise, + } export interface ContactId { diff --git a/src/structures/Contact.js b/src/structures/Contact.js index 0b58adc..f8ec4e9 100644 --- a/src/structures/Contact.js +++ b/src/structures/Contact.js @@ -152,6 +152,21 @@ class Contact extends Base { return true; } + + /** + * Gets the Contact's current "about" info. Returns null if you don't have permission to read their status. + * @returns {Promise} + */ + async getAbout() { + const about = await this.client.pupPage.evaluate(async (contactId) => { + return window.Store.Wap.statusFind(contactId); + }, this.id._serialized); + + if (typeof about.status !== 'string') + return null; + + return about.status; + } }