feat: forward messages

close #316
This commit is contained in:
Pedro Lopez
2020-08-25 23:00:35 -04:00
parent 590ecc2351
commit 502b22f6d7
2 changed files with 21 additions and 0 deletions

View File

@@ -190,6 +190,23 @@ class Message extends Base {
return this.client.sendMessage(chatId, content, options);
}
/**
* Forwards this message to another chat
*
* @param {string|Chat} chat Chat model or chat ID to which the message will be forwarded
* @returns {Promise}
*/
async forward(chat) {
const chatId = typeof chat === 'string' ? chat : chat.id._serialized;
await this.client.pupPage.evaluate(async (msgId, chatId) => {
let msg = window.Store.Msg.get(msgId);
let chat = window.Store.Chat.get(chatId);
return await chat.forwardMessages([msg]);
}, this.id._serialized, chatId);
}
/**
* Downloads and returns the attatched message media
* @returns {Promise<MessageMedia>}