Get Mentions (#35)

This commit is contained in:
Aliyss Snow
2020-02-06 20:47:47 +01:00
committed by GitHub
parent 0cbc24fc6c
commit 4b1768450f

View File

@@ -90,6 +90,16 @@ class Message extends Base {
*/
this.hasQuotedMsg = data.quotedMsg ? true : false;
/**
* Indicates the mentions in the message body.
* @type {Array<string>}
*/
this.mentionedIds = [];
if (data.mentionedJidList) {
this.mentionedIds = data.mentionedJidList;
}
return super._patch(data);
}
@@ -113,6 +123,14 @@ class Message extends Base {
return this.client.getContactById(this._getChatId());
}
/**
* Returns the Contacts mentioned in this message
* @returns {Promise<Array<Contact>>}
*/
async getMentions() {
return await Promise.all(this.mentionedIds.map(async m => await this.client.getContactById(m)));
}
/**
* Returns the quoted message, if any
* @returns {Promise<Message>}
@@ -178,4 +196,4 @@ class Message extends Base {
}
}
module.exports = Message;
module.exports = Message;