mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-21 13:09:15 +00:00
Return new message after sending
This commit is contained in:
@@ -25,7 +25,11 @@ class Chat extends Base {
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
sendMessage(message) {
|
||||
/**
|
||||
* Sends a message to this chat.
|
||||
* @param {string} message
|
||||
*/
|
||||
async sendMessage(message) {
|
||||
return this.client.sendMessage(this.id._serialized, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,18 +48,18 @@ class Message extends Base {
|
||||
chatId = this.from;
|
||||
}
|
||||
|
||||
return await this.client.pupPage.evaluate((chatId, quotedMessageId, message) => {
|
||||
const newMessage = await this.client.pupPage.evaluate(async (chatId, quotedMessageId, message) => {
|
||||
let quotedMessage = Store.Msg.get(quotedMessageId);
|
||||
if(quotedMessage.canReply()) {
|
||||
const chat = Store.Chat.get(chatId);
|
||||
chat.composeQuotedMsg = quotedMessage;
|
||||
window.Store.SendMessage(chat, message, {quotedMsg: quotedMessage});
|
||||
chat.composeQuotedMsg = null;
|
||||
const newMessage = await WWebJS.sendMessage(chat, message, quotedMessage.msgContextInfo(chat));
|
||||
return newMessage.serialize();
|
||||
} else {
|
||||
throw new Error('This message cannot be replied to.');
|
||||
}
|
||||
|
||||
}, chatId, this.id._serialized, message);
|
||||
|
||||
return new Message(this.client, newMessage);
|
||||
}
|
||||
|
||||
async downloadMedia() {
|
||||
|
||||
Reference in New Issue
Block a user