docs: generate docs for the latest release (#3279)
* docs: generate docs for the latest release * docs: mark version v1.26.0 * docs: mark WWeb version v2.3000.1016590837
This commit is contained in:
parent
d2597bba72
commit
01c45047d2
1 changed files with 3898 additions and 891 deletions
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.23.0 » Source: structures/Message.js</title>
|
||||
<title>whatsapp-web.js 1.26.0 » Source: structures/Message.js</title>
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||
<div id="jsdoc-navbar-container">
|
||||
<div id="jsdoc-navbar-content">
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>23.<wbr>0</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>25.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
@ -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' &amp;&amp; '_serialized' in data.from ? data.from._serialized : data.from,
|
||||
toId: typeof data.to === 'object' &amp;&amp; '_serialized' in data.to ? data.to._serialized : data.to
|
||||
} : undefined;
|
||||
|
||||
/**
|
||||
* Indicates the mentions in the message body.
|
||||
* @type {Array&lt;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&lt;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&lt;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 &amp;&amp; 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&lt;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&lt;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&lt;?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 &lt; 1250) &amp;&amp; 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&lt;?Message>}
|
||||
*/
|
||||
async edit(content, options = {}) {
|
||||
if (options.mentions &amp;&amp; options.mentions.some(possiblyContact => possiblyContact instanceof Contact)) {
|
||||
options.mentions = options.mentions.map(a => a.id._serialized);
|
||||
if (options.mentions) {
|
||||
!Array.isArray(options.mentions) &amp;&amp; (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 &amp;&amp; !Array.isArray(options.groupMentions) &amp;&amp; (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' &amp;&amp; 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;
|
|||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on October 21, 2023.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on September 18, 2024.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
|
|
|||
Loading…
Reference in a new issue