From f8cfc7889c99b7e0d804786ddd68899334b957f6 Mon Sep 17 00:00:00 2001 From: Gabryel Rigol Date: Sun, 9 Apr 2023 09:22:56 -0400 Subject: [PATCH 1/6] Fix isStatus (#2108) * Fix isStatus * Fiz isStatus --- src/structures/Message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index 87d716311d..97aa3e3cff 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -109,7 +109,7 @@ class Message extends Base { * Indicates if the message is a status update * @type {boolean} */ - this.isStatus = data.isStatusV3; + this.isStatus = data.isStatusV3 || data.id.remote === 'status@broadcast'; /** * Indicates if the message was starred From 37724f6959ae3058acc738d2a8fce2e2fe2d5a09 Mon Sep 17 00:00:00 2001 From: tofers Date: Wed, 19 Apr 2023 02:50:08 +0300 Subject: [PATCH 2/6] fix: msg.chat (#2139) * fix function openChatWindowAt * fix star \ unstar * fix function delete * fix closeRightDrawer --- src/structures/Message.js | 21 ++++++++++++--------- src/util/Injected.js | 2 ++ src/util/InterfaceController.js | 6 ++++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index 97aa3e3cff..d16e5ca1f1 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -443,15 +443,16 @@ class Message extends Base { * @param {?boolean} everyone If true and the message is sent by the current user or the user is an admin, will delete it for everyone in the chat. */ async delete(everyone) { - await this.client.pupPage.evaluate((msgId, everyone) => { + await this.client.pupPage.evaluate(async (msgId, everyone) => { let msg = window.Store.Msg.get(msgId); - + let chat = await window.Store.Chat.find(msg.id.remote); + const canRevoke = window.Store.MsgActionChecks.canSenderRevokeMsg(msg) || window.Store.MsgActionChecks.canAdminRevokeMsg(msg); if (everyone && canRevoke) { - return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], { type: msg.id.fromMe ? 'Sender' : 'Admin' }); + return window.Store.Cmd.sendRevokeMsgs(chat, [msg], { clearMedia: true, type: msg.id.fromMe ? 'Sender' : 'Admin' }); } - return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true); + return window.Store.Cmd.sendDeleteMsgs(chat, [msg], true); }, this.id._serialized, everyone); } @@ -459,11 +460,12 @@ class Message extends Base { * Stars this message */ async star() { - await this.client.pupPage.evaluate((msgId) => { + await this.client.pupPage.evaluate(async (msgId) => { let msg = window.Store.Msg.get(msgId); - + if (window.Store.MsgActionChecks.canStarMsg(msg)) { - return window.Store.Cmd.sendStarMsgs(msg.chat, [msg], false); + let chat = await window.Store.Chat.find(msg.id.remote); + return window.Store.Cmd.sendStarMsgs(chat, [msg], false); } }, this.id._serialized); } @@ -472,11 +474,12 @@ class Message extends Base { * Unstars this message */ async unstar() { - await this.client.pupPage.evaluate((msgId) => { + await this.client.pupPage.evaluate(async (msgId) => { let msg = window.Store.Msg.get(msgId); if (window.Store.MsgActionChecks.canStarMsg(msg)) { - return window.Store.Cmd.sendUnstarMsgs(msg.chat, [msg], false); + let chat = await window.Store.Chat.find(msg.id.remote); + return window.Store.Cmd.sendUnstarMsgs(chat, [msg], false); } }, this.id._serialized); } diff --git a/src/util/Injected.js b/src/util/Injected.js index cf812a9f98..cec31434a5 100644 --- a/src/util/Injected.js +++ b/src/util/Injected.js @@ -54,6 +54,8 @@ exports.ExposeStore = (moduleRaidStr) => { window.Store.QuotedMsg = window.mR.findModule('getQuotedMsgObj')[0]; window.Store.Socket = window.mR.findModule('deprecatedSendIq')[0]; window.Store.SocketWap = window.mR.findModule('wap')[0]; + window.Store.SearchContext = window.mR.findModule('getSearchContext')[0].getSearchContext; + window.Store.DrawerManager = window.mR.findModule('DrawerManager')[0].DrawerManager; window.Store.StickerTools = { ...window.mR.findModule('toWebpSticker')[0], ...window.mR.findModule('addWebpMetadata')[0] diff --git a/src/util/InterfaceController.js b/src/util/InterfaceController.js index a87959da63..2c7e1cab0a 100644 --- a/src/util/InterfaceController.js +++ b/src/util/InterfaceController.js @@ -50,7 +50,9 @@ class InterfaceController { async openChatWindowAt(msgId) { await this.pupPage.evaluate(async msgId => { let msg = await window.Store.Msg.get(msgId); - await window.Store.Cmd.openChatAt(msg.chat, msg.chat.getSearchContext(msg)); + let chat = await window.Store.Chat.find(msg.id.remote); + let searchContext = await window.Store.SearchContext(chat,msg); + await window.Store.Cmd.openChatAt(chat, searchContext); }, msgId); } @@ -70,7 +72,7 @@ class InterfaceController { */ async closeRightDrawer() { await this.pupPage.evaluate(async () => { - await window.Store.Cmd.closeDrawerRight(); + await window.Store.DrawerManager.closeDrawerRight(); }); } From d8fd4579143624384004c1f966bb1d92f0a69036 Mon Sep 17 00:00:00 2001 From: Pierluca Lino Date: Thu, 20 Apr 2023 17:19:57 +0200 Subject: [PATCH 3/6] feat: Optional proxy autentication (#2143) --- example.js | 6 +++++- index.d.ts | 4 +++- src/Client.js | 5 +++++ src/util/Constants.js | 3 ++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/example.js b/example.js index f00b1303b6..065fd123ec 100644 --- a/example.js +++ b/example.js @@ -2,7 +2,11 @@ const { Client, Location, List, Buttons, LocalAuth } = require('./index'); const client = new Client({ authStrategy: new LocalAuth(), - puppeteer: { headless: false } + // proxyAuthentication: { username: 'username', password: 'password' }, + puppeteer: { + // args: ['--proxy-server=proxy-server-that-requires-authentication.example.com'], + headless: false + } }); client.initialize(); diff --git a/index.d.ts b/index.d.ts index 23ba35cd45..38d2ebbd50 100644 --- a/index.d.ts +++ b/index.d.ts @@ -387,7 +387,9 @@ declare namespace WAWebJS { userAgent?: string /** Ffmpeg path to use when formating videos to webp while sending stickers * @default 'ffmpeg' */ - ffmpegPath?: string + ffmpegPath?: string, + /** Object with proxy autentication requirements @default: undefined */ + proxyAuthentication?: {username: string, password: string} | undefined } /** diff --git a/src/Client.js b/src/Client.js index d0c949c5d2..fef8e4c456 100644 --- a/src/Client.js +++ b/src/Client.js @@ -29,6 +29,7 @@ const NoAuth = require('./authStrategies/NoAuth'); * @param {string} options.userAgent - User agent to use in puppeteer * @param {string} options.ffmpegPath - Ffmpeg path to use when formating videos to webp while sending stickers * @param {boolean} options.bypassCSP - Sets bypassing of page's Content-Security-Policy. + * @param {object} options.proxyAuthentication - Proxy Authentication object. * * @fires Client#qr * @fires Client#authenticated @@ -102,6 +103,10 @@ class Client extends EventEmitter { browser = await puppeteer.launch({...puppeteerOpts, args: browserArgs}); page = (await browser.pages())[0]; } + + if (this.options.proxyAuthentication !== undefined) { + await page.authenticate(this.options.proxyAuthentication); + } await page.setUserAgent(this.options.userAgent); if (this.options.bypassCSP) await page.setBypassCSP(true); diff --git a/src/util/Constants.js b/src/util/Constants.js index 97512c1b4d..aa1005d155 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -13,7 +13,8 @@ exports.DefaultOptions = { takeoverTimeoutMs: 0, userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36', ffmpegPath: 'ffmpeg', - bypassCSP: false + bypassCSP: false, + proxyAuthentication: undefined }; /** From 081b455fa513758fb06de577973179ee1c82a04a Mon Sep 17 00:00:00 2001 From: tofers Date: Fri, 19 May 2023 19:25:54 +0300 Subject: [PATCH 4/6] hotfix: newId and deviceType (#2196) * update method generate Msg id, newId to newIdV2 * replace newId and await in version WA 2.2321.6 * fix deviceType --- src/structures/Message.js | 3 +-- src/util/Injected.js | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index d16e5ca1f1..a3b311796e 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -89,8 +89,7 @@ class Message extends Base { * String that represents from which device type the message was sent * @type {string} */ - this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0, 2) == '3A' ? 'ios' : 'web'; - + this.deviceType = typeof data.id.id === 'string' && data.id.id.length > 21 ? 'android' : typeof data.id.id === 'string' && data.id.id.substring(0, 2) === '3A' ? 'ios' : 'web'; /** * Indicates if the message was forwarded * @type {boolean} diff --git a/src/util/Injected.js b/src/util/Injected.js index cec31434a5..76d134abe0 100644 --- a/src/util/Injected.js +++ b/src/util/Injected.js @@ -245,11 +245,12 @@ exports.LoadUtils = () => { const meUser = window.Store.User.getMaybeMeUser(); const isMD = window.Store.MDBackend; - + const newId = await window.Store.MsgKey.newId(); + const newMsgId = new window.Store.MsgKey({ from: meUser, to: chat.id, - id: window.Store.MsgKey.newId(), + id: newId, participant: isMD && chat.id.isGroup() ? meUser : undefined, selfDir: 'out', }); From 2b8eb518ede9f3a5aa165d16e404b63546d25d16 Mon Sep 17 00:00:00 2001 From: WWebJS Bot Date: Fri, 19 May 2023 22:17:56 +0000 Subject: [PATCH 5/6] 1.20.0-alpha.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 012bff6717..f272b46e3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "whatsapp-web.js", - "version": "1.19.5", + "version": "1.20.0-alpha.0", "description": "Library for interacting with the WhatsApp Web API ", "main": "./index.js", "typings": "./index.d.ts", From 915763a8d04c37c2ddcb93faa512cfe208f1798e Mon Sep 17 00:00:00 2001 From: Pedro S Lopez Date: Fri, 19 May 2023 23:58:10 -0400 Subject: [PATCH 6/6] chore: mark version v1.20.0 --- docs/Base.html | 8 +- docs/BaseAuthStrategy.html | 8 +- docs/BusinessContact.html | 8 +- docs/Buttons.html | 8 +- docs/Call.html | 8 +- docs/Chat.html | 22 +- docs/Client.html | 303 +- docs/Client.js.html | 113 +- docs/ClientInfo.html | 8 +- docs/Contact.html | 8 +- docs/GroupChat.html | 92 +- docs/GroupNotification.html | 8 +- docs/InterfaceController.html | 8 +- docs/Label.html | 8 +- docs/LegacySessionAuth.html | 8 +- docs/List.html | 8 +- docs/LocalAuth.html | 8 +- docs/Location.html | 8 +- docs/Message.html | 38 +- docs/MessageMedia.html | 8 +- docs/NoAuth.html | 8 +- docs/Order.html | 8 +- docs/PrivateChat.html | 24 +- docs/PrivateContact.html | 8 +- docs/Product.html | 8 +- docs/Reaction.html | 8 +- docs/RemoteAuth.html | 8 +- docs/Util.html | 8 +- docs/authStrategies_BaseAuthStrategy.js.html | 8 +- docs/authStrategies_LegacySessionAuth.js.html | 8 +- docs/authStrategies_LocalAuth.js.html | 8 +- docs/authStrategies_NoAuth.js.html | 8 +- docs/authStrategies_RemoteAuth.js.html | 8 +- docs/global.html | 152 +- docs/index.html | 6525 +++++++++-------- docs/structures_Base.js.html | 8 +- docs/structures_BusinessContact.js.html | 8 +- docs/structures_Buttons.js.html | 8 +- docs/structures_Call.js.html | 8 +- docs/structures_Chat.js.html | 14 +- docs/structures_ClientInfo.js.html | 8 +- docs/structures_Contact.js.html | 8 +- docs/structures_GroupChat.js.html | 33 +- docs/structures_GroupNotification.js.html | 8 +- docs/structures_Label.js.html | 8 +- docs/structures_List.js.html | 8 +- docs/structures_Location.js.html | 8 +- docs/structures_Message.js.html | 81 +- docs/structures_MessageMedia.js.html | 8 +- docs/structures_Order.js.html | 8 +- docs/structures_Payment.js.html | 8 +- docs/structures_PrivateChat.js.html | 8 +- docs/structures_PrivateContact.js.html | 8 +- docs/structures_Product.js.html | 8 +- docs/structures_ProductMetadata.js.html | 8 +- docs/structures_Reaction.js.html | 8 +- docs/util_Constants.js.html | 16 +- docs/util_InterfaceController.js.html | 14 +- docs/util_Util.js.html | 8 +- package.json | 2 +- 60 files changed, 4356 insertions(+), 3441 deletions(-) diff --git a/docs/Base.html b/docs/Base.html index 8b72b80521..c8c8fdbfc6 100644 --- a/docs/Base.html +++ b/docs/Base.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Base + whatsapp-web.js 1.20.0 » Class: Base @@ -15,7 +15,7 @@ @@ -50,7 +50,7 @@

new Base diff --git a/docs/BaseAuthStrategy.html b/docs/BaseAuthStrategy.html index 45b4f5d15d..ad240e7078 100644 --- a/docs/BaseAuthStrategy.html +++ b/docs/BaseAuthStrategy.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: BaseAuthStrategy + whatsapp-web.js 1.20.0 » Class: BaseAuthStrategy @@ -15,7 +15,7 @@ @@ -50,7 +50,7 @@

new BaseAuthStrategy diff --git a/docs/BusinessContact.html b/docs/BusinessContact.html index 8ca34628a7..9bb1f76989 100644 --- a/docs/BusinessContact.html +++ b/docs/BusinessContact.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: BusinessContact + whatsapp-web.js 1.20.0 » Class: BusinessContact @@ -15,7 +15,7 @@ @@ -326,7 +326,7 @@

unblock diff --git a/docs/Buttons.html b/docs/Buttons.html index db66dc31f4..646c69c48b 100644 --- a/docs/Buttons.html +++ b/docs/Buttons.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Buttons + whatsapp-web.js 1.20.0 » Class: Buttons @@ -15,7 +15,7 @@ @@ -234,7 +234,7 @@

Parameter

diff --git a/docs/Call.html b/docs/Call.html index 2ed0b0d76a..9f6d2877c6 100644 --- a/docs/Call.html +++ b/docs/Call.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Call + whatsapp-web.js 1.20.0 » Class: Call @@ -15,7 +15,7 @@ @@ -168,7 +168,7 @@

reject<
diff --git a/docs/Chat.html b/docs/Chat.html index 48ef3299c2..f8d8d21af1 100644 --- a/docs/Chat.html +++ b/docs/Chat.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Chat + whatsapp-web.js 1.20.0 » Class: Chat @@ -15,7 +15,7 @@ @@ -58,19 +58,22 @@

Properties

isReadOnly
-
muteExpiration
+
lastMessage
-
name
+
muteExpiration
-
pinned
+
name
+
pinned
+
+
timestamp
@@ -185,6 +188,11 @@

isReadOnly

+

lastMessage +  Message

+

Last message fo chat

+
+

muteExpiration  number

Unix timestamp for when the mute expires

@@ -497,7 +505,7 @@

unpin diff --git a/docs/Client.html b/docs/Client.html index 01ef7bb4a6..fcbbad8d30 100644 --- a/docs/Client.html +++ b/docs/Client.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Client + whatsapp-web.js 1.20.0 » Class: Client @@ -15,7 +15,7 @@ @@ -26,7 +26,7 @@

+
group_admin_changed
+
+
+
group_join
+
+
group_leave
@@ -447,6 +465,20 @@

Parameters

Sets bypassing of page's Content-Security-Policy.

+ + +

proxyAuthentication

+ + +

 

+ + +

 

+ + +

Proxy Authentication object.

+ + @@ -473,6 +505,8 @@

Parameters

Client#event:group_update
Client#event:disconnected
Client#event:change_state
+
Client#event:contact_changed
+
Client#event:group_admin_changed
@@ -638,6 +672,17 @@

Parameters

async
+

deleteProfilePicture() → Promise containing boolean

+

Deletes the current user's profile picture.

+
+
Returns
+
+

Promise containing boolean  +

Returns true if the picture was properly deleted.

+

+
+
+
async

destroy()

Closes the client

@@ -1515,6 +1560,45 @@

Parameter

async
+

setProfilePicture(media) → Promise containing boolean

+

Sets the current user's profile picture.

+
+

Parameter

+ + + + + + + + + + + + + + + + + +
NameTypeOptionalDescription
+

media

+
+

MessageMedia

+
+

 

+
+
+
+
+
Returns
+
+

Promise containing boolean  +

Returns true if the picture was properly updated.

+

+
+
+
async

setStatus(status)

Sets the current user's status message

@@ -1749,6 +1833,172 @@

Parameter

+

chat_archived

+

Emitted when a chat is archived/unarchived

+
+

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeOptionalDescription
+

chat

+
+

Chat

+
+

 

+
+
+

currState

+
+

boolean

+
+

 

+
+
+

prevState

+
+

boolean

+
+

 

+
+
+
+
+
+

chat_removed

+

Emitted when a chat is removed

+
+

Parameter

+ + + + + + + + + + + + + + + + + +
NameTypeOptionalDescription
+

chat

+
+

Chat

+
+

 

+
+
+
+
+
+

contact_changed

+

Emitted when a contact or a group participant changes their phone number.

+
+

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeOptionalDescription
+

message

+
+

Message

+
+

 

+
+

Message with more information about the event.

+
+

oldId

+
+

String

+
+

 

+
+

The user's id (an old one) who changed their phone number + and who triggered the notification.

+
+

newId

+
+

String

+
+

 

+
+

The user's new id after the change.

+
+

isContact

+
+

Boolean

+
+

 

+
+

Indicates if a contact or a group participant changed their phone number.

+
+
+
+

disconnected

Emitted when the client has been disconnected

@@ -1782,6 +2032,39 @@

Parameter

+

group_admin_changed

+

Emitted when a current user is promoted to an admin or demoted to a regular user.

+
+

Parameter

+ + + + + + + + + + + + + + + + + +
NameTypeOptionalDescription
+

notification

+
+

GroupNotification

+
+

 

+
+

GroupNotification with more information about the action

+
+
+
+

group_join

Emitted when a user joins the chat via invite link or is added by an admin.

@@ -2486,7 +2769,7 @@

ready

diff --git a/docs/Client.js.html b/docs/Client.js.html index 6a180d7c51..80f345bd89 100644 --- a/docs/Client.js.html +++ b/docs/Client.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: Client.js + whatsapp-web.js 1.20.0 » Source: Client.js @@ -15,7 +15,7 @@ @@ -41,7 +41,7 @@

Source: Client.js

const { ExposeStore, LoadUtils } = require('./util/Injected'); const ChatFactory = require('./factories/ChatFactory'); const ContactFactory = require('./factories/ContactFactory'); -const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List, Reaction } = require('./structures'); +const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List, Reaction, Chat } = require('./structures'); const LegacySessionAuth = require('./authStrategies/LegacySessionAuth'); const NoAuth = require('./authStrategies/NoAuth'); @@ -60,6 +60,7 @@

Source: Client.js

* @param {string} options.userAgent - User agent to use in puppeteer * @param {string} options.ffmpegPath - Ffmpeg path to use when formating videos to webp while sending stickers * @param {boolean} options.bypassCSP - Sets bypassing of page's Content-Security-Policy. + * @param {object} options.proxyAuthentication - Proxy Authentication object. * * @fires Client#qr * @fires Client#authenticated @@ -76,6 +77,8 @@

Source: Client.js

* @fires Client#group_update * @fires Client#disconnected * @fires Client#change_state + * @fires Client#contact_changed + * @fires Client#group_admin_changed */ class Client extends EventEmitter { constructor(options = {}) { @@ -131,6 +134,10 @@

Source: Client.js

browser = await puppeteer.launch({...puppeteerOpts, args: browserArgs}); page = (await browser.pages())[0]; } + + if (this.options.proxyAuthentication !== undefined) { + await page.authenticate(this.options.proxyAuthentication); + } await page.setUserAgent(this.options.userAgent); if (this.options.bypassCSP) await page.setBypassCSP(true); @@ -348,6 +355,13 @@

Source: Client.js

* @param {GroupNotification} notification GroupNotification with more information about the action */ this.emit(Events.GROUP_LEAVE, notification); + } else if (msg.subtype === 'promote' || msg.subtype === 'demote') { + /** + * Emitted when a current user is promoted to an admin or demoted to a regular user. + * @event Client#group_admin_changed + * @param {GroupNotification} notification GroupNotification with more information about the action + */ + this.emit(Events.GROUP_ADMIN_CHANGED, notification); } else { /** * Emitted when group settings are updated, such as subject, description or picture. @@ -407,6 +421,36 @@

Source: Client.js

last_message = msg; } + /** + * The event notification that is received when one of + * the group participants changes thier phone number. + */ + const isParticipant = msg.type === 'gp2' &amp;&amp; msg.subtype === 'modify'; + + /** + * The event notification that is received when one of + * the contacts changes thier phone number. + */ + const isContact = msg.type === 'notification_template' &amp;&amp; msg.subtype === 'change_number'; + + if (isParticipant || isContact) { + /** {@link GroupNotification} object does not provide enough information about this event, so a {@link Message} object is used. */ + const message = new Message(this, msg); + + const newId = isParticipant ? msg.recipients[0] : msg.to; + const oldId = isParticipant ? msg.author : msg.templateParams.find(id => id !== newId); + + /** + * Emitted when a contact or a group participant changes their phone number. + * @event Client#contact_changed + * @param {Message} message Message with more information about the event. + * @param {String} oldId The user's id (an old one) who changed their phone number + * and who triggered the notification. + * @param {String} newId The user's new id after the change. + * @param {Boolean} isContact Indicates if a contact or a group participant changed their phone number. + */ + this.emit(Events.CONTACT_CHANGED, message, oldId, newId, isContact); + } }); await page.exposeFunction('onRemoveMessageEvent', (msg) => { @@ -438,6 +482,15 @@

Source: Client.js

}); + await page.exposeFunction('onChatUnreadCountEvent', async (data) =>{ + const chat = await this.getChatById(data.id); + + /** + * Emitted when the chat unread count changes + */ + this.emit(Events.UNREAD_COUNT, chat); + }); + await page.exposeFunction('onMessageMediaUploadedEvent', (msg) => { const message = new Message(this, msg); @@ -538,6 +591,26 @@

Source: Client.js

} }); + await page.exposeFunction('onRemoveChatEvent', (chat) => { + /** + * Emitted when a chat is removed + * @event Client#chat_removed + * @param {Chat} chat + */ + this.emit(Events.CHAT_REMOVED, new Chat(this, chat)); + }); + + await page.exposeFunction('onArchiveChatEvent', (chat, currState, prevState) => { + /** + * Emitted when a chat is archived/unarchived + * @event Client#chat_archived + * @param {Chat} chat + * @param {boolean} currState + * @param {boolean} prevState + */ + this.emit(Events.CHAT_ARCHIVED, new Chat(this, chat), currState, prevState); + }); + await page.evaluate(() => { window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); }); window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(window.WWebJS.getMessageModel(msg)); }); @@ -547,6 +620,8 @@

Source: Client.js

window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); }); window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); }); window.Store.Call.on('add', (call) => { window.onIncomingCall(call); }); + window.Store.Chat.on('remove', async (chat) => { window.onRemoveChatEvent(await window.WWebJS.getChatModel(chat)); }); + window.Store.Chat.on('change:archive', async (chat, currState, prevState) => { window.onArchiveChatEvent(await window.WWebJS.getChatModel(chat), currState, prevState); }); window.Store.Msg.on('add', (msg) => { if (msg.isNewMsg) { if(msg.type === 'ciphertext') { @@ -557,7 +632,8 @@

Source: Client.js

} } }); - + window.Store.Chat.on('change:unreadCount', (chat) => {window.onChatUnreadCountEvent(chat);}); + { const module = window.Store.createOrUpdateReactionsModule; const ogMethod = module.createOrUpdateReactions; @@ -1209,6 +1285,31 @@

Source: Client.js

return blockedContacts.map(contact => ContactFactory.create(this.client, contact)); } + + /** + * Sets the current user's profile picture. + * @param {MessageMedia} media + * @returns {Promise&lt;boolean>} Returns true if the picture was properly updated. + */ + async setProfilePicture(media) { + const success = await this.pupPage.evaluate((chatid, media) => { + return window.WWebJS.setPicture(chatid, media); + }, this.info.wid._serialized, media); + + return success; + } + + /** + * Deletes the current user's profile picture. + * @returns {Promise&lt;boolean>} Returns true if the picture was properly deleted. + */ + async deleteProfilePicture() { + const success = await this.pupPage.evaluate((chatid) => { + return window.WWebJS.deletePicture(chatid); + }, this.info.wid._serialized); + + return success; + } } module.exports = Client; @@ -1222,7 +1323,7 @@

Source: Client.js

diff --git a/docs/ClientInfo.html b/docs/ClientInfo.html index 02211359be..9e3ec10a70 100644 --- a/docs/ClientInfo.html +++ b/docs/ClientInfo.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: ClientInfo + whatsapp-web.js 1.20.0 » Class: ClientInfo @@ -15,7 +15,7 @@ @@ -242,7 +242,7 @@

getBatteryStatus diff --git a/docs/Contact.html b/docs/Contact.html index 29a9d00552..e6fd4f8c89 100644 --- a/docs/Contact.html +++ b/docs/Contact.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Contact + whatsapp-web.js 1.20.0 » Class: Contact @@ -15,7 +15,7 @@ @@ -293,7 +293,7 @@

unblock diff --git a/docs/GroupChat.html b/docs/GroupChat.html index a27f22dedc..3065d2ec7f 100644 --- a/docs/GroupChat.html +++ b/docs/GroupChat.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: GroupChat + whatsapp-web.js 1.20.0 » Class: GroupChat @@ -15,7 +15,7 @@ @@ -64,19 +64,22 @@

Properties

isReadOnly
-
muteExpiration
+
lastMessage
-
name
+
muteExpiration
-
owner
+
name

+
owner
+
+
participants
@@ -113,6 +116,9 @@

Methods

delete()
+
deletePicture()
+
+
demoteParticipants(participantIds)
@@ -125,13 +131,13 @@

Methods

getInviteCode()
-
getLabels()
-
-
+
getLabels()
+
+
leave()
@@ -159,13 +165,13 @@

Methods

sendSeen()
-
sendStateRecording()
-
-
+
sendStateRecording()
+
+
sendStateTyping()
@@ -178,6 +184,9 @@

Methods

setMessagesAdminsOnly([adminsOnly])
+
setPicture(media)
+
+
setSubject(subject)
@@ -250,6 +259,13 @@

isReadOnlyChat#isReadOnly

+

lastMessage +  unknown

+

Last message fo chat

+
+
Inherited from
+
Chat#lastMessage
+

muteExpiration  unknown

Unix timestamp for when the mute expires

@@ -372,6 +388,17 @@

delete<
async
+

deletePicture() → Promise containing boolean

+

Deletes the group's picture.

+
+
Returns
+
+

Promise containing boolean  +

Returns true if the picture was properly deleted. This can return false if the user does not have the necessary permissions.

+

+
+
+
async

demoteParticipants(participantIds) → Promise containing {status: number}

Demotes participants by IDs to regular users

@@ -868,6 +895,45 @@

Parameter

async
+

setPicture(media) → Promise containing boolean

+

Sets the group's picture.

+
+

Parameter

+ + + + + + + + + + + + + + + + + +
NameTypeOptionalDescription
+

media

+
+

MessageMedia

+
+

 

+
+
+
+
+
Returns
+
+

Promise containing boolean  +

Returns true if the picture was properly updated. This can return false if the user does not have the necessary permissions.

+

+
+
+
async

setSubject(subject) → Promise containing boolean

Updates the group subject

@@ -941,7 +1007,7 @@

unpin diff --git a/docs/GroupNotification.html b/docs/GroupNotification.html index 739b7a2e7c..b26ef118c2 100644 --- a/docs/GroupNotification.html +++ b/docs/GroupNotification.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: GroupNotification + whatsapp-web.js 1.20.0 » Class: GroupNotification @@ -15,7 +15,7 @@ @@ -233,7 +233,7 @@

Parameters

diff --git a/docs/InterfaceController.html b/docs/InterfaceController.html index 862364ce49..9826824cf9 100644 --- a/docs/InterfaceController.html +++ b/docs/InterfaceController.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: InterfaceController + whatsapp-web.js 1.20.0 » Class: InterfaceController @@ -15,7 +15,7 @@ @@ -382,7 +382,7 @@

Parameter

diff --git a/docs/Label.html b/docs/Label.html index da6fac5546..ddbe7fc2d3 100644 --- a/docs/Label.html +++ b/docs/Label.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Label + whatsapp-web.js 1.20.0 » Class: Label @@ -15,7 +15,7 @@ @@ -163,7 +163,7 @@

getChats diff --git a/docs/LegacySessionAuth.html b/docs/LegacySessionAuth.html index b248e58d57..6fdde0bc07 100644 --- a/docs/LegacySessionAuth.html +++ b/docs/LegacySessionAuth.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: LegacySessionAuth + whatsapp-web.js 1.20.0 » Class: LegacySessionAuth @@ -15,7 +15,7 @@ @@ -173,7 +173,7 @@

Parameters

diff --git a/docs/List.html b/docs/List.html index f2c4affe3d..d1190a5190 100644 --- a/docs/List.html +++ b/docs/List.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: List + whatsapp-web.js 1.20.0 » Class: List @@ -15,7 +15,7 @@ @@ -256,7 +256,7 @@

Parameter

diff --git a/docs/LocalAuth.html b/docs/LocalAuth.html index 1a4f18a4b1..e722be24c3 100644 --- a/docs/LocalAuth.html +++ b/docs/LocalAuth.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: LocalAuth + whatsapp-web.js 1.20.0 » Class: LocalAuth @@ -15,7 +15,7 @@ @@ -120,7 +120,7 @@

Parameters

diff --git a/docs/Location.html b/docs/Location.html index 0c80012040..012a74af7b 100644 --- a/docs/Location.html +++ b/docs/Location.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Location + whatsapp-web.js 1.20.0 » Class: Location @@ -15,7 +15,7 @@ @@ -149,7 +149,7 @@

longitude diff --git a/docs/Message.html b/docs/Message.html index d528a725d3..6d47a76a35 100644 --- a/docs/Message.html +++ b/docs/Message.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Message + whatsapp-web.js 1.20.0 » Class: Message @@ -15,7 +15,7 @@ @@ -26,7 +26,7 @@

+
location
+
+
mediaKey
@@ -180,13 +183,16 @@

Methods

getQuotedMessage()
-
react(reaction)
+
getReactions()
+
react(reaction)
+
+
reload()
@@ -270,6 +276,11 @@

hasQuotedMsgIndicates if the message was sent as a reply to another message.

+

hasReaction +  boolean

+

Indicates whether there are reactions to the message

+
+

id  object

ID that represents the message

@@ -518,6 +529,15 @@

getQuotedMessage

async
+

getReactions() → Promise containing Array of ReactionList

+

Gets the reactions associated with the given message

+
+
Returns
+
+

Promise containing Array of ReactionList 

+
+
+
async

react(reaction) → Promise

React to this message with an emoji

@@ -650,7 +670,7 @@

unstar<
diff --git a/docs/MessageMedia.html b/docs/MessageMedia.html index 17046c4077..5d617b8a49 100644 --- a/docs/MessageMedia.html +++ b/docs/MessageMedia.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: MessageMedia + whatsapp-web.js 1.20.0 » Class: MessageMedia @@ -15,7 +15,7 @@ @@ -364,7 +364,7 @@

Parameters

diff --git a/docs/NoAuth.html b/docs/NoAuth.html index 1ee676e048..d112cbc823 100644 --- a/docs/NoAuth.html +++ b/docs/NoAuth.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: NoAuth + whatsapp-web.js 1.20.0 » Class: NoAuth @@ -15,7 +15,7 @@ @@ -51,7 +51,7 @@

new NoAuth diff --git a/docs/Order.html b/docs/Order.html index a116147fe3..f63b6d4469 100644 --- a/docs/Order.html +++ b/docs/Order.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Order + whatsapp-web.js 1.20.0 » Class: Order @@ -15,7 +15,7 @@ @@ -102,7 +102,7 @@

total diff --git a/docs/PrivateChat.html b/docs/PrivateChat.html index d903c67246..19e1e479d0 100644 --- a/docs/PrivateChat.html +++ b/docs/PrivateChat.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: PrivateChat + whatsapp-web.js 1.20.0 » Class: PrivateChat @@ -15,7 +15,7 @@ @@ -58,19 +58,22 @@

Properties

isReadOnly
-
muteExpiration
+
lastMessage
-
name
+
muteExpiration
-
pinned
+
name

+
pinned
+
+
timestamp
@@ -195,6 +198,13 @@

isReadOnlyChat#isReadOnly

+

lastMessage +  unknown

+

Last message fo chat

+
+
Inherited from
+
Chat#lastMessage
+

muteExpiration  unknown

Unix timestamp for when the mute expires

@@ -533,7 +543,7 @@

unpin diff --git a/docs/PrivateContact.html b/docs/PrivateContact.html index b41f3e9cb2..20d0e9e089 100644 --- a/docs/PrivateContact.html +++ b/docs/PrivateContact.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: PrivateContact + whatsapp-web.js 1.20.0 » Class: PrivateContact @@ -15,7 +15,7 @@ @@ -319,7 +319,7 @@

unblock diff --git a/docs/Product.html b/docs/Product.html index 549ce626f0..9212e025cc 100644 --- a/docs/Product.html +++ b/docs/Product.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Product + whatsapp-web.js 1.20.0 » Class: Product @@ -15,7 +15,7 @@ @@ -127,7 +127,7 @@

thumbnailUrl diff --git a/docs/Reaction.html b/docs/Reaction.html index ade180ce7e..b56459f3f6 100644 --- a/docs/Reaction.html +++ b/docs/Reaction.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Reaction + whatsapp-web.js 1.20.0 » Class: Reaction @@ -15,7 +15,7 @@ @@ -144,7 +144,7 @@

timestamp diff --git a/docs/RemoteAuth.html b/docs/RemoteAuth.html index 077388e30b..4003fc49ad 100644 --- a/docs/RemoteAuth.html +++ b/docs/RemoteAuth.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: RemoteAuth + whatsapp-web.js 1.20.0 » Class: RemoteAuth @@ -15,7 +15,7 @@ @@ -148,7 +148,7 @@

Parameters

diff --git a/docs/Util.html b/docs/Util.html index ca629bade4..3c6ea6b07a 100644 --- a/docs/Util.html +++ b/docs/Util.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Class: Util + whatsapp-web.js 1.20.0 » Class: Util @@ -15,7 +15,7 @@ @@ -243,7 +243,7 @@

Parameter

diff --git a/docs/authStrategies_BaseAuthStrategy.js.html b/docs/authStrategies_BaseAuthStrategy.js.html index 2d02c68cc4..d8b4b2d842 100644 --- a/docs/authStrategies_BaseAuthStrategy.js.html +++ b/docs/authStrategies_BaseAuthStrategy.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: authStrategies/BaseAuthStrategy.js + whatsapp-web.js 1.20.0 » Source: authStrategies/BaseAuthStrategy.js @@ -15,7 +15,7 @@ @@ -65,7 +65,7 @@

Source: authStrategies/BaseAuthStrategy.js

diff --git a/docs/authStrategies_LegacySessionAuth.js.html b/docs/authStrategies_LegacySessionAuth.js.html index 3c9e0d3e95..44642fd748 100644 --- a/docs/authStrategies_LegacySessionAuth.js.html +++ b/docs/authStrategies_LegacySessionAuth.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: authStrategies/LegacySessionAuth.js + whatsapp-web.js 1.20.0 » Source: authStrategies/LegacySessionAuth.js @@ -15,7 +15,7 @@ @@ -111,7 +111,7 @@

Source: authStrategies/LegacySessionAuth.js

diff --git a/docs/authStrategies_LocalAuth.js.html b/docs/authStrategies_LocalAuth.js.html index 9b370062d2..58688aba18 100644 --- a/docs/authStrategies_LocalAuth.js.html +++ b/docs/authStrategies_LocalAuth.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: authStrategies/LocalAuth.js + whatsapp-web.js 1.20.0 » Source: authStrategies/LocalAuth.js @@ -15,7 +15,7 @@ @@ -91,7 +91,7 @@

Source: authStrategies/LocalAuth.js

diff --git a/docs/authStrategies_NoAuth.js.html b/docs/authStrategies_NoAuth.js.html index 6321c1d00f..97d65519f5 100644 --- a/docs/authStrategies_NoAuth.js.html +++ b/docs/authStrategies_NoAuth.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: authStrategies/NoAuth.js + whatsapp-web.js 1.20.0 » Source: authStrategies/NoAuth.js @@ -15,7 +15,7 @@ @@ -50,7 +50,7 @@

Source: authStrategies/NoAuth.js

diff --git a/docs/authStrategies_RemoteAuth.js.html b/docs/authStrategies_RemoteAuth.js.html index b4a777fc2e..c42fea6d51 100644 --- a/docs/authStrategies_RemoteAuth.js.html +++ b/docs/authStrategies_RemoteAuth.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: authStrategies/RemoteAuth.js + whatsapp-web.js 1.20.0 » Source: authStrategies/RemoteAuth.js @@ -15,7 +15,7 @@ @@ -243,7 +243,7 @@

Source: authStrategies/RemoteAuth.js

diff --git a/docs/global.html b/docs/global.html index 50c2cb31a2..206a6ffdb0 100644 --- a/docs/global.html +++ b/docs/global.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Globals + whatsapp-web.js 1.20.0 » Globals @@ -15,7 +15,7 @@ @@ -94,6 +94,9 @@

Abstract types

+
ReactionList
+
+
StickerMetadata
@@ -220,6 +223,32 @@

Properties

+ + +

CHAT_REMOVED

+ + +

 

+ + +

 

+ + + + + + +

CHAT_ARCHIVED

+ + +

 

+ + +

 

+ + + +

MESSAGE_RECEIVED

@@ -285,6 +314,19 @@

Properties

+ + +

UNREAD_COUNT

+ + +

 

+ + +

 

+ + + +

MESSAGE_REACTION

@@ -311,6 +353,19 @@

Properties

+ + +

CONTACT_CHANGED

+ + +

 

+ + +

 

+ + + +

GROUP_JOIN

@@ -337,6 +392,19 @@

Properties

+ + +

GROUP_ADMIN_CHANGED

+ + +

 

+ + +

 

+ + + +

GROUP_UPDATE

@@ -1950,6 +2018,82 @@

Properties

+

ReactionList +  Object

+

Reaction List

+
+

Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeOptionalDescription
+

id

+
+

string

+
+

 

+
+

Original emoji

+
+

aggregateEmoji

+
+

string

+
+

 

+
+

aggregate emoji

+
+

hasReactionByMe

+
+

boolean

+
+

 

+
+

Flag who sent the reaction

+
+

senders

+
+

Array of Reaction

+
+

 

+
+

Reaction senders, to this message

+
+
+
+

StickerMetadata  Object

Sticker metadata.

@@ -2019,7 +2163,7 @@

Properties

diff --git a/docs/index.html b/docs/index.html index 17e9fb8402..8fa8a46861 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,53 +1,52 @@ - - - - - whatsapp-web.js 1.19.5 » Home - - - - - - - - + +
+
+
+ +
+ + +

npm Depfu WhatsApp_Web 2.2306.7 Discord Chat

+

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.

+

NOTE: I can't guarantee you will not be blocked by using this method, although it has worked for me. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.

+

Quick Links

+ +

Installation

+

The module is now available on npm! npm i whatsapp-web.js

+

Please note that Node v12+ is required.

+

Example usage

+
const { Client } = require('whatsapp-web.js');
 
 const client = new Client();
 
@@ -68,3229 +67,3427 @@ 

Example usage

client.initialize();
-

Take a look at example.js for another example with more use cases.

-

For more information on saving and restoring sessions, check out the available Authentication Strategies.

-

Supported features

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FeatureStatus
Multi Device
Send messages
Receive messages
Send media (images/audio/documents)
Send media (video)(requires google chrome)
Send stickers
Receive media (images/audio/video/documents)
Send contact cards
Send location
Send buttons
Send lists✅ (business accounts not supported)
Receive location
Message replies
Join groups by invite
Get invite for group
Modify group info (subject, description)
Modify group settings (send messages, edit info)
Add group participants
Kick group participants
Promote/demote group participants
Mention users
Mute/unmute chats
Block/unblock contacts
Get contact info
Get profile pictures
Set user status message
React to messages
-

Something missing? Make an issue and let us know!

-

Contributing

-

Pull requests are welcome! If you see something you'd like to add, please do. For drastic changes, please open an issue first.

-

Supporting the project

-

You can support the maintainer of this project through the links below

- -

Disclaimer

-

This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found at https://whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.

-

License

-

Copyright 2019 Pedro S Lopez

-

Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this project except in compliance with the License. - You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

-

Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

-
-
-
-
+

Take a look at example.js for another example with more use cases.

+

For more information on saving and restoring sessions, check out the available Authentication Strategies.

+

Supported features

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureStatus
Multi Device
Send messages
Receive messages
Send media (images/audio/documents)
Send media (video)(requires google chrome)
Send stickers
Receive media (images/audio/video/documents)
Send contact cards
Send location
Send buttons
Send lists✅ (business accounts not supported)
Receive location
Message replies
Join groups by invite
Get invite for group
Modify group info (subject, description)
Modify group settings (send messages, edit info)
Add group participants
Kick group participants
Promote/demote group participants
Mention users
Mute/unmute chats
Block/unblock contacts
Get contact info
Get profile pictures
Set user status message
React to messages
+

Something missing? Make an issue and let us know!

+

Contributing

+

Pull requests are welcome! If you see something you'd like to add, please do. For drastic changes, please open an issue first.

+

Supporting the project

+

You can support the maintainer of this project through the links below

+ +

Disclaimer

+

This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found at https://whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.

+

License

+

Copyright 2019 Pedro S Lopez

+

Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this project except in compliance with the License. +You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

+

Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.

+ +
+
+

Base

-
-
-
- Base() -
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ Base() +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
-
-
-
-
+
+
+
+

BaseAuthStrategy

-
-
-
- BaseAuthStrategy() -
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ BaseAuthStrategy() +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
-
-
-
-
+
+
+
+

BusinessContact

- - - + + + + + +
-
-
-
-
+
+
+
+

Buttons

- -
-
-
- Buttons#body -
-
-
-
- Buttons#buttons -
-
-
-
-
-
-
-
- Buttons#footer -
-
-
-
- Buttons#title -
-
-
-
-
+ + +
+
+
+ Buttons#body +
+
+
+
+ Buttons#buttons +
+
+
+
+
+ +
+
+
+ Buttons#footer +
+
+
+
+ Buttons#title +
+
+
+
+
+
-
-
-
-
+
+
+
+

Call

-
-
-
- Call() -
-
-
-
- Call#canHandleLocally -
-
-
-
- Call#from -
-
-
-
- Call#fromMe -
-
-
-
-
-
-
-
- Call#id -
-
-
-
- Call#isGroup -
-
-
-
- Call#isVideo -
-
-
-
- Call#participants -
-
-
-
-
-
-
-
- Call#reject() -
-
-
-
- Call#timestamp -
-
-
-
- Call#webClientShouldHandle -
-
-
-
-
+
+
+
+ Call() +
+
+
+
+ Call#canHandleLocally +
+
+
+
+ Call#from +
+
+
+
+ Call#fromMe +
+
+
+
+
+ +
+
+
+ Call#id +
+
+
+
+ Call#isGroup +
+
+
+
+ Call#isVideo +
+
+
+
+ Call#participants +
+
+
+
+
+ +
+
+
+ Call#reject() +
+
+
+
+ Call#timestamp +
+
+
+
+ Call#webClientShouldHandle +
+
+
+
+
+
-
-
-
-
+
+
+
+

Chat

-
-
-
- Chat() -
-
-
-
- Chat#archive() -
-
-
-
- Chat#archived -
-
-
-
- Chat#clearMessages() -
-
-
-
- Chat#clearState() -
-
-
-
- Chat#delete() -
-
-
-
- Chat#fetchMessages(searchOptions) -
-
-
-
- Chat#getContact() -
-
-
-
- Chat#getLabels() -
-
-
-
- Chat#id -
-
-
-
-
-
-
-
- Chat#isGroup -
-
-
-
- Chat#isMuted -
-
-
-
- Chat#isReadOnly -
-
-
-
- Chat#markUnread() -
-
-
-
- Chat#mute(unmuteDate) -
-
-
-
- Chat#muteExpiration -
-
-
-
- Chat#name -
-
-
-
- Chat#pin() -
-
-
-
- Chat#pinned -
-
-
-
- Chat#sendMessage(content[, options]) -
-
-
-
-
-
-
-
- Chat#sendSeen() -
-
-
-
- Chat#sendStateRecording() -
-
-
-
- Chat#sendStateTyping() -
-
-
-
- Chat#timestamp -
-
-
-
- Chat#unarchive() -
-
-
-
- Chat#unmute() -
-
-
-
- Chat#unpin() -
-
-
-
- Chat#unreadCount -
-
-
-
-
+
+
+
+ Chat() +
+
+
+
+ Chat#archive() +
+
+
+
+ Chat#archived +
+
+
+
+ Chat#clearMessages() +
+
+
+
+ Chat#clearState() +
+
+
+
+ Chat#delete() +
+
+
+
+ Chat#fetchMessages(searchOptions) +
+
+
+
+ Chat#getContact() +
+
+
+
+ Chat#getLabels() +
+
+
+
+ Chat#id +
+
+
+
+
+ +
+
+
+ Chat#isGroup +
+
+
+
+ Chat#isMuted +
+
+
+
+ Chat#isReadOnly +
+
+
+
+ Chat#lastMessage +
+
+
+
+ Chat#markUnread() +
+
+
+
+ Chat#mute(unmuteDate) +
+
+
+
+ Chat#muteExpiration +
+
+
+
+ Chat#name +
+
+
+
+ Chat#pin() +
+
+
+
+ Chat#pinned +
+
+
+
+
+ + +
-
-
-
-
+
+
+
+

ChatTypes

-
-
-
- ChatTypes.GROUP -
-
-
-
-
-
-
-
- ChatTypes.SOLO -
-
-
-
-
-
-
-
- ChatTypes.UNKNOWN -
-
-
-
-
+
+
+
+ ChatTypes.GROUP +
+
+
+
+
+ +
+
+
+ ChatTypes.SOLO +
+
+
+
+
+ +
+
+
+ ChatTypes.UNKNOWN +
+
+
+
+
+
-
-
-
-
+
+
+
+

Client

- - - + + + + + +
-
-
-
-
+
+
+
+

ClientInfo

-
-
-
- ClientInfo() -
-
-
-
- ClientInfo#getBatteryStatus() -
-
-
-
- ClientInfo#me -
-
-
-
-
-
-
-
- ClientInfo#phone -
-
-
-
- ClientInfo#platform -
-
-
-
- ClientInfo#pushname -
-
-
-
-
-
-
-
- ClientInfo#wid -
-
-
-
-
+
+
+
+ ClientInfo() +
+
+
+
+ ClientInfo#getBatteryStatus() +
+
+
+
+ ClientInfo#me +
+
+
+
+
+ +
+
+
+ ClientInfo#phone +
+
+
+
+ ClientInfo#platform +
+
+
+
+ ClientInfo#pushname +
+
+
+
+
+ +
+
+
+ ClientInfo#wid +
+
+
+
+
+
-
-
-
-
+
+
+
+

Contact

- -
-
-
- Contact#id -
-
-
-
- Contact#isBlocked -
-
-
-
- Contact#isBusiness -
-
-
-
- Contact#isEnterprise -
-
-
-
- Contact#isGroup -
-
-
-
- Contact#isMe -
-
-
-
- Contact#isMyContact -
-
-
-
- Contact#isUser -
-
-
-
-
-
-
-
- Contact#isWAContact -
-
-
-
- Contact#name -
-
-
-
- Contact#number -
-
-
-
- Contact#pushname -
-
-
-
- Contact#shortName -
-
-
-
- Contact#unblock() -
-
-
-
-
+ + +
+
+
+ Contact#id +
+
+
+
+ Contact#isBlocked +
+
+
+
+ Contact#isBusiness +
+
+
+
+ Contact#isEnterprise +
+
+
+
+ Contact#isGroup +
+
+
+
+ Contact#isMe +
+
+
+
+ Contact#isMyContact +
+
+
+
+ Contact#isUser +
+
+
+
+
+ +
+
+
+ Contact#isWAContact +
+
+
+
+ Contact#name +
+
+
+
+ Contact#number +
+
+
+
+ Contact#pushname +
+
+
+
+ Contact#shortName +
+
+
+
+ Contact#unblock() +
+
+
+
+
+
-
-
-
-
+
+
+
+

Events

- - - + + + + + +
-
-
-
-
+
+
+
+

GroupChat

- - - + + + + + +
-
-
-
-
+
+
+
+ -
-
-
+
+
+
+ -
-
-
+
+
+
+ -
-
-
+
+
+
+

Label

-
-
-
- Label(client, labelData) -
-
-
-
- Label#getChats() -
-
-
-
-
-
-
-
- Label#hexColor -
-
-
-
- Label#id -
-
-
-
-
-
-
-
- Label#name -
-
-
-
-
+
+
+
+ Label(client, labelData) +
+
+
+
+ Label#getChats() +
+
+
+
+
+ +
+
+
+ Label#hexColor +
+
+
+
+ Label#id +
+
+
+
+
+ +
+
+
+ Label#name +
+
+
+
+
+
-
-
-
-
+
+
+
+

LegacySessionAuth

-
-
-
- LegacySessionAuth(options) -
-
-
-
-
-
-
-
-
-
-
-
-
+ + +
+
+
+
+ +
+
+
+
+
-
-
-
-
+
+
+
+

List

- -
-
-
- List#description -
-
-
-
- List#footer -
-
-
-
- List#sections -
-
-
-
-
-
-
-
- List#title -
-
-
-
-
+ + +
+
+
+ List#description +
+
+
+
+ List#footer +
+
+
+
+ List#sections +
+
+
+
+
+ +
+
+
+ List#title +
+
+
+
+
+
-
-
-
-
+
+
+
+

LocalAuth

-
-
-
- LocalAuth(options) -
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ LocalAuth(options) +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
-
-
-
-
+
+
+
+

Location

- -
-
-
- Location#latitude -
-
-
-
- Location#longitude -
-
-
-
-
-
-
-
-
+ + +
+
+
+ Location#latitude +
+
+
+
+ Location#longitude +
+
+
+
+
+ +
+
+
+
+
-
-
-
-
+
+
+
+

Message

- - - + + + + +
+
+
+ Message#links +
+
+
+
+ Message#location +
+
+
+
+ Message#mediaKey +
+
+
+
+ Message#mentionedIds +
+
+
+
+ Message#orderId +
+
+
+
+ Message#rawData +
+
+
+
+ Message#react(reaction) +
+
+
+
+ Message#reload() +
+
+
+
+ Message#reply(content[, chatId][, options]) +
+
+
+
+ Message#star() +
+
+
+
+ Message#timestamp +
+
+
+
+ Message#to +
+
+
+
+ Message#token +
+
+
+
+ Message#type +
+
+
+
+ Message#unstar() +
+
+
+
+ Message#vCards +
+
+
+
+
+
-
-
-
-
+
+
+
+

MessageAck

-
-
-
- MessageAck.ACK_DEVICE -
-
-
-
- MessageAck.ACK_ERROR -
-
-
-
-
-
-
-
- MessageAck.ACK_PENDING -
-
-
-
- MessageAck.ACK_PLAYED -
-
-
-
-
-
-
-
- MessageAck.ACK_READ -
-
-
-
- MessageAck.ACK_SERVER -
-
-
-
-
+
+
+
+ MessageAck.ACK_DEVICE +
+
+
+
+ MessageAck.ACK_ERROR +
+
+
+
+
+ + + +
+
+
+ MessageAck.ACK_READ +
+
+
+
+ MessageAck.ACK_SERVER +
+
+
+
+
+
-
-
-
-
+
+
+
+ -
-
-
+
+
+
+

MessageTypes

- - - + + + + + +
-
-
-
-
+
+
+
+

NoAuth

-
-
-
- NoAuth() -
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ NoAuth() +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
-
-
-
-
+
+
+
+

Order

-
-
-
- Order() -
-
-
-
- Order#createdAt -
-
-
-
-
-
-
-
- Order#currency -
-
-
-
- Order#subtotal -
-
-
-
-
-
-
-
- Order#total -
-
-
-
-
+
+
+
+ Order() +
+
+
+
+ Order#createdAt +
+
+
+
+
+ +
+
+
+ Order#currency +
+
+
+
+ Order#subtotal +
+
+
+
+
+ +
+
+
+ Order#total +
+
+
+
+
+
-
-
-
-
+
+
+
+ -
-
-
+
+
+
+

PrivateChat

- - - + + + + + +
-
-
-
-
+
+
+
+

PrivateContact

- - - + + + + + +
-
-
-
-
+
+
+
+

Product

-
-
-
- Product() -
-
-
-
- Product#currency -
-
-
-
- Product#data -
-
-
-
-
-
-
-
- Product#id -
-
-
-
- Product#name -
-
-
-
- Product#price -
-
-
-
-
-
-
-
- Product#quantity -
-
-
-
- Product#thumbnailUrl -
-
-
-
-
+
+
+
+ Product() +
+
+
+
+ Product#currency +
+
+
+
+ Product#data +
+
+
+
+
+ +
+
+
+ Product#id +
+
+
+
+ Product#name +
+
+
+
+ Product#price +
+
+
+
+
+ +
+
+
+ Product#quantity +
+
+
+
+ Product#thumbnailUrl +
+
+
+
+
+
-
-
-
-
+
+
+
+

ProductMetadata

- - -
-
-
-
+ + + + +
+
+
+
+
-
-
-
-
+
+
+
+

Reaction

-
-
-
- Reaction() -
-
-
-
- Reaction#ack -
-
-
-
- Reaction#id -
-
-
-
- Reaction#msgId -
-
-
-
-
-
-
-
- Reaction#orphan -
-
-
-
- Reaction#orphanReason -
-
-
-
- Reaction#reaction -
-
-
-
- Reaction#read -
-
-
-
-
-
-
-
- Reaction#senderId -
-
-
-
- Reaction#timestamp -
-
-
-
-
+
+
+
+ Reaction() +
+
+
+
+ Reaction#ack +
+
+
+
+ Reaction#id +
+
+
+
+ Reaction#msgId +
+
+
+
+
+ +
+
+
+ Reaction#orphan +
+
+
+
+ Reaction#orphanReason +
+
+
+
+ Reaction#reaction +
+
+
+
+ Reaction#read +
+
+
+
+
+ +
+
+
+ Reaction#senderId +
+
+
+
+ Reaction#timestamp +
+
+
+
+
+
-
-
-
-
+
+
+
+

RemoteAuth

-
-
-
- RemoteAuth(options) -
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ RemoteAuth(options) +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
-
-
-
-
+
+
+
+

Status

-
-
-
- Status.AUTHENTICATING -
-
-
-
-
-
-
-
- Status.INITIALIZING -
-
-
-
-
-
-
-
- Status.READY -
-
-
-
-
+
+
+
+ Status.AUTHENTICATING +
+
+
+
+
+ +
+
+
+ Status.INITIALIZING +
+
+
+
+
+ +
+
+
+ Status.READY +
+
+
+
+
+
-
-
-
-
+
+
+
+ -
-
-
+
+
+
+

WAState

-
-
-
- WAState.CONFLICT -
-
-
-
- WAState.CONNECTED -
-
-
-
- WAState.DEPRECATED_VERSION -
-
-
-
- WAState.OPENING -
-
-
-
-
-
-
-
- WAState.PAIRING -
-
-
-
- WAState.PROXYBLOCK -
-
-
-
- WAState.SMB_TOS_BLOCK -
-
-
-
- WAState.TIMEOUT -
-
-
-
-
-
-
-
- WAState.TOS_BLOCK -
-
-
-
- WAState.UNLAUNCHED -
-
-
-
- WAState.UNPAIRED -
-
-
-
- WAState.UNPAIRED_IDLE -
-
-
-
-
+
+
+
+ WAState.CONFLICT +
+
+
+
+ WAState.CONNECTED +
+
+
+
+ WAState.DEPRECATED_VERSION +
+
+
+
+ WAState.OPENING +
+
+
+
+
+ +
+
+
+ WAState.PAIRING +
+
+
+
+ WAState.PROXYBLOCK +
+
+
+
+ WAState.SMB_TOS_BLOCK +
+
+
+
+ WAState.TIMEOUT +
+
+
+
+
+ +
+
+
+ WAState.TOS_BLOCK +
+
+
+
+ WAState.UNLAUNCHED +
+
+
+
+ WAState.UNPAIRED +
+
+
+
+ WAState.UNPAIRED_IDLE +
+
+
+
+
+
-
-
-
-
-
- -
-
-
- -
- - - - - - - - - \ No newline at end of file +
+ +
+ +
+ + + + +
+ +
+ + + + + + + + diff --git a/docs/structures_Base.js.html b/docs/structures_Base.js.html index 9298998739..d43cdbadbc 100644 --- a/docs/structures_Base.js.html +++ b/docs/structures_Base.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Base.js + whatsapp-web.js 1.20.0 » Source: structures/Base.js @@ -15,7 +15,7 @@ @@ -60,7 +60,7 @@

Source: structures/Base.js

diff --git a/docs/structures_BusinessContact.js.html b/docs/structures_BusinessContact.js.html index 3b5feb76e9..1912469bd0 100644 --- a/docs/structures_BusinessContact.js.html +++ b/docs/structures_BusinessContact.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/BusinessContact.js + whatsapp-web.js 1.20.0 » Source: structures/BusinessContact.js @@ -15,7 +15,7 @@ @@ -59,7 +59,7 @@

Source: structures/BusinessContact.js

diff --git a/docs/structures_Buttons.js.html b/docs/structures_Buttons.js.html index 7637c6ca05..96a7203c7f 100644 --- a/docs/structures_Buttons.js.html +++ b/docs/structures_Buttons.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Buttons.js + whatsapp-web.js 1.20.0 » Source: structures/Buttons.js @@ -15,7 +15,7 @@ @@ -120,7 +120,7 @@

Source: structures/Buttons.js

diff --git a/docs/structures_Call.js.html b/docs/structures_Call.js.html index 09504d6944..98dfdfff87 100644 --- a/docs/structures_Call.js.html +++ b/docs/structures_Call.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Call.js + whatsapp-web.js 1.20.0 » Source: structures/Call.js @@ -15,7 +15,7 @@ @@ -114,7 +114,7 @@

Source: structures/Call.js

diff --git a/docs/structures_Chat.js.html b/docs/structures_Chat.js.html index e470070c97..9baaa840a2 100644 --- a/docs/structures_Chat.js.html +++ b/docs/structures_Chat.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Chat.js + whatsapp-web.js 1.20.0 » Source: structures/Chat.js @@ -15,7 +15,7 @@ @@ -106,6 +106,12 @@

Source: structures/Chat.js

*/ this.muteExpiration = data.muteExpiration; + /** + * Last message fo chat + * @type {Message} + */ + this.lastMessage = data.lastMessage ? new Message(super.client, data.lastMessage) : undefined; + return super._patch(data); } @@ -299,7 +305,7 @@

Source: structures/Chat.js

diff --git a/docs/structures_ClientInfo.js.html b/docs/structures_ClientInfo.js.html index 5c59f8448d..d7878b8e70 100644 --- a/docs/structures_ClientInfo.js.html +++ b/docs/structures_ClientInfo.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/ClientInfo.js + whatsapp-web.js 1.20.0 » Source: structures/ClientInfo.js @@ -15,7 +15,7 @@ @@ -109,7 +109,7 @@

Source: structures/ClientInfo.js

diff --git a/docs/structures_Contact.js.html b/docs/structures_Contact.js.html index 9659220f02..bce1f316d5 100644 --- a/docs/structures_Contact.js.html +++ b/docs/structures_Contact.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Contact.js + whatsapp-web.js 1.20.0 » Source: structures/Contact.js @@ -15,7 +15,7 @@ @@ -245,7 +245,7 @@

Source: structures/Contact.js

diff --git a/docs/structures_GroupChat.js.html b/docs/structures_GroupChat.js.html index 03ef7ee6ac..737830fd4c 100644 --- a/docs/structures_GroupChat.js.html +++ b/docs/structures_GroupChat.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/GroupChat.js + whatsapp-web.js 1.20.0 » Source: structures/GroupChat.js @@ -15,7 +15,7 @@ @@ -244,6 +244,31 @@

Source: structures/GroupChat.js

return true; } + /** + * Deletes the group's picture. + * @returns {Promise&lt;boolean>} Returns true if the picture was properly deleted. This can return false if the user does not have the necessary permissions. + */ + async deletePicture() { + const success = await this.client.pupPage.evaluate((chatid) => { + return window.WWebJS.deletePicture(chatid); + }, this.id._serialized); + + return success; + } + + /** + * Sets the group's picture. + * @param {MessageMedia} media + * @returns {Promise&lt;boolean>} Returns true if the picture was properly updated. This can return false if the user does not have the necessary permissions. + */ + async setPicture(media) { + const success = await this.client.pupPage.evaluate((chatid, media) => { + return window.WWebJS.setPicture(chatid, media); + }, this.id._serialized, media); + + return success; + } + /** * Gets the invite code for a specific group * @returns {Promise&lt;string>} Group's invite code @@ -294,7 +319,7 @@

Source: structures/GroupChat.js

diff --git a/docs/structures_GroupNotification.js.html b/docs/structures_GroupNotification.js.html index 8885d690d3..4c3a80c695 100644 --- a/docs/structures_GroupNotification.js.html +++ b/docs/structures_GroupNotification.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/GroupNotification.js + whatsapp-web.js 1.20.0 » Source: structures/GroupNotification.js @@ -15,7 +15,7 @@ @@ -143,7 +143,7 @@

Source: structures/GroupNotification.js

diff --git a/docs/structures_Label.js.html b/docs/structures_Label.js.html index 0085387f54..e30b9a3f60 100644 --- a/docs/structures_Label.js.html +++ b/docs/structures_Label.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Label.js + whatsapp-web.js 1.20.0 » Source: structures/Label.js @@ -15,7 +15,7 @@ @@ -88,7 +88,7 @@

Source: structures/Label.js

diff --git a/docs/structures_List.js.html b/docs/structures_List.js.html index 4939fa15bd..a258dd4b46 100644 --- a/docs/structures_List.js.html +++ b/docs/structures_List.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/List.js + whatsapp-web.js 1.20.0 » Source: structures/List.js @@ -15,7 +15,7 @@ @@ -118,7 +118,7 @@

Source: structures/List.js

diff --git a/docs/structures_Location.js.html b/docs/structures_Location.js.html index 2e263b664b..cb490a8dbe 100644 --- a/docs/structures_Location.js.html +++ b/docs/structures_Location.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Location.js + whatsapp-web.js 1.20.0 » Source: structures/Location.js @@ -15,7 +15,7 @@ @@ -71,7 +71,7 @@

Source: structures/Location.js

diff --git a/docs/structures_Message.js.html b/docs/structures_Message.js.html index 42962cb01a..e86248cfbb 100644 --- a/docs/structures_Message.js.html +++ b/docs/structures_Message.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Message.js + whatsapp-web.js 1.20.0 » Source: structures/Message.js @@ -15,7 +15,7 @@ @@ -36,7 +36,8 @@

Source: structures/Message.js

const Location = require('./Location'); const Order = require('./Order'); const Payment = require('./Payment'); -const { MessageTypes } = require('../util/Constants'); +const Reaction = require('./Reaction'); +const {MessageTypes} = require('../util/Constants'); /** * Represents a Message on WhatsApp @@ -119,8 +120,7 @@

Source: structures/Message.js

* String that represents from which device type the message was sent * @type {string} */ - this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0, 2) == '3A' ? 'ios' : 'web'; - + this.deviceType = typeof data.id.id === 'string' &amp;&amp; data.id.id.length > 21 ? 'android' : typeof data.id.id === 'string' &amp;&amp; data.id.id.substring(0, 2) === '3A' ? 'ios' : 'web'; /** * Indicates if the message was forwarded * @type {boolean} @@ -139,7 +139,7 @@

Source: structures/Message.js

* Indicates if the message is a status update * @type {boolean} */ - this.isStatus = data.isStatusV3; + this.isStatus = data.isStatusV3 || data.id.remote === 'status@broadcast'; /** * Indicates if the message was starred @@ -165,6 +165,12 @@

Source: structures/Message.js

*/ this.hasQuotedMsg = data.quotedMsg ? true : false; + /** + * Indicates whether there are reactions to the message + * @type {boolean} + */ + this.hasReaction = data.hasReaction ? true : false; + /** * Indicates the duration of the message in seconds * @type {string} @@ -467,15 +473,16 @@

Source: structures/Message.js

* @param {?boolean} everyone If true and the message is sent by the current user or the user is an admin, will delete it for everyone in the chat. */ async delete(everyone) { - await this.client.pupPage.evaluate((msgId, everyone) => { + await this.client.pupPage.evaluate(async (msgId, everyone) => { let msg = window.Store.Msg.get(msgId); - + let chat = await window.Store.Chat.find(msg.id.remote); + const canRevoke = window.Store.MsgActionChecks.canSenderRevokeMsg(msg) || window.Store.MsgActionChecks.canAdminRevokeMsg(msg); if (everyone &amp;&amp; canRevoke) { - return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], { type: msg.id.fromMe ? 'Sender' : 'Admin' }); + return window.Store.Cmd.sendRevokeMsgs(chat, [msg], { clearMedia: true, type: msg.id.fromMe ? 'Sender' : 'Admin' }); } - return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true); + return window.Store.Cmd.sendDeleteMsgs(chat, [msg], true); }, this.id._serialized, everyone); } @@ -483,11 +490,12 @@

Source: structures/Message.js

* Stars this message */ async star() { - await this.client.pupPage.evaluate((msgId) => { + await this.client.pupPage.evaluate(async (msgId) => { let msg = window.Store.Msg.get(msgId); - + if (window.Store.MsgActionChecks.canStarMsg(msg)) { - return window.Store.Cmd.sendStarMsgs(msg.chat, [msg], false); + let chat = await window.Store.Chat.find(msg.id.remote); + return window.Store.Cmd.sendStarMsgs(chat, [msg], false); } }, this.id._serialized); } @@ -496,11 +504,12 @@

Source: structures/Message.js

* Unstars this message */ async unstar() { - await this.client.pupPage.evaluate((msgId) => { + await this.client.pupPage.evaluate(async (msgId) => { let msg = window.Store.Msg.get(msgId); if (window.Store.MsgActionChecks.canStarMsg(msg)) { - return window.Store.Cmd.sendUnstarMsgs(msg.chat, [msg], false); + let chat = await window.Store.Chat.find(msg.id.remote); + return window.Store.Cmd.sendUnstarMsgs(chat, [msg], false); } }, this.id._serialized); } @@ -560,6 +569,44 @@

Source: structures/Message.js

} return undefined; } + + + /** + * Reaction List + * @typedef {Object} ReactionList + * @property {string} id Original emoji + * @property {string} aggregateEmoji aggregate emoji + * @property {boolean} hasReactionByMe Flag who sent the reaction + * @property {Array&lt;Reaction>} senders Reaction senders, to this message + */ + + /** + * Gets the reactions associated with the given message + * @return {Promise&lt;ReactionList[]>} + */ + async getReactions() { + if (!this.hasReaction) { + return undefined; + } + + const reactions = await this.client.pupPage.evaluate(async (msgId) => { + const msgReactions = await window.Store.Reactions.find(msgId); + if (!msgReactions || !msgReactions.reactions.length) return null; + return msgReactions.reactions.serialize(); + }, this.id._serialized); + + if (!reactions) { + return undefined; + } + + return reactions.map(reaction => { + reaction.senders = reaction.senders.map(sender => { + sender.timestamp = Math.round(sender.timestamp / 1000); + return new Reaction(this.client, sender); + }); + return reaction; + }); + } } module.exports = Message; @@ -573,7 +620,7 @@

Source: structures/Message.js

diff --git a/docs/structures_MessageMedia.js.html b/docs/structures_MessageMedia.js.html index 5648e76c25..eac0353eff 100644 --- a/docs/structures_MessageMedia.js.html +++ b/docs/structures_MessageMedia.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/MessageMedia.js + whatsapp-web.js 1.20.0 » Source: structures/MessageMedia.js @@ -15,7 +15,7 @@ @@ -150,7 +150,7 @@

Source: structures/MessageMedia.js

diff --git a/docs/structures_Order.js.html b/docs/structures_Order.js.html index 3da4befad2..ab36e6683d 100644 --- a/docs/structures_Order.js.html +++ b/docs/structures_Order.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Order.js + whatsapp-web.js 1.20.0 » Source: structures/Order.js @@ -15,7 +15,7 @@ @@ -90,7 +90,7 @@

Source: structures/Order.js

diff --git a/docs/structures_Payment.js.html b/docs/structures_Payment.js.html index 2392de0997..197016bc38 100644 --- a/docs/structures_Payment.js.html +++ b/docs/structures_Payment.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Payment.js + whatsapp-web.js 1.20.0 » Source: structures/Payment.js @@ -15,7 +15,7 @@ @@ -118,7 +118,7 @@

Source: structures/Payment.js

diff --git a/docs/structures_PrivateChat.js.html b/docs/structures_PrivateChat.js.html index 46d5c2ee8e..a247712941 100644 --- a/docs/structures_PrivateChat.js.html +++ b/docs/structures_PrivateChat.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/PrivateChat.js + whatsapp-web.js 1.20.0 » Source: structures/PrivateChat.js @@ -15,7 +15,7 @@ @@ -51,7 +51,7 @@

Source: structures/PrivateChat.js

diff --git a/docs/structures_PrivateContact.js.html b/docs/structures_PrivateContact.js.html index 0bf52689eb..d30f3c3453 100644 --- a/docs/structures_PrivateContact.js.html +++ b/docs/structures_PrivateContact.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/PrivateContact.js + whatsapp-web.js 1.20.0 » Source: structures/PrivateContact.js @@ -15,7 +15,7 @@ @@ -51,7 +51,7 @@

Source: structures/PrivateContact.js

diff --git a/docs/structures_Product.js.html b/docs/structures_Product.js.html index 6a42dbf231..c991bc9615 100644 --- a/docs/structures_Product.js.html +++ b/docs/structures_Product.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Product.js + whatsapp-web.js 1.20.0 » Source: structures/Product.js @@ -15,7 +15,7 @@ @@ -106,7 +106,7 @@

Source: structures/Product.js

diff --git a/docs/structures_ProductMetadata.js.html b/docs/structures_ProductMetadata.js.html index be6fa76ff5..e370c26f77 100644 --- a/docs/structures_ProductMetadata.js.html +++ b/docs/structures_ProductMetadata.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/ProductMetadata.js + whatsapp-web.js 1.20.0 » Source: structures/ProductMetadata.js @@ -15,7 +15,7 @@ @@ -63,7 +63,7 @@

Source: structures/ProductMetadata.js

diff --git a/docs/structures_Reaction.js.html b/docs/structures_Reaction.js.html index e4e4b009a0..2af40deb86 100644 --- a/docs/structures_Reaction.js.html +++ b/docs/structures_Reaction.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: structures/Reaction.js + whatsapp-web.js 1.20.0 » Source: structures/Reaction.js @@ -15,7 +15,7 @@ @@ -107,7 +107,7 @@

Source: structures/Reaction.js

diff --git a/docs/util_Constants.js.html b/docs/util_Constants.js.html index 9389185d78..2d155800c6 100644 --- a/docs/util_Constants.js.html +++ b/docs/util_Constants.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: util/Constants.js + whatsapp-web.js 1.20.0 » Source: util/Constants.js @@ -15,7 +15,7 @@ @@ -44,7 +44,8 @@

Source: util/Constants.js

takeoverTimeoutMs: 0, userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36', ffmpegPath: 'ffmpeg', - bypassCSP: false + bypassCSP: false, + proxyAuthentication: undefined }; /** @@ -67,15 +68,20 @@

Source: util/Constants.js

AUTHENTICATED: 'authenticated', AUTHENTICATION_FAILURE: 'auth_failure', READY: 'ready', + CHAT_REMOVED: 'chat_removed', + CHAT_ARCHIVED: 'chat_archived', MESSAGE_RECEIVED: 'message', MESSAGE_CREATE: 'message_create', MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone', MESSAGE_REVOKED_ME: 'message_revoke_me', MESSAGE_ACK: 'message_ack', + UNREAD_COUNT: 'unread_count', MESSAGE_REACTION: 'message_reaction', MEDIA_UPLOADED: 'media_uploaded', + CONTACT_CHANGED: 'contact_changed', GROUP_JOIN: 'group_join', GROUP_LEAVE: 'group_leave', + GROUP_ADMIN_CHANGED: 'group_admin_changed', GROUP_UPDATE: 'group_update', QR_RECEIVED: 'qr', LOADING_SCREEN: 'loading_screen', @@ -200,7 +206,7 @@

Source: util/Constants.js

diff --git a/docs/util_InterfaceController.js.html b/docs/util_InterfaceController.js.html index 17abf6d599..eb5aea6ad6 100644 --- a/docs/util_InterfaceController.js.html +++ b/docs/util_InterfaceController.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: util/InterfaceController.js + whatsapp-web.js 1.20.0 » Source: util/InterfaceController.js @@ -15,7 +15,7 @@ @@ -81,7 +81,9 @@

Source: util/InterfaceController.js

async openChatWindowAt(msgId) { await this.pupPage.evaluate(async msgId => { let msg = await window.Store.Msg.get(msgId); - await window.Store.Cmd.openChatAt(msg.chat, msg.chat.getSearchContext(msg)); + let chat = await window.Store.Chat.find(msg.id.remote); + let searchContext = await window.Store.SearchContext(chat,msg); + await window.Store.Cmd.openChatAt(chat, searchContext); }, msgId); } @@ -101,7 +103,7 @@

Source: util/InterfaceController.js

*/ async closeRightDrawer() { await this.pupPage.evaluate(async () => { - await window.Store.Cmd.closeDrawerRight(); + await window.Store.DrawerManager.closeDrawerRight(); }); } @@ -164,7 +166,7 @@

Source: util/InterfaceController.js

diff --git a/docs/util_Util.js.html b/docs/util_Util.js.html index ee2b4b4c50..e852f0b135 100644 --- a/docs/util_Util.js.html +++ b/docs/util_Util.js.html @@ -2,9 +2,9 @@ - + - whatsapp-web.js 1.19.5 » Source: util/Util.js + whatsapp-web.js 1.20.0 » Source: util/Util.js @@ -15,7 +15,7 @@ @@ -225,7 +225,7 @@

Source: util/Util.js

diff --git a/package.json b/package.json index f272b46e3b..e951c56df0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "whatsapp-web.js", - "version": "1.20.0-alpha.0", + "version": "1.20.0", "description": "Library for interacting with the WhatsApp Web API ", "main": "./index.js", "typings": "./index.d.ts",