+
+ function
string
@@ -3229,7 +3599,7 @@
diff --git a/docs/index.html b/docs/index.html
index e29c2b6..b07a22a 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -3,7 +3,7 @@
- whatsapp-web.js 1.23.0 » Home
+ whatsapp-web.js 1.26.0 » Home
@@ -13,7 +13,7 @@
@@ -26,25 +26,64 @@
-
-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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+About
+A WhatsApp API client that connects through the WhatsApp Web browser app
+The library works by launching the WhatsApp Web browser application and managing it using Puppeteer to create an instance of WhatsApp Web, thereby mitigating the risk of being blocked. The WhatsApp API client connects through the WhatsApp Web browser app, accessing its internal functions. This grants you access to nearly all the features available on WhatsApp Web, enabling dynamic handling similar to any other Node.js application.
+
+[!IMPORTANT]
+It is not guaranteed you will not be blocked by using this method. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.
+
+Links
Installation
The module is now available on npm! npm i whatsapp-web.js
-Please note that Node v12+ is required.
+
+[!NOTE]
+Node v18+ is required.
+
+QUICK STEPS TO UPGRADE NODE
+Windows
+Manual
+Just get the latest LTS from the official node website .
+npm
+sudo npm install -g n
+sudo n stable
+
+Choco
+choco install nodejs-lts
+
+Winget
+winget install OpenJS.NodeJS.LTS
+
+Ubuntu / Debian
+curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - &&\
+sudo apt-get install -y nodejs
+
Example usage
const { Client } = require('whatsapp-web.js');
@@ -67,8 +106,8 @@ client.on('message', msg => {
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 .
+Take a look at example.js for another examples with additional use cases.
+For further details on saving and restoring sessions, explore the provided Authentication Strategies .
Supported features
@@ -96,7 +135,7 @@ client.initialize();
Send media (video)
-✅ (requires google chrome)
+✅ (requires Google Chrome)
Send stickers
@@ -116,11 +155,11 @@ client.initialize();
Send buttons
-✅
+❌ (DEPRECATED)
Send lists
-✅ (business accounts not supported)
+❌ (DEPRECATED)
Receive location
@@ -163,6 +202,10 @@ client.initialize();
✅
+Mention groups
+✅
+
+
Mute/unmute chats
✅
@@ -186,11 +229,27 @@ client.initialize();
React to messages
✅
+
+Create polls
+✅
+
+
+Vote in polls
+🔜
+
+
+Communities
+🔜
+
+
+Channels
+🔜
+
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.
+Feel free to open pull requests; we welcome contributions! However, for significant changes, it's best to open an issue beforehand. Make sure to review our contribution guidelines before creating a pull request. Before creating your own issue or pull request, always check to see if one already exists!
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.
+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 whatsapp.com . "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners. Also it is not guaranteed you will not be blocked by using this method. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.
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.
+
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
+
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.
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1680,6 +1809,11 @@ limitations under the License.
+
+ GroupChat#setAddMembersAdminsOnly([adminsOnly])
+
+
+
GroupChat#setDescription(description)
@@ -2009,33 +2143,6 @@ limitations under the License.
-
List
@@ -2295,6 +2402,11 @@ limitations under the License.
+
+ Message#getGroupMentions()
+
+
+
@@ -2330,6 +2442,11 @@ limitations under the License.
+
+ Message#groupMentions
+
+
+
Message#hasMedia
@@ -2410,6 +2527,11 @@ limitations under the License.
+
+ Message#pin(duration)
+
+
+
Message#rawData
@@ -2455,6 +2577,11 @@ limitations under the License.
+
+ Message#unpin()
+
+
+
Message#unstar()
@@ -2960,6 +3087,53 @@ limitations under the License.
+
PrivateChat
@@ -3734,7 +3908,7 @@ limitations under the License.
diff --git a/docs/scripts/jsdoc-toc.js b/docs/scripts/jsdoc-toc.js
index 80c357f..a21d2ac 100644
--- a/docs/scripts/jsdoc-toc.js
+++ b/docs/scripts/jsdoc-toc.js
@@ -6,7 +6,7 @@
treeNode.tree({
autoEscape: false,
closedIcon: '⇢',
- data: [{"label":"
Globals ","id":"global","children":[]},{"label":"
Base ","id":"Base","children":[]},{"label":"
BaseAuthStrategy ","id":"BaseAuthStrategy","children":[]},{"label":"
BusinessContact ","id":"BusinessContact","children":[]},{"label":"
Buttons ","id":"Buttons","children":[]},{"label":"
Call ","id":"Call","children":[]},{"label":"
Chat ","id":"Chat","children":[]},{"label":"
Client ","id":"Client","children":[]},{"label":"
ClientInfo ","id":"ClientInfo","children":[]},{"label":"
Contact ","id":"Contact","children":[]},{"label":"
GroupChat ","id":"GroupChat","children":[]},{"label":"
GroupNotification ","id":"GroupNotification","children":[]},{"label":"
InterfaceController ","id":"InterfaceController","children":[]},{"label":"
Label ","id":"Label","children":[]},{"label":"
LegacySessionAuth ","id":"LegacySessionAuth","children":[]},{"label":"
List ","id":"List","children":[]},{"label":"
LocalAuth ","id":"LocalAuth","children":[]},{"label":"
LocalWebCache ","id":"LocalWebCache","children":[]},{"label":"
Location ","id":"Location","children":[]},{"label":"
Message ","id":"Message","children":[]},{"label":"
MessageMedia ","id":"MessageMedia","children":[]},{"label":"
NoAuth ","id":"NoAuth","children":[]},{"label":"
Order ","id":"Order","children":[]},{"label":"
Poll ","id":"Poll","children":[]},{"label":"
PrivateChat ","id":"PrivateChat","children":[]},{"label":"
PrivateContact ","id":"PrivateContact","children":[]},{"label":"
Product ","id":"Product","children":[]},{"label":"
Reaction ","id":"Reaction","children":[]},{"label":"
RemoteAuth ","id":"RemoteAuth","children":[]},{"label":"
RemoteWebCache ","id":"RemoteWebCache","children":[]},{"label":"
Util ","id":"Util","children":[]},{"label":"
WebCache ","id":"WebCache","children":[]}],
+ data: [{"label":"
Globals ","id":"global","children":[]},{"label":"
Base ","id":"Base","children":[]},{"label":"
BaseAuthStrategy ","id":"BaseAuthStrategy","children":[]},{"label":"
BusinessContact ","id":"BusinessContact","children":[]},{"label":"
Buttons ","id":"Buttons","children":[]},{"label":"
Call ","id":"Call","children":[]},{"label":"
Chat ","id":"Chat","children":[]},{"label":"
Client ","id":"Client","children":[]},{"label":"
ClientInfo ","id":"ClientInfo","children":[]},{"label":"
Contact ","id":"Contact","children":[]},{"label":"
GroupChat ","id":"GroupChat","children":[]},{"label":"
GroupNotification ","id":"GroupNotification","children":[]},{"label":"
InterfaceController ","id":"InterfaceController","children":[]},{"label":"
Label ","id":"Label","children":[]},{"label":"
List ","id":"List","children":[]},{"label":"
LocalAuth ","id":"LocalAuth","children":[]},{"label":"
LocalWebCache ","id":"LocalWebCache","children":[]},{"label":"
Location ","id":"Location","children":[]},{"label":"
Message ","id":"Message","children":[]},{"label":"
MessageMedia ","id":"MessageMedia","children":[]},{"label":"
NoAuth ","id":"NoAuth","children":[]},{"label":"
Order ","id":"Order","children":[]},{"label":"
Poll ","id":"Poll","children":[]},{"label":"
PollVote ","id":"PollVote","children":[]},{"label":"
PrivateChat ","id":"PrivateChat","children":[]},{"label":"
PrivateContact ","id":"PrivateContact","children":[]},{"label":"
Product ","id":"Product","children":[]},{"label":"
Reaction ","id":"Reaction","children":[]},{"label":"
RemoteAuth ","id":"RemoteAuth","children":[]},{"label":"
RemoteWebCache ","id":"RemoteWebCache","children":[]},{"label":"
Util ","id":"Util","children":[]},{"label":"
WebCache ","id":"WebCache","children":[]}],
openedIcon: ' ⇣',
saveState: false,
useContextMenu: false
diff --git a/docs/structures_Base.js.html b/docs/structures_Base.js.html
index dc4ee1f..f5a09a2 100644
--- a/docs/structures_Base.js.html
+++ b/docs/structures_Base.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Base.js
+
whatsapp-web.js 1.26.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 54b5345..5d34a72 100644
--- a/docs/structures_BusinessContact.js.html
+++ b/docs/structures_BusinessContact.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/BusinessContact.js
+
whatsapp-web.js 1.26.0 » Source: structures/BusinessContact.js
@@ -15,7 +15,7 @@
@@ -59,7 +59,7 @@ module.exports = BusinessContact;
diff --git a/docs/structures_Buttons.js.html b/docs/structures_Buttons.js.html
index 0ccc184..6264599 100644
--- a/docs/structures_Buttons.js.html
+++ b/docs/structures_Buttons.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Buttons.js
+
whatsapp-web.js 1.26.0 » Source: structures/Buttons.js
@@ -15,7 +15,7 @@
@@ -120,7 +120,7 @@ module.exports = Buttons;
diff --git a/docs/structures_Call.js.html b/docs/structures_Call.js.html
index 089363c..c76c3ff 100644
--- a/docs/structures_Call.js.html
+++ b/docs/structures_Call.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Call.js
+
whatsapp-web.js 1.26.0 » Source: structures/Call.js
@@ -15,7 +15,7 @@
@@ -114,7 +114,7 @@ module.exports = Call;
diff --git a/docs/structures_Chat.js.html b/docs/structures_Chat.js.html
index c9dec6e..22bea7b 100644
--- a/docs/structures_Chat.js.html
+++ b/docs/structures_Chat.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Chat.js
+
whatsapp-web.js 1.26.0 » Source: structures/Chat.js
@@ -15,7 +15,7 @@
@@ -314,7 +314,7 @@ module.exports = Chat;
diff --git a/docs/structures_ClientInfo.js.html b/docs/structures_ClientInfo.js.html
index 4c19f3c..2d7f831 100644
--- a/docs/structures_ClientInfo.js.html
+++ b/docs/structures_ClientInfo.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/ClientInfo.js
+
whatsapp-web.js 1.26.0 » Source: structures/ClientInfo.js
@@ -15,7 +15,7 @@
@@ -109,7 +109,7 @@ module.exports = ClientInfo;
diff --git a/docs/structures_Contact.js.html b/docs/structures_Contact.js.html
index 06a1e0a..58aaaf7 100644
--- a/docs/structures_Contact.js.html
+++ b/docs/structures_Contact.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Contact.js
+
whatsapp-web.js 1.26.0 » Source: structures/Contact.js
@@ -15,7 +15,7 @@
@@ -247,7 +247,7 @@ module.exports = Contact;
diff --git a/docs/structures_GroupChat.js.html b/docs/structures_GroupChat.js.html
index 319c776..03b4e35 100644
--- a/docs/structures_GroupChat.js.html
+++ b/docs/structures_GroupChat.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/GroupChat.js
+
whatsapp-web.js 1.26.0 » Source: structures/GroupChat.js
@@ -15,7 +15,7 @@
@@ -129,7 +129,7 @@ class GroupChat extends Chat {
419: 'The participant can\'t be added because the group is full'
};
- await window.Store.GroupMetadata.queryAndUpdate(groupWid);
+ await window.Store.GroupQueryAndUpdate(groupWid);
const groupMetadata = group.groupMetadata;
const groupParticipants = groupMetadata?.participants;
@@ -183,7 +183,7 @@ class GroupChat extends Chat {
if (autoSendInviteV4 && rpcResultCode === 403) {
let userChat, isInviteV4Sent = false;
- window.Store.ContactCollection.gadd(pWid, { silent: true });
+ window.Store.Contact.gadd(pWid, { silent: true });
if (rpcResult.name === 'ParticipantRequestCodeCanBeSent' &&
(userChat = await window.Store.Chat.find(pWid))) {
@@ -312,6 +312,27 @@ class GroupChat extends Chat {
return true;
}
+ /**
+ * Updates the group setting to allow only admins to add members to the group.
+ * @param {boolean} [adminsOnly=true] Enable or disable this option
+ * @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
+ */
+ async setAddMembersAdminsOnly(adminsOnly=true) {
+ const success = await this.client.pupPage.evaluate(async (groupId, adminsOnly) => {
+ const chatWid = window.Store.WidFactory.createWid(groupId);
+ try {
+ const response = await window.Store.GroupUtils.setGroupMemberAddMode(chatWid, 'member_add_mode', adminsOnly ? 0 : 1);
+ return response.name === 'SetMemberAddModeResponseSuccess';
+ } catch (err) {
+ if(err.name === 'SmaxParsingFailure') return false;
+ throw err;
+ }
+ }, this.id._serialized, adminsOnly);
+
+ success && (this.groupMetadata.memberAddMode = adminsOnly ? 'admin_add' : 'all_member_add');
+ return success;
+ }
+
/**
* Updates the group settings to only allow admins to send messages.
* @param {boolean} [adminsOnly=true] Enable or disable this option
@@ -390,10 +411,18 @@ class GroupChat extends Chat {
async getInviteCode() {
const codeRes = await this.client.pupPage.evaluate(async chatId => {
const chatWid = window.Store.WidFactory.createWid(chatId);
- return window.Store.GroupInvite.queryGroupInviteCode(chatWid);
+ try {
+ return window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')
+ ? await window.Store.GroupInvite.queryGroupInviteCode(chatWid, true)
+ : await window.Store.GroupInvite.queryGroupInviteCode(chatWid);
+ }
+ catch (err) {
+ if(err.name === 'ServerStatusCodeError') return undefined;
+ throw err;
+ }
}, this.id._serialized);
- return codeRes.code;
+ return codeRes?.code;
}
/**
@@ -485,7 +514,7 @@ module.exports = GroupChat;
diff --git a/docs/structures_GroupNotification.js.html b/docs/structures_GroupNotification.js.html
index 9e71139..2ebf6d2 100644
--- a/docs/structures_GroupNotification.js.html
+++ b/docs/structures_GroupNotification.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/GroupNotification.js
+
whatsapp-web.js 1.26.0 » Source: structures/GroupNotification.js
@@ -15,7 +15,7 @@
@@ -143,7 +143,7 @@ module.exports = GroupNotification;
diff --git a/docs/structures_Label.js.html b/docs/structures_Label.js.html
index a0df02a..74aee29 100644
--- a/docs/structures_Label.js.html
+++ b/docs/structures_Label.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Label.js
+
whatsapp-web.js 1.26.0 » Source: structures/Label.js
@@ -15,7 +15,7 @@
@@ -88,7 +88,7 @@ module.exports = Label;
diff --git a/docs/structures_List.js.html b/docs/structures_List.js.html
index a6e5e51..722e99f 100644
--- a/docs/structures_List.js.html
+++ b/docs/structures_List.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/List.js
+
whatsapp-web.js 1.26.0 » Source: structures/List.js
@@ -15,7 +15,7 @@
@@ -118,7 +118,7 @@ module.exports = List;
diff --git a/docs/structures_Location.js.html b/docs/structures_Location.js.html
index c56cb78..217e826 100644
--- a/docs/structures_Location.js.html
+++ b/docs/structures_Location.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Location.js
+
whatsapp-web.js 1.26.0 » Source: structures/Location.js
@@ -15,7 +15,7 @@
@@ -99,7 +99,7 @@ module.exports = Location;
diff --git a/docs/structures_Message.js.html b/docs/structures_Message.js.html
index 6b1b4bb..5013f81 100644
--- a/docs/structures_Message.js.html
+++ b/docs/structures_Message.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Message.js
+
whatsapp-web.js 1.26.0 » Source: structures/Message.js
@@ -15,7 +15,7 @@
@@ -37,8 +37,8 @@ const Location = require('./Location');
const Order = require('./Order');
const Payment = require('./Payment');
const Reaction = require('./Reaction');
-const {MessageTypes} = require('../util/Constants');
-const {Contact} = require('./Contact');
+const Contact = require('./Contact');
+const { MessageTypes } = require('../util/Constants');
/**
* Represents a Message on WhatsApp
@@ -213,19 +213,37 @@ class Message extends Base {
inviteCodeExp: data.inviteCodeExp,
groupId: data.inviteGrp,
groupName: data.inviteGrpName,
- fromId: '_serialized' in data.from ? data.from._serialized : data.from,
- toId: '_serialized' in data.to ? data.to._serialized : data.to
+ fromId: typeof data.from === 'object' && '_serialized' in data.from ? data.from._serialized : data.from,
+ toId: typeof data.to === 'object' && '_serialized' in data.to ? data.to._serialized : data.to
} : undefined;
/**
- * Indicates the mentions in the message body.
- * @type {Array<string>}
+ * @typedef {Object} Mention
+ * @property {string} server
+ * @property {string} user
+ * @property {string} _serialized
*/
- this.mentionedIds = [];
- if (data.mentionedJidList) {
- this.mentionedIds = data.mentionedJidList;
- }
+ /**
+ * Indicates the mentions in the message body.
+ * @type {Mention[]}
+ */
+ this.mentionedIds = data.mentionedJidList || [];
+
+ /**
+ * @typedef {Object} GroupMention
+ * @property {string} groupSubject The name of the group
+ * @property {Object} groupJid The group ID
+ * @property {string} groupJid.server
+ * @property {string} groupJid.user
+ * @property {string} groupJid._serialized
+ */
+
+ /**
+ * Indicates whether there are group mentions in the message body
+ * @type {GroupMention[]}
+ */
+ this.groupMentions = data.groupMentions || [];
/**
* Order ID for message type ORDER
@@ -308,12 +326,7 @@ class Message extends Base {
this.allowMultipleAnswers = Boolean(!data.pollSelectableOptionsCount);
this.pollInvalidated = data.pollInvalidated;
this.isSentCagPollCreation = data.isSentCagPollCreation;
-
- delete this._data.pollName;
- delete this._data.pollOptions;
- delete this._data.pollSelectableOptionsCount;
- delete this._data.pollInvalidated;
- delete this._data.isSentCagPollCreation;
+ this.messageSecret = Object.keys(data.messageSecret).map((key) => data.messageSecret[key]);
}
return super._patch(data);
@@ -329,9 +342,9 @@ class Message extends Base {
* @returns {Promise<Message>}
*/
async reload() {
- const newData = await this.client.pupPage.evaluate((msgId) => {
- const msg = window.Store.Msg.get(msgId);
- if(!msg) return null;
+ const newData = await this.client.pupPage.evaluate(async (msgId) => {
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
+ if (!msg) return null;
return window.WWebJS.getMessageModel(msg);
}, this.id._serialized);
@@ -372,6 +385,14 @@ class Message extends Base {
async getMentions() {
return await Promise.all(this.mentionedIds.map(async m => await this.client.getContactById(m)));
}
+
+ /**
+ * Returns groups mentioned in this message
+ * @returns {Promise<GroupChat[]|[]>}
+ */
+ async getGroupMentions() {
+ return await Promise.all(this.groupMentions.map(async (m) => await this.client.getChatById(m.groupJid._serialized)));
+ }
/**
* Returns the quoted message, if any
@@ -380,8 +401,8 @@ class Message extends Base {
async getQuotedMessage() {
if (!this.hasQuotedMsg) return undefined;
- const quotedMsg = await this.client.pupPage.evaluate((msgId) => {
- const msg = window.Store.Msg.get(msgId);
+ const quotedMsg = await this.client.pupPage.evaluate(async (msgId) => {
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
const quotedMsg = window.Store.QuotedMsg.getQuotedMsgObj(msg);
return window.WWebJS.getMessageModel(quotedMsg);
}, this.id._serialized);
@@ -419,9 +440,10 @@ class Message extends Base {
*/
async react(reaction){
await this.client.pupPage.evaluate(async (messageId, reaction) => {
- if (!messageId) { return undefined; }
-
- const msg = await window.Store.Msg.get(messageId);
+ if (!messageId) return null;
+ const msg =
+ window.Store.Msg.get(messageId) || (await window.Store.Msg.getMessagesById([messageId]))?.messages?.[0];
+ if(!msg) return null;
await window.Store.sendReactionToMsg(msg, reaction);
}, this.id._serialized, reaction);
}
@@ -444,10 +466,7 @@ class Message extends Base {
const chatId = typeof chat === 'string' ? chat : chat.id._serialized;
await this.client.pupPage.evaluate(async (msgId, chatId) => {
- let msg = window.Store.Msg.get(msgId);
- let chat = window.Store.Chat.get(chatId);
-
- return await chat.forwardMessages([msg]);
+ return window.WWebJS.forwardMessage(chatId, msgId);
}, this.id._serialized, chatId);
}
@@ -461,9 +480,9 @@ class Message extends Base {
}
const result = await this.client.pupPage.evaluate(async (msgId) => {
- const msg = window.Store.Msg.get(msgId);
- if (!msg) {
- return undefined;
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
+ if (!msg || !msg.mediaData) {
+ return null;
}
if (msg.mediaData.mediaStage != 'RESOLVED') {
// try to resolve media
@@ -513,12 +532,16 @@ class Message extends Base {
*/
async delete(everyone) {
await this.client.pupPage.evaluate(async (msgId, everyone) => {
- let msg = window.Store.Msg.get(msgId);
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
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(chat, [msg], { clearMedia: true, type: msg.id.fromMe ? 'Sender' : 'Admin' });
+ if (window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.0')) {
+ return window.Store.Cmd.sendRevokeMsgs(chat, { list: [msg], type: 'message' }, { clearMedia: true });
+ } else {
+ return window.Store.Cmd.sendRevokeMsgs(chat, [msg], { clearMedia: true, type: msg.id.fromMe ? 'Sender' : 'Admin' });
+ }
}
return window.Store.Cmd.sendDeleteMsgs(chat, [msg], true);
@@ -530,8 +553,7 @@ class Message extends Base {
*/
async star() {
await this.client.pupPage.evaluate(async (msgId) => {
- let msg = window.Store.Msg.get(msgId);
-
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
if (window.Store.MsgActionChecks.canStarMsg(msg)) {
let chat = await window.Store.Chat.find(msg.id.remote);
return window.Store.Cmd.sendStarMsgs(chat, [msg], false);
@@ -544,8 +566,7 @@ class Message extends Base {
*/
async unstar() {
await this.client.pupPage.evaluate(async (msgId) => {
- let msg = window.Store.Msg.get(msgId);
-
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
if (window.Store.MsgActionChecks.canStarMsg(msg)) {
let chat = await window.Store.Chat.find(msg.id.remote);
return window.Store.Cmd.sendUnstarMsgs(chat, [msg], false);
@@ -553,6 +574,27 @@ class Message extends Base {
}, this.id._serialized);
}
+ /**
+ * Pins the message (group admins can pin messages of all group members)
+ * @param {number} duration The duration in seconds the message will be pinned in a chat
+ * @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
+ */
+ async pin(duration) {
+ return await this.client.pupPage.evaluate(async (msgId, duration) => {
+ return await window.WWebJS.pinUnpinMsgAction(msgId, 1, duration);
+ }, this.id._serialized, duration);
+ }
+
+ /**
+ * Unpins the message (group admins can unpin messages of all group members)
+ * @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
+ */
+ async unpin() {
+ return await this.client.pupPage.evaluate(async (msgId) => {
+ return await window.WWebJS.pinUnpinMsgAction(msgId, 2);
+ }, this.id._serialized);
+ }
+
/**
* Message Info
* @typedef {Object} MessageInfo
@@ -565,15 +607,20 @@ class Message extends Base {
*/
/**
- * Get information about message delivery status. May return null if the message does not exist or is not sent by you.
+ * Get information about message delivery status.
+ * May return null if the message does not exist or is not sent by you.
* @returns {Promise<?MessageInfo>}
*/
async getInfo() {
const info = await this.client.pupPage.evaluate(async (msgId) => {
- const msg = window.Store.Msg.get(msgId);
- if (!msg) return null;
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
+ if (!msg || !msg.id.fromMe) return null;
- return await window.Store.MessageInfo.sendQueryMsgInfo(msg.id);
+ return new Promise((resolve) => {
+ setTimeout(async () => {
+ resolve(await window.Store.getMsgInfo(msg.id));
+ }, (Date.now() - msg.t * 1000 < 1250) && Math.floor(Math.random() * (1200 - 1100 + 1)) + 1100 || 0);
+ });
}, this.id._serialized);
return info;
@@ -600,7 +647,7 @@ class Message extends Base {
async getPayment() {
if (this.type === MessageTypes.PAYMENT) {
const msg = await this.client.pupPage.evaluate(async (msgId) => {
- const msg = window.Store.Msg.get(msgId);
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
if(!msg) return null;
return msg.serialize();
}, this.id._serialized);
@@ -654,12 +701,20 @@ class Message extends Base {
* @returns {Promise<?Message>}
*/
async edit(content, options = {}) {
- if (options.mentions && options.mentions.some(possiblyContact => possiblyContact instanceof Contact)) {
- options.mentions = options.mentions.map(a => a.id._serialized);
+ if (options.mentions) {
+ !Array.isArray(options.mentions) && (options.mentions = [options.mentions]);
+ if (options.mentions.some((possiblyContact) => possiblyContact instanceof Contact)) {
+ console.warn('Mentions with an array of Contact are now deprecated. See more at https://github.com/pedroslopez/whatsapp-web.js/pull/2166.');
+ options.mentions = options.mentions.map((a) => a.id._serialized);
+ }
}
+
+ options.groupMentions && !Array.isArray(options.groupMentions) && (options.groupMentions = [options.groupMentions]);
+
let internalOptions = {
linkPreview: options.linkPreview === false ? undefined : true,
- mentionedJidList: Array.isArray(options.mentions) ? options.mentions : [],
+ mentionedJidList: options.mentions || [],
+ groupMentions: options.groupMentions,
extraOptions: options.extra
};
@@ -667,11 +722,11 @@ class Message extends Base {
return null;
}
const messageEdit = await this.client.pupPage.evaluate(async (msgId, message, options) => {
- let msg = window.Store.Msg.get(msgId);
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
if (!msg) return null;
- let catEdit = (msg.type === 'chat' && window.Store.MsgActionChecks.canEditText(msg));
- if (catEdit) {
+ let canEdit = window.Store.MsgActionChecks.canEditText(msg) || window.Store.MsgActionChecks.canEditCaption(msg);
+ if (canEdit) {
const msgEdit = await window.WWebJS.editMessage(msg, message, options);
return msgEdit.serialize();
}
@@ -695,7 +750,7 @@ module.exports = Message;
diff --git a/docs/structures_MessageMedia.js.html b/docs/structures_MessageMedia.js.html
index 60a1248..4b334eb 100644
--- a/docs/structures_MessageMedia.js.html
+++ b/docs/structures_MessageMedia.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/MessageMedia.js
+
whatsapp-web.js 1.26.0 » Source: structures/MessageMedia.js
@@ -15,7 +15,7 @@
@@ -150,7 +150,7 @@ module.exports = MessageMedia;
diff --git a/docs/structures_Order.js.html b/docs/structures_Order.js.html
index cb091f3..4a89915 100644
--- a/docs/structures_Order.js.html
+++ b/docs/structures_Order.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Order.js
+
whatsapp-web.js 1.26.0 » Source: structures/Order.js
@@ -15,7 +15,7 @@
@@ -90,7 +90,7 @@ module.exports = Order;
diff --git a/docs/structures_Payment.js.html b/docs/structures_Payment.js.html
index f4598b1..a0cd91e 100644
--- a/docs/structures_Payment.js.html
+++ b/docs/structures_Payment.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Payment.js
+
whatsapp-web.js 1.26.0 » Source: structures/Payment.js
@@ -15,7 +15,7 @@
@@ -118,7 +118,7 @@ module.exports = Payment;
diff --git a/docs/structures_Poll.js.html b/docs/structures_Poll.js.html
index da5c481..7e05c31 100644
--- a/docs/structures_Poll.js.html
+++ b/docs/structures_Poll.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Poll.js
+
whatsapp-web.js 1.26.0 » Source: structures/Poll.js
@@ -15,7 +15,7 @@
@@ -83,7 +83,7 @@ module.exports = Poll;
diff --git a/docs/structures_PollVote.js.html b/docs/structures_PollVote.js.html
new file mode 100644
index 0000000..63e4c20
--- /dev/null
+++ b/docs/structures_PollVote.js.html
@@ -0,0 +1,115 @@
+
+
+
+
+
+
+
whatsapp-web.js 1.26.0 » Source: structures/PollVote.js
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 'use strict';
+
+const Message = require('./Message');
+const Base = require('./Base');
+
+/**
+ * Selected poll option structure
+ * @typedef {Object} SelectedPollOption
+ * @property {number} id The local selected or deselected option ID
+ * @property {string} name The option name
+ */
+
+/**
+ * Represents a Poll Vote on WhatsApp
+ * @extends {Base}
+ */
+class PollVote extends Base {
+ constructor(client, data) {
+ super(client);
+
+ if (data) this._patch(data);
+ }
+
+ _patch(data) {
+ /**
+ * The person who voted
+ * @type {string}
+ */
+ this.voter = data.sender;
+
+ /**
+ * The selected poll option(s)
+ * If it's an empty array, the user hasn't selected any options on the poll,
+ * may occur when they deselected all poll options
+ * @type {SelectedPollOption[]}
+ */
+ this.selectedOptions =
+ data.selectedOptionLocalIds.length > 0
+ ? data.selectedOptionLocalIds.map((e) => ({
+ name: data.parentMessage.pollOptions.find((x) => x.localId === e).name,
+ localId: e
+ }))
+ : [];
+
+ /**
+ * Timestamp the option was selected or deselected at
+ * @type {number}
+ */
+ this.interractedAtTs = data.senderTimestampMs;
+
+ /**
+ * The poll creation message associated with the poll vote
+ * @type {Message}
+ */
+ this.parentMessage = new Message(this.client, data.parentMessage);
+
+ return super._patch(data);
+ }
+}
+
+module.exports = PollVote;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/structures_PrivateChat.js.html b/docs/structures_PrivateChat.js.html
index e337bd5..e8889b9 100644
--- a/docs/structures_PrivateChat.js.html
+++ b/docs/structures_PrivateChat.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/PrivateChat.js
+
whatsapp-web.js 1.26.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 5017b0f..2df6fae 100644
--- a/docs/structures_PrivateContact.js.html
+++ b/docs/structures_PrivateContact.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/PrivateContact.js
+
whatsapp-web.js 1.26.0 » Source: structures/PrivateContact.js
@@ -15,7 +15,7 @@
@@ -51,7 +51,7 @@ module.exports = PrivateContact;
diff --git a/docs/structures_Product.js.html b/docs/structures_Product.js.html
index a5e898f..ab12f12 100644
--- a/docs/structures_Product.js.html
+++ b/docs/structures_Product.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Product.js
+
whatsapp-web.js 1.26.0 » Source: structures/Product.js
@@ -15,7 +15,7 @@
@@ -106,7 +106,7 @@ module.exports = Product;
diff --git a/docs/structures_ProductMetadata.js.html b/docs/structures_ProductMetadata.js.html
index c0c38ad..7b09d69 100644
--- a/docs/structures_ProductMetadata.js.html
+++ b/docs/structures_ProductMetadata.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/ProductMetadata.js
+
whatsapp-web.js 1.26.0 » Source: structures/ProductMetadata.js
@@ -15,7 +15,7 @@
@@ -63,7 +63,7 @@ module.exports = ProductMetadata;
diff --git a/docs/structures_Reaction.js.html b/docs/structures_Reaction.js.html
index a2ac667..80ff22a 100644
--- a/docs/structures_Reaction.js.html
+++ b/docs/structures_Reaction.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: structures/Reaction.js
+
whatsapp-web.js 1.26.0 » Source: structures/Reaction.js
@@ -15,7 +15,7 @@
@@ -107,7 +107,7 @@ module.exports = Reaction;
diff --git a/docs/util_Constants.js.html b/docs/util_Constants.js.html
index 596f819..c045d04 100644
--- a/docs/util_Constants.js.html
+++ b/docs/util_Constants.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: util/Constants.js
+
whatsapp-web.js 1.26.0 » Source: util/Constants.js
@@ -15,7 +15,7 @@
@@ -75,6 +75,7 @@ exports.Events = {
CHAT_REMOVED: 'chat_removed',
CHAT_ARCHIVED: 'chat_archived',
MESSAGE_RECEIVED: 'message',
+ MESSAGE_CIPHERTEXT: 'message_ciphertext',
MESSAGE_CREATE: 'message_create',
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
MESSAGE_REVOKED_ME: 'message_revoke_me',
@@ -95,7 +96,8 @@ exports.Events = {
STATE_CHANGED: 'change_state',
BATTERY_CHANGED: 'change_battery',
INCOMING_CALL: 'call',
- REMOTE_SESSION_SAVED: 'remote_session_saved'
+ REMOTE_SESSION_SAVED: 'remote_session_saved',
+ VOTE_UPDATE: 'vote_update'
};
/**
@@ -213,7 +215,7 @@ exports.MessageAck = {
diff --git a/docs/util_Injected_LegacyStore.js.html b/docs/util_Injected_LegacyStore.js.html
new file mode 100644
index 0000000..82d7127
--- /dev/null
+++ b/docs/util_Injected_LegacyStore.js.html
@@ -0,0 +1,199 @@
+
+
+
+
+
+
+
whatsapp-web.js 1.26.0 » Source: util/Injected/LegacyStore.js
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 'use strict';
+
+//TODO: To be removed by version 2.3000.x hard release
+
+// Exposes the internal Store to the WhatsApp Web client
+exports.ExposeLegacyStore = () => {
+ window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
+ window.Store.AppState = window.mR.findModule('Socket')[0].Socket;
+ window.Store.Conn = window.mR.findModule('Conn')[0].Conn;
+ window.Store.BlockContact = window.mR.findModule('blockContact')[0];
+ window.Store.Call = window.mR.findModule((module) => module.default && module.default.Call)[0].default.Call;
+ window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
+ window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
+ window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;
+ window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata;
+ window.Store.GroupQueryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
+ window.Store.Label = window.mR.findModule('LabelCollection')[0].LabelCollection;
+ window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0];
+ window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
+ window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
+ window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
+ window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
+ window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
+ window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
+ window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
+ window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
+ window.Store.SendClear = window.mR.findModule('sendClear')[0];
+ window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
+ window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
+ window.Store.EditMessage = window.mR.findModule('addAndSendMessageEdit')[0];
+ window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
+ window.Store.User = window.mR.findModule('getMaybeMeUser')[0];
+ window.Store.ContactMethods = window.mR.findModule('getUserid')[0];
+ window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
+ window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
+ window.Store.Validators = window.mR.findModule('findLinks')[0];
+ window.Store.VCard = window.mR.findModule('vcardFromContactModel')[0];
+ window.Store.WidFactory = window.mR.findModule('createWid')[0];
+ window.Store.ProfilePic = window.mR.findModule('profilePicResync')[0];
+ window.Store.PresenceUtils = window.mR.findModule('sendPresenceAvailable')[0];
+ window.Store.ChatState = window.mR.findModule('sendChatStateComposing')[0];
+ window.Store.findCommonGroups = window.mR.findModule('findCommonGroups')[0].findCommonGroups;
+ window.Store.StatusUtils = window.mR.findModule('setMyStatus')[0];
+ window.Store.ConversationMsgs = window.mR.findModule('loadEarlierMsgs')[0];
+ window.Store.sendReactionToMsg = window.mR.findModule('sendReactionToMsg')[0].sendReactionToMsg;
+ window.Store.createOrUpdateReactionsModule = window.mR.findModule('createOrUpdateReactions')[0];
+ window.Store.EphemeralFields = window.mR.findModule('getEphemeralFields')[0];
+ window.Store.MsgActionChecks = window.mR.findModule('canSenderRevokeMsg')[0];
+ window.Store.QuotedMsg = window.mR.findModule('getQuotedMsgObj')[0];
+ window.Store.LinkPreview = window.mR.findModule('getLinkPreview')[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.LidUtils = window.mR.findModule('getCurrentLid')[0];
+ window.Store.WidToJid = window.mR.findModule('widToUserJid')[0];
+ window.Store.JidToWid = window.mR.findModule('userJidToUserWid')[0];
+ window.Store.getMsgInfo = (window.mR.findModule('sendQueryMsgInfo')[0] || {}).sendQueryMsgInfo || window.mR.findModule('queryMsgInfo')[0].queryMsgInfo;
+ window.Store.pinUnpinMsg = window.mR.findModule('sendPinInChatMsg')[0].sendPinInChatMsg;
+
+ /* eslint-disable no-undef, no-cond-assign */
+ window.Store.QueryExist = ((m = window.mR.findModule('queryExists')[0]) ? m.queryExists : window.mR.findModule('queryExist')[0].queryWidExists);
+ window.Store.ReplyUtils = (m = window.mR.findModule('canReplyMsg')).length > 0 && m[0];
+ /* eslint-enable no-undef, no-cond-assign */
+
+ window.Store.Settings = {
+ ...window.mR.findModule('ChatlistPanelState')[0],
+ setPushname: window.mR.findModule((m) => m.setPushname && !m.ChatlistPanelState)[0].setPushname
+ };
+ window.Store.StickerTools = {
+ ...window.mR.findModule('toWebpSticker')[0],
+ ...window.mR.findModule('addWebpMetadata')[0]
+ };
+ window.Store.GroupUtils = {
+ ...window.mR.findModule('createGroup')[0],
+ ...window.mR.findModule('setGroupDescription')[0],
+ ...window.mR.findModule('sendExitGroup')[0],
+ ...window.mR.findModule('sendSetPicture')[0]
+ };
+ window.Store.GroupParticipants = {
+ ...window.mR.findModule('promoteParticipants')[0],
+ ...window.mR.findModule('sendAddParticipantsRPC')[0]
+ };
+ window.Store.GroupInvite = {
+ ...window.mR.findModule('resetGroupInviteCode')[0],
+ ...window.mR.findModule('queryGroupInvite')[0]
+ };
+ window.Store.GroupInviteV4 = {
+ ...window.mR.findModule('queryGroupInviteV4')[0],
+ ...window.mR.findModule('sendGroupInviteMessage')[0]
+ };
+ window.Store.MembershipRequestUtils = {
+ ...window.mR.findModule('getMembershipApprovalRequests')[0],
+ ...window.mR.findModule('sendMembershipRequestsActionRPC')[0]
+ };
+
+ if (!window.Store.Chat._find) {
+ window.Store.Chat._find = e => {
+ const target = window.Store.Chat.get(e);
+ return target ? Promise.resolve(target) : Promise.resolve({
+ id: e
+ });
+ };
+ }
+
+ // eslint-disable-next-line no-undef
+ if ((m = window.mR.findModule('ChatCollection')[0]) && m.ChatCollection && typeof m.ChatCollection.findImpl === 'undefined' && typeof m.ChatCollection._find !== 'undefined') m.ChatCollection.findImpl = m.ChatCollection._find;
+
+ const _isMDBackend = window.mR.findModule('isMDBackend');
+ if(_isMDBackend && _isMDBackend[0] && _isMDBackend[0].isMDBackend) {
+ window.Store.MDBackend = _isMDBackend[0].isMDBackend();
+ } else {
+ window.Store.MDBackend = true;
+ }
+
+ const _features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0];
+ if(_features) {
+ window.Store.Features = _features.LegacyPhoneFeatures;
+ }
+
+ /**
+ * Target options object description
+ * @typedef {Object} TargetOptions
+ * @property {string|number} module The name or a key of the target module to search
+ * @property {number} index The index value of the target module
+ * @property {string} function The function name to get from a module
+ */
+
+ /**
+ * Function to modify functions
+ * @param {TargetOptions} target Options specifying the target function to search for modifying
+ * @param {Function} callback Modified function
+ */
+ window.injectToFunction = (target, callback) => {
+ const module = typeof target.module === 'string'
+ ? window.mR.findModule(target.module)
+ : window.mR.modules[target.module];
+ const originalFunction = module[target.index][target.function];
+ const modifiedFunction = (...args) => callback(originalFunction, ...args);
+ module[target.index][target.function] = modifiedFunction;
+ };
+
+ window.injectToFunction({ module: 'mediaTypeFromProtobuf', index: 0, function: 'mediaTypeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage ? null : func(...args); });
+
+ window.injectToFunction({ module: 'typeAttributeFromProtobuf', index: 0, function: 'typeAttributeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage || proto.groupInviteMessage ? 'text' : func(...args); });
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/util_Injected_Store.js.html b/docs/util_Injected_Store.js.html
new file mode 100644
index 0000000..b96ac29
--- /dev/null
+++ b/docs/util_Injected_Store.js.html
@@ -0,0 +1,221 @@
+
+
+
+
+
+
+
whatsapp-web.js 1.26.0 » Source: util/Injected/Store.js
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 'use strict';
+
+exports.ExposeStore = () => {
+ /**
+ * Helper function that compares between two WWeb versions. Its purpose is to help the developer to choose the correct code implementation depending on the comparison value and the WWeb version.
+ * @param {string} lOperand The left operand for the WWeb version string to compare with
+ * @param {string} operator The comparison operator
+ * @param {string} rOperand The right operand for the WWeb version string to compare with
+ * @returns {boolean} Boolean value that indicates the result of the comparison
+ */
+ window.compareWwebVersions = (lOperand, operator, rOperand) => {
+ if (!['>', '>=', '<', '<=', '='].includes(operator)) {
+ throw new class _ extends Error {
+ constructor(m) { super(m); this.name = 'CompareWwebVersionsError'; }
+ }('Invalid comparison operator is provided');
+
+ }
+ if (typeof lOperand !== 'string' || typeof rOperand !== 'string') {
+ throw new class _ extends Error {
+ constructor(m) { super(m); this.name = 'CompareWwebVersionsError'; }
+ }('A non-string WWeb version type is provided');
+ }
+
+ lOperand = lOperand.replace(/-beta$/, '');
+ rOperand = rOperand.replace(/-beta$/, '');
+
+ while (lOperand.length !== rOperand.length) {
+ lOperand.length > rOperand.length
+ ? rOperand = rOperand.concat('0')
+ : lOperand = lOperand.concat('0');
+ }
+
+ lOperand = Number(lOperand.replace(/\./g, ''));
+ rOperand = Number(rOperand.replace(/\./g, ''));
+
+ return (
+ operator === '>' ? lOperand > rOperand :
+ operator === '>=' ? lOperand >= rOperand :
+ operator === '<' ? lOperand < rOperand :
+ operator === '<=' ? lOperand <= rOperand :
+ operator === '=' ? lOperand === rOperand :
+ false
+ );
+ };
+
+ window.Store = Object.assign({}, window.require('WAWebCollections'));
+ window.Store.AppState = window.require('WAWebSocketModel').Socket;
+ window.Store.BlockContact = window.require('WAWebBlockContactAction');
+ window.Store.Conn = window.require('WAWebConnModel').Conn;
+ window.Store.Cmd = window.require('WAWebCmd').Cmd;
+ window.Store.DownloadManager = window.require('WAWebDownloadManager').downloadManager;
+ window.Store.GroupQueryAndUpdate = window.require('WAWebGroupQueryJob').queryAndUpdateGroupMetadataById;
+ window.Store.MediaPrep = window.require('WAWebPrepRawMedia');
+ window.Store.MediaObject = window.require('WAWebMediaStorage');
+ window.Store.MediaTypes = window.require('WAWebMmsMediaTypes');
+ window.Store.MediaUpload = window.require('WAWebMediaMmsV4Upload');
+ window.Store.MsgKey = window.require('WAWebMsgKey');
+ window.Store.NumberInfo = window.require('WAPhoneUtils');
+ window.Store.OpaqueData = window.require('WAWebMediaOpaqueData');
+ window.Store.QueryProduct = window.require('WAWebBizProductCatalogBridge');
+ window.Store.QueryOrder = window.require('WAWebBizOrderBridge');
+ window.Store.SendClear = window.require('WAWebChatClearBridge');
+ window.Store.SendDelete = window.require('WAWebDeleteChatAction');
+ window.Store.SendMessage = window.require('WAWebSendMsgChatAction');
+ window.Store.EditMessage = window.require('WAWebSendMessageEditAction');
+ window.Store.SendSeen = window.require('WAWebUpdateUnreadChatAction');
+ window.Store.User = window.require('WAWebUserPrefsMeUser');
+ window.Store.ContactMethods = window.require('WAWebContactGetters');
+ window.Store.UploadUtils = window.require('WAWebUploadManager');
+ window.Store.UserConstructor = window.require('WAWebWid');
+ window.Store.Validators = window.require('WALinkify');
+ window.Store.VCard = window.require('WAWebFrontendVcardUtils');
+ window.Store.WidFactory = window.require('WAWebWidFactory');
+ window.Store.ProfilePic = window.require('WAWebContactProfilePicThumbBridge');
+ window.Store.PresenceUtils = window.require('WAWebPresenceChatAction');
+ window.Store.ChatState = window.require('WAWebChatStateBridge');
+ window.Store.findCommonGroups = window.require('WAWebFindCommonGroupsContactAction').findCommonGroups;
+ window.Store.StatusUtils = window.require('WAWebContactStatusBridge');
+ window.Store.ConversationMsgs = window.require('WAWebChatLoadMessages');
+ window.Store.sendReactionToMsg = window.require('WAWebSendReactionMsgAction').sendReactionToMsg;
+ window.Store.createOrUpdateReactionsModule = window.require('WAWebDBCreateOrUpdateReactions');
+ window.Store.EphemeralFields = window.require('WAWebGetEphemeralFieldsMsgActionsUtils');
+ window.Store.MsgActionChecks = window.require('WAWebMsgActionCapability');
+ window.Store.QuotedMsg = window.require('WAWebQuotedMsgModelUtils');
+ window.Store.LinkPreview = window.require('WAWebLinkPreviewChatAction');
+ window.Store.Socket = window.require('WADeprecatedSendIq');
+ window.Store.SocketWap = window.require('WAWap');
+ window.Store.SearchContext = window.require('WAWebChatMessageSearch').getSearchContext;
+ window.Store.DrawerManager = window.require('WAWebDrawerManager').DrawerManager;
+ window.Store.LidUtils = window.require('WAWebApiContact');
+ window.Store.WidToJid = window.require('WAWebWidToJid');
+ window.Store.JidToWid = window.require('WAWebJidToWid');
+ window.Store.getMsgInfo = window.require('WAWebApiMessageInfoStore').queryMsgInfo;
+ window.Store.pinUnpinMsg = window.require('WAWebSendPinMessageAction').sendPinInChatMsg;
+ window.Store.QueryExist = window.require('WAWebQueryExistsJob').queryWidExists;
+ window.Store.ReplyUtils = window.require('WAWebMsgReply');
+ window.Store.Settings = window.require('WAWebUserPrefsGeneral');
+ window.Store.BotSecret = window.require('WAWebBotMessageSecret');
+ window.Store.BotProfiles = window.require('WAWebBotProfileCollection');
+ window.Store.DeviceList = window.require('WAWebApiDeviceList');
+ if (window.compareWwebVersions(window.Debug.VERSION, '>=', '2.3000.1014111620'))
+ window.Store.AddonReactionTable = window.require('WAWebAddonReactionTableMode').reactionTableMode;
+
+ window.Store.ForwardUtils = {
+ ...window.require('WAWebForwardMessagesToChat')
+ };
+
+ window.Store.StickerTools = {
+ ...window.require('WAWebImageUtils'),
+ ...window.require('WAWebAddWebpMetadata')
+ };
+ window.Store.GroupUtils = {
+ ...window.require('WAWebGroupCreateJob'),
+ ...window.require('WAWebGroupModifyInfoJob'),
+ ...window.require('WAWebExitGroupAction'),
+ ...window.require('WAWebContactProfilePicThumbBridge')
+ };
+ window.Store.GroupParticipants = {
+ ...window.require('WAWebModifyParticipantsGroupAction'),
+ ...window.require('WASmaxGroupsAddParticipantsRPC')
+ };
+ window.Store.GroupInvite = {
+ ...window.require('WAWebGroupInviteJob'),
+ ...window.require('WAWebGroupQueryJob')
+ };
+ window.Store.GroupInviteV4 = {
+ ...window.require('WAWebGroupInviteV4Job'),
+ ...window.require('WAWebChatSendMessages')
+ };
+ window.Store.MembershipRequestUtils = {
+ ...window.require('WAWebApiMembershipApprovalRequestStore'),
+ ...window.require('WASmaxGroupsMembershipRequestsActionRPC')
+ };
+
+ if (!window.Store.Chat._find || !window.Store.Chat.findImpl) {
+ window.Store.Chat._find = e => {
+ const target = window.Store.Chat.get(e);
+ return target ? Promise.resolve(target) : Promise.resolve({
+ id: e
+ });
+ };
+ window.Store.Chat.findImpl = window.Store.Chat._find;
+ }
+
+ /**
+ * Target options object description
+ * @typedef {Object} TargetOptions
+ * @property {string|number} module The target module
+ * @property {string} function The function name to get from a module
+ */
+ /**
+ * Function to modify functions
+ * @param {TargetOptions} target Options specifying the target function to search for modifying
+ * @param {Function} callback Modified function
+ */
+ window.injectToFunction = (target, callback) => {
+ const module = window.require(target.module);
+ const originalFunction = module[target.function];
+ const modifiedFunction = (...args) => callback(originalFunction, ...args);
+ module[target.function] = modifiedFunction;
+ };
+
+ window.injectToFunction({ module: 'WAWebBackendJobsCommon', function: 'mediaTypeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage ? null : func(...args); });
+
+ window.injectToFunction({ module: 'WAWebE2EProtoUtils', function: 'typeAttributeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage || proto.groupInviteMessage ? 'text' : func(...args); });
+
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/util_Injected_Utils.js.html b/docs/util_Injected_Utils.js.html
new file mode 100644
index 0000000..2cf922c
--- /dev/null
+++ b/docs/util_Injected_Utils.js.html
@@ -0,0 +1,1071 @@
+
+
+
+
+
+
+
whatsapp-web.js 1.26.0 » Source: util/Injected/Utils.js
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 'use strict';
+
+exports.LoadUtils = () => {
+ window.WWebJS = {};
+
+ window.WWebJS.forwardMessage = async (chatId, msgId) => {
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
+ let chat = window.Store.Chat.get(chatId);
+
+ if (window.compareWwebVersions(window.Debug.VERSION, '>', '2.3000.0')) {
+ return window.Store.ForwardUtils.forwardMessagesToChats([msg], [chat], false);
+ } else {
+ return chat.forwardMessages([msg]);
+ }
+ };
+
+ window.WWebJS.sendSeen = async (chatId) => {
+ let chat = window.Store.Chat.get(chatId);
+ if (chat !== undefined) {
+ await window.Store.SendSeen.sendSeen(chat, false);
+ return true;
+ }
+ return false;
+
+ };
+
+ window.WWebJS.sendMessage = async (chat, content, options = {}) => {
+ let attOptions = {};
+ if (options.attachment) {
+ attOptions = options.sendMediaAsSticker
+ ? await window.WWebJS.processStickerData(options.attachment)
+ : await window.WWebJS.processMediaData(options.attachment, {
+ forceVoice: options.sendAudioAsVoice,
+ forceDocument: options.sendMediaAsDocument,
+ forceGif: options.sendVideoAsGif
+ });
+
+ attOptions.caption = options.caption;
+ content = options.sendMediaAsSticker ? undefined : attOptions.preview;
+ attOptions.isViewOnce = options.isViewOnce;
+
+ delete options.attachment;
+ delete options.sendMediaAsSticker;
+ }
+ let quotedMsgOptions = {};
+ if (options.quotedMessageId) {
+ let quotedMessage = await window.Store.Msg.getMessagesById([options.quotedMessageId]);
+
+ if (quotedMessage['messages'].length != 1) {
+ throw new Error('Could not get the quoted message.');
+ }
+
+ quotedMessage = quotedMessage['messages'][0];
+
+ // TODO remove .canReply() once all clients are updated to >= v2.2241.6
+ const canReply = window.Store.ReplyUtils ?
+ window.Store.ReplyUtils.canReplyMsg(quotedMessage.unsafe()) :
+ quotedMessage.canReply();
+
+ if (canReply) {
+ quotedMsgOptions = quotedMessage.msgContextInfo(chat);
+ }
+ delete options.quotedMessageId;
+ }
+
+ if (options.mentionedJidList) {
+ options.mentionedJidList = await Promise.all(
+ options.mentionedJidList.map(async (id) => {
+ const wid = window.Store.WidFactory.createWid(id);
+ if (await window.Store.QueryExist(wid)) {
+ return wid;
+ }
+ })
+ );
+ options.mentionedJidList = options.mentionedJidList.filter(Boolean);
+ }
+
+ if (options.groupMentions) {
+ options.groupMentions = options.groupMentions.map((e) => ({
+ groupSubject: e.subject,
+ groupJid: window.Store.WidFactory.createWid(e.id)
+ }));
+ }
+
+ let locationOptions = {};
+ if (options.location) {
+ let { latitude, longitude, description, url } = options.location;
+ url = window.Store.Validators.findLink(url)?.href;
+ url && !description && (description = url);
+ locationOptions = {
+ type: 'location',
+ loc: description,
+ lat: latitude,
+ lng: longitude,
+ clientUrl: url
+ };
+ delete options.location;
+ }
+
+ let _pollOptions = {};
+ if (options.poll) {
+ const { pollName, pollOptions } = options.poll;
+ const { allowMultipleAnswers, messageSecret } = options.poll.options;
+ _pollOptions = {
+ type: 'poll_creation',
+ pollName: pollName,
+ pollOptions: pollOptions,
+ pollSelectableOptionsCount: allowMultipleAnswers ? 0 : 1,
+ messageSecret:
+ Array.isArray(messageSecret) && messageSecret.length === 32
+ ? new Uint8Array(messageSecret)
+ : window.crypto.getRandomValues(new Uint8Array(32))
+ };
+ delete options.poll;
+ }
+
+ let vcardOptions = {};
+ if (options.contactCard) {
+ let contact = window.Store.Contact.get(options.contactCard);
+ vcardOptions = {
+ body: window.Store.VCard.vcardFromContactModel(contact).vcard,
+ type: 'vcard',
+ vcardFormattedName: contact.formattedName
+ };
+ delete options.contactCard;
+ } else if (options.contactCardList) {
+ let contacts = options.contactCardList.map(c => window.Store.Contact.get(c));
+ let vcards = contacts.map(c => window.Store.VCard.vcardFromContactModel(c));
+ vcardOptions = {
+ type: 'multi_vcard',
+ vcardList: vcards,
+ body: undefined
+ };
+ delete options.contactCardList;
+ } else if (options.parseVCards && typeof (content) === 'string' && content.startsWith('BEGIN:VCARD')) {
+ delete options.parseVCards;
+ try {
+ const parsed = window.Store.VCard.parseVcard(content);
+ if (parsed) {
+ vcardOptions = {
+ type: 'vcard',
+ vcardFormattedName: window.Store.VCard.vcardGetNameFromParsed(parsed)
+ };
+ }
+ } catch (_) {
+ // not a vcard
+ }
+ }
+
+ if (options.linkPreview) {
+ delete options.linkPreview;
+ const link = window.Store.Validators.findLink(content);
+ if (link) {
+ let preview = await window.Store.LinkPreview.getLinkPreview(link);
+ if (preview && preview.data) {
+ preview = preview.data;
+ preview.preview = true;
+ preview.subtype = 'url';
+ options = {...options, ...preview};
+ }
+ }
+ }
+
+ let buttonOptions = {};
+ if(options.buttons){
+ let caption;
+ if (options.buttons.type === 'chat') {
+ content = options.buttons.body;
+ caption = content;
+ } else {
+ caption = options.caption ? options.caption : ' '; //Caption can't be empty
+ }
+ buttonOptions = {
+ productHeaderImageRejected: false,
+ isFromTemplate: false,
+ isDynamicReplyButtonsMsg: true,
+ title: options.buttons.title ? options.buttons.title : undefined,
+ footer: options.buttons.footer ? options.buttons.footer : undefined,
+ dynamicReplyButtons: options.buttons.buttons,
+ replyButtons: options.buttons.buttons,
+ caption: caption
+ };
+ delete options.buttons;
+ }
+
+ let listOptions = {};
+ if (options.list) {
+ if (window.Store.Conn.platform === 'smba' || window.Store.Conn.platform === 'smbi') {
+ throw '[LT01] Whatsapp business can\'t send this yet';
+ }
+ listOptions = {
+ type: 'list',
+ footer: options.list.footer,
+ list: {
+ ...options.list,
+ listType: 1
+ },
+ body: options.list.description
+ };
+ delete options.list;
+ delete listOptions.list.footer;
+ }
+
+ const botOptions = {};
+ if (options.invokedBotWid) {
+ botOptions.messageSecret = window.crypto.getRandomValues(new Uint8Array(32));
+ botOptions.botMessageSecret = await window.Store.BotSecret.genBotMsgSecretFromMsgSecret(botOptions.messageSecret);
+ botOptions.invokedBotWid = window.Store.WidFactory.createWid(options.invokedBotWid);
+ botOptions.botPersonaId = window.Store.BotProfiles.BotProfileCollection.get(options.invokedBotWid).personaId;
+ delete options.invokedBotWid;
+ }
+
+ const meUser = window.Store.User.getMaybeMeUser();
+ const newId = await window.Store.MsgKey.newId();
+
+ const newMsgId = new window.Store.MsgKey({
+ from: meUser,
+ to: chat.id,
+ id: newId,
+ participant: chat.id.isGroup() ? meUser : undefined,
+ selfDir: 'out',
+ });
+
+ const extraOptions = options.extraOptions || {};
+ delete options.extraOptions;
+
+ const ephemeralFields = window.Store.EphemeralFields.getEphemeralFields(chat);
+
+ const message = {
+ ...options,
+ id: newMsgId,
+ ack: 0,
+ body: content,
+ from: meUser,
+ to: chat.id,
+ local: true,
+ self: 'out',
+ t: parseInt(new Date().getTime() / 1000),
+ isNewMsg: true,
+ type: 'chat',
+ ...ephemeralFields,
+ ...locationOptions,
+ ..._pollOptions,
+ ...attOptions,
+ ...(attOptions.toJSON ? attOptions.toJSON() : {}),
+ ...quotedMsgOptions,
+ ...vcardOptions,
+ ...buttonOptions,
+ ...listOptions,
+ ...botOptions,
+ ...extraOptions
+ };
+
+ // Bot's won't reply if canonicalUrl is set (linking)
+ if (botOptions) {
+ delete message.canonicalUrl;
+ }
+
+ await window.Store.SendMessage.addAndSendMsgToChat(chat, message);
+ return window.Store.Msg.get(newMsgId._serialized);
+ };
+
+ window.WWebJS.editMessage = async (msg, content, options = {}) => {
+
+ const extraOptions = options.extraOptions || {};
+ delete options.extraOptions;
+
+ if (options.mentionedJidList) {
+ options.mentionedJidList = await Promise.all(
+ options.mentionedJidList.map(async (id) => {
+ const wid = window.Store.WidFactory.createWid(id);
+ if (await window.Store.QueryExist(wid)) {
+ return wid;
+ }
+ })
+ );
+ options.mentionedJidList = options.mentionedJidList.filter(Boolean);
+ }
+
+ if (options.groupMentions) {
+ options.groupMentions = options.groupMentions.map((e) => ({
+ groupSubject: e.subject,
+ groupJid: window.Store.WidFactory.createWid(e.id)
+ }));
+ }
+
+ if (options.linkPreview) {
+ delete options.linkPreview;
+ const link = window.Store.Validators.findLink(content);
+ if (link) {
+ const preview = await window.Store.LinkPreview.getLinkPreview(link);
+ preview.preview = true;
+ preview.subtype = 'url';
+ options = { ...options, ...preview };
+ }
+ }
+
+
+ const internalOptions = {
+ ...options,
+ ...extraOptions
+ };
+
+ await window.Store.EditMessage.sendMessageEdit(msg, content, internalOptions);
+ return window.Store.Msg.get(msg.id._serialized);
+ };
+
+ window.WWebJS.toStickerData = async (mediaInfo) => {
+ if (mediaInfo.mimetype == 'image/webp') return mediaInfo;
+
+ const file = window.WWebJS.mediaInfoToFile(mediaInfo);
+ const webpSticker = await window.Store.StickerTools.toWebpSticker(file);
+ const webpBuffer = await webpSticker.arrayBuffer();
+ const data = window.WWebJS.arrayBufferToBase64(webpBuffer);
+
+ return {
+ mimetype: 'image/webp',
+ data
+ };
+ };
+
+ window.WWebJS.processStickerData = async (mediaInfo) => {
+ if (mediaInfo.mimetype !== 'image/webp') throw new Error('Invalid media type');
+
+ const file = window.WWebJS.mediaInfoToFile(mediaInfo);
+ let filehash = await window.WWebJS.getFileHash(file);
+ let mediaKey = await window.WWebJS.generateHash(32);
+
+ const controller = new AbortController();
+ const uploadedInfo = await window.Store.UploadUtils.encryptAndUpload({
+ blob: file,
+ type: 'sticker',
+ signal: controller.signal,
+ mediaKey
+ });
+
+ const stickerInfo = {
+ ...uploadedInfo,
+ clientUrl: uploadedInfo.url,
+ deprecatedMms3Url: uploadedInfo.url,
+ uploadhash: uploadedInfo.encFilehash,
+ size: file.size,
+ type: 'sticker',
+ filehash
+ };
+
+ return stickerInfo;
+ };
+
+ window.WWebJS.processMediaData = async (mediaInfo, { forceVoice, forceDocument, forceGif }) => {
+ const file = window.WWebJS.mediaInfoToFile(mediaInfo);
+ const mData = await window.Store.OpaqueData.createFromData(file, file.type);
+ const mediaPrep = window.Store.MediaPrep.prepRawMedia(mData, { asDocument: forceDocument });
+ const mediaData = await mediaPrep.waitForPrep();
+ const mediaObject = window.Store.MediaObject.getOrCreateMediaObject(mediaData.filehash);
+
+ const mediaType = window.Store.MediaTypes.msgToMediaType({
+ type: mediaData.type,
+ isGif: mediaData.isGif
+ });
+
+ if (forceVoice && mediaData.type === 'audio') {
+ mediaData.type = 'ptt';
+ const waveform = mediaObject.contentInfo.waveform;
+ mediaData.waveform =
+ waveform ?? await window.WWebJS.generateWaveform(file);
+ }
+
+ if (forceGif && mediaData.type === 'video') {
+ mediaData.isGif = true;
+ }
+
+ if (forceDocument) {
+ mediaData.type = 'document';
+ }
+
+ if (!(mediaData.mediaBlob instanceof window.Store.OpaqueData)) {
+ mediaData.mediaBlob = await window.Store.OpaqueData.createFromData(mediaData.mediaBlob, mediaData.mediaBlob.type);
+ }
+
+ mediaData.renderableUrl = mediaData.mediaBlob.url();
+ mediaObject.consolidate(mediaData.toJSON());
+ mediaData.mediaBlob.autorelease();
+
+ const uploadedMedia = await window.Store.MediaUpload.uploadMedia({
+ mimetype: mediaData.mimetype,
+ mediaObject,
+ mediaType
+ });
+
+ const mediaEntry = uploadedMedia.mediaEntry;
+ if (!mediaEntry) {
+ throw new Error('upload failed: media entry was not created');
+ }
+
+ mediaData.set({
+ clientUrl: mediaEntry.mmsUrl,
+ deprecatedMms3Url: mediaEntry.deprecatedMms3Url,
+ directPath: mediaEntry.directPath,
+ mediaKey: mediaEntry.mediaKey,
+ mediaKeyTimestamp: mediaEntry.mediaKeyTimestamp,
+ filehash: mediaObject.filehash,
+ encFilehash: mediaEntry.encFilehash,
+ uploadhash: mediaEntry.uploadHash,
+ size: mediaObject.size,
+ streamingSidecar: mediaEntry.sidecar,
+ firstFrameSidecar: mediaEntry.firstFrameSidecar
+ });
+
+ return mediaData;
+ };
+
+ window.WWebJS.getMessageModel = message => {
+ const msg = message.serialize();
+
+ msg.isEphemeral = message.isEphemeral;
+ msg.isStatusV3 = message.isStatusV3;
+ msg.links = (window.Store.Validators.findLinks(message.mediaObject ? message.caption : message.body)).map((link) => ({
+ link: link.href,
+ isSuspicious: Boolean(link.suspiciousCharacters && link.suspiciousCharacters.size)
+ }));
+
+ if (msg.buttons) {
+ msg.buttons = msg.buttons.serialize();
+ }
+ if (msg.dynamicReplyButtons) {
+ msg.dynamicReplyButtons = JSON.parse(JSON.stringify(msg.dynamicReplyButtons));
+ }
+ if (msg.replyButtons) {
+ msg.replyButtons = JSON.parse(JSON.stringify(msg.replyButtons));
+ }
+
+ if (typeof msg.id.remote === 'object') {
+ msg.id = Object.assign({}, msg.id, { remote: msg.id.remote._serialized });
+ }
+
+ delete msg.pendingAckUpdate;
+
+ return msg;
+ };
+
+ window.WWebJS.getPollVoteModel = async (vote) => {
+ const _vote = vote.serialize();
+ if (!vote.parentMsgKey) return null;
+ const msg =
+ window.Store.Msg.get(vote.parentMsgKey) || (await window.Store.Msg.getMessagesById([vote.parentMsgKey]))?.messages?.[0];
+ msg && (_vote.parentMessage = window.WWebJS.getMessageModel(msg));
+ return _vote;
+ };
+
+ window.WWebJS.getChatModel = async chat => {
+
+ let res = chat.serialize();
+ res.isGroup = chat.isGroup;
+ res.formattedTitle = chat.formattedTitle;
+ res.isMuted = chat.mute && chat.mute.isMuted;
+
+ if (chat.groupMetadata) {
+ const chatWid = window.Store.WidFactory.createWid((chat.id._serialized));
+ await window.Store.GroupMetadata.update(chatWid);
+ res.groupMetadata = chat.groupMetadata.serialize();
+ }
+
+ res.lastMessage = null;
+ if (res.msgs && res.msgs.length) {
+ const lastMessage = chat.lastReceivedKey
+ ? window.Store.Msg.get(chat.lastReceivedKey._serialized) || (await window.Store.Msg.getMessagesById([chat.lastReceivedKey._serialized]))?.messages?.[0]
+ : null;
+ if (lastMessage) {
+ res.lastMessage = window.WWebJS.getMessageModel(lastMessage);
+ }
+ }
+
+ delete res.msgs;
+ delete res.msgUnsyncedButtonReplyMsgs;
+ delete res.unsyncedButtonReplies;
+
+ return res;
+ };
+
+ window.WWebJS.getChat = async chatId => {
+ const chatWid = window.Store.WidFactory.createWid(chatId);
+ const chat = await window.Store.Chat.find(chatWid);
+ return await window.WWebJS.getChatModel(chat);
+ };
+
+ window.WWebJS.getChats = async () => {
+ const chats = window.Store.Chat.getModelsArray();
+
+ const chatPromises = chats.map(chat => window.WWebJS.getChatModel(chat));
+ return await Promise.all(chatPromises);
+ };
+
+ window.WWebJS.getContactModel = contact => {
+ let res = contact.serialize();
+ res.isBusiness = contact.isBusiness === undefined ? false : contact.isBusiness;
+
+ if (contact.businessProfile) {
+ res.businessProfile = contact.businessProfile.serialize();
+ }
+
+ // TODO: remove useOldImplementation and its checks once all clients are updated to >= v2.2327.4
+ const useOldImplementation
+ = window.compareWwebVersions(window.Debug.VERSION, '<', '2.2327.4');
+
+ res.isMe = useOldImplementation
+ ? contact.isMe
+ : window.Store.ContactMethods.getIsMe(contact);
+ res.isUser = useOldImplementation
+ ? contact.isUser
+ : window.Store.ContactMethods.getIsUser(contact);
+ res.isGroup = useOldImplementation
+ ? contact.isGroup
+ : window.Store.ContactMethods.getIsGroup(contact);
+ res.isWAContact = useOldImplementation
+ ? contact.isWAContact
+ : window.Store.ContactMethods.getIsWAContact(contact);
+ res.isMyContact = useOldImplementation
+ ? contact.isMyContact
+ : window.Store.ContactMethods.getIsMyContact(contact);
+ res.isBlocked = contact.isContactBlocked;
+ res.userid = useOldImplementation
+ ? contact.userid
+ : window.Store.ContactMethods.getUserid(contact);
+ res.isEnterprise = useOldImplementation
+ ? contact.isEnterprise
+ : window.Store.ContactMethods.getIsEnterprise(contact);
+ res.verifiedName = useOldImplementation
+ ? contact.verifiedName
+ : window.Store.ContactMethods.getVerifiedName(contact);
+ res.verifiedLevel = useOldImplementation
+ ? contact.verifiedLevel
+ : window.Store.ContactMethods.getVerifiedLevel(contact);
+ res.statusMute = useOldImplementation
+ ? contact.statusMute
+ : window.Store.ContactMethods.getStatusMute(contact);
+ res.name = useOldImplementation
+ ? contact.name
+ : window.Store.ContactMethods.getName(contact);
+ res.shortName = useOldImplementation
+ ? contact.shortName
+ : window.Store.ContactMethods.getShortName(contact);
+ res.pushname = useOldImplementation
+ ? contact.pushname
+ : window.Store.ContactMethods.getPushname(contact);
+
+ return res;
+ };
+
+ window.WWebJS.getContact = async contactId => {
+ const wid = window.Store.WidFactory.createWid(contactId);
+ const contact = await window.Store.Contact.find(wid);
+ const bizProfile = await window.Store.BusinessProfile.fetchBizProfile(wid);
+ bizProfile.profileOptions && (contact.businessProfile = bizProfile);
+ return window.WWebJS.getContactModel(contact);
+ };
+
+ window.WWebJS.getContacts = () => {
+ const contacts = window.Store.Contact.getModelsArray();
+ return contacts.map(contact => window.WWebJS.getContactModel(contact));
+ };
+
+ window.WWebJS.mediaInfoToFile = ({ data, mimetype, filename }) => {
+ const binaryData = window.atob(data);
+
+ const buffer = new ArrayBuffer(binaryData.length);
+ const view = new Uint8Array(buffer);
+ for (let i = 0; i < binaryData.length; i++) {
+ view[i] = binaryData.charCodeAt(i);
+ }
+
+ const blob = new Blob([buffer], { type: mimetype });
+ return new File([blob], filename, {
+ type: mimetype,
+ lastModified: Date.now()
+ });
+ };
+
+ window.WWebJS.arrayBufferToBase64 = (arrayBuffer) => {
+ let binary = '';
+ const bytes = new Uint8Array(arrayBuffer);
+ const len = bytes.byteLength;
+ for (let i = 0; i < len; i++) {
+ binary += String.fromCharCode(bytes[i]);
+ }
+ return window.btoa(binary);
+ };
+
+ window.WWebJS.arrayBufferToBase64Async = (arrayBuffer) =>
+ new Promise((resolve, reject) => {
+ const blob = new Blob([arrayBuffer], {
+ type: 'application/octet-stream',
+ });
+ const fileReader = new FileReader();
+ fileReader.onload = () => {
+ const [, data] = fileReader.result.split(',');
+ resolve(data);
+ };
+ fileReader.onerror = (e) => reject(e);
+ fileReader.readAsDataURL(blob);
+ });
+
+ window.WWebJS.getFileHash = async (data) => {
+ let buffer = await data.arrayBuffer();
+ const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
+ return btoa(String.fromCharCode(...new Uint8Array(hashBuffer)));
+ };
+
+ window.WWebJS.generateHash = async (length) => {
+ var result = '';
+ var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+ var charactersLength = characters.length;
+ for (var i = 0; i < length; i++) {
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
+ }
+ return result;
+ };
+
+ /**
+ * Referenced from and modified:
+ * @see https://github.com/wppconnect-team/wa-js/commit/290ebfefe6021b3d17f7fdfdda5545bb0473b26f
+ */
+ window.WWebJS.generateWaveform = async (audioFile) => {
+ try {
+ const audioData = await audioFile.arrayBuffer();
+ const audioContext = new AudioContext();
+ const audioBuffer = await audioContext.decodeAudioData(audioData);
+
+ const rawData = audioBuffer.getChannelData(0);
+ const samples = 64;
+ const blockSize = Math.floor(rawData.length / samples);
+ const filteredData = [];
+ for (let i = 0; i < samples; i++) {
+ const blockStart = blockSize * i;
+ let sum = 0;
+ for (let j = 0; j < blockSize; j++) {
+ sum = sum + Math.abs(rawData[blockStart + j]);
+ }
+ filteredData.push(sum / blockSize);
+ }
+
+ const multiplier = Math.pow(Math.max(...filteredData), -1);
+ const normalizedData = filteredData.map((n) => n * multiplier);
+
+ const waveform = new Uint8Array(
+ normalizedData.map((n) => Math.floor(100 * n))
+ );
+
+ return waveform;
+ } catch (e) {
+ return undefined;
+ }
+ };
+
+ window.WWebJS.sendClearChat = async (chatId) => {
+ let chat = window.Store.Chat.get(chatId);
+ if (chat !== undefined) {
+ await window.Store.SendClear.sendClear(chat, false);
+ return true;
+ }
+ return false;
+ };
+
+ window.WWebJS.sendDeleteChat = async (chatId) => {
+ let chat = window.Store.Chat.get(chatId);
+ if (chat !== undefined) {
+ await window.Store.SendDelete.sendDelete(chat);
+ return true;
+ }
+ return false;
+ };
+
+ window.WWebJS.sendChatstate = async (state, chatId) => {
+ chatId = window.Store.WidFactory.createWid(chatId);
+
+ switch (state) {
+ case 'typing':
+ await window.Store.ChatState.sendChatStateComposing(chatId);
+ break;
+ case 'recording':
+ await window.Store.ChatState.sendChatStateRecording(chatId);
+ break;
+ case 'stop':
+ await window.Store.ChatState.sendChatStatePaused(chatId);
+ break;
+ default:
+ throw 'Invalid chatstate';
+ }
+
+ return true;
+ };
+
+ window.WWebJS.getLabelModel = label => {
+ let res = label.serialize();
+ res.hexColor = label.hexColor;
+
+ return res;
+ };
+
+ window.WWebJS.getLabels = () => {
+ const labels = window.Store.Label.getModelsArray();
+ return labels.map(label => window.WWebJS.getLabelModel(label));
+ };
+
+ window.WWebJS.getLabel = (labelId) => {
+ const label = window.Store.Label.get(labelId);
+ return window.WWebJS.getLabelModel(label);
+ };
+
+ window.WWebJS.getChatLabels = async (chatId) => {
+ const chat = await window.WWebJS.getChat(chatId);
+ return (chat.labels || []).map(id => window.WWebJS.getLabel(id));
+ };
+
+ window.WWebJS.getOrderDetail = async (orderId, token, chatId) => {
+ const chatWid = window.Store.WidFactory.createWid(chatId);
+ return window.Store.QueryOrder.queryOrder(chatWid, orderId, 80, 80, token);
+ };
+
+ window.WWebJS.getProductMetadata = async (productId) => {
+ let sellerId = window.Store.Conn.wid;
+ let product = await window.Store.QueryProduct.queryProduct(sellerId, productId);
+ if (product && product.data) {
+ return product.data;
+ }
+
+ return undefined;
+ };
+
+ window.WWebJS.rejectCall = async (peerJid, id) => {
+ peerJid = peerJid.split('@')[0] + '@s.whatsapp.net';
+ let userId = window.Store.User.getMaybeMeUser().user + '@s.whatsapp.net';
+ const stanza = window.Store.SocketWap.wap('call', {
+ id: window.Store.SocketWap.generateId(),
+ from: window.Store.SocketWap.USER_JID(userId),
+ to: window.Store.SocketWap.USER_JID(peerJid),
+ }, [
+ window.Store.SocketWap.wap('reject', {
+ 'call-id': id,
+ 'call-creator': window.Store.SocketWap.USER_JID(peerJid),
+ count: '0',
+ })
+ ]);
+ await window.Store.Socket.deprecatedCastStanza(stanza);
+ };
+
+ window.WWebJS.cropAndResizeImage = async (media, options = {}) => {
+ if (!media.mimetype.includes('image'))
+ throw new Error('Media is not an image');
+
+ if (options.mimetype && !options.mimetype.includes('image'))
+ delete options.mimetype;
+
+ options = Object.assign({ size: 640, mimetype: media.mimetype, quality: .75, asDataUrl: false }, options);
+
+ const img = await new Promise ((resolve, reject) => {
+ const img = new Image();
+ img.onload = () => resolve(img);
+ img.onerror = reject;
+ img.src = `data:${media.mimetype};base64,${media.data}`;
+ });
+
+ const sl = Math.min(img.width, img.height);
+ const sx = Math.floor((img.width - sl) / 2);
+ const sy = Math.floor((img.height - sl) / 2);
+
+ const canvas = document.createElement('canvas');
+ canvas.width = options.size;
+ canvas.height = options.size;
+
+ const ctx = canvas.getContext('2d');
+ ctx.drawImage(img, sx, sy, sl, sl, 0, 0, options.size, options.size);
+
+ const dataUrl = canvas.toDataURL(options.mimetype, options.quality);
+
+ if (options.asDataUrl)
+ return dataUrl;
+
+ return Object.assign(media, {
+ mimetype: options.mimeType,
+ data: dataUrl.replace(`data:${options.mimeType};base64,`, '')
+ });
+ };
+
+ window.WWebJS.setPicture = async (chatid, media) => {
+ const thumbnail = await window.WWebJS.cropAndResizeImage(media, { asDataUrl: true, mimetype: 'image/jpeg', size: 96 });
+ const profilePic = await window.WWebJS.cropAndResizeImage(media, { asDataUrl: true, mimetype: 'image/jpeg', size: 640 });
+
+ const chatWid = window.Store.WidFactory.createWid(chatid);
+ try {
+ const collection = window.Store.ProfilePicThumb.get(chatid);
+ if (!collection.canSet()) return;
+
+ const res = await window.Store.GroupUtils.sendSetPicture(chatWid, thumbnail, profilePic);
+ return res ? res.status === 200 : false;
+ } catch (err) {
+ if(err.name === 'ServerStatusCodeError') return false;
+ throw err;
+ }
+ };
+
+ window.WWebJS.deletePicture = async (chatid) => {
+ const chatWid = window.Store.WidFactory.createWid(chatid);
+ try {
+ const collection = window.Store.ProfilePicThumb.get(chatid);
+ if (!collection.canDelete()) return;
+
+ const res = await window.Store.GroupUtils.requestDeletePicture(chatWid);
+ return res ? res.status === 200 : false;
+ } catch (err) {
+ if(err.name === 'ServerStatusCodeError') return false;
+ throw err;
+ }
+ };
+
+ window.WWebJS.getProfilePicThumbToBase64 = async (chatWid) => {
+ const profilePicCollection = await window.Store.ProfilePicThumb.find(chatWid);
+
+ const _readImageAsBase64 = (imageBlob) => {
+ return new Promise((resolve) => {
+ const reader = new FileReader();
+ reader.onloadend = function () {
+ const base64Image = reader.result;
+ if (base64Image == null) {
+ resolve(undefined);
+ } else {
+ const base64Data = base64Image.toString().split(',')[1];
+ resolve(base64Data);
+ }
+ };
+ reader.readAsDataURL(imageBlob);
+ });
+ };
+
+ if (profilePicCollection?.img) {
+ try {
+ const response = await fetch(profilePicCollection.img);
+ if (response.ok) {
+ const imageBlob = await response.blob();
+ if (imageBlob) {
+ const base64Image = await _readImageAsBase64(imageBlob);
+ return base64Image;
+ }
+ }
+ } catch (error) { /* empty */ }
+ }
+ return undefined;
+ };
+
+ window.WWebJS.getAddParticipantsRpcResult = async (groupMetadata, groupWid, participantWid) => {
+ const participantLidArgs = groupMetadata?.isLidAddressingMode
+ ? {
+ phoneNumber: participantWid,
+ lid: window.Store.LidUtils.getCurrentLid(participantWid)
+ }
+ : { phoneNumber: participantWid };
+
+ const iqTo = window.Store.WidToJid.widToGroupJid(groupWid);
+
+ const participantArgs =
+ participantLidArgs.lid
+ ? [{
+ participantJid: window.Store.WidToJid.widToUserJid(participantLidArgs.lid),
+ phoneNumberMixinArgs: {
+ anyPhoneNumber: window.Store.WidToJid.widToUserJid(participantLidArgs.phoneNumber)
+ }
+ }]
+ : [{
+ participantJid: window.Store.WidToJid.widToUserJid(participantLidArgs.phoneNumber)
+ }];
+
+ let rpcResult, resultArgs;
+ const isOldImpl = window.compareWwebVersions(window.Debug.VERSION, '<=', '2.2335.9');
+ const data = {
+ name: undefined,
+ code: undefined,
+ inviteV4Code: undefined,
+ inviteV4CodeExp: undefined
+ };
+
+ try {
+ rpcResult = await window.Store.GroupParticipants.sendAddParticipantsRPC({ participantArgs, iqTo });
+ resultArgs = isOldImpl
+ ? rpcResult.value.addParticipant[0].addParticipantsParticipantMixins
+ : rpcResult.value.addParticipant[0]
+ .addParticipantsParticipantAddedOrNonRegisteredWaUserParticipantErrorLidResponseMixinGroup
+ .value
+ .addParticipantsParticipantMixins;
+ } catch (err) {
+ data.code = 400;
+ return data;
+ }
+
+ if (rpcResult.name === 'AddParticipantsResponseSuccess') {
+ const code = resultArgs?.value.error ?? '200';
+ data.name = resultArgs?.name;
+ data.code = +code;
+ data.inviteV4Code = resultArgs?.value.addRequestCode;
+ data.inviteV4CodeExp = resultArgs?.value.addRequestExpiration?.toString();
+ }
+
+ else if (rpcResult.name === 'AddParticipantsResponseClientError') {
+ const { code: code } = rpcResult.value.errorAddParticipantsClientErrors.value;
+ data.code = +code;
+ }
+
+ else if (rpcResult.name === 'AddParticipantsResponseServerError') {
+ const { code: code } = rpcResult.value.errorServerErrors.value;
+ data.code = +code;
+ }
+
+ return data;
+ };
+
+ window.WWebJS.membershipRequestAction = async (groupId, action, requesterIds, sleep) => {
+ const groupWid = window.Store.WidFactory.createWid(groupId);
+ const group = await window.Store.Chat.find(groupWid);
+ const toApprove = action === 'Approve';
+ let membershipRequests;
+ let response;
+ let result = [];
+
+ await window.Store.GroupQueryAndUpdate(groupWid);
+
+ if (!requesterIds?.length) {
+ membershipRequests = group.groupMetadata.membershipApprovalRequests._models.map(({ id }) => id);
+ } else {
+ !Array.isArray(requesterIds) && (requesterIds = [requesterIds]);
+ membershipRequests = requesterIds.map(r => window.Store.WidFactory.createWid(r));
+ }
+
+ if (!membershipRequests.length) return [];
+
+ const participantArgs = membershipRequests.map(m => ({
+ participantArgs: [
+ {
+ participantJid: window.Store.WidToJid.widToUserJid(m)
+ }
+ ]
+ }));
+
+ const groupJid = window.Store.WidToJid.widToGroupJid(groupWid);
+
+ const _getSleepTime = (sleep) => {
+ if (!Array.isArray(sleep) || (sleep.length === 2 && sleep[0] === sleep[1])) {
+ return sleep;
+ }
+ if (sleep.length === 1) {
+ return sleep[0];
+ }
+ sleep[1] - sleep[0] < 100 && (sleep[0] = sleep[1]) && (sleep[1] += 100);
+ return Math.floor(Math.random() * (sleep[1] - sleep[0] + 1)) + sleep[0];
+ };
+
+ const membReqResCodes = {
+ default: `An unknown error occupied while ${toApprove ? 'approving' : 'rejecting'} the participant membership request`,
+ 400: 'ParticipantNotFoundError',
+ 401: 'ParticipantNotAuthorizedError',
+ 403: 'ParticipantForbiddenError',
+ 404: 'ParticipantRequestNotFoundError',
+ 408: 'ParticipantTemporarilyBlockedError',
+ 409: 'ParticipantConflictError',
+ 412: 'ParticipantParentLinkedGroupsResourceConstraintError',
+ 500: 'ParticipantResourceConstraintError'
+ };
+
+ try {
+ for (const participant of participantArgs) {
+ response = await window.Store.MembershipRequestUtils.sendMembershipRequestsActionRPC({
+ iqTo: groupJid,
+ [toApprove ? 'approveArgs' : 'rejectArgs']: participant
+ });
+
+ if (response.name === 'MembershipRequestsActionResponseSuccess') {
+ const value = toApprove
+ ? response.value.membershipRequestsActionApprove
+ : response.value.membershipRequestsActionReject;
+ if (value?.participant) {
+ const [_] = value.participant.map(p => {
+ const error = toApprove
+ ? value.participant[0].membershipRequestsActionAcceptParticipantMixins?.value.error
+ : value.participant[0].membershipRequestsActionRejectParticipantMixins?.value.error;
+ return {
+ requesterId: window.Store.WidFactory.createWid(p.jid)._serialized,
+ ...(error
+ ? { error: +error, message: membReqResCodes[error] || membReqResCodes.default }
+ : { message: `${toApprove ? 'Approved' : 'Rejected'} successfully` })
+ };
+ });
+ _ && result.push(_);
+ }
+ } else {
+ result.push({
+ requesterId: window.Store.JidToWid.userJidToUserWid(participant.participantArgs[0].participantJid)._serialized,
+ message: 'ServerStatusCodeError'
+ });
+ }
+
+ sleep &&
+ participantArgs.length > 1 &&
+ participantArgs.indexOf(participant) !== participantArgs.length - 1 &&
+ (await new Promise((resolve) => setTimeout(resolve, _getSleepTime(sleep))));
+ }
+ return result;
+ } catch (err) {
+ return [];
+ }
+ };
+
+ window.WWebJS.pinUnpinMsgAction = async (msgId, action, duration) => {
+ const message = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
+ if (!message) return false;
+ const response = await window.Store.pinUnpinMsg(message, action, duration);
+ return response.messageSendResult === 'OK';
+ };
+
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/util_InterfaceController.js.html b/docs/util_InterfaceController.js.html
index 9c0196c..ec6a5c2 100644
--- a/docs/util_InterfaceController.js.html
+++ b/docs/util_InterfaceController.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: util/InterfaceController.js
+
whatsapp-web.js 1.26.0 » Source: util/InterfaceController.js
@@ -15,7 +15,7 @@
@@ -80,7 +80,7 @@ class InterfaceController {
*/
async openChatWindowAt(msgId) {
await this.pupPage.evaluate(async msgId => {
- let msg = await window.Store.Msg.get(msgId);
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
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);
@@ -93,7 +93,7 @@ class InterfaceController {
*/
async openMessageDrawer(msgId) {
await this.pupPage.evaluate(async msgId => {
- let msg = await window.Store.Msg.get(msgId);
+ const msg = window.Store.Msg.get(msgId) || (await window.Store.Msg.getMessagesById([msgId]))?.messages?.[0];
await window.Store.Cmd.msgInfoDrawer(msg);
}, msgId);
}
@@ -166,7 +166,7 @@ module.exports = InterfaceController;
diff --git a/docs/util_Util.js.html b/docs/util_Util.js.html
index d8ce40d..bda87a9 100644
--- a/docs/util_Util.js.html
+++ b/docs/util_Util.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: util/Util.js
+
whatsapp-web.js 1.26.0 » Source: util/Util.js
@@ -15,7 +15,7 @@
@@ -225,7 +225,7 @@ module.exports = Util;
diff --git a/docs/webCache_LocalWebCache.js.html b/docs/webCache_LocalWebCache.js.html
index ccdb09d..d820adf 100644
--- a/docs/webCache_LocalWebCache.js.html
+++ b/docs/webCache_LocalWebCache.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.23.0 » Source: webCache/LocalWebCache.js
+
whatsapp-web.js 1.26.0 » Source: webCache/LocalWebCache.js
@@ -15,7 +15,7 @@
@@ -60,18 +60,16 @@ class LocalWebCache extends WebCache {
}
}
- async persist(indexHtml) {
- // extract version from index (e.g. manifest-2.2206.9.json -> 2.2206.9)
- const version = indexHtml.match(/manifest-([\d\\.]+)\.json/)[1];
- if(!version) return;
-
+ async persist(indexHtml, version) {
+ // version = (version+'').replace(/[^0-9.]/g,'');
const filePath = path.join(this.path, `${version}.html`);
fs.mkdirSync(this.path, { recursive: true });
fs.writeFileSync(filePath, indexHtml);
}
}
-module.exports = LocalWebCache;
+module.exports = LocalWebCache;
+
@@ -81,7 +79,7 @@ module.exports = LocalWebCache;
diff --git a/docs/webCache_RemoteWebCache.js.html b/docs/webCache_RemoteWebCache.js.html
index 75a643e..88d4f7b 100644
--- a/docs/webCache_RemoteWebCache.js.html
+++ b/docs/webCache_RemoteWebCache.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.23.0 » Source: webCache/RemoteWebCache.js
+ whatsapp-web.js 1.26.0 » Source: webCache/RemoteWebCache.js
@@ -15,7 +15,7 @@
@@ -78,7 +78,7 @@ module.exports = RemoteWebCache;
diff --git a/docs/webCache_WebCache.js.html b/docs/webCache_WebCache.js.html
index a19a40e..7f33579 100644
--- a/docs/webCache_WebCache.js.html
+++ b/docs/webCache_WebCache.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.23.0 » Source: webCache/WebCache.js
+ whatsapp-web.js 1.26.0 » Source: webCache/WebCache.js
@@ -15,7 +15,7 @@
@@ -52,7 +52,7 @@ module.exports = {
diff --git a/src/util/Constants.js b/src/util/Constants.js
index e8c5fe3..9f33448 100644
--- a/src/util/Constants.js
+++ b/src/util/Constants.js
@@ -7,7 +7,7 @@ exports.DefaultOptions = {
headless: true,
defaultViewport: null
},
- webVersion: '2.2346.52',
+ webVersion: '2.3000.1016590837',
webVersionCache: {
type: 'local',
},
diff --git a/tools/version-checker/.version b/tools/version-checker/.version
index 8986cbf..374994e 100644
--- a/tools/version-checker/.version
+++ b/tools/version-checker/.version
@@ -1 +1 @@
-2.2346.52
\ No newline at end of file
+2.3000.1016590837
\ No newline at end of file