chore: mark version v1.20.0
This commit is contained in:
parent
2b8eb518ed
commit
915763a8d0
60 changed files with 4356 additions and 3441 deletions
|
|
@ -2,9 +2,9 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.19.5 » Source: Client.js</title>
|
||||
<title>whatsapp-web.js 1.20.0 » Source: Client.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>19.<wbr>5</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>20.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
@ -41,7 +41,7 @@ const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./ut
|
|||
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
||||
const ChatFactory = require('./factories/ChatFactory');
|
||||
const ContactFactory = require('./factories/ContactFactory');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List, Reaction } = require('./structures');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List, Reaction, Chat } = require('./structures');
|
||||
const LegacySessionAuth = require('./authStrategies/LegacySessionAuth');
|
||||
const NoAuth = require('./authStrategies/NoAuth');
|
||||
|
||||
|
|
@ -60,6 +60,7 @@ const NoAuth = require('./authStrategies/NoAuth');
|
|||
* @param {string} options.userAgent - User agent to use in puppeteer
|
||||
* @param {string} options.ffmpegPath - Ffmpeg path to use when formating videos to webp while sending stickers
|
||||
* @param {boolean} options.bypassCSP - Sets bypassing of page's Content-Security-Policy.
|
||||
* @param {object} options.proxyAuthentication - Proxy Authentication object.
|
||||
*
|
||||
* @fires Client#qr
|
||||
* @fires Client#authenticated
|
||||
|
|
@ -76,6 +77,8 @@ const NoAuth = require('./authStrategies/NoAuth');
|
|||
* @fires Client#group_update
|
||||
* @fires Client#disconnected
|
||||
* @fires Client#change_state
|
||||
* @fires Client#contact_changed
|
||||
* @fires Client#group_admin_changed
|
||||
*/
|
||||
class Client extends EventEmitter {
|
||||
constructor(options = {}) {
|
||||
|
|
@ -131,6 +134,10 @@ class Client extends EventEmitter {
|
|||
browser = await puppeteer.launch({...puppeteerOpts, args: browserArgs});
|
||||
page = (await browser.pages())[0];
|
||||
}
|
||||
|
||||
if (this.options.proxyAuthentication !== undefined) {
|
||||
await page.authenticate(this.options.proxyAuthentication);
|
||||
}
|
||||
|
||||
await page.setUserAgent(this.options.userAgent);
|
||||
if (this.options.bypassCSP) await page.setBypassCSP(true);
|
||||
|
|
@ -348,6 +355,13 @@ class Client extends EventEmitter {
|
|||
* @param {GroupNotification} notification GroupNotification with more information about the action
|
||||
*/
|
||||
this.emit(Events.GROUP_LEAVE, notification);
|
||||
} else if (msg.subtype === 'promote' || msg.subtype === 'demote') {
|
||||
/**
|
||||
* Emitted when a current user is promoted to an admin or demoted to a regular user.
|
||||
* @event Client#group_admin_changed
|
||||
* @param {GroupNotification} notification GroupNotification with more information about the action
|
||||
*/
|
||||
this.emit(Events.GROUP_ADMIN_CHANGED, notification);
|
||||
} else {
|
||||
/**
|
||||
* Emitted when group settings are updated, such as subject, description or picture.
|
||||
|
|
@ -407,6 +421,36 @@ class Client extends EventEmitter {
|
|||
last_message = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* The event notification that is received when one of
|
||||
* the group participants changes thier phone number.
|
||||
*/
|
||||
const isParticipant = msg.type === 'gp2' &amp;&amp; msg.subtype === 'modify';
|
||||
|
||||
/**
|
||||
* The event notification that is received when one of
|
||||
* the contacts changes thier phone number.
|
||||
*/
|
||||
const isContact = msg.type === 'notification_template' &amp;&amp; msg.subtype === 'change_number';
|
||||
|
||||
if (isParticipant || isContact) {
|
||||
/** {@link GroupNotification} object does not provide enough information about this event, so a {@link Message} object is used. */
|
||||
const message = new Message(this, msg);
|
||||
|
||||
const newId = isParticipant ? msg.recipients[0] : msg.to;
|
||||
const oldId = isParticipant ? msg.author : msg.templateParams.find(id => id !== newId);
|
||||
|
||||
/**
|
||||
* Emitted when a contact or a group participant changes their phone number.
|
||||
* @event Client#contact_changed
|
||||
* @param {Message} message Message with more information about the event.
|
||||
* @param {String} oldId The user's id (an old one) who changed their phone number
|
||||
* and who triggered the notification.
|
||||
* @param {String} newId The user's new id after the change.
|
||||
* @param {Boolean} isContact Indicates if a contact or a group participant changed their phone number.
|
||||
*/
|
||||
this.emit(Events.CONTACT_CHANGED, message, oldId, newId, isContact);
|
||||
}
|
||||
});
|
||||
|
||||
await page.exposeFunction('onRemoveMessageEvent', (msg) => {
|
||||
|
|
@ -438,6 +482,15 @@ class Client extends EventEmitter {
|
|||
|
||||
});
|
||||
|
||||
await page.exposeFunction('onChatUnreadCountEvent', async (data) =>{
|
||||
const chat = await this.getChatById(data.id);
|
||||
|
||||
/**
|
||||
* Emitted when the chat unread count changes
|
||||
*/
|
||||
this.emit(Events.UNREAD_COUNT, chat);
|
||||
});
|
||||
|
||||
await page.exposeFunction('onMessageMediaUploadedEvent', (msg) => {
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
|
@ -538,6 +591,26 @@ class Client extends EventEmitter {
|
|||
}
|
||||
});
|
||||
|
||||
await page.exposeFunction('onRemoveChatEvent', (chat) => {
|
||||
/**
|
||||
* Emitted when a chat is removed
|
||||
* @event Client#chat_removed
|
||||
* @param {Chat} chat
|
||||
*/
|
||||
this.emit(Events.CHAT_REMOVED, new Chat(this, chat));
|
||||
});
|
||||
|
||||
await page.exposeFunction('onArchiveChatEvent', (chat, currState, prevState) => {
|
||||
/**
|
||||
* Emitted when a chat is archived/unarchived
|
||||
* @event Client#chat_archived
|
||||
* @param {Chat} chat
|
||||
* @param {boolean} currState
|
||||
* @param {boolean} prevState
|
||||
*/
|
||||
this.emit(Events.CHAT_ARCHIVED, new Chat(this, chat), currState, prevState);
|
||||
});
|
||||
|
||||
await page.evaluate(() => {
|
||||
window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
||||
window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(window.WWebJS.getMessageModel(msg)); });
|
||||
|
|
@ -547,6 +620,8 @@ class Client extends EventEmitter {
|
|||
window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); });
|
||||
window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); });
|
||||
window.Store.Call.on('add', (call) => { window.onIncomingCall(call); });
|
||||
window.Store.Chat.on('remove', async (chat) => { window.onRemoveChatEvent(await window.WWebJS.getChatModel(chat)); });
|
||||
window.Store.Chat.on('change:archive', async (chat, currState, prevState) => { window.onArchiveChatEvent(await window.WWebJS.getChatModel(chat), currState, prevState); });
|
||||
window.Store.Msg.on('add', (msg) => {
|
||||
if (msg.isNewMsg) {
|
||||
if(msg.type === 'ciphertext') {
|
||||
|
|
@ -557,7 +632,8 @@ class Client extends EventEmitter {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.Store.Chat.on('change:unreadCount', (chat) => {window.onChatUnreadCountEvent(chat);});
|
||||
|
||||
{
|
||||
const module = window.Store.createOrUpdateReactionsModule;
|
||||
const ogMethod = module.createOrUpdateReactions;
|
||||
|
|
@ -1209,6 +1285,31 @@ class Client extends EventEmitter {
|
|||
|
||||
return blockedContacts.map(contact => ContactFactory.create(this.client, contact));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current user's profile picture.
|
||||
* @param {MessageMedia} media
|
||||
* @returns {Promise&lt;boolean>} Returns true if the picture was properly updated.
|
||||
*/
|
||||
async setProfilePicture(media) {
|
||||
const success = await this.pupPage.evaluate((chatid, media) => {
|
||||
return window.WWebJS.setPicture(chatid, media);
|
||||
}, this.info.wid._serialized, media);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the current user's profile picture.
|
||||
* @returns {Promise&lt;boolean>} Returns true if the picture was properly deleted.
|
||||
*/
|
||||
async deleteProfilePicture() {
|
||||
const success = await this.pupPage.evaluate((chatid) => {
|
||||
return window.WWebJS.deletePicture(chatid);
|
||||
}, this.info.wid._serialized);
|
||||
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
|
|
@ -1222,7 +1323,7 @@ module.exports = Client;
|
|||
<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.7 on March 18, 2023.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on May 19, 2023.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
|
|
|||
Loading…
Reference in a new issue