From 130da046f5f945b1583c823f2e79da2af19b24eb Mon Sep 17 00:00:00 2001
From: Pedro Lopez
Date: Wed, 26 Feb 2020 23:34:01 -0400
Subject: [PATCH] chore: mark version v1.1.0
---
docs/Base.html | 6 +-
docs/BusinessContact.html | 6 +-
docs/Chat.html | 74 +++++++--
docs/Client.html | 98 ++++++++++-
docs/Client.js.html | 128 ++++++++++++---
docs/ClientInfo.html | 6 +-
docs/Contact.html | 6 +-
docs/GroupChat.html | 84 ++++++++--
docs/Location.html | 6 +-
docs/Message.html | 50 +++++-
docs/MessageMedia.html | 6 +-
docs/PrivateChat.html | 82 ++++++++--
docs/PrivateContact.html | 6 +-
docs/Util.html | 6 +-
docs/global.html | 125 +++++++++++++-
docs/index.html | 208 +++++++++++++++++++++---
docs/structures_Base.js.html | 6 +-
docs/structures_BusinessContact.js.html | 6 +-
docs/structures_Chat.js.html | 47 +++++-
docs/structures_ClientInfo.js.html | 6 +-
docs/structures_Contact.js.html | 6 +-
docs/structures_GroupChat.js.html | 6 +-
docs/structures_Location.js.html | 6 +-
docs/structures_Message.js.html | 22 ++-
docs/structures_MessageMedia.js.html | 6 +-
docs/structures_PrivateChat.js.html | 6 +-
docs/structures_PrivateContact.js.html | 6 +-
docs/util_Constants.js.html | 26 ++-
docs/util_Util.js.html | 6 +-
package.json | 2 +-
30 files changed, 886 insertions(+), 168 deletions(-)
diff --git a/docs/Base.html b/docs/Base.html
index b86f4fb..ae45336 100644
--- a/docs/Base.html
+++ b/docs/Base.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Class: Base
+ whatsapp-web.js 1.1.0 » Class: Base
@@ -15,7 +15,7 @@
@@ -50,7 +50,7 @@
diff --git a/docs/BusinessContact.html b/docs/BusinessContact.html
index 8fd9ce2..1076acd 100644
--- a/docs/BusinessContact.html
+++ b/docs/BusinessContact.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Class: BusinessContact
+ whatsapp-web.js 1.1.0 » Class: BusinessContact
@@ -15,7 +15,7 @@
@@ -227,7 +227,7 @@
diff --git a/docs/Chat.html b/docs/Chat.html
index bbe85fe..03f9246 100644
--- a/docs/Chat.html
+++ b/docs/Chat.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Class: Chat
+ whatsapp-web.js 1.1.0 » Class: Chat
@@ -15,7 +15,7 @@
@@ -39,6 +39,9 @@
@@ -96,6 +115,11 @@
Properties
+ archived
+ boolean
+ Indicates if the Chat is archived
+
+
id
object
ID that represents the chat
@@ -127,8 +151,33 @@
- Method
+ Methods
+ async
+ archive()
+ Archives this chat
+
+
+ async
+ clearMessages() → Promise containing Boolean
+ Clears all messages from the chat
+
+ - Returns
+ -
+
Promise containing Boolean
result
+
+
+
+ async
+ delete() → Promise containing Boolean
+ Deletes the chat
+
+ - Returns
+ -
+
Promise containing Boolean
result
+
+
+
async
sendMessage(content, options) → Promise containing Message
Send a message to this chat
@@ -180,6 +229,11 @@
+ async
+ unarchive()
+ un-archives this chat
+
+
@@ -190,7 +244,7 @@
diff --git a/docs/Client.html b/docs/Client.html
index c75c340..98b5413 100644
--- a/docs/Client.html
+++ b/docs/Client.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Class: Client
+ whatsapp-web.js 1.1.0 » Class: Client
@@ -15,7 +15,7 @@
@@ -42,6 +42,9 @@
acceptInvite(inviteCode)
+ archiveChat()
+
+
destroy()
@@ -61,6 +64,9 @@
getContacts()
+ getState()
+
+
@@ -102,19 +111,22 @@
message
+ message_ack
+
+
message_create
message_revoke_everyone
- message_revoke_me
-
-
+ - message_revoke_me
+ -
+
- qr
-
@@ -182,6 +194,15 @@
async
+ archiveChat() → boolean
+ Enables and returns the archive state of the Chat
+
+ - Returns
+ -
+
boolean
+
+
+ async
destroy()
Closes the client
@@ -279,6 +300,15 @@
async
+
+ Gets the current connection state for the client
+
+ - Returns
+ -
+
WAState
+
+
+ async
initialize()
Sets up events and requirements, kicks off authentication request
@@ -381,6 +411,15 @@
+ async
+ unarchiveChat() → boolean
+ Changes and returns the archive state of the Chat
+
+ - Returns
+ -
+
boolean
+
+
Events
+ message_ack
+ Emitted when an ack event occurrs on message type.
+
+ Parameters
+
+
+
+ | Name |
+ Type |
+ Optional |
+ Description |
+
+
+
+
+ |
+ message
+ |
+
+ Message
+ |
+
+
+ |
+
+ The message that was affected
+ |
+
+
+ |
+ ack
+ |
+
+ MessageAck
+ |
+
+
+ |
+
+ The new ACK value
+ |
+
+
+
+
+
+
message_create
Emitted when a new message is created, which may include the current user's own messages.
@@ -710,7 +796,7 @@
diff --git a/docs/Client.js.html b/docs/Client.js.html
index 60e663b..143188b 100644
--- a/docs/Client.js.html
+++ b/docs/Client.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: Client.js
+ whatsapp-web.js 1.1.0 » Source: Client.js
@@ -15,7 +15,7 @@
@@ -75,7 +75,7 @@ class Client extends EventEmitter {
*/
async initialize() {
const browser = await puppeteer.launch(this.options.puppeteer);
- const page = await browser.newPage();
+ const page = (await browser.pages())[0];
page.setUserAgent(UserAgent);
if (this.options.session) {
@@ -114,21 +114,34 @@ class Client extends EventEmitter {
}
} else {
- // Wait for QR Code
- const QR_CANVAS_SELECTOR = 'canvas';
- await page.waitForSelector(QR_CANVAS_SELECTOR);
- const qrImgData = await page.$eval(QR_CANVAS_SELECTOR, canvas => [].slice.call(canvas.getContext('2d').getImageData(0,0,264,264).data));
- const qr = jsQR(qrImgData, 264, 264).data;
-
- /**
- * Emitted when the QR code is received
- * @event Client#qr
- * @param {string} qr QR Code
- */
- this.emit(Events.QR_RECEIVED, qr);
+ const getQrCode = async () => {
+ // Check if retry button is present
+ var QR_RETRY_SELECTOR = 'div[data-ref] > span > div';
+ var qrRetry = await page.$(QR_RETRY_SELECTOR);
+ if (qrRetry) {
+ await qrRetry.click();
+ }
+
+ // Wait for QR Code
+
+ const QR_CANVAS_SELECTOR = 'canvas';
+ await page.waitForSelector(QR_CANVAS_SELECTOR);
+ const qrImgData = await page.$eval(QR_CANVAS_SELECTOR, canvas => [].slice.call(canvas.getContext('2d').getImageData(0, 0, 264, 264).data));
+ const qr = jsQR(qrImgData, 264, 264).data;
+ /**
+ * Emitted when the QR code is received
+ * @event Client#qr
+ * @param {string} qr QR Code
+ */
+ this.emit(Events.QR_RECEIVED, qr);
+ };
+ getQrCode();
+ let retryInterval = setInterval(getQrCode, 20000); // check for qr code every 20 seconds
// Wait for code scan
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
+ clearInterval(retryInterval);
+
}
await page.evaluate(ExposeStore, moduleRaid.toString());
@@ -193,7 +206,7 @@ class Client extends EventEmitter {
if (msg.type === 'revoked') {
const message = new Message(this, msg);
let revoked_msg;
- if(last_message && msg.id.id === last_message.id.id) {
+ if (last_message && msg.id.id === last_message.id.id) {
revoked_msg = new Message(this, last_message);
}
@@ -206,11 +219,11 @@ class Client extends EventEmitter {
*/
this.emit(Events.MESSAGE_REVOKED_EVERYONE, message, revoked_msg);
}
-
+
});
await page.exposeFunction('onChangeMessageEvent', (msg) => {
-
+
if (msg.type !== 'revoked') {
last_message = msg;
}
@@ -232,6 +245,20 @@ class Client extends EventEmitter {
});
+ await page.exposeFunction('onMessageAckEvent', (msg, ack) => {
+
+ const message = new Message(this, msg);
+
+ /**
+ * Emitted when an ack event occurrs on message type.
+ * @event Client#message_ack
+ * @param {Message} message The message that was affected
+ * @param {MessageAck} ack The new ACK value
+ */
+ this.emit(Events.MESSAGE_ACK, message, ack);
+
+ });
+
await page.exposeFunction('onAppStateChangedEvent', (_AppState, state) => {
/**
@@ -257,6 +284,7 @@ class Client extends EventEmitter {
window.Store.Msg.on('add', window.onAddMessageEvent);
window.Store.Msg.on('change', window.onChangeMessageEvent);
window.Store.Msg.on('change:type', window.onChangeMessageTypeEvent);
+ window.Store.Msg.on('change:ack', window.onMessageAckEvent);
window.Store.Msg.on('remove', window.onRemoveMessageEvent);
window.Store.AppState.on('change:state', window.onAppStateChangedEvent);
});
@@ -285,26 +313,42 @@ class Client extends EventEmitter {
* @param {object} options
* @returns {Promise<Message>} Message that was just sent
*/
- async sendMessage(chatId, content, options={}) {
+ async sendMessage(chatId, content, options = {}) {
let internalOptions = {
caption: options.caption,
quotedMessageId: options.quotedMessageId,
- mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : []
+ mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : []
};
- if(content instanceof MessageMedia) {
+ if (content instanceof MessageMedia) {
internalOptions.attachment = content;
content = '';
- } else if(options.media instanceof MessageMedia) {
+ } else if (options.media instanceof MessageMedia) {
internalOptions.attachment = options.media;
internalOptions.caption = content;
- } else if(content instanceof Location) {
+ } else if (content instanceof Location) {
internalOptions.location = content;
content = '';
}
const newMessage = await this.pupPage.evaluate(async (chatId, message, options) => {
- const msg = await window.WWebJS.sendMessage(window.Store.Chat.get(chatId), message, options);
+ let chat = window.Store.Chat.get(chatId);
+ let msg;
+ if (!chat) { // The chat is not available in the previously chatted list
+
+ let newChatId = await window.WWebJS.getNumberId(chatId);
+ if (newChatId) {
+ //get the topmost chat object and assign the new chatId to it .
+ //This is just a workaround.May cause problem if there are no chats at all. Need to dig in and emulate how whatsapp web does
+ let chat = window.Store.Chat.models[0];
+ let originalChatObjId = chat.id;
+ chat.id = newChatId;
+ msg = await window.WWebJS.sendMessage(chat, message, options);
+ chat.id = originalChatObjId; //replace the chat with its original id
+ }
+ }
+ else
+ msg = await window.WWebJS.sendMessage(chat, message, options);
return msg.serialize();
}, chatId, content, internalOptions);
@@ -383,6 +427,40 @@ class Client extends EventEmitter {
}, status);
}
+ /**
+ * Gets the current connection state for the client
+ * @returns {WAState}
+ */
+ async getState() {
+ return await this.pupPage.evaluate(() => {
+ return window.Store.AppState.state;
+ });
+ }
+
+ /**
+ * Enables and returns the archive state of the Chat
+ * @returns {boolean}
+ */
+ async archiveChat(chatId) {
+ return await this.pupPage.evaluate(async chatId => {
+ let chat = await window.Store.Chat.get(chatId);
+ await window.Store.Cmd.archiveChat(chat, true);
+ return chat.archive;
+ }, chatId);
+ }
+
+ /**
+ * Changes and returns the archive state of the Chat
+ * @returns {boolean}
+ */
+ async unarchiveChat(chatId) {
+ return await this.pupPage.evaluate(async chatId => {
+ let chat = await window.Store.Chat.get(chatId);
+ await window.Store.Cmd.archiveChat(chat, false);
+ return chat.archive;
+ }, chatId);
+ }
+
}
module.exports = Client;
@@ -396,7 +474,7 @@ module.exports = Client;
diff --git a/docs/ClientInfo.html b/docs/ClientInfo.html
index fd16d3c..be5f90a 100644
--- a/docs/ClientInfo.html
+++ b/docs/ClientInfo.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Class: ClientInfo
+ whatsapp-web.js 1.1.0 » Class: ClientInfo
@@ -15,7 +15,7 @@
@@ -187,7 +187,7 @@
diff --git a/docs/Contact.html b/docs/Contact.html
index be03024..4cca527 100644
--- a/docs/Contact.html
+++ b/docs/Contact.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Class: Contact
+ whatsapp-web.js 1.1.0 » Class: Contact
@@ -15,7 +15,7 @@
@@ -196,7 +196,7 @@
diff --git a/docs/GroupChat.html b/docs/GroupChat.html
index 96c2083..d248290 100644
--- a/docs/GroupChat.html
+++ b/docs/GroupChat.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Class: GroupChat
+ whatsapp-web.js 1.1.0 » Class: GroupChat
@@ -15,7 +15,7 @@
@@ -39,6 +39,9 @@
@@ -145,6 +160,13 @@
Properties
+ archived
+ unknown
+ Indicates if the Chat is archived
+
+ - Inherited from
+ - Chat#archived
+
createdAt
date
Gets the date at which the group was created
@@ -314,6 +336,35 @@
async
+ archive()
+ Archives this chat
+
+ - Inherited from
+ - Chat#archive
+
+ async
+ clearMessages() → Promise containing Boolean
+ Clears all messages from the chat
+
+ - Inherited from
+ - Chat#clearMessages
+ - Returns
+ -
+
result
+
+
+ async
+ delete() → Promise containing Boolean
+ Deletes the chat
+
+ - Inherited from
+ - Chat#delete
+ - Returns
+ -
+
result
+
+
+ async
demoteParticipants(participantIds)
Demotes participants by IDs to regular users
+ async
+ unarchive()
+ un-archives this chat
+
+ - Inherited from
+ - Chat#unarchive
+
@@ -555,7 +613,7 @@
diff --git a/docs/Location.html b/docs/Location.html
index 5a2a0cb..b4131ba 100644
--- a/docs/Location.html
+++ b/docs/Location.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Class: Location
+ whatsapp-web.js 1.1.0 » Class: Location
@@ -15,7 +15,7 @@
@@ -149,7 +149,7 @@
diff --git a/docs/Message.html b/docs/Message.html
index 7cc1337..47d4259 100644
--- a/docs/Message.html
+++ b/docs/Message.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Class: Message
+ whatsapp-web.js 1.1.0 » Class: Message
@@ -15,7 +15,7 @@
@@ -98,6 +98,9 @@
- - getQuotedMessage()
- -
-
- reply(content, chatId, options)
-
@@ -214,6 +217,41 @@
Methods
+ async
+ delete(everyone)
+ Deletes a message from the chat
+
+ Parameter
+
+
+
+ | Name |
+ Type |
+ Optional |
+ Description |
+
+
+
+
+ |
+ everyone
+ |
+
+ boolean
+ |
+
+
+ |
+
+ If true and the message is sent by the current user, will delete it for everyone in the chat.
+ Value can be null.
+ |
+
+
+
+
+
+
async
Downloads and returns the attatched message media
@@ -333,7 +371,7 @@
diff --git a/docs/MessageMedia.html b/docs/MessageMedia.html
index 9ffca38..af2551f 100644
--- a/docs/MessageMedia.html
+++ b/docs/MessageMedia.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Class: MessageMedia
+ whatsapp-web.js 1.1.0 » Class: MessageMedia
@@ -15,7 +15,7 @@
@@ -152,7 +152,7 @@
diff --git a/docs/PrivateChat.html b/docs/PrivateChat.html
index 42d54fc..f203b91 100644
--- a/docs/PrivateChat.html
+++ b/docs/PrivateChat.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Class: PrivateChat
+ whatsapp-web.js 1.1.0 » Class: PrivateChat
@@ -15,7 +15,7 @@
@@ -39,6 +39,9 @@
@@ -96,6 +115,13 @@
Properties
+ archived
+ unknown
+ Indicates if the Chat is archived
+
+ - Inherited from
+ - Chat#archived
+
id
unknown
ID that represents the chat
@@ -139,8 +165,37 @@
- Chat#unreadCount
-
Method
+
Methods
+ async
+ archive()
+ Archives this chat
+
+ - Inherited from
+ - Chat#archive
+
+ async
+ clearMessages() → Promise containing Boolean
+ Clears all messages from the chat
+
+ - Inherited from
+ - Chat#clearMessages
+ - Returns
+ -
+
result
+
+
+ async
+ delete() → Promise containing Boolean
+ Deletes the chat
+
+ - Inherited from
+ - Chat#delete
+ - Returns
+ -
+
result
+
+
async
sendMessage(content, options) → Promise containing Message
Send a message to this chat
@@ -193,6 +248,13 @@
Message that was just sent
+ async
+ unarchive()
+ un-archives this chat
+
+ - Inherited from
+ - Chat#unarchive
+
@@ -203,7 +265,7 @@
diff --git a/docs/PrivateContact.html b/docs/PrivateContact.html
index ab9de8a..3e1a74a 100644
--- a/docs/PrivateContact.html
+++ b/docs/PrivateContact.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.0.2 » Class: PrivateContact
+
whatsapp-web.js 1.1.0 » Class: PrivateContact
@@ -15,7 +15,7 @@
@@ -220,7 +220,7 @@
diff --git a/docs/Util.html b/docs/Util.html
index 7d69ab9..e20adb1 100644
--- a/docs/Util.html
+++ b/docs/Util.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.0.2 » Class: Util
+
whatsapp-web.js 1.1.0 » Class: Util
@@ -15,7 +15,7 @@
@@ -50,7 +50,7 @@
diff --git a/docs/global.html b/docs/global.html
index c83e3c9..054717d 100644
--- a/docs/global.html
+++ b/docs/global.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.0.2 » Globals
+
whatsapp-web.js 1.1.0 » Globals
@@ -15,7 +15,7 @@
@@ -40,16 +40,19 @@
+ - Status
+ -
+
- WAState
-
@@ -228,6 +231,19 @@
|
+
+ |
+ MESSAGE_ACK
+ |
+
+
+ |
+
+
+ |
+
+ |
+
|
QR_RECEIVED
@@ -273,6 +289,105 @@
read-only
+ MessageAck
+ number
+ Message ACK
+
+ Properties
+
+
+
+ | Name |
+ Type |
+ Optional |
+ Description |
+
+
+
+
+ |
+ ACK_ERROR
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+ ACK_PENDING
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+ ACK_SERVER
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+ ACK_DEVICE
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+ ACK_READ
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+ |
+ ACK_PLAYED
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+
+
+
+
+
+ read-only
MessageTypes
string
Message types
@@ -696,7 +811,7 @@
diff --git a/docs/index.html b/docs/index.html
index 3825079..196bda4 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Home
+ whatsapp-web.js 1.1.0 » Home
@@ -15,7 +15,7 @@
@@ -27,11 +27,11 @@
- 
+ 
whatsapp-web.js
A WhatsApp API client that connects through the WhatsApp Web browser app
It uses Puppeteer to run a real instance of Whatsapp Web to avoid getting blocked.
@@ -84,7 +84,7 @@ client.initialize();
|
| Send media (video) |
- pending |
+ ✅ (requires google chrome) |
| Send stickers |
@@ -291,6 +291,30 @@ client.initialize();
-
+ -
+ Chat#archive()
+
+ -
+
+ -
+ Chat#archived
+
+ -
+
+ -
+ Chat#clearMessages()
+
+ -
+
+ -
+ Chat#delete()
+
+ -
+
+
+
+
+
-
Chat#id
@@ -301,10 +325,6 @@ client.initialize();
-
-
-
-
-
-
Chat#isReadOnly
@@ -329,6 +349,11 @@ client.initialize();
-
+ -
+ Chat#unarchive()
+
+ -
+
-
Chat#unreadCount
@@ -389,6 +414,11 @@ client.initialize();
-
+ -
+ Client#archiveChat()
+
+ -
+
-
Client#destroy()
@@ -423,6 +453,11 @@ client.initialize();
-
+ -
+ Client#event:message_ack
+
+ -
+
-
Client#event:message_create
@@ -472,6 +507,11 @@ client.initialize();
-
+ -
+ Client#getState()
+
+ -
+
-
Client#initialize()
@@ -487,6 +527,11 @@ client.initialize();
-
+ -
+ Client#unarchiveChat()
+
+ -
+
@@ -647,7 +692,7 @@ client.initialize();
-
-
- Events.MESSAGE_CREATE
+ Events.MESSAGE_ACK
-
@@ -655,6 +700,11 @@ client.initialize();
+
-
+
-
-
+
+
@@ -1120,6 +1249,30 @@ client.initialize();
-
+
-
+ PrivateChat#archive()
+
+
-
+
+
-
+ PrivateChat#archived
+
+
-
+
+
-
+ PrivateChat#clearMessages()
+
+
-
+
+
-
+ PrivateChat#delete()
+
+
-
+
+
+
+
-
-
-
PrivateChat#isReadOnly
@@ -1158,6 +1307,11 @@ client.initialize();
-
+ -
+ PrivateChat#unarchive()
+
+ -
+
-
PrivateChat#unreadCount
@@ -1403,7 +1557,7 @@ client.initialize();
diff --git a/docs/structures_Base.js.html b/docs/structures_Base.js.html
index d4bccf1..455b708 100644
--- a/docs/structures_Base.js.html
+++ b/docs/structures_Base.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: structures/Base.js
+ whatsapp-web.js 1.1.0 » Source: structures/Base.js
@@ -15,7 +15,7 @@
@@ -60,7 +60,7 @@ module.exports = Base;
diff --git a/docs/structures_BusinessContact.js.html b/docs/structures_BusinessContact.js.html
index 68a2197..6369b3c 100644
--- a/docs/structures_BusinessContact.js.html
+++ b/docs/structures_BusinessContact.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: structures/BusinessContact.js
+ whatsapp-web.js 1.1.0 » Source: structures/BusinessContact.js
@@ -15,7 +15,7 @@
@@ -59,7 +59,7 @@ module.exports = BusinessContact;
diff --git a/docs/structures_Chat.js.html b/docs/structures_Chat.js.html
index 6a711cc..7c9a9fe 100644
--- a/docs/structures_Chat.js.html
+++ b/docs/structures_Chat.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: structures/Chat.js
+ whatsapp-web.js 1.1.0 » Source: structures/Chat.js
@@ -15,7 +15,7 @@
@@ -81,6 +81,12 @@ class Chat extends Base {
*/
this.timestamp = data.t;
+ /**
+ * Indicates if the Chat is archived
+ * @type {boolean}
+ */
+ this.archived = data.archive;
+
return super._patch(data);
}
@@ -93,6 +99,41 @@ class Chat extends Base {
async sendMessage(content, options) {
return this.client.sendMessage(this.id._serialized, content, options);
}
+
+ /**
+ * Clears all messages from the chat
+ * @returns {Promise<Boolean>} result
+ */
+ async clearMessages() {
+ return this.client.pupPage.evaluate(chatId => {
+ return window.WWebJS.sendClearChat(chatId);
+ }, this.id._serialized);
+ }
+
+ /**
+ * Deletes the chat
+ * @returns {Promise<Boolean>} result
+ */
+ async delete() {
+ return this.client.pupPage.evaluate(chatId => {
+ return window.WWebJS.sendDeleteChat(chatId);
+ }, this.id._serialized);
+ }
+
+ /**
+ * Archives this chat
+ */
+ async archive() {
+ return this.client.archiveChat(this.id._serialized);
+ }
+
+ /**
+ * un-archives this chat
+ */
+ async unarchive() {
+ return this.client.unarchiveChat(this.id._serialized);
+ }
+
}
module.exports = Chat;
@@ -105,7 +146,7 @@ module.exports = Chat;
diff --git a/docs/structures_ClientInfo.js.html b/docs/structures_ClientInfo.js.html
index bf85f39..09583a9 100644
--- a/docs/structures_ClientInfo.js.html
+++ b/docs/structures_ClientInfo.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: structures/ClientInfo.js
+ whatsapp-web.js 1.1.0 » Source: structures/ClientInfo.js
@@ -15,7 +15,7 @@
@@ -89,7 +89,7 @@ module.exports = ClientInfo;
diff --git a/docs/structures_Contact.js.html b/docs/structures_Contact.js.html
index 231c3d1..6e25d2a 100644
--- a/docs/structures_Contact.js.html
+++ b/docs/structures_Contact.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: structures/Contact.js
+ whatsapp-web.js 1.1.0 » Source: structures/Contact.js
@@ -15,7 +15,7 @@
@@ -153,7 +153,7 @@ module.exports = Contact;
diff --git a/docs/structures_GroupChat.js.html b/docs/structures_GroupChat.js.html
index a892cee..36d439c 100644
--- a/docs/structures_GroupChat.js.html
+++ b/docs/structures_GroupChat.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: structures/GroupChat.js
+ whatsapp-web.js 1.1.0 » Source: structures/GroupChat.js
@@ -15,7 +15,7 @@
@@ -209,7 +209,7 @@ module.exports = GroupChat;
diff --git a/docs/structures_Location.js.html b/docs/structures_Location.js.html
index 1d9862a..b4951b1 100644
--- a/docs/structures_Location.js.html
+++ b/docs/structures_Location.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: structures/Location.js
+ whatsapp-web.js 1.1.0 » Source: structures/Location.js
@@ -15,7 +15,7 @@
@@ -71,7 +71,7 @@ module.exports = Location;
diff --git a/docs/structures_Message.js.html b/docs/structures_Message.js.html
index 1241b3f..8311873 100644
--- a/docs/structures_Message.js.html
+++ b/docs/structures_Message.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: structures/Message.js
+ whatsapp-web.js 1.1.0 » Source: structures/Message.js
@@ -15,7 +15,7 @@
@@ -233,6 +233,22 @@ class Message extends Base {
return new MessageMedia(mimetype, data, filename);
}
+
+ /**
+ * Deletes a message from the chat
+ * @param {?boolean} everyone If true and the message is sent by the current user, will delete it for everyone in the chat.
+ */
+ async delete(everyone) {
+ await this.client.pupPage.evaluate((msgId, everyone) => {
+ let msg = window.Store.Msg.get(msgId);
+
+ if(everyone && msg.id.fromMe && msg.canRevoke()) {
+ return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], true);
+ }
+
+ return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
+ }, this.id._serialized, everyone);
+ }
}
module.exports = Message;
@@ -246,7 +262,7 @@ module.exports = Message;
diff --git a/docs/structures_MessageMedia.js.html b/docs/structures_MessageMedia.js.html
index bd03685..c3ee4f5 100644
--- a/docs/structures_MessageMedia.js.html
+++ b/docs/structures_MessageMedia.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: structures/MessageMedia.js
+ whatsapp-web.js 1.1.0 » Source: structures/MessageMedia.js
@@ -15,7 +15,7 @@
@@ -69,7 +69,7 @@ module.exports = MessageMedia;
diff --git a/docs/structures_PrivateChat.js.html b/docs/structures_PrivateChat.js.html
index cdfd321..2090d21 100644
--- a/docs/structures_PrivateChat.js.html
+++ b/docs/structures_PrivateChat.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: structures/PrivateChat.js
+ whatsapp-web.js 1.1.0 » Source: structures/PrivateChat.js
@@ -15,7 +15,7 @@
@@ -51,7 +51,7 @@ module.exports = PrivateChat;
diff --git a/docs/structures_PrivateContact.js.html b/docs/structures_PrivateContact.js.html
index 06da827..54dc2ab 100644
--- a/docs/structures_PrivateContact.js.html
+++ b/docs/structures_PrivateContact.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: structures/PrivateContact.js
+ whatsapp-web.js 1.1.0 » Source: structures/PrivateContact.js
@@ -15,7 +15,7 @@
@@ -51,7 +51,7 @@ module.exports = PrivateContact;
diff --git a/docs/util_Constants.js.html b/docs/util_Constants.js.html
index 8b48371..aa5840d 100644
--- a/docs/util_Constants.js.html
+++ b/docs/util_Constants.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: util/Constants.js
+ whatsapp-web.js 1.1.0 » Source: util/Constants.js
@@ -15,7 +15,7 @@
@@ -66,9 +66,10 @@ exports.Events = {
MESSAGE_CREATE: 'message_create',
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
MESSAGE_REVOKED_ME: 'message_revoke_me',
+ MESSAGE_ACK: 'message_ack',
QR_RECEIVED: 'qr',
DISCONNECTED: 'disconnected',
- STATE_CHANGED: 'change_state'
+ STATE_CHANGED: 'change_state',
};
/**
@@ -120,7 +121,22 @@ exports.WAState = {
UNLAUNCHED: 'UNLAUNCHED',
UNPAIRED: 'UNPAIRED',
UNPAIRED_IDLE: 'UNPAIRED_IDLE'
-};
+};
+
+/**
+ * Message ACK
+ * @readonly
+ * @enum {number}
+ */
+exports.MessageAck = {
+ ACK_ERROR: -1,
+ ACK_PENDING: 0,
+ ACK_SERVER: 1,
+ ACK_DEVICE: 2,
+ ACK_READ: 3,
+ ACK_PLAYED: 4,
+};
+
@@ -130,7 +146,7 @@ exports.WAState = {
diff --git a/docs/util_Util.js.html b/docs/util_Util.js.html
index 004fe58..728a7fe 100644
--- a/docs/util_Util.js.html
+++ b/docs/util_Util.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.0.2 » Source: util/Util.js
+ whatsapp-web.js 1.1.0 » Source: util/Util.js
@@ -15,7 +15,7 @@
@@ -73,7 +73,7 @@ module.exports = Util;
diff --git a/package.json b/package.json
index 2d0ce34..b59f7fe 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "whatsapp-web.js",
- "version": "1.0.2-post",
+ "version": "1.1.0",
"description": "Library for interacting with the WhatsApp Web API ",
"main": "./index.js",
"scripts": {