Compare commits

..

59 Commits

Author SHA1 Message Date
Pedro Lopez
3d06babed9 chore: mark version v1.10.0 2020-10-21 15:22:05 -04:00
Pedro Lopez
0ca909233d Merge branch 'master' of https://github.com/pedroslopez/whatsapp-web.js 2020-10-21 15:21:08 -04:00
Pedro Lopez
f4a2c44ed7 chore: bump supported WhatsApp Web version to v2.2043.8 2020-10-21 15:21:02 -04:00
Pedro S. Lopez
604656cf73 fix: change OpaqueData module lookup function (#391)
A change introduced in WhatsApp Web v2.2043.8 caused this to break, leading to issues while sending media

fix #390
2020-10-21 15:18:51 -04:00
Aliyss Snow
aedf41b762 feat: Pin and unpin Chats (#166)
* Added Pinning
- chat.pin() to pin
- chat.unpin() to unpin

Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
2020-10-11 15:50:12 -04:00
Pedro S. Lopez
bf2775d1f0 feat: update group settings (messages and set info admins only) (#374)
close #187
2020-10-11 15:14:06 -04:00
Pedro Lopez
0b112004d5 chore: mark version v1.9.0 2020-10-09 02:34:02 -04:00
Pedro Lopez
336fb9b551 chore: update supported WhatsApp Web version to v2.2041.6 2020-10-09 02:32:42 -04:00
Pedro Lopez
ba6ec7feab fix: apply message serialization fix everywhere
Moving this to a serializer function like done with a couple other models guarantees getting messages with pending acks won't fail elsewhere. It also sets it up so the we can add/remove properties on the Message model as needed in the future.

related: 51a1028588
2020-10-09 02:29:07 -04:00
Pedro Lopez
51a1028588 fix: remove pendingAckUpdate from serialization on changed message ack
As of WhatsApp Web v2.2041.6, a "pendingAckUpdate" property was added to the Message model that persists on serialization but is a non-serializable type. This fix removes it from the change:ack so it can be properly sent through puppeteer.

fix #371
2020-10-09 01:40:07 -04:00
Pedro Lopez
1c31139434 fix(types): add missing type defs for chat.muteExpiration 2020-09-27 19:18:07 -04:00
Pedro Lopez
ee21e14547 feat: indicate if chat is currently muted 2020-09-27 19:15:34 -04:00
Leonardo Almeida
cbf8fb7cf5 feat: chat mute expiration timestamp (#351)
add chat.muteExpiration to indicate when the mute expires

Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
2020-09-27 19:11:08 -04:00
Pedro Lopez
c7d5eb67ee chore: bump version to v1.8.2-post 2020-09-01 15:27:36 -04:00
Pedro Lopez
7fcd43f100 chore: mark version v1.8.2 2020-09-01 15:23:46 -04:00
Pedro Lopez
a60f0ce139 chore: update supported WhatsApp Web version to v2.2035.14 2020-09-01 15:00:45 -04:00
Pedro Lopez
ab0db80063 fix: reliably get group metadata
GroupMetadata was only loaded for the first couple chats, so you could not access it on older group chats without performing an action that would update its state

close #264
2020-09-01 12:48:22 -04:00
Hendra827
e7c76fe069 chore: update puppeteer to v5.2.1 2020-08-31 14:11:31 -04:00
Pedro Lopez
233382ce7a chore: ignore test session files when pushing to git 2020-08-28 23:15:15 -04:00
Pedro Lopez
e08dd7d835 chore: add .npmignore for smaller package size 2020-08-28 23:12:45 -04:00
Pedro Lopez
a1e8e8cf51 chore: bump version to v1.8.1-post 2020-08-28 23:08:25 -04:00
Pedro Lopez
a1e0970e1e chore: mark version v1.8.1 2020-08-28 23:04:31 -04:00
Caio Henrique Agiani
c827b32328 fix(types): correct response type for message.forward() (#324) 2020-08-28 22:00:13 -04:00
Pedro Lopez
2345b5c4ee chore: bump version to v1.8.0-post 2020-08-25 23:26:55 -04:00
Pedro Lopez
8627fc3d71 chore: mark version v1.8.0 2020-08-25 23:06:36 -04:00
Pedro Lopez
502b22f6d7 feat: forward messages
close #316
2020-08-25 23:00:35 -04:00
Pedro Lopez
590ecc2351 chore: update supported WhatsApp Web version to 2.2035.12 2020-08-25 22:34:10 -04:00
Pedro Lopez
7da8345722 fix: upload media
As of WhatsApp Web v2.2035.12, the structure of the return value for  `uploadMedia()` now returns an object that contains the previously returned data in its `mediaEntry` property.

fix #318
2020-08-25 22:30:04 -04:00
Pedro Lopez
4344df6152 fix: properly detect successful authentication on dark mode 2020-08-25 21:40:57 -04:00
Pedro Lopez
382259488b feat(dev): Interactive shell for quick testing/exploration 2020-08-17 23:43:50 -04:00
Pedro Lopez
7180beda2e feat: Get corresponding Chat from Contact object and vice versa
close #269
2020-08-17 23:31:19 -04:00
Pedro Lopez
34aa136bf9 fix(docs): Correctly document Chat timestamp property
close #287
2020-08-17 22:36:32 -04:00
Pedro Lopez
2a58cfe8e2 fix(types): properly set optional arguments when sending / replying to messages
close #309
2020-08-17 22:28:27 -04:00
Pedro Lopez
9da553ecb9 feat: Set client's display name (pushname) 2020-08-17 22:19:29 -04:00
stefanfuchs
97705b1865 fix: MessageMedia interface to class (index.d.ts) (#301)
* fix: change MessageMedia to class

* fix: remove all references to MessageMediaInterface

* add MessageMedia constructor params docs
2020-08-08 15:03:09 -04:00
stefanfuchs
fbdfd2c4dd fix: Constants export in index.js (#285)
* fix: add Constants export in index.js
* fix: add missing constants export in index.d.ts


Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
2020-08-03 02:58:15 -04:00
stefanfuchs
5c84a1651d chore: add missing types in JSDoc/TSDoc (ClientOptions, ClientInfo, MessageSendOptions, Session) (#286)
* chore: add ClientOptions and ClientInfo in JSDoc

* chore: add MessageSendOptions type

* chore: add ClientSession type in JSDoc

* chore: remove @todo from createGroup (was already solved)

Co-authored-by: Pedro Lopez <pedroslopez@me.com>
2020-08-03 02:52:37 -04:00
stefanfuchs
bfea74f567 fix: add missing type definitions (#278)
* fix: @todo docs improvements

* fix: add ClientInfo to Client typings

* add ClientInfoPhone

* fix: set getBatteryStatus as async

* add ClientInfo comment

Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
2020-07-11 02:58:57 -04:00
YY
a10b458cd5 feat: custom user Agent in Client (#271)
* Added Option to Custom User Agent in Client

* Update Typescript Index

* Delete Variable UserAgent From Client

* Update Variable UserAgent to userAgent
2020-07-03 02:05:23 -04:00
Pedro Lopez
de2c441870 chore: update supported whatsapp web version 2.2025.6 2020-06-18 01:48:10 -04:00
Pedro Lopez
bff60bc9f6 chore: bump version v1.7.0-post 2020-06-18 01:47:46 -04:00
Pedro Lopez
9cc668e4d9 chore: mark version v1.7.0 2020-06-18 01:41:36 -04:00
Pedro Lopez
753b6772ab feat: get current battery status 2020-06-18 01:28:25 -04:00
Pedro Lopez
300b367fa0 feat: logout client
close #255
2020-06-17 23:58:02 -04:00
Pedro Lopez
b0baeaa8da Merge branch 'master' of https://github.com/pedroslopez/whatsapp-web.js 2020-06-17 23:30:01 -04:00
Pedro Lopez
ad9ae1f703 fix: move invite info to client
Since static methods do not have access to `this.client`, it was giving an error when trying to call these functions. The client itself is a better place for them.

close #258
2020-06-17 23:29:34 -04:00
Pedro Lopez
b89f0e146f fix: move invite info to client
Since static methods do not have access to `this.client`, it was giving an error when trying to call these functions. The client itself is a better place for them.
2020-06-17 23:28:54 -04:00
Maximilian Walterskirchen
6c7a3f9899 fix: Added check for null in Message constructor (#253)
Co-authored-by: Walterskirchen <walterskirchen@walter-group.com>
Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
2020-06-16 18:15:19 -04:00
stefanfuchs
d7459eac23 feat: add typescript definition file (#252)
Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
2020-06-16 18:12:14 -04:00
Javier Portillo
2abd3729d8 fix: clear qr refresh interval on client.destroy() (#249)
* fix: client.destroy() keeps trying to get QR code when client is not authorized yet

Co-authored-by: Javier Portillo <javier.marquez@dada-dada.com>
2020-06-08 22:31:22 -04:00
Pedro S. Lopez
810ff4603b chore: add discord link to issue creation 2020-06-07 18:10:49 -04:00
Pedro S. Lopez
4d5619019c chore: Add issue templates
close #246
2020-06-07 18:06:02 -04:00
Pedro Lopez
84213cc781 chore: bump version v1.6.1-post 2020-06-04 20:25:04 -04:00
Pedro Lopez
bf94d20db3 Merge branch 'hotfix/v1.6.1' 2020-06-04 20:23:55 -04:00
Caio Henrique Agiani
832e402671 fix: WhatsApp Autentication by oguzhan51 (#237)
The selector used to detect successful authentication was changed in WhatsApp Web v2.2023.2

Co-authored-by: oguzhan51
2020-06-04 20:03:44 -04:00
Aliyss Snow
47011a32a5 feat: Interface controls (#220)
- Open chat drawer
- Open chat window
- Open message info drawer
- Close drawer
2020-05-31 18:14:21 -04:00
Pedro S. Lopez
a7ca628775 chore: update required node version (#222)
Puppeteer v3 now requires 10.18.1+
2020-05-26 13:52:52 -04:00
Aliyss Snow
aa60e89911 docs: add mute/unmute feature to readme (#214)
Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
2020-05-24 19:27:41 -04:00
Pedro Lopez
d922e4df2f chore: bump version to v1.6.0-post 2020-05-24 01:11:07 -04:00
54 changed files with 3320 additions and 518 deletions

39
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,39 @@
---
name: Bug report
about: Is something not working as intended? Report it here.
title: ''
labels: bug
assignees: ''
---
### Bug description
A clear and concise description of what the bug is.
### Reproduction steps
Steps to reproduce the behavior:
1.
2.
3.
...
### Expected behavior
A clear and concise description of what you expected to happen.
### Relevant code
If applicable, add code snippets to help explain your problem.
### Environment (please complete the following information):
**WhatsApp**
- Account type [Standard / Business]:
- Device OS [iOS / Android]:
- WhatsApp Web version [run `await client.getWWebVersion()`]:
**Library**
- Browser [Chrome / Chromium]:
- NodeJS version (`node -v`):
- npm or yarn version (`npm -v`):
- whatsapp-web.js version:
### Additional context
Add any other context about the problem here.

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Official WWebJS Discord Server
url: https://discord.gg/H7DqQs4
about: Please ask and answer questions here.

View File

@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

6
.gitignore vendored
View File

@@ -63,3 +63,9 @@ typings/
# next.js build output
.next
# macOS Thumbnails
._*
# Test sessions
*session.json

8
.npmignore Normal file
View File

@@ -0,0 +1,8 @@
docs/*
.github/*
.eslintrc.json
.jsdoc.json
.editorconfig
session.json

View File

@@ -1,4 +1,4 @@
[![npm](https://img.shields.io/npm/v/whatsapp-web.js.svg)](https://www.npmjs.com/package/whatsapp-web.js) [![Depfu](https://badges.depfu.com/badges/4a65a0de96ece65fdf39e294e0c8dcba/overview.svg)](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765) ![WhatsApp_Web 2.2023.2](https://img.shields.io/badge/WhatsApp_Web-2.2023.2-brightgreen.svg) [![Discord Chat](https://img.shields.io/discord/698610475432411196.svg?logo=discord)](https://discord.gg/H7DqQs4)
[![npm](https://img.shields.io/npm/v/whatsapp-web.js.svg)](https://www.npmjs.com/package/whatsapp-web.js) [![Depfu](https://badges.depfu.com/badges/4a65a0de96ece65fdf39e294e0c8dcba/overview.svg)](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765) ![WhatsApp_Web 2.2043.8](https://img.shields.io/badge/WhatsApp_Web-2.2043.8-brightgreen.svg) [![Discord Chat](https://img.shields.io/discord/698610475432411196.svg?logo=discord)](https://discord.gg/H7DqQs4)
# whatsapp-web.js
A WhatsApp API client that connects through the WhatsApp Web browser app
@@ -11,7 +11,7 @@ It uses Puppeteer to run a real instance of Whatsapp Web to avoid getting blocke
The module is now available on npm! `npm i whatsapp-web.js`
Please note that Node v8+ is required due to Puppeteer.
Please note that Node v10.18.1+ is required due to Puppeteer.
## Example usage
@@ -60,6 +60,7 @@ Take a look at [example.js](https://github.com/pedroslopez/whatsapp-web.js/blob/
| Kick group participants | ✅ |
| Promote/demote group participants | ✅ |
| Mention users | ✅ |
| Mute/unmute chats | ✅ |
| Get contact info | ✅ |
| Get profile pictures | ✅ |
| Set user status message | ✅ |

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: Base</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: Base</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -50,7 +50,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: BusinessContact</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: BusinessContact</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -91,8 +91,15 @@
</div>
</div>
<div class="summary-callout">
<h2 class="summary-callout-heading">Method</h2>
<h2 class="summary-callout-heading">Methods</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="BusinessContact.html#getChat">getChat()</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="BusinessContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
@@ -102,8 +109,6 @@
</div>
<div class="summary-column">
</div>
<div class="summary-column">
</div>
</div>
</div>
</section>
@@ -206,8 +211,18 @@
<dd><a href="Contact.html#shortName">Contact#shortName</a></dd>
</dl>
</section>
<h2>Method</h2>
<h2>Methods</h2>
<section>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getChat"><span class="symbol-name">getChat</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Chat.html">Chat</a></span></span></h3>
<p>Returns the Chat that corresponds to this Contact.
Will return null when getting chat for currently logged in user.</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Contact.html#getChat">Contact#getChat</a></dd>
<dt>Returns</dt>
<dd></dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing string</span></span></h3>
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
@@ -227,7 +242,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: Chat</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: Chat</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -48,6 +48,9 @@
<dt><a href="Chat.html#isGroup">isGroup</a></dt>
<dd>
</dd>
<dt><a href="Chat.html#isMuted">isMuted</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
@@ -55,16 +58,22 @@
<dt><a href="Chat.html#isReadOnly">isReadOnly</a></dt>
<dd>
</dd>
<dt><a href="Chat.html#muteExpiration">muteExpiration</a></dt>
<dd>
</dd>
<dt><a href="Chat.html#name">name</a></dt>
<dd>
</dd>
<dt><a href="Chat.html#timestamp">timestamp</a></dt>
<dt><a href="Chat.html#pinned">pinned</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Chat.html#timestamp">timestamp</a></dt>
<dd>
</dd>
<dt><a href="Chat.html#unreadCount">unreadCount</a></dt>
<dd>
</dd>
@@ -89,17 +98,23 @@
<dt><a href="Chat.html#delete">delete()</a></dt>
<dd>
</dd>
<dt><a href="Chat.html#fetchMessages">fetchMessages(searchOptions)</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Chat.html#fetchMessages">fetchMessages(searchOptions)</a></dt>
<dt><a href="Chat.html#getContact">getContact()</a></dt>
<dd>
</dd>
<dt><a href="Chat.html#mute">mute(unmuteDate)</a></dt>
<dd>
</dd>
<dt><a href="Chat.html#sendMessage">sendMessage(content, options)</a></dt>
<dt><a href="Chat.html#pin">pin()</a></dt>
<dd>
</dd>
<dt><a href="Chat.html#sendMessage">sendMessage(content[, options])</a></dt>
<dd>
</dd>
<dt><a href="Chat.html#sendSeen">sendSeen()</a></dt>
@@ -121,6 +136,9 @@
<dt><a href="Chat.html#unmute">unmute()</a></dt>
<dd>
</dd>
<dt><a href="Chat.html#unpin">unpin()</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
@@ -151,19 +169,34 @@
<p>Indicates if the Chat is a Group Chat</p>
<dl class="dl-compact">
</dl>
<h3 id="isMuted"><span class="symbol-name">isMuted</span><small class="property-type">
&nbsp;number</small></h3>
<p>Indicates if the chat is muted or not</p>
<dl class="dl-compact">
</dl>
<h3 id="isReadOnly"><span class="symbol-name">isReadOnly</span><small class="property-type">
&nbsp;boolean</small></h3>
<p>Indicates if the Chat is readonly</p>
<dl class="dl-compact">
</dl>
<h3 id="muteExpiration"><span class="symbol-name">muteExpiration</span><small class="property-type">
&nbsp;number</small></h3>
<p>Unix timestamp for when the mute expires</p>
<dl class="dl-compact">
</dl>
<h3 id="name"><span class="symbol-name">name</span><small class="property-type">
&nbsp;string</small></h3>
<p>Title of the chat</p>
<dl class="dl-compact">
</dl>
<h3 id="pinned"><span class="symbol-name">pinned</span><small class="property-type">
&nbsp;boolean</small></h3>
<p>Indicates if the Chat is pinned</p>
<dl class="dl-compact">
</dl>
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
&nbsp;number</small></h3>
<p>Unix timestamp for when the chat was created</p>
<p>Unix timestamp for when the last activity occurred</p>
<dl class="dl-compact">
</dl>
<h3 id="unreadCount"><span class="symbol-name">unreadCount</span><small class="property-type">
@@ -271,6 +304,15 @@
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getContact"><span class="symbol-name">getContact</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Contact.html">Contact</a></span></span></h3>
<p>Returns the Contact that corresponds to this Chat.</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing <a href="Contact.html">Contact</a></code> </p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="mute"><span class="symbol-name">mute</span><span class="signature"><span class="signature-params">(unmuteDate)</span></span></h3>
<p>Mutes this chat until a specified date</p>
<section>
@@ -305,7 +347,17 @@
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content, options)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<h3 id="pin"><span class="symbol-name">pin</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing boolean</span></span></h3>
<p>Pins this chat</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> <p>New pin state. Could be false if the max number of pinned chats was reached.</p>
</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content[, options])</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<p>Send a message to this chat</p>
<section>
<h4>Parameters</h4>
@@ -337,10 +389,10 @@
<p>options</p>
</td>
<td>
<p>object</p>
<p><a href="global.html#MessageSendOptions">MessageSendOptions</a></p>
</td>
<td>
<p>&nbsp;</p>
<p>Yes</p>
</td>
<td>
</td>
@@ -385,6 +437,16 @@
<p>Unmutes this chat</p>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="unpin"><span class="symbol-name">unpin</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing boolean</span></span></h3>
<p>Unpins this chat</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> <p>New pin state</p>
</p>
</dd>
</dl>
</section>
</section>
</div>
@@ -395,7 +457,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: Client</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: Client</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -26,7 +26,7 @@
<header class="page-header">
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
<h1><small></small><span class="symbol-name">Client</span></h1>
<p class="source-link">Source: <a href="Client.js.html#source-line-35">Client.<wbr>js:35</a></p>
<p class="source-link">Source: <a href="Client.js.html#source-line-51">Client.<wbr>js:51</a></p>
<div class="symbol-classdesc">
<p>Starting point for interacting with the WhatsApp Web API</p>
</div>
@@ -34,6 +34,22 @@
</dl>
</header>
<section id="summary">
<div class="summary-callout">
<h2 class="summary-callout-heading">Property</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Client.html#info">info</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
</div>
<div class="summary-column">
</div>
</div>
</div>
<div class="summary-callout">
<h2 class="summary-callout-heading">Methods</h2>
<div class="summary-content">
@@ -60,13 +76,16 @@
<dt><a href="Client.html#getContactById">getContactById(contactId)</a></dt>
<dd>
</dd>
<dt><a href="Client.html#getContacts">getContacts()</a></dt>
<dd>
</dd>
<dt><a href="Client.html#getInviteInfo">getInviteInfo(inviteCode)</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Client.html#getContacts">getContacts()</a></dt>
<dd>
</dd>
<dt><a href="Client.html#getProfilePicUrl">getProfilePicUrl(contactId)</a></dt>
<dd>
</dd>
@@ -79,20 +98,26 @@
<dt><a href="Client.html#initialize">initialize()</a></dt>
<dd>
</dd>
<dt><a href="Client.html#isRegisteredUser">isRegisteredUser()</a></dt>
<dt><a href="Client.html#isRegisteredUser">isRegisteredUser(id)</a></dt>
<dd>
</dd>
<dt><a href="Client.html#logout">logout()</a></dt>
<dd>
</dd>
<dt><a href="Client.html#muteChat">muteChat(chatId, unmuteDate)</a></dt>
<dd>
</dd>
<dt><a href="Client.html#pinChat">pinChat()</a></dt>
<dd>
</dd>
<dt><a href="Client.html#resetState">resetState()</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Client.html#resetState">resetState()</a></dt>
<dd>
</dd>
<dt><a href="Client.html#sendMessage">sendMessage(chatId, content, options)</a></dt>
<dt><a href="Client.html#sendMessage">sendMessage(chatId, content[, options])</a></dt>
<dd>
</dd>
<dt><a href="Client.html#sendPresenceAvailable">sendPresenceAvailable()</a></dt>
@@ -101,6 +126,9 @@
<dt><a href="Client.html#sendSeen">sendSeen(chatId)</a></dt>
<dd>
</dd>
<dt><a href="Client.html#setDisplayName">setDisplayName(displayName)</a></dt>
<dd>
</dd>
<dt><a href="Client.html#setStatus">setStatus(status)</a></dt>
<dd>
</dd>
@@ -110,6 +138,9 @@
<dt><a href="Client.html#unmuteChat">unmuteChat(chatId)</a></dt>
<dd>
</dd>
<dt><a href="Client.html#unpinChat">unpinChat()</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
@@ -181,7 +212,227 @@
</div>
</section>
<section>
<h2 id="Client">new&nbsp;<span class="symbol-name">Client</span><span class="signature"><span class="signature-params">()</span></span></h2>
<h2 id="Client">new&nbsp;<span class="symbol-name">Client</span><span class="signature"><span class="signature-params">(options)</span></span></h2>
<section>
<h3>Parameters</h3>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>options</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Client options</p>
<p>Values in <code>options</code> have the following properties:</p>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>authTimeoutMs</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Timeout for authentication selector in puppeteer</p>
</td>
</tr>
<tr>
<td>
<p>puppeteer</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/</p>
</td>
</tr>
<tr>
<td>
<p>qrRefreshIntervalMs</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Refresh interval for qr code (how much time to wait before checking if the qr code has changed)</p>
</td>
</tr>
<tr>
<td>
<p>qrTimeoutMs</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Timeout for qr code selector in puppeteer</p>
</td>
</tr>
<tr>
<td>
<p>restartOnAuthFail</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Restart client with a new session (i.e. use null 'session' var) if authentication fails</p>
</td>
</tr>
<tr>
<td>
<p>session</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Whatsapp session to restore. If not set, will start a new session</p>
</td>
</tr>
<tr>
<td>
<p>session.WABrowserId</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>session.WASecretBundle</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>session.WAToken1</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>session.WAToken2</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>takeoverOnConflict</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>If another whatsapp web session is detected (another browser), take over the session in the current browser</p>
</td>
</tr>
<tr>
<td>
<p>takeoverTimeoutMs</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>How much time to wait before taking over the session</p>
</td>
</tr>
<tr>
<td>
<p>userAgent</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>User agent to use in puppeteer</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Extends</dt>
<dd>EventEmitter</dd>
@@ -205,6 +456,14 @@
</dl>
</section>
<section>
<h2>Property</h2>
<section>
<h3 id="info"><span class="symbol-name">info</span><small class="property-type">
&nbsp;<a href="ClientInfo.html">ClientInfo</a></small></h3>
<p>Current connection information</p>
<dl class="dl-compact">
</dl>
</section>
<h2>Methods</h2>
<section>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
@@ -409,6 +668,44 @@
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getInviteInfo"><span class="symbol-name">getInviteInfo</span><span class="signature"><span class="signature-params">(inviteCode)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing object</span></span></h3>
<p>Returns an object with information about the invite code's group</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>inviteCode</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing object</code> <p>Invite information</p>
</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">(contactId)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing string</span></span></h3>
<p>Returns the contact ID's profile picture URL, if privacy settings allow it</p>
<section>
@@ -456,13 +753,12 @@
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getWWebVersion"><span class="symbol-name">getWWebVersion</span><span class="signature"><span class="signature-params">()</span></span></h3>
<h3 id="getWWebVersion"><span class="symbol-name">getWWebVersion</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing string</span></span></h3>
<p>Returns the version of WhatsApp Web currently being run</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p>Promise<string>
</p>
<p><code>Promise containing string</code> </p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
@@ -471,8 +767,37 @@
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="isRegisteredUser"><span class="symbol-name">isRegisteredUser</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing Boolean</span></span></h3>
<h3 id="isRegisteredUser"><span class="symbol-name">isRegisteredUser</span><span class="signature"><span class="signature-params">(id)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing Boolean</span></span></h3>
<p>Check if a given ID is registered in whatsapp</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>id</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>the whatsapp user's ID</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
@@ -480,6 +805,11 @@
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="logout"><span class="symbol-name">logout</span><span class="signature"><span class="signature-params">()</span></span></h3>
<p>Logs out the client, closing the current session</p>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="muteChat"><span class="symbol-name">muteChat</span><span class="signature"><span class="signature-params">(chatId, unmuteDate)</span></span></h3>
<p>Mutes the Chat until a specified date</p>
<section>
@@ -528,12 +858,22 @@
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="pinChat"><span class="symbol-name">pinChat</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing boolean</span></span></h3>
<p>Pins the Chat</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> <p>New pin state. Could be false if the max number of pinned chats was reached.</p>
</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="resetState"><span class="symbol-name">resetState</span><span class="signature"><span class="signature-params">()</span></span></h3>
<p>Force reset of connection state for the client</p>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(chatId, content, options)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(chatId, content[, options])</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<p>Send a message to a specific chatId</p>
<section>
<h4>Parameters</h4>
@@ -578,12 +918,13 @@
<p>options</p>
</td>
<td>
<p>object</p>
<p><a href="global.html#MessageSendOptions">MessageSendOptions</a></p>
</td>
<td>
<p>&nbsp;</p>
<p>Yes</p>
</td>
<td>
<p>Options used when sending the message</p>
</td>
</tr>
</tbody>
@@ -640,6 +981,41 @@
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="setDisplayName"><span class="symbol-name">setDisplayName</span><span class="signature"><span class="signature-params">(displayName)</span></span></h3>
<p>Sets the current user's display name.
This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>displayName</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>New display name</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="setStatus"><span class="symbol-name">setStatus</span><span class="signature"><span class="signature-params">(status)</span></span></h3>
<p>Sets the current user's status message</p>
<section>
@@ -716,6 +1092,16 @@
</section>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="unpinChat"><span class="symbol-name">unpinChat</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing boolean</span></span></h3>
<p>Unpins the Chat</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> <p>New pin state</p>
</p>
</dd>
</dl>
</section>
<h2>Events</h2>
<section>
@@ -754,7 +1140,7 @@
<h3 id="event:authenticated"><span class="symbol-name">authenticated</span></h3>
<p>Emitted when authentication is successful</p>
<section>
<h4>Parameter</h4>
<h4>Parameters</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
@@ -777,6 +1163,71 @@
</td>
<td>
<p>Object containing session information. Can be used to restore the session.</p>
<p>Values in <code>session</code> have the following properties:</p>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>WABrowserId</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>WASecretBundle</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>WAToken1</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>WAToken2</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
@@ -1297,7 +1748,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: Client.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; 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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -37,7 +37,8 @@ const moduleRaid &#x3D; require(&#x27;@pedroslopez/moduleraid/moduleraid&#x27;);
const jsQR &#x3D; require(&#x27;jsqr&#x27;);
const Util &#x3D; require(&#x27;./util/Util&#x27;);
const { WhatsWebURL, UserAgent, DefaultOptions, Events, WAState } &#x3D; require(&#x27;./util/Constants&#x27;);
const InterfaceController &#x3D; require(&#x27;./util/InterfaceController&#x27;);
const { WhatsWebURL, DefaultOptions, Events, WAState } &#x3D; require(&#x27;./util/Constants&#x27;);
const { ExposeStore, LoadUtils } &#x3D; require(&#x27;./util/Injected&#x27;);
const ChatFactory &#x3D; require(&#x27;./factories/ChatFactory&#x27;);
const ContactFactory &#x3D; require(&#x27;./factories/ContactFactory&#x27;);
@@ -45,6 +46,21 @@ const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification
/**
* Starting point for interacting with the WhatsApp Web API
* @extends {EventEmitter}
* @param {object} options - Client options
* @param {number} options.authTimeoutMs - Timeout for authentication selector in puppeteer
* @param {object} options.puppeteer - Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/
* @param {number} options.qrRefreshIntervalMs - Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
* @param {number} options.qrTimeoutMs - Timeout for qr code selector in puppeteer
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null &#x27;session&#x27; var) if authentication fails
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
* @param {string} options.session.WABrowserId
* @param {string} options.session.WASecretBundle
* @param {string} options.session.WAToken1
* @param {string} options.session.WAToken2
* @param {number} options.takeoverOnConflict - If another whatsapp web session is detected (another browser), take over the session in the current browser
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
* @param {string} options.userAgent - User agent to use in puppeteer
*
* @fires Client#qr
* @fires Client#authenticated
* @fires Client#auth_failure
@@ -78,11 +94,11 @@ class Client extends EventEmitter {
async initialize() {
const browser &#x3D; await puppeteer.launch(this.options.puppeteer);
const page &#x3D; (await browser.pages())[0];
page.setUserAgent(UserAgent);
page.setUserAgent(this.options.userAgent);
this.pupBrowser &#x3D; browser;
this.pupPage &#x3D; page;
if (this.options.session) {
await page.evaluateOnNewDocument(
session &#x3D;&gt; {
@@ -98,8 +114,8 @@ class Client extends EventEmitter {
waitUntil: &#x27;load&#x27;,
timeout: 0,
});
const KEEP_PHONE_CONNECTED_IMG_SELECTOR &#x3D; &#x27;[data-asset-intro-image-light&#x3D;&quot;true&quot;]&#x27;;
const KEEP_PHONE_CONNECTED_IMG_SELECTOR &#x3D; &#x27;[data-asset-intro-image-light&#x3D;&quot;true&quot;], [data-asset-intro-image-dark&#x3D;&quot;true&quot;]&#x27;;
if (this.options.session) {
// Check if session restore was successfull
@@ -148,11 +164,12 @@ class Client extends EventEmitter {
this.emit(Events.QR_RECEIVED, qr);
};
getQrCode();
let retryInterval &#x3D; setInterval(getQrCode, this.options.qrRefreshIntervalMs);
this._qrRefreshInterval &#x3D; setInterval(getQrCode, this.options.qrRefreshIntervalMs);
// Wait for code scan
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
clearInterval(retryInterval);
clearInterval(this._qrRefreshInterval);
this._qrRefreshInterval &#x3D; undefined;
}
@@ -174,6 +191,10 @@ class Client extends EventEmitter {
* Emitted when authentication is successful
* @event Client#authenticated
* @param {object} session Object containing session information. Can be used to restore the session.
* @param {string} session.WABrowserId
* @param {string} session.WASecretBundle
* @param {string} session.WAToken1
* @param {string} session.WAToken2
*/
this.emit(Events.AUTHENTICATED, session);
@@ -184,10 +205,17 @@ class Client extends EventEmitter {
await page.evaluate(LoadUtils);
// Expose client info
/**
* Current connection information
* @type {ClientInfo}
*/
this.info &#x3D; new ClientInfo(this, await page.evaluate(() &#x3D;&gt; {
return window.Store.Conn.serialize();
}));
// Add InterfaceController
this.interface &#x3D; new InterfaceController(this);
// Register events
await page.exposeFunction(&#x27;onAddMessageEvent&#x27;, msg &#x3D;&gt; {
if (!msg.isNewMsg) return;
@@ -218,7 +246,7 @@ class Client extends EventEmitter {
}
return;
}
const message &#x3D; new Message(this, msg);
/**
@@ -287,7 +315,7 @@ class Client extends EventEmitter {
await page.exposeFunction(&#x27;onMessageAckEvent&#x27;, (msg, ack) &#x3D;&gt; {
const message &#x3D; new Message(this, msg);
/**
* Emitted when an ack event occurrs on message type.
* @event Client#message_ack
@@ -301,7 +329,7 @@ class Client extends EventEmitter {
await page.exposeFunction(&#x27;onMessageMediaUploadedEvent&#x27;, (msg) &#x3D;&gt; {
const message &#x3D; new Message(this, msg);
/**
* Emitted when media has been uploaded for a message sent by the client.
* @event Client#media_uploaded
@@ -321,10 +349,10 @@ class Client extends EventEmitter {
const ACCEPTED_STATES &#x3D; [WAState.CONNECTED, WAState.OPENING, WAState.PAIRING, WAState.TIMEOUT];
if(this.options.takeoverOnConflict) {
if (this.options.takeoverOnConflict) {
ACCEPTED_STATES.push(WAState.CONFLICT);
if(state &#x3D;&#x3D;&#x3D; WAState.CONFLICT) {
if (state &#x3D;&#x3D;&#x3D; WAState.CONFLICT) {
setTimeout(() &#x3D;&gt; {
this.pupPage.evaluate(() &#x3D;&gt; window.Store.AppState.takeover());
}, this.options.takeoverTimeoutMs);
@@ -345,7 +373,7 @@ class Client extends EventEmitter {
await page.exposeFunction(&#x27;onBatteryStateChangedEvent&#x27;, (state) &#x3D;&gt; {
const { battery, plugged } &#x3D; state;
if(battery &#x3D;&#x3D;&#x3D; undefined) return;
if (battery &#x3D;&#x3D;&#x3D; undefined) return;
/**
* Emitted when the battery percentage for the attached device changes
@@ -358,12 +386,12 @@ class Client extends EventEmitter {
});
await page.evaluate(() &#x3D;&gt; {
window.Store.Msg.on(&#x27;add&#x27;, (msg) &#x3D;&gt; { if(msg.isNewMsg) window.onAddMessageEvent(msg); });
window.Store.Msg.on(&#x27;change&#x27;, (msg) &#x3D;&gt; { window.onChangeMessageEvent(msg); });
window.Store.Msg.on(&#x27;change:type&#x27;, (msg) &#x3D;&gt; { window.onChangeMessageTypeEvent(msg); });
window.Store.Msg.on(&#x27;change:ack&#x27;, (msg, ack) &#x3D;&gt; { window.onMessageAckEvent(msg, ack); });
window.Store.Msg.on(&#x27;change:isUnsentMedia&#x27;, (msg, unsent) &#x3D;&gt; { if(msg.id.fromMe &amp;amp;&amp;amp; !unsent) window.onMessageMediaUploadedEvent(msg); });
window.Store.Msg.on(&#x27;remove&#x27;, (msg) &#x3D;&gt; { if(msg.isNewMsg) window.onRemoveMessageEvent(msg); });
window.Store.Msg.on(&#x27;add&#x27;, (msg) &#x3D;&gt; { if (msg.isNewMsg) window.onAddMessageEvent(window.WWebJS.getMessageModel(msg)); });
window.Store.Msg.on(&#x27;change&#x27;, (msg) &#x3D;&gt; { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); });
window.Store.Msg.on(&#x27;change:type&#x27;, (msg) &#x3D;&gt; { window.onChangeMessageTypeEvent(window.WWebJS.getMessageModel(msg)); });
window.Store.Msg.on(&#x27;change:ack&#x27;, (msg,ack) &#x3D;&gt; { window.onMessageAckEvent(window.WWebJS.getMessageModel(msg), ack); });
window.Store.Msg.on(&#x27;change:isUnsentMedia&#x27;, (msg, unsent) &#x3D;&gt; { if (msg.id.fromMe &amp;amp;&amp;amp; !unsent) window.onMessageMediaUploadedEvent(window.WWebJS.getMessageModel(msg)); });
window.Store.Msg.on(&#x27;remove&#x27;, (msg) &#x3D;&gt; { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); });
window.Store.AppState.on(&#x27;change:state&#x27;, (_AppState, state) &#x3D;&gt; { window.onAppStateChangedEvent(state); });
window.Store.Conn.on(&#x27;change:battery&#x27;, (state) &#x3D;&gt; { window.onBatteryStateChangedEvent(state); });
});
@@ -379,12 +407,24 @@ class Client extends EventEmitter {
* Closes the client
*/
async destroy() {
if (this._qrRefreshInterval) {
clearInterval(this._qrRefreshInterval);
}
await this.pupBrowser.close();
}
/**
* Logs out the client, closing the current session
*/
async logout() {
return await this.pupPage.evaluate(() &#x3D;&gt; {
return window.Store.AppState.logout();
});
}
/**
* Returns the version of WhatsApp Web currently being run
* @returns Promise&amp;lt;string&gt;
* @returns {Promise&amp;lt;string&gt;}
*/
async getWWebVersion() {
return await this.pupPage.evaluate(() &#x3D;&gt; {
@@ -406,11 +446,24 @@ class Client extends EventEmitter {
return result;
}
/**
* Message options.
* @typedef {Object} MessageSendOptions
* @property {boolean} [linkPreview&#x3D;true] - Show links preview
* @property {boolean} [sendAudioAsVoice&#x3D;false] - Send audio as voice message
* @property {string} [caption] - Image or video caption
* @property {string} [quotedMessageId] - Id of the message that is being quoted (or replied to)
* @property {Contact[]} [mentions] - Contacts that are being mentioned in the message
* @property {boolean} [sendSeen&#x3D;true] - Mark the conversation as seen after sending the message
* @property {boolean} [media] - Media to be sent
*/
/**
* Send a message to a specific chatId
* @param {string} chatId
* @param {string|MessageMedia|Location} content
* @param {object} options
* @param {MessageSendOptions} [options] - Options used when sending the message
*
* @returns {Promise&amp;lt;Message&gt;} Message that was just sent
*/
async sendMessage(chatId, content, options &#x3D; {}) {
@@ -421,7 +474,7 @@ class Client extends EventEmitter {
quotedMessageId: options.quotedMessageId,
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact &#x3D;&gt; contact.id._serialized) : []
};
const sendSeen &#x3D; typeof options.sendSeen &#x3D;&#x3D;&#x3D; &#x27;undefined&#x27; ? true : options.sendSeen;
if (content instanceof MessageMedia) {
@@ -440,7 +493,7 @@ class Client extends EventEmitter {
const chatWid &#x3D; window.Store.WidFactory.createWid(chatId);
const chat &#x3D; await window.Store.Chat.find(chatWid);
if(sendSeen) {
if (sendSeen) {
window.WWebJS.sendSeen(chatId);
}
@@ -456,8 +509,8 @@ class Client extends EventEmitter {
* @returns {Promise&amp;lt;Array&amp;lt;Chat&gt;&gt;}
*/
async getChats() {
let chats &#x3D; await this.pupPage.evaluate(() &#x3D;&gt; {
return window.WWebJS.getChats();
let chats &#x3D; await this.pupPage.evaluate(async () &#x3D;&gt; {
return await window.WWebJS.getChats();
});
return chats.map(chat &#x3D;&gt; ChatFactory.create(this, chat));
@@ -469,8 +522,8 @@ class Client extends EventEmitter {
* @returns {Promise&amp;lt;Chat&gt;}
*/
async getChatById(chatId) {
let chat &#x3D; await this.pupPage.evaluate(chatId &#x3D;&gt; {
return window.WWebJS.getChat(chatId);
let chat &#x3D; await this.pupPage.evaluate(async chatId &#x3D;&gt; {
return await window.WWebJS.getChat(chatId);
}, chatId);
return ChatFactory.create(this, chat);
@@ -501,6 +554,17 @@ class Client extends EventEmitter {
return ContactFactory.create(this, contact);
}
/**
* Returns an object with information about the invite code&#x27;s group
* @param {string} inviteCode
* @returns {Promise&amp;lt;object&gt;} Invite information
*/
async getInviteInfo(inviteCode) {
return await this.pupPage.evaluate(inviteCode &#x3D;&gt; {
return window.Store.Wap.groupInviteInfo(inviteCode);
}, inviteCode);
}
/**
* Accepts an invitation to join a group
* @param {string} inviteCode Invitation code
@@ -523,6 +587,17 @@ class Client extends EventEmitter {
}, status);
}
/**
* Sets the current user&#x27;s display name.
* This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
* @param {string} displayName New display name
*/
async setDisplayName(displayName) {
await this.pupPage.evaluate(async displayName &#x3D;&gt; {
return await window.Store.Wap.setPushname(displayName);
}, displayName);
}
/**
* Gets the current connection state for the client
* @returns {WAState}
@@ -566,6 +641,43 @@ class Client extends EventEmitter {
}, chatId);
}
/**
* Pins the Chat
* @returns {Promise&amp;lt;boolean&gt;} New pin state. Could be false if the max number of pinned chats was reached.
*/
async pinChat(chatId) {
return this.pupPage.evaluate(async chatId &#x3D;&gt; {
let chat &#x3D; window.Store.Chat.get(chatId);
if (chat.pin) {
return true;
}
const MAX_PIN_COUNT &#x3D; 3;
if (window.Store.Chat.models.length &gt; MAX_PIN_COUNT) {
let maxPinned &#x3D; window.Store.Chat.models[MAX_PIN_COUNT - 1].pin;
if (maxPinned) {
return false;
}
}
await window.Store.Cmd.pinChat(chat, true);
return true;
}, chatId);
}
/**
* Unpins the Chat
* @returns {Promise&amp;lt;boolean&gt;} New pin state
*/
async unpinChat(chatId) {
return this.pupPage.evaluate(async chatId &#x3D;&gt; {
let chat &#x3D; window.Store.Chat.get(chatId);
if (!chat.pin) {
return false;
}
await window.Store.Cmd.pinChat(chat, false);
return false;
}, chatId);
}
/**
* Mutes the Chat until a specified date
* @param {string} chatId ID of the chat that will be muted
@@ -577,7 +689,7 @@ class Client extends EventEmitter {
await chat.mute.mute(timestamp, !0);
}, chatId, unmuteDate.getTime() / 1000);
}
/**
* Unmutes the Chat
* @param {string} chatId ID of the chat that will be unmuted
@@ -588,7 +700,7 @@ class Client extends EventEmitter {
await window.Store.Cmd.muteChat(chat, false);
}, chatId);
}
/**
* Returns the contact ID&#x27;s profile picture URL, if privacy settings allow it
* @param {string} contactId the whatsapp user&#x27;s ID
@@ -605,7 +717,7 @@ class Client extends EventEmitter {
/**
* Force reset of connection state for the client
*/
async resetState(){
async resetState() {
await this.pupPage.evaluate(() &#x3D;&gt; {
window.Store.AppState.phoneWatchdog.shiftTimer.forceRunNow();
});
@@ -613,6 +725,7 @@ class Client extends EventEmitter {
/**
* Check if a given ID is registered in whatsapp
* @param {string} id the whatsapp user&#x27;s ID
* @returns {Promise&amp;lt;Boolean&gt;}
*/
async isRegisteredUser(id) {
@@ -631,18 +744,18 @@ class Client extends EventEmitter {
* @returns {Object.&amp;lt;string,string&gt;} createRes.missingParticipants - participants that were not added to the group. Keys represent the ID for participant that was not added and its value is a status code that represents the reason why participant could not be added. This is usually 403 if the user&#x27;s privacy settings don&#x27;t allow you to add them to groups.
*/
async createGroup(name, participants) {
if(!Array.isArray(participants) || participants.length &#x3D;&#x3D; 0) {
if (!Array.isArray(participants) || participants.length &#x3D;&#x3D; 0) {
throw &#x27;You need to add at least one other participant to the group&#x27;;
}
if(participants.every(c &#x3D;&gt; c instanceof Contact)) {
if (participants.every(c &#x3D;&gt; c instanceof Contact)) {
participants &#x3D; participants.map(c &#x3D;&gt; c.id._serialized);
}
const createRes &#x3D; await this.pupPage.evaluate(async (name, participantIds) &#x3D;&gt; {
const res &#x3D; await window.Store.Wap.createGroup(name, participantIds);
console.log(res);
if(!res.status &#x3D;&#x3D;&#x3D; 200) {
if (!res.status &#x3D;&#x3D;&#x3D; 200) {
throw &#x27;An error occurred while creating the group!&#x27;;
}
@@ -652,11 +765,11 @@ class Client extends EventEmitter {
const missingParticipants &#x3D; createRes.participants.reduce(((missing, c) &#x3D;&gt; {
const id &#x3D; Object.keys(c)[0];
const statusCode &#x3D; c[id].code;
if(statusCode !&#x3D; 200) return Object.assign(missing, {[id]: statusCode});
if (statusCode !&#x3D; 200) return Object.assign(missing, { [id]: statusCode });
return missing;
}), {});
return { gid: createRes.gid, missingParticipants};
return { gid: createRes.gid, missingParticipants };
}
}
@@ -672,7 +785,7 @@ module.exports &#x3D; 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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: ClientInfo</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: ClientInfo</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -61,6 +61,22 @@
</div>
</div>
</div>
<div class="summary-callout">
<h2 class="summary-callout-heading">Method</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="ClientInfo.html#getBatteryStatus">getBatteryStatus()</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
</div>
<div class="summary-column">
</div>
</div>
</div>
</section>
<section>
<h2 id="ClientInfo">new&nbsp;<span class="symbol-name">ClientInfo</span><span class="signature"><span class="signature-params">()</span></span></h2>
@@ -178,6 +194,27 @@
<dl class="dl-compact">
</dl>
</section>
<h2>Method</h2>
<section>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getBatteryStatus"><span class="symbol-name">getBatteryStatus</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> (object, number, or boolean)</span></span></h3>
<p>Get current battery percentage and charging status for the attached device</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>object</code> <p>batteryStatus</p>
</p>
</dd>
<dd>
<p><code>number</code> <p>batteryStatus.battery - The current battery percentage</p>
</p>
</dd>
<dd>
<p><code>boolean</code> <p>batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)</p>
</p>
</dd>
</dl>
</section>
</section>
</div>
</div>
@@ -187,7 +224,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: Contact</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: Contact</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -88,8 +88,15 @@
</div>
</div>
<div class="summary-callout">
<h2 class="summary-callout-heading">Method</h2>
<h2 class="summary-callout-heading">Methods</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Contact.html#getChat">getChat()</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Contact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
@@ -99,8 +106,6 @@
</div>
<div class="summary-column">
</div>
<div class="summary-column">
</div>
</div>
</div>
</section>
@@ -175,8 +180,18 @@
<dl class="dl-compact">
</dl>
</section>
<h2>Method</h2>
<h2>Methods</h2>
<section>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getChat"><span class="symbol-name">getChat</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Chat.html">Chat</a></span></span></h3>
<p>Returns the Chat that corresponds to this Contact.
Will return null when getting chat for currently logged in user.</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing <a href="Chat.html">Chat</a></code> </p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing string</span></span></h3>
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
@@ -196,7 +211,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: GroupChat</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: GroupChat</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -51,16 +51,22 @@
<dt><a href="GroupChat.html#id">id</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#isGroup">isGroup</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="GroupChat.html#isGroup">isGroup</a></dt>
<dt><a href="GroupChat.html#isMuted">isMuted</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#isReadOnly">isReadOnly</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#muteExpiration">muteExpiration</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#name">name</a></dt>
<dd>
</dd>
@@ -74,6 +80,9 @@
<dt><a href="GroupChat.html#participants">participants</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#pinned">pinned</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#timestamp">timestamp</a></dt>
<dd>
</dd>
@@ -89,12 +98,6 @@
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="GroupChat.html#.getInviteInfo">getInviteInfo(inviteCode)</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#.join">join(inviteCode)</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#addParticipants">addParticipants(participantIds)</a></dt>
<dd>
</dd>
@@ -113,22 +116,28 @@
<dt><a href="GroupChat.html#demoteParticipants">demoteParticipants(participantIds)</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="GroupChat.html#fetchMessages">fetchMessages(searchOptions)</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#getContact">getContact()</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#getInviteCode">getInviteCode()</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="GroupChat.html#leave">leave()</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#mute">mute(unmuteDate)</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#pin">pin()</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#promoteParticipants">promoteParticipants(participantIds)</a></dt>
<dd>
</dd>
@@ -138,25 +147,31 @@
<dt><a href="GroupChat.html#revokeInvite">revokeInvite()</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#sendMessage">sendMessage(content, options)</a></dt>
<dt><a href="GroupChat.html#sendMessage">sendMessage(content[, options])</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="GroupChat.html#sendSeen">sendSeen()</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#sendStateRecording">sendStateRecording()</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="GroupChat.html#sendStateTyping">sendStateTyping()</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#setDescription">setDescription(description)</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#setInfoAdminsOnly">setInfoAdminsOnly([adminsOnly])</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#setMessagesAdminsOnly">setMessagesAdminsOnly([adminsOnly])</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#setSubject">setSubject(subject)</a></dt>
<dd>
</dd>
@@ -166,6 +181,9 @@
<dt><a href="GroupChat.html#unmute">unmute()</a></dt>
<dd>
</dd>
<dt><a href="GroupChat.html#unpin">unpin()</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
@@ -212,6 +230,13 @@
<dt>Inherited from</dt>
<dd><a href="Chat.html#isGroup">Chat#isGroup</a></dd>
</dl>
<h3 id="isMuted"><span class="symbol-name">isMuted</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Indicates if the chat is muted or not</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#isMuted">Chat#isMuted</a></dd>
</dl>
<h3 id="isReadOnly"><span class="symbol-name">isReadOnly</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Indicates if the Chat is readonly</p>
@@ -219,6 +244,13 @@
<dt>Inherited from</dt>
<dd><a href="Chat.html#isReadOnly">Chat#isReadOnly</a></dd>
</dl>
<h3 id="muteExpiration"><span class="symbol-name">muteExpiration</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Unix timestamp for when the mute expires</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#muteExpiration">Chat#muteExpiration</a></dd>
</dl>
<h3 id="name"><span class="symbol-name">name</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Title of the chat</p>
@@ -235,9 +267,16 @@
<p>Gets the group participants</p>
<dl class="dl-compact">
</dl>
<h3 id="pinned"><span class="symbol-name">pinned</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Indicates if the Chat is pinned</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#pinned">Chat#pinned</a></dd>
</dl>
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Unix timestamp for when the chat was created</p>
<p>Unix timestamp for when the last activity occurred</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#timestamp">Chat#timestamp</a></dd>
@@ -252,77 +291,6 @@
</section>
<h2>Methods</h2>
<section>
<div class="symbol-detail-labels"><span class="label label-async">async</span>&nbsp;<span class="label label-static">static</span></div>
<h3 id=".getInviteInfo"><span class="symbol-name">getInviteInfo</span><span class="signature"><span class="signature-params">(inviteCode)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing object</span></span></h3>
<p>Returns an object with information about the invite code's group</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>inviteCode</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing object</code> <p>Invite information</p>
</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span>&nbsp;<span class="label label-static">static</span></div>
<h3 id=".join"><span class="symbol-name">join</span><span class="signature"><span class="signature-params">(inviteCode)</span></span></h3>
<p>Joins a group with an invite code</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>inviteCode</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="addParticipants"><span class="symbol-name">addParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span></span></h3>
<p>Adds a list of participants by ID to the group</p>
@@ -492,6 +460,15 @@
<dd></dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getContact"><span class="symbol-name">getContact</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Contact.html">Contact</a></span></span></h3>
<p>Returns the Contact that corresponds to this Chat.</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#getContact">Chat#getContact</a></dd>
<dt>Returns</dt>
<dd></dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getInviteCode"><span class="symbol-name">getInviteCode</span><span class="signature"><span class="signature-params">()</span></span></h3>
<p>Gets the invite code for a specific group</p>
<dl class="dl-compact">
@@ -538,6 +515,17 @@
<dd><a href="Chat.html#mute">Chat#mute</a></dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="pin"><span class="symbol-name">pin</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing boolean</span></span></h3>
<p>Pins this chat</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#pin">Chat#pin</a></dd>
<dt>Returns</dt>
<dd>
<p>New pin state. Could be false if the max number of pinned chats was reached.</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="promoteParticipants"><span class="symbol-name">promoteParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span></span></h3>
<p>Promotes participants by IDs to admins</p>
<section>
@@ -609,7 +597,7 @@
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content, options)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content[, options])</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<p>Send a message to this chat</p>
<section>
<h4>Parameters</h4>
@@ -644,7 +632,7 @@
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
<p>Yes</p>
</td>
<td>
</td>
@@ -719,6 +707,86 @@
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="setInfoAdminsOnly"><span class="symbol-name">setInfoAdminsOnly</span><span class="signature"><span class="signature-params">([adminsOnly])</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing boolean</span></span></h3>
<p>Updates the group settings to only allow admins to edit group info (title, description, photo).</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>adminsOnly</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Enable or disable this option</p>
<p>Defaults to <code>true</code>.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> <p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="setMessagesAdminsOnly"><span class="symbol-name">setMessagesAdminsOnly</span><span class="signature"><span class="signature-params">([adminsOnly])</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing boolean</span></span></h3>
<p>Updates the group settings to only allow admins to send messages.</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>adminsOnly</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Enable or disable this option</p>
<p>Defaults to <code>true</code>.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> <p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="setSubject"><span class="symbol-name">setSubject</span><span class="signature"><span class="signature-params">(subject)</span></span></h3>
<p>Updates the group subject</p>
<section>
@@ -765,6 +833,17 @@
<dt>Inherited from</dt>
<dd><a href="Chat.html#unmute">Chat#unmute</a></dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="unpin"><span class="symbol-name">unpin</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing boolean</span></span></h3>
<p>Unpins this chat</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#unpin">Chat#unpin</a></dd>
<dt>Returns</dt>
<dd>
<p>New pin state</p>
</dd>
</dl>
</section>
</section>
</div>
@@ -775,7 +854,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: GroupNotification</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: GroupNotification</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -233,7 +233,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -0,0 +1,202 @@
<!doctype html>
<html>
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.10.0 &raquo; Class: InterfaceController</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">
<link href="css/baseline.css" rel="stylesheet">
</head>
<body onload="prettyPrint()">
<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>10.<wbr>0</a>
</div>
</div>
</nav>
<div id="jsdoc-body-container">
<div id="jsdoc-content">
<div id="jsdoc-content-container">
<div id="jsdoc-main" role="main">
<header class="page-header">
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
<h1><small></small><span class="symbol-name">InterfaceController</span></h1>
<p class="source-link">Source: <a href="util_InterfaceController.js.html#source-line-8">util/<wbr>InterfaceController.<wbr>js:8</a></p>
<div class="symbol-classdesc">
<p>Interface Controller</p>
</div>
<dl class="dl-compact">
</dl>
</header>
<section id="summary">
<div class="summary-callout">
<h2 class="summary-callout-heading">Methods</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="InterfaceController.html#closeRightDrawer">closeRightDrawer()</a></dt>
<dd>
</dd>
<dt><a href="InterfaceController.html#openChatDrawer">openChatDrawer(chatId)</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="InterfaceController.html#openChatWindow">openChatWindow(chatId)</a></dt>
<dd>
</dd>
<dt><a href="InterfaceController.html#openMessageDrawer">openMessageDrawer(msgId)</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
</div>
</div>
</div>
</section>
<section>
<h2 id="InterfaceController">new&nbsp;<span class="symbol-name">InterfaceController</span><span class="signature"><span class="signature-params">()</span></span></h2>
<dl class="dl-compact">
</dl>
</section>
<section>
<h2>Methods</h2>
<section>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="closeRightDrawer"><span class="symbol-name">closeRightDrawer</span><span class="signature"><span class="signature-params">()</span></span></h3>
<p>Closes the Right Drawer</p>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="openChatDrawer"><span class="symbol-name">openChatDrawer</span><span class="signature"><span class="signature-params">(chatId)</span></span></h3>
<p>Opens the Chat Drawer</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>chatId</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>ID of the chat drawer that will be opened</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="openChatWindow"><span class="symbol-name">openChatWindow</span><span class="signature"><span class="signature-params">(chatId)</span></span></h3>
<p>Opens the Chat Window</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>chatId</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>ID of the chat window that will be opened</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="openMessageDrawer"><span class="symbol-name">openMessageDrawer</span><span class="signature"><span class="signature-params">(msgId)</span></span></h3>
<p>Opens the Message Drawer</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>msgId</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>ID of the message drawer that will be opened</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
</section>
</section>
</div>
</div>
<nav id="jsdoc-toc-nav" role="navigation"></nav>
</div>
</div>
<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.4 on October 21, 2020.
</p>
</div>
</footer>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/tree.jquery.js"></script>
<script src="scripts/prettify.js"></script>
<script src="scripts/jsdoc-toc.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/scrollanchor.js"></script>
</body>
</html>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: Location</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: Location</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -149,7 +149,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: Message</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: Message</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -110,27 +110,30 @@
<dt><a href="Message.html#downloadMedia">downloadMedia()</a></dt>
<dd>
</dd>
<dt><a href="Message.html#getChat">getChat()</a></dt>
<dt><a href="Message.html#forward">forward(chat)</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Message.html#getChat">getChat()</a></dt>
<dd>
</dd>
<dt><a href="Message.html#getContact">getContact()</a></dt>
<dd>
</dd>
<dt><a href="Message.html#getMentions">getMentions()</a></dt>
<dd>
</dd>
<dt><a href="Message.html#getQuotedMessage">getQuotedMessage()</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Message.html#reply">reply(content, chatId, options)</a></dt>
<dt><a href="Message.html#getQuotedMessage">getQuotedMessage()</a></dt>
<dd>
</dd>
<dt><a href="Message.html#reply">reply(content[, chatId][, options])</a></dt>
<dd>
</dd>
</dl>
@@ -277,6 +280,44 @@
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> </p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="forward"><span class="symbol-name">forward</span><span class="signature"><span class="signature-params">(chat)</span>&nbsp;&rarr; <span class="signature-returns"> Promise</span></span></h3>
<p>Forwards this message to another chat</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>chat</p>
</td>
<td>
<p>(string or <a href="Chat.html">Chat</a>)</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Chat model or chat ID to which the message will be forwarded</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise</code> </p>
</dd>
</dl>
<h3 id="getChat"><span class="symbol-name">getChat</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Chat.html">Chat</a></span></span></h3>
<p>Returns the Chat this message was sent in</p>
<dl class="dl-compact">
@@ -312,7 +353,7 @@
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="reply"><span class="symbol-name">reply</span><span class="signature"><span class="signature-params">(content, chatId, options)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<h3 id="reply"><span class="symbol-name">reply</span><span class="signature"><span class="signature-params">(content[, chatId][, options])</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<p>Sends a message as a reply to this message. If chatId is specified, it will be sent
through the specified Chat. If not, it will send the message
in the same Chat as the original message was sent.</p>
@@ -349,10 +390,9 @@
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
<p>Yes</p>
</td>
<td>
<p>Value can be null.</p>
</td>
</tr>
<tr>
@@ -360,10 +400,10 @@
<p>options</p>
</td>
<td>
<p>object</p>
<p><a href="global.html#MessageSendOptions">MessageSendOptions</a></p>
</td>
<td>
<p>&nbsp;</p>
<p>Yes</p>
</td>
<td>
</td>
@@ -387,7 +427,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: MessageMedia</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: MessageMedia</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -208,7 +208,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: PrivateChat</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: PrivateChat</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -48,6 +48,9 @@
<dt><a href="PrivateChat.html#isGroup">isGroup</a></dt>
<dd>
</dd>
<dt><a href="PrivateChat.html#isMuted">isMuted</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
@@ -55,16 +58,22 @@
<dt><a href="PrivateChat.html#isReadOnly">isReadOnly</a></dt>
<dd>
</dd>
<dt><a href="PrivateChat.html#muteExpiration">muteExpiration</a></dt>
<dd>
</dd>
<dt><a href="PrivateChat.html#name">name</a></dt>
<dd>
</dd>
<dt><a href="PrivateChat.html#timestamp">timestamp</a></dt>
<dt><a href="PrivateChat.html#pinned">pinned</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="PrivateChat.html#timestamp">timestamp</a></dt>
<dd>
</dd>
<dt><a href="PrivateChat.html#unreadCount">unreadCount</a></dt>
<dd>
</dd>
@@ -89,17 +98,23 @@
<dt><a href="PrivateChat.html#delete">delete()</a></dt>
<dd>
</dd>
<dt><a href="PrivateChat.html#fetchMessages">fetchMessages(searchOptions)</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="PrivateChat.html#fetchMessages">fetchMessages(searchOptions)</a></dt>
<dt><a href="PrivateChat.html#getContact">getContact()</a></dt>
<dd>
</dd>
<dt><a href="PrivateChat.html#mute">mute(unmuteDate)</a></dt>
<dd>
</dd>
<dt><a href="PrivateChat.html#sendMessage">sendMessage(content, options)</a></dt>
<dt><a href="PrivateChat.html#pin">pin()</a></dt>
<dd>
</dd>
<dt><a href="PrivateChat.html#sendMessage">sendMessage(content[, options])</a></dt>
<dd>
</dd>
<dt><a href="PrivateChat.html#sendSeen">sendSeen()</a></dt>
@@ -121,6 +136,9 @@
<dt><a href="PrivateChat.html#unmute">unmute()</a></dt>
<dd>
</dd>
<dt><a href="PrivateChat.html#unpin">unpin()</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
@@ -157,6 +175,13 @@
<dt>Inherited from</dt>
<dd><a href="Chat.html#isGroup">Chat#isGroup</a></dd>
</dl>
<h3 id="isMuted"><span class="symbol-name">isMuted</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Indicates if the chat is muted or not</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#isMuted">Chat#isMuted</a></dd>
</dl>
<h3 id="isReadOnly"><span class="symbol-name">isReadOnly</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Indicates if the Chat is readonly</p>
@@ -164,6 +189,13 @@
<dt>Inherited from</dt>
<dd><a href="Chat.html#isReadOnly">Chat#isReadOnly</a></dd>
</dl>
<h3 id="muteExpiration"><span class="symbol-name">muteExpiration</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Unix timestamp for when the mute expires</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#muteExpiration">Chat#muteExpiration</a></dd>
</dl>
<h3 id="name"><span class="symbol-name">name</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Title of the chat</p>
@@ -171,9 +203,16 @@
<dt>Inherited from</dt>
<dd><a href="Chat.html#name">Chat#name</a></dd>
</dl>
<h3 id="pinned"><span class="symbol-name">pinned</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Indicates if the Chat is pinned</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#pinned">Chat#pinned</a></dd>
</dl>
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
&nbsp;unknown</small></h3>
<p>Unix timestamp for when the chat was created</p>
<p>Unix timestamp for when the last activity occurred</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#timestamp">Chat#timestamp</a></dd>
@@ -291,6 +330,15 @@
<dd></dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getContact"><span class="symbol-name">getContact</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Contact.html">Contact</a></span></span></h3>
<p>Returns the Contact that corresponds to this Chat.</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#getContact">Chat#getContact</a></dd>
<dt>Returns</dt>
<dd></dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="mute"><span class="symbol-name">mute</span><span class="signature"><span class="signature-params">(unmuteDate)</span></span></h3>
<p>Mutes this chat until a specified date</p>
<section>
@@ -327,7 +375,18 @@
<dd><a href="Chat.html#mute">Chat#mute</a></dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content, options)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<h3 id="pin"><span class="symbol-name">pin</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing boolean</span></span></h3>
<p>Pins this chat</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#pin">Chat#pin</a></dd>
<dt>Returns</dt>
<dd>
<p>New pin state. Could be false if the max number of pinned chats was reached.</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content[, options])</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<p>Send a message to this chat</p>
<section>
<h4>Parameters</h4>
@@ -362,7 +421,7 @@
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
<p>Yes</p>
</td>
<td>
</td>
@@ -417,6 +476,17 @@
<dt>Inherited from</dt>
<dd><a href="Chat.html#unmute">Chat#unmute</a></dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="unpin"><span class="symbol-name">unpin</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing boolean</span></span></h3>
<p>Unpins this chat</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Chat.html#unpin">Chat#unpin</a></dd>
<dt>Returns</dt>
<dd>
<p>New pin state</p>
</dd>
</dl>
</section>
</section>
</div>
@@ -427,7 +497,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: PrivateContact</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: PrivateContact</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -88,8 +88,15 @@
</div>
</div>
<div class="summary-callout">
<h2 class="summary-callout-heading">Method</h2>
<h2 class="summary-callout-heading">Methods</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="PrivateContact.html#getChat">getChat()</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="PrivateContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
@@ -99,8 +106,6 @@
</div>
<div class="summary-column">
</div>
<div class="summary-column">
</div>
</div>
</div>
</section>
@@ -199,8 +204,18 @@
<dd><a href="Contact.html#shortName">Contact#shortName</a></dd>
</dl>
</section>
<h2>Method</h2>
<h2>Methods</h2>
<section>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getChat"><span class="symbol-name">getChat</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Chat.html">Chat</a></span></span></h3>
<p>Returns the Chat that corresponds to this Contact.
Will return null when getting chat for currently logged in user.</p>
<dl class="dl-compact">
<dt>Inherited from</dt>
<dd><a href="Contact.html#getChat">Contact#getChat</a></dd>
<dt>Returns</dt>
<dd></dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing string</span></span></h3>
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
@@ -220,7 +235,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Class: Util</title>
<title>whatsapp-web.js 1.10.0 &raquo; Class: Util</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -50,7 +50,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Globals</title>
<title>whatsapp-web.js 1.10.0 &raquo; Globals</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -63,6 +63,22 @@
</div>
</div>
</div>
<div class="summary-callout">
<h2 class="summary-callout-heading">Abstract type</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="global.html#MessageSendOptions">MessageSendOptions</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
</div>
<div class="summary-column">
</div>
</div>
</div>
</section>
<section>
<h2>Properties</h2>
@@ -1008,6 +1024,130 @@
<dl class="dl-compact">
</dl>
</section>
<h2>Abstract type</h2>
<section>
<h3 id="MessageSendOptions"><span class="symbol-name">MessageSendOptions</span><small class="property-type">
&nbsp;Object</small></h3>
<p>Message options.</p>
<section>
<h4>Properties</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>linkPreview</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Show links preview</p>
<p>Defaults to <code>true</code>.</p>
</td>
</tr>
<tr>
<td>
<p>sendAudioAsVoice</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Send audio as voice message</p>
<p>Defaults to <code>false</code>.</p>
</td>
</tr>
<tr>
<td>
<p>caption</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Image or video caption</p>
</td>
</tr>
<tr>
<td>
<p>quotedMessageId</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Id of the message that is being quoted (or replied to)</p>
</td>
</tr>
<tr>
<td>
<p>mentions</p>
</td>
<td>
<p>Array of <a href="Contact.html">Contact</a></p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Contacts that are being mentioned in the message</p>
</td>
</tr>
<tr>
<td>
<p>sendSeen</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Mark the conversation as seen after sending the message</p>
<p>Defaults to <code>true</code>.</p>
</td>
</tr>
<tr>
<td>
<p>media</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Media to be sent</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
</section>
</section>
</div>
</div>
@@ -1017,7 +1157,7 @@
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Home</title>
<title>whatsapp-web.js 1.10.0 &raquo; Home</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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -27,18 +27,18 @@
<div id="jsdoc-main" role="main">
<header class="page-header">
<h1>
whatsapp-web.js 1.6.1
whatsapp-web.js 1.10.0
</h1>
</header>
<article>
<p><a href="https://www.npmjs.com/package/whatsapp-web.js"><img src="https://img.shields.io/npm/v/whatsapp-web.js.svg" alt="npm"></a> <a href="https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765"><img src="https://badges.depfu.com/badges/4a65a0de96ece65fdf39e294e0c8dcba/overview.svg" alt="Depfu"></a> <img src="https://img.shields.io/badge/WhatsApp_Web-2.2023.2-brightgreen.svg" alt="WhatsApp_Web 2.2023.2"> <a href="https://discord.gg/H7DqQs4"><img src="https://img.shields.io/discord/698610475432411196.svg?logo=discord" alt="Discord Chat"></a></p>
<p><a href="https://www.npmjs.com/package/whatsapp-web.js"><img src="https://img.shields.io/npm/v/whatsapp-web.js.svg" alt="npm"></a> <a href="https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765"><img src="https://badges.depfu.com/badges/4a65a0de96ece65fdf39e294e0c8dcba/overview.svg" alt="Depfu"></a> <img src="https://img.shields.io/badge/WhatsApp_Web-2.2043.8-brightgreen.svg" alt="WhatsApp_Web 2.2043.8"> <a href="https://discord.gg/H7DqQs4"><img src="https://img.shields.io/discord/698610475432411196.svg?logo=discord" alt="Discord Chat"></a></p>
<h1>whatsapp-web.js</h1>
<p>A WhatsApp API client that connects through the WhatsApp Web browser app</p>
<p>It uses Puppeteer to run a real instance of Whatsapp Web to avoid getting blocked.</p>
<p><strong>NOTE:</strong> 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.</p>
<h2>Installation</h2>
<p>The module is now available on npm! <code>npm i whatsapp-web.js</code></p>
<p>Please note that Node v8+ is required due to Puppeteer.</p>
<p>Please note that Node v10.18.1+ is required due to Puppeteer.</p>
<h2>Example usage</h2>
<pre class="prettyprint source lang-js"><code>const { Client } = require('whatsapp-web.js');
const client = new Client();
@@ -138,6 +138,10 @@ client.initialize();
<td>Mention users</td>
<td></td>
</tr>
<tr>
<td>Mute/unmute chats</td>
<td></td>
</tr>
<tr>
<td>Get contact info</td>
<td></td>
@@ -218,6 +222,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="BusinessContact.html#getChat" class="!symbol-index-name">BusinessContact#<wbr>getChat()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="BusinessContact.html#getProfilePicUrl" class="!symbol-index-name">BusinessContact#<wbr>getProfilePicUrl()</a>
</dt>
@@ -262,15 +271,15 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="BusinessContact.html#isWAContact" class="!symbol-index-name">BusinessContact#<wbr>isWAContact</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="BusinessContact.html#name" class="!symbol-index-name">BusinessContact#<wbr>name</a>
</dt>
@@ -337,20 +346,30 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Chat.html#getContact" class="!symbol-index-name">Chat#<wbr>getContact()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Chat.html#id" class="!symbol-index-name">Chat#<wbr>id</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Chat.html#isGroup" class="!symbol-index-name">Chat#<wbr>isGroup</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Chat.html#isMuted" class="!symbol-index-name">Chat#<wbr>isMuted</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Chat.html#isReadOnly" class="!symbol-index-name">Chat#<wbr>isReadOnly</a>
</dt>
@@ -361,18 +380,28 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Chat.html#muteExpiration" class="!symbol-index-name">Chat#<wbr>muteExpiration</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Chat.html#name" class="!symbol-index-name">Chat#<wbr>name</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Chat.html#sendMessage" class="!symbol-index-name">Chat#<wbr>sendMessage(content, options)</a>
<a href="Chat.html#pin" class="!symbol-index-name">Chat#<wbr>pin()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Chat.html#sendSeen" class="!symbol-index-name">Chat#<wbr>sendSeen()</a>
<a href="Chat.html#pinned" class="!symbol-index-name">Chat#<wbr>pinned</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Chat.html#sendMessage" class="!symbol-index-name">Chat#<wbr>sendMessage(content[, options])</a>
</dt>
<dd>
</dd>
@@ -380,6 +409,11 @@ client.initialize();
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Chat.html#sendSeen" class="!symbol-index-name">Chat#<wbr>sendSeen()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Chat.html#sendStateRecording" class="!symbol-index-name">Chat#<wbr>sendStateRecording()</a>
</dt>
@@ -405,6 +439,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Chat.html#unpin" class="!symbol-index-name">Chat#<wbr>unpin()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Chat.html#unreadCount" class="!symbol-index-name">Chat#<wbr>unreadCount</a>
</dt>
@@ -456,7 +495,7 @@ client.initialize();
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Client.html" class="!symbol-index-name">Client()</a>
<a href="Client.html" class="!symbol-index-name">Client(options)</a>
</dt>
<dd>
</dd>
@@ -520,10 +559,6 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Client.html#event:media_uploaded" class="!symbol-index-name">Client#<wbr>event:media_uploaded</a>
</dt>
@@ -534,6 +569,10 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Client.html#event:message_ack" class="!symbol-index-name">Client#<wbr>event:message_ack</a>
</dt>
@@ -584,15 +623,16 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#getInviteInfo" class="!symbol-index-name">Client#<wbr>getInviteInfo(inviteCode)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#getProfilePicUrl" class="!symbol-index-name">Client#<wbr>getProfilePicUrl(contactId)</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Client.html#getState" class="!symbol-index-name">Client#<wbr>getState()</a>
</dt>
@@ -603,13 +643,27 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#info" class="!symbol-index-name">Client#<wbr>info</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Client.html#initialize" class="!symbol-index-name">Client#<wbr>initialize()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#isRegisteredUser" class="!symbol-index-name">Client#<wbr>isRegisteredUser()</a>
<a href="Client.html#isRegisteredUser" class="!symbol-index-name">Client#<wbr>isRegisteredUser(id)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#logout" class="!symbol-index-name">Client#<wbr>logout()</a>
</dt>
<dd>
</dd>
@@ -618,13 +672,18 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#pinChat" class="!symbol-index-name">Client#<wbr>pinChat()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#resetState" class="!symbol-index-name">Client#<wbr>resetState()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#sendMessage" class="!symbol-index-name">Client#<wbr>sendMessage(chatId, content, options)</a>
<a href="Client.html#sendMessage" class="!symbol-index-name">Client#<wbr>sendMessage(chatId, content[, options])</a>
</dt>
<dd>
</dd>
@@ -638,6 +697,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#setDisplayName" class="!symbol-index-name">Client#<wbr>setDisplayName(displayName)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#setStatus" class="!symbol-index-name">Client#<wbr>setStatus(status)</a>
</dt>
@@ -653,6 +717,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#unpinChat" class="!symbol-index-name">Client#<wbr>unpinChat()</a>
</dt>
<dd>
</dd>
</dl>
</div>
</div>
@@ -670,7 +739,7 @@ client.initialize();
<dd>
</dd>
<dt class="symbol-index-name">
<a href="ClientInfo.html#me" class="!symbol-index-name">ClientInfo#<wbr>me</a>
<a href="ClientInfo.html#getBatteryStatus" class="!symbol-index-name">ClientInfo#<wbr>getBatteryStatus()</a>
</dt>
<dd>
</dd>
@@ -678,20 +747,25 @@ client.initialize();
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="ClientInfo.html#me" class="!symbol-index-name">ClientInfo#<wbr>me</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="ClientInfo.html#phone" class="!symbol-index-name">ClientInfo#<wbr>phone</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="ClientInfo.html#platform" class="!symbol-index-name">ClientInfo#<wbr>platform</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="ClientInfo.html#pushname" class="!symbol-index-name">ClientInfo#<wbr>pushname</a>
</dt>
@@ -713,6 +787,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Contact.html#getChat" class="!symbol-index-name">Contact#<wbr>getChat()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Contact.html#getProfilePicUrl" class="!symbol-index-name">Contact#<wbr>getProfilePicUrl()</a>
</dt>
@@ -728,15 +807,15 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Contact.html#isEnterprise" class="!symbol-index-name">Contact#<wbr>isEnterprise</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Contact.html#isGroup" class="!symbol-index-name">Contact#<wbr>isGroup</a>
</dt>
@@ -757,15 +836,15 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Contact.html#isWAContact" class="!symbol-index-name">Contact#<wbr>isWAContact</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Contact.html#name" class="!symbol-index-name">Contact#<wbr>name</a>
</dt>
@@ -901,16 +980,6 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#.getInviteInfo" class="!symbol-index-name">GroupChat.<wbr>getInviteInfo(inviteCode)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#.join" class="!symbol-index-name">GroupChat.<wbr>join(inviteCode)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#addParticipants" class="!symbol-index-name">GroupChat#<wbr>addParticipants(participantIds)</a>
</dt>
@@ -956,15 +1025,16 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="GroupChat.html#fetchMessages" class="!symbol-index-name">GroupChat#<wbr>fetchMessages(searchOptions)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#getContact" class="!symbol-index-name">GroupChat#<wbr>getContact()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#getInviteCode" class="!symbol-index-name">GroupChat#<wbr>getInviteCode()</a>
</dt>
@@ -975,11 +1045,20 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="GroupChat.html#isGroup" class="!symbol-index-name">GroupChat#<wbr>isGroup</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#isMuted" class="!symbol-index-name">GroupChat#<wbr>isMuted</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#isReadOnly" class="!symbol-index-name">GroupChat#<wbr>isReadOnly</a>
</dt>
@@ -995,6 +1074,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#muteExpiration" class="!symbol-index-name">GroupChat#<wbr>muteExpiration</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#name" class="!symbol-index-name">GroupChat#<wbr>name</a>
</dt>
@@ -1010,6 +1094,16 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#pin" class="!symbol-index-name">GroupChat#<wbr>pin()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#pinned" class="!symbol-index-name">GroupChat#<wbr>pinned</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#promoteParticipants" class="!symbol-index-name">GroupChat#<wbr>promoteParticipants(participantIds)</a>
</dt>
@@ -1020,17 +1114,17 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="GroupChat.html#revokeInvite" class="!symbol-index-name">GroupChat#<wbr>revokeInvite()</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="GroupChat.html#sendMessage" class="!symbol-index-name">GroupChat#<wbr>sendMessage(content, options)</a>
<a href="GroupChat.html#sendMessage" class="!symbol-index-name">GroupChat#<wbr>sendMessage(content[, options])</a>
</dt>
<dd>
</dd>
@@ -1054,6 +1148,16 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#setInfoAdminsOnly" class="!symbol-index-name">GroupChat#<wbr>setInfoAdminsOnly([adminsOnly])</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#setMessagesAdminsOnly" class="!symbol-index-name">GroupChat#<wbr>setMessagesAdminsOnly([adminsOnly])</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#setSubject" class="!symbol-index-name">GroupChat#<wbr>setSubject(subject)</a>
</dt>
@@ -1074,6 +1178,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#unpin" class="!symbol-index-name">GroupChat#<wbr>unpin()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="GroupChat.html#unreadCount" class="!symbol-index-name">GroupChat#<wbr>unreadCount</a>
</dt>
@@ -1227,6 +1336,50 @@ client.initialize();
</div>
</div>
</section>
<section>
<div class="symbol-index-content">
<h2 id="InterfaceController">InterfaceController</h2>
<div class="symbol-index-section">
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="InterfaceController.html" class="!symbol-index-name">InterfaceController()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="InterfaceController.html#closeRightDrawer" class="!symbol-index-name">InterfaceController#<wbr>closeRightDrawer()</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="InterfaceController.html#openChatDrawer" class="!symbol-index-name">InterfaceController#<wbr>openChatDrawer(chatId)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="InterfaceController.html#openChatWindow" class="!symbol-index-name">InterfaceController#<wbr>openChatWindow(chatId)</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="InterfaceController.html#openMessageDrawer" class="!symbol-index-name">InterfaceController#<wbr>openMessageDrawer(msgId)</a>
</dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
</section>
<section>
<div class="symbol-index-content">
<h2 id="Location">Location</h2>
@@ -1307,6 +1460,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#forward" class="!symbol-index-name">Message#<wbr>forward(chat)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#from" class="!symbol-index-name">Message#<wbr>from</a>
</dt>
@@ -1356,15 +1514,15 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Message.html#isForwarded" class="!symbol-index-name">Message#<wbr>isForwarded</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Message.html#location" class="!symbol-index-name">Message#<wbr>location</a>
</dt>
@@ -1381,7 +1539,7 @@ client.initialize();
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#reply" class="!symbol-index-name">Message#<wbr>reply(content, chatId, options)</a>
<a href="Message.html#reply" class="!symbol-index-name">Message#<wbr>reply(content[, chatId][, options])</a>
</dt>
<dd>
</dd>
@@ -1618,20 +1776,30 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="PrivateChat.html#getContact" class="!symbol-index-name">PrivateChat#<wbr>getContact()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateChat.html#id" class="!symbol-index-name">PrivateChat#<wbr>id</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="PrivateChat.html#isGroup" class="!symbol-index-name">PrivateChat#<wbr>isGroup</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateChat.html#isMuted" class="!symbol-index-name">PrivateChat#<wbr>isMuted</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateChat.html#isReadOnly" class="!symbol-index-name">PrivateChat#<wbr>isReadOnly</a>
</dt>
@@ -1642,18 +1810,28 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateChat.html#muteExpiration" class="!symbol-index-name">PrivateChat#<wbr>muteExpiration</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateChat.html#name" class="!symbol-index-name">PrivateChat#<wbr>name</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateChat.html#sendMessage" class="!symbol-index-name">PrivateChat#<wbr>sendMessage(content, options)</a>
<a href="PrivateChat.html#pin" class="!symbol-index-name">PrivateChat#<wbr>pin()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateChat.html#sendSeen" class="!symbol-index-name">PrivateChat#<wbr>sendSeen()</a>
<a href="PrivateChat.html#pinned" class="!symbol-index-name">PrivateChat#<wbr>pinned</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateChat.html#sendMessage" class="!symbol-index-name">PrivateChat#<wbr>sendMessage(content[, options])</a>
</dt>
<dd>
</dd>
@@ -1661,6 +1839,11 @@ client.initialize();
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="PrivateChat.html#sendSeen" class="!symbol-index-name">PrivateChat#<wbr>sendSeen()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateChat.html#sendStateRecording" class="!symbol-index-name">PrivateChat#<wbr>sendStateRecording()</a>
</dt>
@@ -1686,6 +1869,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateChat.html#unpin" class="!symbol-index-name">PrivateChat#<wbr>unpin()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateChat.html#unreadCount" class="!symbol-index-name">PrivateChat#<wbr>unreadCount</a>
</dt>
@@ -1707,6 +1895,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateContact.html#getChat" class="!symbol-index-name">PrivateContact#<wbr>getChat()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="PrivateContact.html#getProfilePicUrl" class="!symbol-index-name">PrivateContact#<wbr>getProfilePicUrl()</a>
</dt>
@@ -1722,15 +1915,15 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="PrivateContact.html#isEnterprise" class="!symbol-index-name">PrivateContact#<wbr>isEnterprise</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="PrivateContact.html#isGroup" class="!symbol-index-name">PrivateContact#<wbr>isGroup</a>
</dt>
@@ -1751,15 +1944,15 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="PrivateContact.html#isWAContact" class="!symbol-index-name">PrivateContact#<wbr>isWAContact</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="PrivateContact.html#name" class="!symbol-index-name">PrivateContact#<wbr>name</a>
</dt>
@@ -1931,7 +2124,7 @@ client.initialize();
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -6,7 +6,7 @@
treeNode.tree({
autoEscape: false,
closedIcon: '&#x21e2;',
data: [{"label":"<a href=\"global.html\">Globals</a>","id":"global","children":[]},{"label":"<a href=\"Base.html\">Base</a>","id":"Base","children":[]},{"label":"<a href=\"BusinessContact.html\">BusinessContact</a>","id":"BusinessContact","children":[]},{"label":"<a href=\"Chat.html\">Chat</a>","id":"Chat","children":[]},{"label":"<a href=\"Client.html\">Client</a>","id":"Client","children":[]},{"label":"<a href=\"ClientInfo.html\">ClientInfo</a>","id":"ClientInfo","children":[]},{"label":"<a href=\"Contact.html\">Contact</a>","id":"Contact","children":[]},{"label":"<a href=\"GroupChat.html\">GroupChat</a>","id":"GroupChat","children":[]},{"label":"<a href=\"GroupNotification.html\">GroupNotification</a>","id":"GroupNotification","children":[]},{"label":"<a href=\"Location.html\">Location</a>","id":"Location","children":[]},{"label":"<a href=\"Message.html\">Message</a>","id":"Message","children":[]},{"label":"<a href=\"MessageMedia.html\">MessageMedia</a>","id":"MessageMedia","children":[]},{"label":"<a href=\"PrivateChat.html\">PrivateChat</a>","id":"PrivateChat","children":[]},{"label":"<a href=\"PrivateContact.html\">PrivateContact</a>","id":"PrivateContact","children":[]},{"label":"<a href=\"Util.html\">Util</a>","id":"Util","children":[]}],
data: [{"label":"<a href=\"global.html\">Globals</a>","id":"global","children":[]},{"label":"<a href=\"Base.html\">Base</a>","id":"Base","children":[]},{"label":"<a href=\"BusinessContact.html\">BusinessContact</a>","id":"BusinessContact","children":[]},{"label":"<a href=\"Chat.html\">Chat</a>","id":"Chat","children":[]},{"label":"<a href=\"Client.html\">Client</a>","id":"Client","children":[]},{"label":"<a href=\"ClientInfo.html\">ClientInfo</a>","id":"ClientInfo","children":[]},{"label":"<a href=\"Contact.html\">Contact</a>","id":"Contact","children":[]},{"label":"<a href=\"GroupChat.html\">GroupChat</a>","id":"GroupChat","children":[]},{"label":"<a href=\"GroupNotification.html\">GroupNotification</a>","id":"GroupNotification","children":[]},{"label":"<a href=\"InterfaceController.html\">InterfaceController</a>","id":"InterfaceController","children":[]},{"label":"<a href=\"Location.html\">Location</a>","id":"Location","children":[]},{"label":"<a href=\"Message.html\">Message</a>","id":"Message","children":[]},{"label":"<a href=\"MessageMedia.html\">MessageMedia</a>","id":"MessageMedia","children":[]},{"label":"<a href=\"PrivateChat.html\">PrivateChat</a>","id":"PrivateChat","children":[]},{"label":"<a href=\"PrivateContact.html\">PrivateContact</a>","id":"PrivateContact","children":[]},{"label":"<a href=\"Util.html\">Util</a>","id":"Util","children":[]}],
openedIcon: ' &#x21e3;',
saveState: false,
useContextMenu: false

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/Base.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: structures/Base.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -60,7 +60,7 @@ module.exports &#x3D; Base;</code></pre>
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/BusinessContact.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: structures/BusinessContact.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -59,7 +59,7 @@ module.exports &#x3D; BusinessContact;</code></pre>
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/Chat.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: structures/Chat.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -77,7 +77,7 @@ class Chat extends Base {
this.unreadCount &#x3D; data.unreadCount;
/**
* Unix timestamp for when the chat was created
* Unix timestamp for when the last activity occurred
* @type {number}
*/
this.timestamp &#x3D; data.t;
@@ -88,13 +88,31 @@ class Chat extends Base {
*/
this.archived &#x3D; data.archive;
/**
* Indicates if the Chat is pinned
* @type {boolean}
*/
this.pinned &#x3D; !!data.pin;
/**
* Indicates if the chat is muted or not
* @type {number}
*/
this.isMuted &#x3D; data.isMuted;
/**
* Unix timestamp for when the mute expires
* @type {number}
*/
this.muteExpiration &#x3D; data.muteExpiration;
return super._patch(data);
}
/**
* Send a message to this chat
* @param {string|MessageMedia|Location} content
* @param {object} options
* @param {MessageSendOptions} [options]
* @returns {Promise&amp;lt;Message&gt;} Message that was just sent
*/
async sendMessage(content, options) {
@@ -143,6 +161,22 @@ class Chat extends Base {
return this.client.unarchiveChat(this.id._serialized);
}
/**
* Pins this chat
* @returns {Promise&amp;lt;boolean&gt;} New pin state. Could be false if the max number of pinned chats was reached.
*/
async pin() {
return this.client.pinChat(this.id._serialized);
}
/**
* Unpins this chat
* @returns {Promise&amp;lt;boolean&gt;} New pin state
*/
async unpin() {
return this.client.unpinChat(this.id._serialized);
}
/**
* Mutes this chat until a specified date
* @param {Date} unmuteDate Date at which the Chat will be unmuted
@@ -150,7 +184,7 @@ class Chat extends Base {
async mute(unmuteDate) {
return this.client.muteChat(this.id._serialized, unmuteDate);
}
/**
* Unmutes this chat
*/
@@ -165,29 +199,29 @@ class Chat extends Base {
* @returns {Promise&amp;lt;Array&amp;lt;Message&gt;&gt;}
*/
async fetchMessages(searchOptions) {
if(!searchOptions || !searchOptions.limit) {
searchOptions &#x3D; {limit: 50};
if (!searchOptions || !searchOptions.limit) {
searchOptions &#x3D; { limit: 50 };
}
let messages &#x3D; await this.client.pupPage.evaluate(async (chatId, limit) &#x3D;&gt; {
const msgFilter &#x3D; m &#x3D;&gt; !m.isNotification; // dont include notification messages
const chat &#x3D; window.Store.Chat.get(chatId);
let msgs &#x3D; chat.msgs.models.filter(msgFilter);
while(msgs.length &amp;lt; limit) {
while (msgs.length &amp;lt; limit) {
const loadedMessages &#x3D; await chat.loadEarlierMsgs();
if(!loadedMessages) break;
if (!loadedMessages) break;
msgs &#x3D; [...loadedMessages.filter(msgFilter), ...msgs];
}
msgs.sort((a, b) &#x3D;&gt; (a.t &gt; b.t) ? 1 : -1);
return msgs.splice(msgs.length - limit).map(m &#x3D;&gt; m.serialize());
return msgs.splice(msgs.length - limit).map(m &#x3D;&gt; window.WWebJS.getMessageModel(m));
}, this.id._serialized, searchOptions.limit);
return messages.map(m &#x3D;&gt; new Message(this.client, m));
}
/**
* Simulate typing in chat. This will last for 25 seconds.
*/
@@ -197,7 +231,7 @@ class Chat extends Base {
return true;
}, this.id._serialized);
}
/**
* Simulate recording audio in chat. This will last for 25 seconds.
*/
@@ -217,6 +251,14 @@ class Chat extends Base {
return true;
}, this.id._serialized);
}
/**
* Returns the Contact that corresponds to this Chat.
* @returns {Promise&amp;lt;Contact&gt;}
*/
async getContact() {
return await this.client.getContactById(this.id._serialized);
}
}
module.exports &#x3D; Chat;
@@ -230,7 +272,7 @@ module.exports &#x3D; Chat;
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/ClientInfo.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: structures/ClientInfo.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -77,6 +77,19 @@ class ClientInfo extends Base {
return super._patch(data);
}
/**
* Get current battery percentage and charging status for the attached device
* @returns {object} batteryStatus
* @returns {number} batteryStatus.battery - The current battery percentage
* @returns {boolean} batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)
*/
async getBatteryStatus() {
return await this.client.pupPage.evaluate(() &#x3D;&gt; {
const { battery, plugged } &#x3D; window.Store.Conn;
return { battery, plugged };
});
}
}
module.exports &#x3D; ClientInfo;</code></pre>
@@ -89,7 +102,7 @@ module.exports &#x3D; ClientInfo;</code></pre>
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/Contact.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: structures/Contact.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -136,6 +136,17 @@ class Contact extends Base {
async getProfilePicUrl() {
return await this.client.getProfilePicUrl(this.id._serialized);
}
/**
* Returns the Chat that corresponds to this Contact.
* Will return null when getting chat for currently logged in user.
* @returns {Promise&amp;lt;Chat&gt;}
*/
async getChat() {
if(this.isMe) return null;
return await this.client.getChatById(this.id._serialized);
}
}
@@ -149,7 +160,7 @@ module.exports &#x3D; Contact;</code></pre>
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/GroupChat.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: structures/GroupChat.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -66,6 +66,7 @@ class GroupChat extends Chat {
get description() {
return this.groupMetadata.desc;
}
/**
* Gets the group participants
* @type {array}
@@ -143,6 +144,38 @@ class GroupChat extends Chat {
}
}
/**
* Updates the group settings to only allow admins to send messages.
* @param {boolean} [adminsOnly&#x3D;true] Enable or disable this option
* @returns {Promise&amp;lt;boolean&gt;} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
*/
async setMessagesAdminsOnly(adminsOnly&#x3D;true) {
let res &#x3D; await this.client.pupPage.evaluate((chatId, value) &#x3D;&gt; {
return window.Store.Wap.setGroupProperty(chatId, &#x27;announcement&#x27;, value);
}, this.id._serialized, adminsOnly);
if (res.status !&#x3D;&#x3D; 200) return false;
this.groupMetadata.announce &#x3D; adminsOnly;
return true;
}
/**
* Updates the group settings to only allow admins to edit group info (title, description, photo).
* @param {boolean} [adminsOnly&#x3D;true] Enable or disable this option
* @returns {Promise&amp;lt;boolean&gt;} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
*/
async setInfoAdminsOnly(adminsOnly&#x3D;true) {
let res &#x3D; await this.client.pupPage.evaluate((chatId, value) &#x3D;&gt; {
return window.Store.Wap.setGroupProperty(chatId, &#x27;restrict&#x27;, value);
}, this.id._serialized, adminsOnly);
if (res.status !&#x3D;&#x3D; 200) return false;
this.groupMetadata.restrict &#x3D; adminsOnly;
return true;
}
/**
* Gets the invite code for a specific group
*/
@@ -167,27 +200,6 @@ class GroupChat extends Chat {
}, this.id._serialized);
}
/**
* Returns an object with information about the invite code&#x27;s group
* @param {string} inviteCode
* @returns {Promise&amp;lt;object&gt;} Invite information
*/
static async getInviteInfo(inviteCode) {
return await this.client.pupPage.evaluate(inviteCode &#x3D;&gt; {
return window.Store.Wap.groupInviteInfo(inviteCode);
}, inviteCode);
}
/**
* Joins a group with an invite code
* @param {string} inviteCode
*/
static async join(inviteCode) {
return await this.client.pupPage.evaluate(inviteCode &#x3D;&gt; {
return window.Store.Wap.acceptGroupInvite(inviteCode);
}, inviteCode);
}
/**
* Makes the bot leave the group
*/
@@ -209,7 +221,7 @@ module.exports &#x3D; GroupChat;</code></pre>
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/GroupNotification.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: structures/GroupNotification.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -143,7 +143,7 @@ module.exports &#x3D; GroupNotification;
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/Location.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: structures/Location.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -71,7 +71,7 @@ module.exports &#x3D; Location;</code></pre>
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/Message.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; 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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -44,7 +44,7 @@ class Message extends Base {
constructor(client, data) {
super(client);
if(data) this._patch(data);
if (data) this._patch(data);
}
_patch(data) {
@@ -95,7 +95,7 @@ class Message extends Base {
* ID for the Chat that this message was sent to, except if the message was sent by the current user.
* @type {string}
*/
this.from &#x3D; typeof (data.from) &#x3D;&#x3D;&#x3D; &#x27;object&#x27; ? data.from._serialized : data.from;
this.from &#x3D; (typeof (data.from) &#x3D;&#x3D;&#x3D; &#x27;object&#x27; &amp;amp;&amp;amp; data.from !&#x3D;&#x3D; null) ? data.from._serialized : data.from;
/**
* ID for who this message is for.
@@ -104,13 +104,13 @@ class Message extends Base {
* If the message is sent by another user, it will be the ID for the current user.
* @type {string}
*/
this.to &#x3D; typeof (data.to) &#x3D;&#x3D;&#x3D; &#x27;object&#x27; ? data.to._serialized : data.to;
this.to &#x3D; (typeof (data.to) &#x3D;&#x3D;&#x3D; &#x27;object&#x27; &amp;amp;&amp;amp; data.to !&#x3D;&#x3D; null) ? data.to._serialized : data.to;
/**
* If the message was sent to a group, this field will contain the user that sent the message.
* @type {string}
*/
this.author &#x3D; typeof (data.author) &#x3D;&#x3D;&#x3D; &#x27;object&#x27; ? data.author._serialized : data.author;
this.author &#x3D; (typeof (data.author) &#x3D;&#x3D;&#x3D; &#x27;object&#x27; &amp;amp;&amp;amp; data.author !&#x3D;&#x3D; null) ? data.author._serialized : data.author;
/**
* Indicates if the message was forwarded
@@ -129,7 +129,7 @@ class Message extends Base {
* @type {boolean}
*/
this.fromMe &#x3D; data.id.fromMe;
/**
* Indicates if the message was sent as a reply to another message.
* @type {boolean}
@@ -204,11 +204,11 @@ class Message extends Base {
* in the same Chat as the original message was sent.
*
* @param {string|MessageMedia|Location} content
* @param {?string} chatId
* @param {object} options
* @param {string} [chatId]
* @param {MessageSendOptions} [options]
* @returns {Promise&amp;lt;Message&gt;}
*/
async reply(content, chatId, options&#x3D;{}) {
async reply(content, chatId, options &#x3D; {}) {
if (!chatId) {
chatId &#x3D; this._getChatId();
}
@@ -221,6 +221,23 @@ class Message extends Base {
return this.client.sendMessage(chatId, content, options);
}
/**
* Forwards this message to another chat
*
* @param {string|Chat} chat Chat model or chat ID to which the message will be forwarded
* @returns {Promise}
*/
async forward(chat) {
const chatId &#x3D; typeof chat &#x3D;&#x3D;&#x3D; &#x27;string&#x27; ? chat : chat.id._serialized;
await this.client.pupPage.evaluate(async (msgId, chatId) &#x3D;&gt; {
let msg &#x3D; window.Store.Msg.get(msgId);
let chat &#x3D; window.Store.Chat.get(chatId);
return await chat.forwardMessages([msg]);
}, this.id._serialized, chatId);
}
/**
* Downloads and returns the attatched message media
* @returns {Promise&amp;lt;MessageMedia&gt;}
@@ -232,13 +249,13 @@ class Message extends Base {
const result &#x3D; await this.client.pupPage.evaluate(async (msgId) &#x3D;&gt; {
const msg &#x3D; window.Store.Msg.get(msgId);
if(msg.mediaData.mediaStage !&#x3D; &#x27;RESOLVED&#x27;) {
if (msg.mediaData.mediaStage !&#x3D; &#x27;RESOLVED&#x27;) {
// try to resolve media
await msg.downloadMedia(true, 1);
}
if(msg.mediaData.mediaStage.includes(&#x27;ERROR&#x27;)) {
if (msg.mediaData.mediaStage.includes(&#x27;ERROR&#x27;)) {
// media could not be downloaded
return undefined;
}
@@ -246,7 +263,7 @@ class Message extends Base {
const buffer &#x3D; await window.WWebJS.downloadBuffer(msg.clientUrl);
const decrypted &#x3D; await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
const data &#x3D; await window.WWebJS.readBlobAsync(decrypted._blob);
return {
data: data.split(&#x27;,&#x27;)[1],
mimetype: msg.mimetype,
@@ -255,7 +272,7 @@ class Message extends Base {
}, this.id._serialized);
if(!result) return undefined;
if (!result) return undefined;
return new MessageMedia(result.mimetype, result.data, result.filename);
}
@@ -267,10 +284,10 @@ class Message extends Base {
await this.client.pupPage.evaluate((msgId, everyone) &#x3D;&gt; {
let msg &#x3D; window.Store.Msg.get(msgId);
if(everyone &amp;amp;&amp;amp; msg.id.fromMe &amp;amp;&amp;amp; msg.canRevoke()) {
if (everyone &amp;amp;&amp;amp; msg.id.fromMe &amp;amp;&amp;amp; msg.canRevoke()) {
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], true);
}
}
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
}, this.id._serialized, everyone);
}
@@ -287,7 +304,7 @@ module.exports &#x3D; 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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/MessageMedia.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: structures/MessageMedia.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -86,7 +86,7 @@ module.exports &#x3D; MessageMedia;</code></pre>
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/PrivateChat.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: structures/PrivateChat.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -51,7 +51,7 @@ module.exports &#x3D; PrivateChat;</code></pre>
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: structures/PrivateContact.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: structures/PrivateContact.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -51,7 +51,7 @@ module.exports &#x3D; PrivateContact;</code></pre>
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: util/Constants.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: util/Constants.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -33,8 +33,6 @@
exports.WhatsWebURL &#x3D; &#x27;https://web.whatsapp.com/&#x27;;
exports.UserAgent &#x3D; &#x27;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36&#x27;;
exports.DefaultOptions &#x3D; {
puppeteer: {
headless: true,
@@ -45,7 +43,8 @@ exports.DefaultOptions &#x3D; {
qrRefreshIntervalMs: 20000,
authTimeoutMs: 45000,
takeoverOnConflict: false,
takeoverTimeoutMs: 0
takeoverTimeoutMs: 0,
userAgent: &#x27;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36&#x27;
};
/**
@@ -174,7 +173,7 @@ exports.MessageAck &#x3D; {
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -0,0 +1,109 @@
<!doctype html>
<html>
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.10.0 &raquo; Source: util/InterfaceController.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">
<link href="css/baseline.css" rel="stylesheet">
</head>
<body onload="prettyPrint()">
<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>10.<wbr>0</a>
</div>
</div>
</nav>
<div id="jsdoc-body-container">
<div id="jsdoc-content">
<div id="jsdoc-content-container">
<div id="jsdoc-banner" role="banner">
</div>
<div id="jsdoc-main" role="main">
<header class="page-header">
<h1>Source: util/InterfaceController.js</h1>
</header>
<article>
<pre class="prettyprint linenums"><code>&#x27;use strict&#x27;;
/**
* Interface Controller
*/
class InterfaceController {
constructor(props) {
this.pupPage &#x3D; props.pupPage;
}
/**
* Opens the Chat Window
* @param {string} chatId ID of the chat window that will be opened
*/
async openChatWindow(chatId) {
await this.pupPage.evaluate(async chatId &#x3D;&gt; {
let chat &#x3D; await window.Store.Chat.get(chatId);
await window.Store.Cmd.openChatAt(chat);
}, chatId);
}
/**
* Opens the Chat Drawer
* @param {string} chatId ID of the chat drawer that will be opened
*/
async openChatDrawer(chatId) {
await this.pupPage.evaluate(async chatId &#x3D;&gt; {
let chat &#x3D; await window.Store.Chat.get(chatId);
await window.Store.Cmd.chatInfoDrawer(chat);
}, chatId);
}
/**
* Opens the Message Drawer
* @param {string} msgId ID of the message drawer that will be opened
*/
async openMessageDrawer(msgId) {
await this.pupPage.evaluate(async msgId &#x3D;&gt; {
let msg &#x3D; await window.Store.Msg.get(msgId);
await window.Store.Cmd.msgInfoDrawer(msg);
}, msgId);
}
/**
* Closes the Right Drawer
*/
async closeRightDrawer() {
await this.pupPage.evaluate(async () &#x3D;&gt; {
await window.Store.Cmd.closeDrawerRight();
});
}
}
module.exports &#x3D; InterfaceController;</code></pre>
</article>
</div>
</div>
<nav id="jsdoc-toc-nav" role="navigation"></nav>
</div>
</div>
<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.4 on October 21, 2020.
</p>
</div>
</footer>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/tree.jquery.js"></script>
<script src="scripts/prettify.js"></script>
<script src="scripts/jsdoc-toc.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/scrollanchor.js"></script>
</body>
</html>

View File

@@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.4">
<meta charset="utf-8">
<title>whatsapp-web.js 1.6.1 &raquo; Source: util/Util.js</title>
<title>whatsapp-web.js 1.10.0 &raquo; Source: util/Util.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>6.<wbr>1</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>10.<wbr>0</a>
</div>
</div>
</nav>
@@ -73,7 +73,7 @@ module.exports &#x3D; Util;</code></pre>
<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.4 on June 4, 2020.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on October 21, 2020.
</p>
</div>
</footer>

View File

@@ -166,9 +166,12 @@ client.on('message', async msg => {
} else {
msg.reply('I can only delete my own messages');
}
} else if (msg.body === '!pin') {
const chat = await msg.getChat();
await chat.pin();
} else if (msg.body === '!archive') {
const chat = await msg.getChat();
chat.archive();
await chat.archive();
} else if (msg.body === '!mute') {
const chat = await msg.getChat();
// mute the chat for 20 seconds

761
index.d.ts vendored Normal file
View File

@@ -0,0 +1,761 @@
import { EventEmitter } from 'events'
import puppeteer = require('puppeteer')
declare namespace WAWebJS {
export class Client extends EventEmitter {
constructor(options: ClientOptions)
/** Current connection information */
public info: ClientInfo
/**Accepts an invitation to join a group */
acceptInvite(inviteCode: string): Promise<void>
/**Returns an object with information about the invite code's group */
getInviteInfo(inviteCode: string): Promise<object>
/** Enables and returns the archive state of the Chat */
archiveChat(chatId: string): Promise<boolean>
/** Pins the Chat and returns its new Pin state */
pinChat(chatId: string): Promise<boolean>
/** Unpins the Chat and returns its new Pin state */
unpinChat(chatId: string): Promise<boolean>
/**
* Create a new group
* @param name group title
* @param participants an array of Contacts or contact IDs to add to the group
*/
createGroup(name: string, participants: Contact[] | string[]): Promise<CreateGroupResult>
/** Closes the client */
destroy(): Promise<void>
/** Logs out the client, closing the current session */
logout(): Promise<void>
/** Get chat instance by ID */
getChatById(chatId: string): Promise<Chat>
/** Get all current chat instances */
getChats(): Promise<Chat[]>
/** Get contact instance by ID */
getContactById(contactId: string): Promise<Contact>
/** Get all current contact instances */
getContacts(): Promise<Contact[]>
/** Returns the contact ID's profile picture URL, if privacy settings allow it */
getProfilePicUrl(contactId: string): Promise<string>
/** Gets the current connection state for the client */
getState(): Promise<WAState>
/** Returns the version of WhatsApp Web currently being run */
getWWebVersion(): Promise<string>
/** Sets up events and requirements, kicks off authentication request */
initialize(): Promise<void>
/** Check if a given ID is registered in whatsapp */
isRegisteredUser(contactId: string): Promise<boolean>
/**
* Mutes the Chat until a specified date
* @param chatId ID of the chat that will be muted
* @param unmuteDate Date when the chat will be unmuted
*/
muteChat(chatId: string, unmuteDate: Date): Promise<void>
/** Force reset of connection state for the client */
resetState(): Promise<void>
/** Send a message to a specific chatId */
sendMessage(chatId: string, content: MessageContent, options?: MessageSendOptions): Promise<Message>
/** Marks the client as online */
sendPresenceAvailable(): Promise<void>
/** Mark as seen for the Chat */
sendSeen(chatId: string): Promise<boolean>
/**
* Sets the current user's status message
* @param status New status message
*/
setStatus(status: string): Promise<void>
/**
* Sets the current user's display name
* @param displayName New display name
*/
setDisplayName(displayName: string): Promise<void>
/** Changes and returns the archive state of the Chat */
unarchiveChat(chatId: string): Promise<boolean>
/** Unmutes the Chat */
unmuteChat(chatId: string): Promise<void>
/** Generic event */
on(event: string, listener: (...args: any) => void): this
/** Emitted when there has been an error while trying to restore an existing session */
on(event: 'auth_failure', listener: (message: string) => void): this
/** Emitted when authentication is successful */
on(event: 'authenticated', listener: (
/** Object containing session information. Can be used to restore the session */
session: ClientSession
) => void): this
/** Emitted when the battery percentage for the attached device changes */
on(event: 'change_battery', listener: (batteryInfo: BatteryInfo) => void): this
/** Emitted when the connection state changes */
on(event: 'change_state', listener: (
/** the new connection state */
state: WAState
) => void): this
/** Emitted when the client has been disconnected */
on(event: 'disconnected', listener: (
/** state that caused the disconnect */
reason: WAState
) => void): this
/** Emitted when a user joins the chat via invite link or is added by an admin */
on(event: 'group_join', listener: (
/** GroupNotification with more information about the action */
notification: GroupNotification
) => void): this
/** Emitted when a user leaves the chat or is removed by an admin */
on(event: 'group_leave', listener: (
/** GroupNotification with more information about the action */
notification: GroupNotification
) => void): this
/** Emitted when group settings are updated, such as subject, description or picture */
on(event: 'group_update', listener: (
/** GroupNotification with more information about the action */
notification: GroupNotification
) => void): this
/** Emitted when media has been uploaded for a message sent by the client */
on(event: 'media_uploaded', listener: (
/** The message with media that was uploaded */
message: Message
) => void): this
/** Emitted when a new message is received */
on(event: 'message', listener: (
/** The message that was received */
message: Message
) => void): this
/** Emitted when an ack event occurrs on message type */
on(event: 'message_ack', listener: (
/** The message that was affected */
message: Message,
/** The new ACK value */
ack: MessageAck
) => void): this
/** Emitted when a new message is created, which may include the current user's own messages */
on(event: 'message_create', listener: (
/** The message that was created */
message: Message
) => void): this
/** Emitted when a message is deleted for everyone in the chat */
on(event: 'message_revoke_everyone', listener: (
/** The message that was revoked, in its current state. It will not contain the original message's data */
message: Message,
/**The message that was revoked, before it was revoked.
* It will contain the message's original data.
* Note that due to the way this data is captured,
* it may be possible that this param will be undefined. */
revoked_msg?: Message | null
) => void): this
/** Emitted when a message is deleted by the current user */
on(event: 'message_revoke_me', listener: (
/** The message that was revoked */
message: Message
) => void): this
/** Emitted when the QR code is received */
on(event: 'qr', listener: (
/** qr code string
* @example ```1@9Q8tWf6bnezr8uVGwVCluyRuBOJ3tIglimzI5dHB0vQW2m4DQ0GMlCGf,f1/vGcW4Z3vBa1eDNl3tOjWqLL5DpYTI84DMVkYnQE8=,ZL7YnK2qdPN8vKo2ESxhOQ==``` */
qr: string
) => void): this
/** Emitted when the client has initialized and is ready to receive messages */
on(event: 'ready', listener: () => void): this
}
/** Current connection information */
export interface ClientInfo {
/** Current user ID */
me: ContactId
/** Information about the phone this client is connected to */
phone: ClientInfoPhone
/** Platform the phone is running on */
platform: string
/** Name configured to be shown in push notifications */
pushname: string
/** Get current battery percentage and charging status for the attached device */
getBatteryStatus: () => Promise<BatteryInfo>
}
/** Information about the phone this client is connected to */
export interface ClientInfoPhone {
/** WhatsApp Version running on the phone */
wa_version: string
/** OS Version running on the phone (iOS or Android version) */
os_version: string
/** Device manufacturer */
device_manufacturer: string
/** Device model */
device_model: string
/** OS build number */
os_build_number: string
}
/** Options for initializing the whatsapp client */
export interface ClientOptions {
/** Timeout for authentication selector in puppeteer
* @default 45000 */
authTimeoutMs?: number,
/** Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/ */
puppeteer?: puppeteer.LaunchOptions
/** Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
* @default 20000 */
qrRefreshIntervalMs?: number
/** Timeout for qr code selector in puppeteer
* @default 45000 */
qrTimeoutMs?: number,
/** Restart client with a new session (i.e. use null 'session' var) if authentication fails
* @default false */
restartOnAuthFail?: boolean
/** Whatsapp session to restore. If not set, will start a new session */
session?: ClientSession
/** If another whatsapp web session is detected (another browser), take over the session in the current browser
* @default false */
takeoverOnConflict?: boolean,
/** How much time to wait before taking over the session
* @default 0 */
takeoverTimeoutMs?: number,
/** User agent to use in puppeteer.
* @default 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36' */
userAgent?: string
}
/** Represents a Whatsapp client session */
export interface ClientSession {
WABrowserId: string,
WASecretBundle: string,
WAToken1: string,
WAToken2: string,
}
export interface BatteryInfo {
/** The current battery percentage */
battery: number,
/** Indicates if the phone is plugged in (true) or not (false) */
plugged: boolean,
}
export interface CreateGroupResult {
/** ID for the group that was just created */
gid: string,
/** participants that were not added to the group.
* Keys represent the ID for participant that was not added and its value is a status code
* that represents the reason why participant could not be added.
* This is usually 403 if the user's privacy settings don't allow you to add them to groups. */
missingParticipants: Record<string, string>
}
export interface GroupNotification {
/** ContactId for the user that produced the GroupNotification */
author: string,
/** Extra content */
body: string,
/** ID for the Chat that this groupNotification was sent for */
chatId: string,
/** ID that represents the groupNotification
* @todo create a more specific type for the id object */
id: object,
/** Contact IDs for the users that were affected by this GroupNotification */
recipientIds: string[],
/** Unix timestamp for when the groupNotification was created */
timestamp: number,
/** GroupNotification type */
type: GroupNotificationTypes,
/** Returns the Chat this GroupNotification was sent in */
getChat: () => Promise<Chat>,
/** Returns the Contact this GroupNotification was produced by */
getContact: () => Promise<Contact>,
/** Returns the Contacts affected by this GroupNotification */
getRecipients: () => Promise<Contact[]>,
/** Sends a message to the same chat this GroupNotification was produced in */
reply: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
}
/** whatsapp web url */
export const WhatsWebURL: string
/** default client options */
export const DefaultOptions: ClientOptions
/** Chat types */
export enum ChatTypes {
SOLO = 'solo',
GROUP = 'group',
UNKNOWN = 'unknown',
}
/** Events that can be emitted by the client */
export enum Events {
AUTHENTICATED = 'authenticated',
AUTHENTICATION_FAILURE = 'auth_failure',
READY = 'ready',
MESSAGE_RECEIVED = 'message',
MESSAGE_CREATE = 'message_create',
MESSAGE_REVOKED_EVERYONE = 'message_revoke_everyone',
MESSAGE_REVOKED_ME = 'message_revoke_me',
MESSAGE_ACK = 'message_ack',
MEDIA_UPLOADED = 'media_uploaded',
GROUP_JOIN = 'group_join',
GROUP_LEAVE = 'group_leave',
GROUP_UPDATE = 'group_update',
QR_RECEIVED = 'qr',
DISCONNECTED = 'disconnected',
STATE_CHANGED = 'change_state',
BATTERY_CHANGED = 'change_battery',
}
/** Group notification types */
export enum GroupNotificationTypes {
ADD = 'add',
INVITE = 'invite',
REMOVE = 'remove',
LEAVE = 'leave',
SUBJECT = 'subject',
DESCRIPTION = 'description',
PICTURE = 'picture',
ANNOUNCE = 'announce',
RESTRICT = 'restrict',
}
/** Message ACK */
export enum MessageAck {
ACK_ERROR = -1,
ACK_PENDING = 0,
ACK_SERVER = 1,
ACK_DEVICE = 2,
ACK_READ = 3,
ACK_PLAYED = 4,
}
/** Message types */
export enum MessageTypes {
TEXT = 'chat',
AUDIO = 'audio',
VOICE = 'ptt',
IMAGE = 'image',
VIDEO = 'video',
DOCUMENT = 'document',
STICKER = 'sticker',
LOCATION = 'location',
CONTACT_CARD = 'vcard',
CONTACT_CARD_MULTI = 'multi_vcard',
REVOKED = 'revoked',
UNKNOWN = 'unknown',
}
/** Client status */
export enum Status {
INITIALIZING = 0,
AUTHENTICATING = 1,
READY = 3,
}
/** WhatsApp state */
export enum WAState {
CONFLICT = 'CONFLICT',
CONNECTED = 'CONNECTED',
DEPRECATED_VERSION = 'DEPRECATED_VERSION',
OPENING = 'OPENING',
PAIRING = 'PAIRING',
PROXYBLOCK = 'PROXYBLOCK',
SMB_TOS_BLOCK = 'SMB_TOS_BLOCK',
TIMEOUT = 'TIMEOUT',
TOS_BLOCK = 'TOS_BLOCK',
UNLAUNCHED = 'UNLAUNCHED',
UNPAIRED = 'UNPAIRED',
UNPAIRED_IDLE = 'UNPAIRED_IDLE',
}
/**
* Represents a Message on WhatsApp
*
* @example
* {
* mediaKey: undefined,
* id: {
* fromMe: false,
* remote: `554199999999@c.us`,
* id: '1234567890ABCDEFGHIJ',
* _serialized: `false_554199999999@c.us_1234567890ABCDEFGHIJ`
* },
* ack: -1,
* hasMedia: false,
* body: 'Hello!',
* type: 'chat',
* timestamp: 1591482682,
* from: `554199999999@c.us`,
* to: `554188888888@c.us`,
* author: undefined,
* isForwarded: false,
* broadcast: false,
* fromMe: false,
* hasQuotedMsg: false,
* location: undefined,
* mentionedIds: []
* }
*/
export interface Message {
/** ACK status for the message */
ack: MessageAck,
/** If the message was sent to a group, this field will contain the user that sent the message. */
author?: string,
/** Message content */
body: string,
/** Indicates if the message was a broadcast */
broadcast: boolean,
/** ID for the Chat that this message was sent to, except if the message was sent by the current user */
from: string,
/** Indicates if the message was sent by the current user */
fromMe: boolean,
/** Indicates if the message has media available for download */
hasMedia: boolean,
/** Indicates if the message was sent as a reply to another message */
hasQuotedMsg: boolean,
/** ID that represents the message */
id: MessageId,
/** Indicates if the message was forwarded */
isForwarded: boolean,
/** Location information contained in the message, if the message is type "location" */
location: Location,
/** MediaKey that represents the sticker 'ID' */
mediaKey?: string,
/** Indicates the mentions in the message body. */
mentionedIds: [],
/** Unix timestamp for when the message was created */
timestamp: number,
/**
* ID for who this message is for.
* If the message is sent by the current user, it will be the Chat to which the message is being sent.
* If the message is sent by another user, it will be the ID for the current user.
*/
to: string,
/** Message type */
type: MessageTypes,
/** Deletes the message from the chat */
delete: (everyone?: boolean) => Promise<void>,
/** Downloads and returns the attatched message media */
downloadMedia: () => Promise<MessageMedia>,
/** Returns the Chat this message was sent in */
getChat: () => Promise<Chat>,
/** Returns the Contact this message was sent from */
getContact: () => Promise<Contact>,
/** Returns the Contacts mentioned in this message */
getMentions: () => Promise<Contact[]>,
/** Returns the quoted message, if any */
getQuotedMessage: () => Promise<Message>,
/**
* Sends a message as a reply to this message.
* If chatId is specified, it will be sent through the specified Chat.
* If not, it will send the message in the same Chat as the original message was sent.
*/
reply: (content: MessageContent, chatId?: string, options?: MessageSendOptions) => Promise<Message>,
/**
* Forwards this message to another chat
*/
forward: (chat: Chat | string) => Promise<void>,
}
/** ID that represents a message */
export interface MessageId {
fromMe: boolean,
remote: string,
id: string,
_serialized: string,
}
export interface Location {
description?: string | null,
latitude: string,
longitude: string,
}
/** Options for sending a message */
export interface MessageSendOptions {
/** Show links preview */
linkPreview?: boolean
/** Send audio as voice message */
sendAudioAsVoice?: boolean
/** Image or videos caption */
caption?: string
/** Id of the message that is being quoted (or replied to) */
quotedMessageId?: string
/** Contacts that are being mentioned in the message */
mentions?: Contact[]
/** Send 'seen' status */
sendSeen?: boolean
/** Media to be sent */
media?: MessageMedia
}
/** Media attached to a message */
export class MessageMedia {
/** MIME type of the attachment */
mimetype: string
/** Base64-encoded data of the file */
data: string
/** Document file name. Value can be null */
filename?: string | null
/**
* @param {string} mimetype MIME type of the attachment
* @param {string} data Base64-encoded data of the file
* @param {?string} filename Document file name. Value can be null
*/
constructor(mimetype: string, data: string, filename?: string | null)
/** Creates a MessageMedia instance from a local file path */
static fromFilePath: (filePath: string) => MessageMedia
}
export type MessageContent = string | MessageMedia | Location
/**
* Represents a Contact on WhatsApp
*
* @example
* {
* id: {
* server: 'c.us',
* user: '554199999999',
* _serialized: `554199999999@c.us`
* },
* number: '554199999999',
* isBusiness: false,
* isEnterprise: false,
* labels: [],
* name: undefined,
* pushname: 'John',
* sectionHeader: undefined,
* shortName: undefined,
* statusMute: false,
* type: 'in',
* verifiedLevel: undefined,
* verifiedName: undefined,
* isMe: false,
* isUser: true,
* isGroup: false,
* isWAContact: true,
* isMyContact: false
* }
*/
export interface Contact {
/** Contact's phone number */
number: string,
/** Indicates if the contact is a business contact */
isBusiness: boolean,
/** ID that represents the contact */
id: ContactId,
/** Indicates if the contact is an enterprise contact */
isEnterprise: boolean,
/** Indicates if the contact is a group contact */
isGroup: boolean,
/** Indicates if the contact is the current user's contact */
isMe: boolean,
/** Indicates if the number is saved in the current phone's contacts */
isMyContact: boolean
/** Indicates if the contact is a user contact */
isUser: boolean,
/** Indicates if the number is registered on WhatsApp */
isWAContact: boolean,
/** @todo verify labels type. didn't have any documentation */
labels?: string[],
/** The contact's name, as saved by the current user */
name?: string,
/** The name that the contact has configured to be shown publically */
pushname: string,
/** @todo missing documentation */
sectionHeader: string,
/** A shortened version of name */
shortName?: string,
/** Indicates if the status from the contact is muted */
statusMute: boolean,
/** @todo missing documentation */
type: string,
/** @todo missing documentation */
verifiedLevel?: undefined,
/** @todo missing documentation */
verifiedName?: undefined,
/** Returns the contact's profile picture URL, if privacy settings allow it */
getProfilePicUrl: () => Promise<string>,
/** Returns the Chat that corresponds to this Contact.
* Will return null when getting chat for currently logged in user.
*/
getChat: () => Promise<Chat>,
}
export interface ContactId {
server: string,
user: string,
_serialized: string,
}
export interface BusinessContact extends Contact {
/**
* The contact's business profile
* @todo add a more specific type for the object
*/
businessProfile: object
}
export interface PrivateContact extends Contact {
}
/**
* Represents a Chat on WhatsApp
*
* @example
* {
* id: {
* server: 'c.us',
* user: '554199999999',
* _serialized: `554199999999@c.us`
* },
* name: '+55 41 9999-9999',
* isGroup: false,
* isReadOnly: false,
* unreadCount: 6,
* timestamp: 1591484087,
* archived: false
* }
*/
export interface Chat {
/** Indicates if the Chat is archived */
archived: boolean,
/** ID that represents the chat */
id: ChatId,
/** Indicates if the Chat is a Group Chat */
isGroup: boolean,
/** Indicates if the Chat is readonly */
isReadOnly: boolean,
/** Indicates if the Chat is muted */
isMuted: boolean,
/** Unix timestamp for when the mute expires */
muteExpiration: number,
/** Title of the chat */
name: string,
/** Unix timestamp for when the last activity occurred */
timestamp: number,
/** Amount of messages unread */
unreadCount: number,
/** Archives this chat */
archive: () => Promise<void>,
/** Pins this chat and returns its new Pin state */
pin: () => Promise<boolean>,
/** Unpins this chat and returns its new Pin state */
unpin: () => Promise<boolean>,
/** Clears all messages from the chat */
clearMessages: () => Promise<boolean>,
/** Stops typing or recording in chat immediately. */
clearState: () => Promise<boolean>,
/** Deletes the chat */
delete: () => Promise<boolean>,
/** Loads chat messages, sorted from earliest to latest. */
fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>,
/** Mutes this chat until a specified date */
mute: (unmuteDate: Date) => Promise<void>,
/** Send a message to this chat */
sendMessage: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
/** Set the message as seen */
sendSeen: () => Promise<void>,
/** Simulate recording audio in chat. This will last for 25 seconds */
sendStateRecording: () => Promise<void>,
/** Simulate typing in chat. This will last for 25 seconds. */
sendStateTyping: () => Promise<void>,
/** un-archives this chat */
unarchive: () => Promise<void>,
/** Unmutes this chat */
unmute: () => Promise<void>,
/** Returns the Contact that corresponds to this Chat. */
getContact: () => Promise<Contact>,
}
export interface MessageSearchOptions {
/**
* The amount of messages to return.
* Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation.
* Set this to Infinity to load all messages.
* @default 50
*/
limit?: number
}
/**
* Id that represents the chat
*
* @example
* id: {
* server: 'c.us',
* user: '554199999999',
* _serialized: `554199999999@c.us`
* },
*/
export interface ChatId {
/**
* Whatsapp server domain
* @example `c.us`
*/
server: string,
/**
* User whatsapp number
* @example `554199999999`
*/
user: string,
/**
* Serialized id
* @example `554199999999@c.us`
*/
_serialized: string,
}
export interface PrivateChat extends Chat {
}
}
export = WAWebJS

View File

@@ -1,5 +1,7 @@
'use strict';
const Constants = require('./src/util/Constants');
module.exports = {
Client: require('./src/Client'),
@@ -15,5 +17,7 @@ module.exports = {
PrivateContact: require('./src/structures/PrivateContact'),
BusinessContact: require('./src/structures/BusinessContact'),
ClientInfo: require('./src/structures/ClientInfo'),
Location: require('./src/structures/Location')
};
Location: require('./src/structures/Location'),
...Constants
};

View File

@@ -1,10 +1,12 @@
{
"name": "whatsapp-web.js",
"version": "1.6.1",
"version": "1.10.0",
"description": "Library for interacting with the WhatsApp Web API ",
"main": "./index.js",
"typings": "./index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"shell": "node --experimental-repl-await ./shell.js",
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
},
"repository": {
@@ -29,7 +31,7 @@
"@pedroslopez/moduleraid": "^4.1.0",
"jsqr": "^1.3.1",
"mime": "^2.4.5",
"puppeteer": "^3.0.4"
"puppeteer": "^5.2.1"
},
"devDependencies": {
"eslint": "^6.8.0",

39
shell.js Normal file
View File

@@ -0,0 +1,39 @@
/**
* ==== wwebjs-shell ====
* Used for quickly testing library features
*
* Running `npm run shell` will start WhatsApp Web in headless mode
* and then drop you into Node REPL with `client` in its context.
*/
const repl = require('repl');
const fs = require('fs');
const { Client } = require('./index');
const SESSION_FILE_PATH = './session.json';
let sessionCfg;
if (fs.existsSync(SESSION_FILE_PATH)) {
sessionCfg = require(SESSION_FILE_PATH);
}
const client = new Client({
puppeteer: { headless: false },
session: sessionCfg
});
console.log('Initializing...');
client.initialize();
client.on('qr', () => {
console.log('Please scan the QR code on the browser.');
});
client.on('ready', () => {
const shell = repl.start('wwebjs> ');
shell.context.client = client;
shell.on('exit', async () => {
await client.destroy();
});
});

View File

@@ -6,7 +6,8 @@ const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
const jsQR = require('jsqr');
const Util = require('./util/Util');
const { WhatsWebURL, UserAgent, DefaultOptions, Events, WAState } = require('./util/Constants');
const InterfaceController = require('./util/InterfaceController');
const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./util/Constants');
const { ExposeStore, LoadUtils } = require('./util/Injected');
const ChatFactory = require('./factories/ChatFactory');
const ContactFactory = require('./factories/ContactFactory');
@@ -14,6 +15,21 @@ const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification
/**
* Starting point for interacting with the WhatsApp Web API
* @extends {EventEmitter}
* @param {object} options - Client options
* @param {number} options.authTimeoutMs - Timeout for authentication selector in puppeteer
* @param {object} options.puppeteer - Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/
* @param {number} options.qrRefreshIntervalMs - Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
* @param {number} options.qrTimeoutMs - Timeout for qr code selector in puppeteer
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null 'session' var) if authentication fails
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
* @param {string} options.session.WABrowserId
* @param {string} options.session.WASecretBundle
* @param {string} options.session.WAToken1
* @param {string} options.session.WAToken2
* @param {number} options.takeoverOnConflict - If another whatsapp web session is detected (another browser), take over the session in the current browser
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
* @param {string} options.userAgent - User agent to use in puppeteer
*
* @fires Client#qr
* @fires Client#authenticated
* @fires Client#auth_failure
@@ -47,11 +63,11 @@ class Client extends EventEmitter {
async initialize() {
const browser = await puppeteer.launch(this.options.puppeteer);
const page = (await browser.pages())[0];
page.setUserAgent(UserAgent);
page.setUserAgent(this.options.userAgent);
this.pupBrowser = browser;
this.pupPage = page;
if (this.options.session) {
await page.evaluateOnNewDocument(
session => {
@@ -67,8 +83,8 @@ class Client extends EventEmitter {
waitUntil: 'load',
timeout: 0,
});
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"]';
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
if (this.options.session) {
// Check if session restore was successfull
@@ -117,11 +133,12 @@ class Client extends EventEmitter {
this.emit(Events.QR_RECEIVED, qr);
};
getQrCode();
let retryInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
// Wait for code scan
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
clearInterval(retryInterval);
clearInterval(this._qrRefreshInterval);
this._qrRefreshInterval = undefined;
}
@@ -143,6 +160,10 @@ class Client extends EventEmitter {
* Emitted when authentication is successful
* @event Client#authenticated
* @param {object} session Object containing session information. Can be used to restore the session.
* @param {string} session.WABrowserId
* @param {string} session.WASecretBundle
* @param {string} session.WAToken1
* @param {string} session.WAToken2
*/
this.emit(Events.AUTHENTICATED, session);
@@ -153,10 +174,17 @@ class Client extends EventEmitter {
await page.evaluate(LoadUtils);
// Expose client info
/**
* Current connection information
* @type {ClientInfo}
*/
this.info = new ClientInfo(this, await page.evaluate(() => {
return window.Store.Conn.serialize();
}));
// Add InterfaceController
this.interface = new InterfaceController(this);
// Register events
await page.exposeFunction('onAddMessageEvent', msg => {
if (!msg.isNewMsg) return;
@@ -187,7 +215,7 @@ class Client extends EventEmitter {
}
return;
}
const message = new Message(this, msg);
/**
@@ -256,7 +284,7 @@ class Client extends EventEmitter {
await page.exposeFunction('onMessageAckEvent', (msg, ack) => {
const message = new Message(this, msg);
/**
* Emitted when an ack event occurrs on message type.
* @event Client#message_ack
@@ -270,7 +298,7 @@ class Client extends EventEmitter {
await page.exposeFunction('onMessageMediaUploadedEvent', (msg) => {
const message = new Message(this, msg);
/**
* Emitted when media has been uploaded for a message sent by the client.
* @event Client#media_uploaded
@@ -290,10 +318,10 @@ class Client extends EventEmitter {
const ACCEPTED_STATES = [WAState.CONNECTED, WAState.OPENING, WAState.PAIRING, WAState.TIMEOUT];
if(this.options.takeoverOnConflict) {
if (this.options.takeoverOnConflict) {
ACCEPTED_STATES.push(WAState.CONFLICT);
if(state === WAState.CONFLICT) {
if (state === WAState.CONFLICT) {
setTimeout(() => {
this.pupPage.evaluate(() => window.Store.AppState.takeover());
}, this.options.takeoverTimeoutMs);
@@ -314,7 +342,7 @@ class Client extends EventEmitter {
await page.exposeFunction('onBatteryStateChangedEvent', (state) => {
const { battery, plugged } = state;
if(battery === undefined) return;
if (battery === undefined) return;
/**
* Emitted when the battery percentage for the attached device changes
@@ -327,12 +355,12 @@ class Client extends EventEmitter {
});
await page.evaluate(() => {
window.Store.Msg.on('add', (msg) => { if(msg.isNewMsg) window.onAddMessageEvent(msg); });
window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(msg); });
window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(msg); });
window.Store.Msg.on('change:ack', (msg, ack) => { window.onMessageAckEvent(msg, ack); });
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if(msg.id.fromMe && !unsent) window.onMessageMediaUploadedEvent(msg); });
window.Store.Msg.on('remove', (msg) => { if(msg.isNewMsg) window.onRemoveMessageEvent(msg); });
window.Store.Msg.on('add', (msg) => { if (msg.isNewMsg) window.onAddMessageEvent(window.WWebJS.getMessageModel(msg)); });
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)); });
window.Store.Msg.on('change:ack', (msg,ack) => { window.onMessageAckEvent(window.WWebJS.getMessageModel(msg), ack); });
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if (msg.id.fromMe && !unsent) window.onMessageMediaUploadedEvent(window.WWebJS.getMessageModel(msg)); });
window.Store.Msg.on('remove', (msg) => { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); });
window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); });
window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); });
});
@@ -348,12 +376,24 @@ class Client extends EventEmitter {
* Closes the client
*/
async destroy() {
if (this._qrRefreshInterval) {
clearInterval(this._qrRefreshInterval);
}
await this.pupBrowser.close();
}
/**
* Logs out the client, closing the current session
*/
async logout() {
return await this.pupPage.evaluate(() => {
return window.Store.AppState.logout();
});
}
/**
* Returns the version of WhatsApp Web currently being run
* @returns Promise<string>
* @returns {Promise<string>}
*/
async getWWebVersion() {
return await this.pupPage.evaluate(() => {
@@ -375,11 +415,24 @@ class Client extends EventEmitter {
return result;
}
/**
* Message options.
* @typedef {Object} MessageSendOptions
* @property {boolean} [linkPreview=true] - Show links preview
* @property {boolean} [sendAudioAsVoice=false] - Send audio as voice message
* @property {string} [caption] - Image or video caption
* @property {string} [quotedMessageId] - Id of the message that is being quoted (or replied to)
* @property {Contact[]} [mentions] - Contacts that are being mentioned in the message
* @property {boolean} [sendSeen=true] - Mark the conversation as seen after sending the message
* @property {boolean} [media] - Media to be sent
*/
/**
* Send a message to a specific chatId
* @param {string} chatId
* @param {string|MessageMedia|Location} content
* @param {object} options
* @param {MessageSendOptions} [options] - Options used when sending the message
*
* @returns {Promise<Message>} Message that was just sent
*/
async sendMessage(chatId, content, options = {}) {
@@ -390,7 +443,7 @@ class Client extends EventEmitter {
quotedMessageId: options.quotedMessageId,
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : []
};
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
if (content instanceof MessageMedia) {
@@ -409,7 +462,7 @@ class Client extends EventEmitter {
const chatWid = window.Store.WidFactory.createWid(chatId);
const chat = await window.Store.Chat.find(chatWid);
if(sendSeen) {
if (sendSeen) {
window.WWebJS.sendSeen(chatId);
}
@@ -425,8 +478,8 @@ class Client extends EventEmitter {
* @returns {Promise<Array<Chat>>}
*/
async getChats() {
let chats = await this.pupPage.evaluate(() => {
return window.WWebJS.getChats();
let chats = await this.pupPage.evaluate(async () => {
return await window.WWebJS.getChats();
});
return chats.map(chat => ChatFactory.create(this, chat));
@@ -438,8 +491,8 @@ class Client extends EventEmitter {
* @returns {Promise<Chat>}
*/
async getChatById(chatId) {
let chat = await this.pupPage.evaluate(chatId => {
return window.WWebJS.getChat(chatId);
let chat = await this.pupPage.evaluate(async chatId => {
return await window.WWebJS.getChat(chatId);
}, chatId);
return ChatFactory.create(this, chat);
@@ -470,6 +523,17 @@ class Client extends EventEmitter {
return ContactFactory.create(this, contact);
}
/**
* Returns an object with information about the invite code's group
* @param {string} inviteCode
* @returns {Promise<object>} Invite information
*/
async getInviteInfo(inviteCode) {
return await this.pupPage.evaluate(inviteCode => {
return window.Store.Wap.groupInviteInfo(inviteCode);
}, inviteCode);
}
/**
* Accepts an invitation to join a group
* @param {string} inviteCode Invitation code
@@ -492,6 +556,17 @@ class Client extends EventEmitter {
}, status);
}
/**
* Sets the current user's display name.
* This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
* @param {string} displayName New display name
*/
async setDisplayName(displayName) {
await this.pupPage.evaluate(async displayName => {
return await window.Store.Wap.setPushname(displayName);
}, displayName);
}
/**
* Gets the current connection state for the client
* @returns {WAState}
@@ -535,6 +610,43 @@ class Client extends EventEmitter {
}, chatId);
}
/**
* Pins the Chat
* @returns {Promise<boolean>} New pin state. Could be false if the max number of pinned chats was reached.
*/
async pinChat(chatId) {
return this.pupPage.evaluate(async chatId => {
let chat = window.Store.Chat.get(chatId);
if (chat.pin) {
return true;
}
const MAX_PIN_COUNT = 3;
if (window.Store.Chat.models.length > MAX_PIN_COUNT) {
let maxPinned = window.Store.Chat.models[MAX_PIN_COUNT - 1].pin;
if (maxPinned) {
return false;
}
}
await window.Store.Cmd.pinChat(chat, true);
return true;
}, chatId);
}
/**
* Unpins the Chat
* @returns {Promise<boolean>} New pin state
*/
async unpinChat(chatId) {
return this.pupPage.evaluate(async chatId => {
let chat = window.Store.Chat.get(chatId);
if (!chat.pin) {
return false;
}
await window.Store.Cmd.pinChat(chat, false);
return false;
}, chatId);
}
/**
* Mutes the Chat until a specified date
* @param {string} chatId ID of the chat that will be muted
@@ -546,7 +658,7 @@ class Client extends EventEmitter {
await chat.mute.mute(timestamp, !0);
}, chatId, unmuteDate.getTime() / 1000);
}
/**
* Unmutes the Chat
* @param {string} chatId ID of the chat that will be unmuted
@@ -557,7 +669,7 @@ class Client extends EventEmitter {
await window.Store.Cmd.muteChat(chat, false);
}, chatId);
}
/**
* Returns the contact ID's profile picture URL, if privacy settings allow it
* @param {string} contactId the whatsapp user's ID
@@ -574,7 +686,7 @@ class Client extends EventEmitter {
/**
* Force reset of connection state for the client
*/
async resetState(){
async resetState() {
await this.pupPage.evaluate(() => {
window.Store.AppState.phoneWatchdog.shiftTimer.forceRunNow();
});
@@ -582,6 +694,7 @@ class Client extends EventEmitter {
/**
* Check if a given ID is registered in whatsapp
* @param {string} id the whatsapp user's ID
* @returns {Promise<Boolean>}
*/
async isRegisteredUser(id) {
@@ -600,18 +713,18 @@ class Client extends EventEmitter {
* @returns {Object.<string,string>} createRes.missingParticipants - participants that were not added to the group. Keys represent the ID for participant that was not added and its value is a status code that represents the reason why participant could not be added. This is usually 403 if the user's privacy settings don't allow you to add them to groups.
*/
async createGroup(name, participants) {
if(!Array.isArray(participants) || participants.length == 0) {
if (!Array.isArray(participants) || participants.length == 0) {
throw 'You need to add at least one other participant to the group';
}
if(participants.every(c => c instanceof Contact)) {
if (participants.every(c => c instanceof Contact)) {
participants = participants.map(c => c.id._serialized);
}
const createRes = await this.pupPage.evaluate(async (name, participantIds) => {
const res = await window.Store.Wap.createGroup(name, participantIds);
console.log(res);
if(!res.status === 200) {
if (!res.status === 200) {
throw 'An error occurred while creating the group!';
}
@@ -621,11 +734,11 @@ class Client extends EventEmitter {
const missingParticipants = createRes.participants.reduce(((missing, c) => {
const id = Object.keys(c)[0];
const statusCode = c[id].code;
if(statusCode != 200) return Object.assign(missing, {[id]: statusCode});
if (statusCode != 200) return Object.assign(missing, { [id]: statusCode });
return missing;
}), {});
return { gid: createRes.gid, missingParticipants};
return { gid: createRes.gid, missingParticipants };
}
}

View File

@@ -46,7 +46,7 @@ class Chat extends Base {
this.unreadCount = data.unreadCount;
/**
* Unix timestamp for when the chat was created
* Unix timestamp for when the last activity occurred
* @type {number}
*/
this.timestamp = data.t;
@@ -57,13 +57,31 @@ class Chat extends Base {
*/
this.archived = data.archive;
/**
* Indicates if the Chat is pinned
* @type {boolean}
*/
this.pinned = !!data.pin;
/**
* Indicates if the chat is muted or not
* @type {number}
*/
this.isMuted = data.isMuted;
/**
* Unix timestamp for when the mute expires
* @type {number}
*/
this.muteExpiration = data.muteExpiration;
return super._patch(data);
}
/**
* Send a message to this chat
* @param {string|MessageMedia|Location} content
* @param {object} options
* @param {MessageSendOptions} [options]
* @returns {Promise<Message>} Message that was just sent
*/
async sendMessage(content, options) {
@@ -112,6 +130,22 @@ class Chat extends Base {
return this.client.unarchiveChat(this.id._serialized);
}
/**
* Pins this chat
* @returns {Promise<boolean>} New pin state. Could be false if the max number of pinned chats was reached.
*/
async pin() {
return this.client.pinChat(this.id._serialized);
}
/**
* Unpins this chat
* @returns {Promise<boolean>} New pin state
*/
async unpin() {
return this.client.unpinChat(this.id._serialized);
}
/**
* Mutes this chat until a specified date
* @param {Date} unmuteDate Date at which the Chat will be unmuted
@@ -119,7 +153,7 @@ class Chat extends Base {
async mute(unmuteDate) {
return this.client.muteChat(this.id._serialized, unmuteDate);
}
/**
* Unmutes this chat
*/
@@ -134,29 +168,29 @@ class Chat extends Base {
* @returns {Promise<Array<Message>>}
*/
async fetchMessages(searchOptions) {
if(!searchOptions || !searchOptions.limit) {
searchOptions = {limit: 50};
if (!searchOptions || !searchOptions.limit) {
searchOptions = { limit: 50 };
}
let messages = await this.client.pupPage.evaluate(async (chatId, limit) => {
const msgFilter = m => !m.isNotification; // dont include notification messages
const chat = window.Store.Chat.get(chatId);
let msgs = chat.msgs.models.filter(msgFilter);
while(msgs.length < limit) {
while (msgs.length < limit) {
const loadedMessages = await chat.loadEarlierMsgs();
if(!loadedMessages) break;
if (!loadedMessages) break;
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
}
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
return msgs.splice(msgs.length - limit).map(m => m.serialize());
return msgs.splice(msgs.length - limit).map(m => window.WWebJS.getMessageModel(m));
}, this.id._serialized, searchOptions.limit);
return messages.map(m => new Message(this.client, m));
}
/**
* Simulate typing in chat. This will last for 25 seconds.
*/
@@ -166,7 +200,7 @@ class Chat extends Base {
return true;
}, this.id._serialized);
}
/**
* Simulate recording audio in chat. This will last for 25 seconds.
*/
@@ -186,6 +220,14 @@ class Chat extends Base {
return true;
}, this.id._serialized);
}
/**
* Returns the Contact that corresponds to this Chat.
* @returns {Promise<Contact>}
*/
async getContact() {
return await this.client.getContactById(this.id._serialized);
}
}
module.exports = Chat;

View File

@@ -46,6 +46,19 @@ class ClientInfo extends Base {
return super._patch(data);
}
/**
* Get current battery percentage and charging status for the attached device
* @returns {object} batteryStatus
* @returns {number} batteryStatus.battery - The current battery percentage
* @returns {boolean} batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)
*/
async getBatteryStatus() {
return await this.client.pupPage.evaluate(() => {
const { battery, plugged } = window.Store.Conn;
return { battery, plugged };
});
}
}
module.exports = ClientInfo;

View File

@@ -105,6 +105,17 @@ class Contact extends Base {
async getProfilePicUrl() {
return await this.client.getProfilePicUrl(this.id._serialized);
}
/**
* Returns the Chat that corresponds to this Contact.
* Will return null when getting chat for currently logged in user.
* @returns {Promise<Chat>}
*/
async getChat() {
if(this.isMe) return null;
return await this.client.getChatById(this.id._serialized);
}
}

View File

@@ -35,6 +35,7 @@ class GroupChat extends Chat {
get description() {
return this.groupMetadata.desc;
}
/**
* Gets the group participants
* @type {array}
@@ -112,6 +113,38 @@ class GroupChat extends Chat {
}
}
/**
* Updates the group settings to only allow admins to send messages.
* @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 setMessagesAdminsOnly(adminsOnly=true) {
let res = await this.client.pupPage.evaluate((chatId, value) => {
return window.Store.Wap.setGroupProperty(chatId, 'announcement', value);
}, this.id._serialized, adminsOnly);
if (res.status !== 200) return false;
this.groupMetadata.announce = adminsOnly;
return true;
}
/**
* Updates the group settings to only allow admins to edit group info (title, description, photo).
* @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 setInfoAdminsOnly(adminsOnly=true) {
let res = await this.client.pupPage.evaluate((chatId, value) => {
return window.Store.Wap.setGroupProperty(chatId, 'restrict', value);
}, this.id._serialized, adminsOnly);
if (res.status !== 200) return false;
this.groupMetadata.restrict = adminsOnly;
return true;
}
/**
* Gets the invite code for a specific group
*/
@@ -136,27 +169,6 @@ class GroupChat extends Chat {
}, this.id._serialized);
}
/**
* Returns an object with information about the invite code's group
* @param {string} inviteCode
* @returns {Promise<object>} Invite information
*/
static async getInviteInfo(inviteCode) {
return await this.client.pupPage.evaluate(inviteCode => {
return window.Store.Wap.groupInviteInfo(inviteCode);
}, inviteCode);
}
/**
* Joins a group with an invite code
* @param {string} inviteCode
*/
static async join(inviteCode) {
return await this.client.pupPage.evaluate(inviteCode => {
return window.Store.Wap.acceptGroupInvite(inviteCode);
}, inviteCode);
}
/**
* Makes the bot leave the group
*/

View File

@@ -13,7 +13,7 @@ class Message extends Base {
constructor(client, data) {
super(client);
if(data) this._patch(data);
if (data) this._patch(data);
}
_patch(data) {
@@ -64,7 +64,7 @@ class Message extends Base {
* ID for the Chat that this message was sent to, except if the message was sent by the current user.
* @type {string}
*/
this.from = typeof (data.from) === 'object' ? data.from._serialized : data.from;
this.from = (typeof (data.from) === 'object' && data.from !== null) ? data.from._serialized : data.from;
/**
* ID for who this message is for.
@@ -73,13 +73,13 @@ class Message extends Base {
* If the message is sent by another user, it will be the ID for the current user.
* @type {string}
*/
this.to = typeof (data.to) === 'object' ? data.to._serialized : data.to;
this.to = (typeof (data.to) === 'object' && data.to !== null) ? data.to._serialized : data.to;
/**
* If the message was sent to a group, this field will contain the user that sent the message.
* @type {string}
*/
this.author = typeof (data.author) === 'object' ? data.author._serialized : data.author;
this.author = (typeof (data.author) === 'object' && data.author !== null) ? data.author._serialized : data.author;
/**
* Indicates if the message was forwarded
@@ -98,7 +98,7 @@ class Message extends Base {
* @type {boolean}
*/
this.fromMe = data.id.fromMe;
/**
* Indicates if the message was sent as a reply to another message.
* @type {boolean}
@@ -173,11 +173,11 @@ class Message extends Base {
* in the same Chat as the original message was sent.
*
* @param {string|MessageMedia|Location} content
* @param {?string} chatId
* @param {object} options
* @param {string} [chatId]
* @param {MessageSendOptions} [options]
* @returns {Promise<Message>}
*/
async reply(content, chatId, options={}) {
async reply(content, chatId, options = {}) {
if (!chatId) {
chatId = this._getChatId();
}
@@ -190,6 +190,23 @@ class Message extends Base {
return this.client.sendMessage(chatId, content, options);
}
/**
* Forwards this message to another chat
*
* @param {string|Chat} chat Chat model or chat ID to which the message will be forwarded
* @returns {Promise}
*/
async forward(chat) {
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]);
}, this.id._serialized, chatId);
}
/**
* Downloads and returns the attatched message media
* @returns {Promise<MessageMedia>}
@@ -201,13 +218,13 @@ class Message extends Base {
const result = await this.client.pupPage.evaluate(async (msgId) => {
const msg = window.Store.Msg.get(msgId);
if(msg.mediaData.mediaStage != 'RESOLVED') {
if (msg.mediaData.mediaStage != 'RESOLVED') {
// try to resolve media
await msg.downloadMedia(true, 1);
}
if(msg.mediaData.mediaStage.includes('ERROR')) {
if (msg.mediaData.mediaStage.includes('ERROR')) {
// media could not be downloaded
return undefined;
}
@@ -215,7 +232,7 @@ class Message extends Base {
const buffer = await window.WWebJS.downloadBuffer(msg.clientUrl);
const decrypted = await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
const data = await window.WWebJS.readBlobAsync(decrypted._blob);
return {
data: data.split(',')[1],
mimetype: msg.mimetype,
@@ -224,7 +241,7 @@ class Message extends Base {
}, this.id._serialized);
if(!result) return undefined;
if (!result) return undefined;
return new MessageMedia(result.mimetype, result.data, result.filename);
}
@@ -236,10 +253,10 @@ class Message extends Base {
await this.client.pupPage.evaluate((msgId, everyone) => {
let msg = window.Store.Msg.get(msgId);
if(everyone && msg.id.fromMe && msg.canRevoke()) {
if (everyone && msg.id.fromMe && msg.canRevoke()) {
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], true);
}
}
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
}, this.id._serialized, everyone);
}

View File

@@ -2,8 +2,6 @@
exports.WhatsWebURL = 'https://web.whatsapp.com/';
exports.UserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36';
exports.DefaultOptions = {
puppeteer: {
headless: true,
@@ -14,7 +12,8 @@ exports.DefaultOptions = {
qrRefreshIntervalMs: 20000,
authTimeoutMs: 45000,
takeoverOnConflict: false,
takeoverTimeoutMs: 0
takeoverTimeoutMs: 0,
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36'
};
/**

View File

@@ -17,7 +17,7 @@ exports.ExposeStore = (moduleRaidStr) => {
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
window.Store.Invite = window.mR.findModule('sendJoinGroupViaInvite')[0];
window.Store.OpaqueData = window.mR.findModule('getOrCreateOpaqueDataForPath')[0];
window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
window.Store.MediaPrep = window.mR.findModule('MediaPrep')[0];
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
@@ -118,7 +118,7 @@ exports.LoadUtils = () => {
window.WWebJS.processMediaData = async (mediaInfo, forceVoice) => {
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
const mData = await window.Store.OpaqueData.default.createFromData(file, file.type);
const mData = await window.Store.OpaqueData.createFromData(file, file.type);
const mediaPrep = window.Store.MediaPrep.prepRawMedia(mData, {});
const mediaData = await mediaPrep.waitForPrep();
const mediaObject = window.Store.MediaObject.getOrCreateMediaObject(mediaData.filehash);
@@ -128,58 +128,74 @@ exports.LoadUtils = () => {
isGif: mediaData.isGif
});
if(forceVoice && mediaData.type === 'audio') {
if (forceVoice && mediaData.type === 'audio') {
mediaData.type = 'ptt';
}
if (!(mediaData.mediaBlob instanceof window.Store.OpaqueData.default)) {
mediaData.mediaBlob = await window.Store.OpaqueData.default.createFromData(mediaData.mediaBlob, mediaData.mediaBlob.type);
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 });
if (!uploadedMedia) {
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: uploadedMedia.mmsUrl,
directPath: uploadedMedia.directPath,
mediaKey: uploadedMedia.mediaKey,
mediaKeyTimestamp: uploadedMedia.mediaKeyTimestamp,
clientUrl: mediaEntry.mmsUrl,
directPath: mediaEntry.directPath,
mediaKey: mediaEntry.mediaKey,
mediaKeyTimestamp: mediaEntry.mediaKeyTimestamp,
filehash: mediaObject.filehash,
uploadhash: uploadedMedia.uploadHash,
uploadhash: mediaEntry.uploadHash,
size: mediaObject.size,
streamingSidecar: uploadedMedia.sidecar,
firstFrameSidecar: uploadedMedia.firstFrameSidecar
streamingSidecar: mediaEntry.sidecar,
firstFrameSidecar: mediaEntry.firstFrameSidecar
});
return mediaData;
};
window.WWebJS.getChatModel = chat => {
window.WWebJS.getMessageModel = message => {
const msg = message.serialize();
delete msg.pendingAckUpdate;
return msg;
};
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) {
await window.Store.GroupMetadata.update(chat.id._serialized);
res.groupMetadata = chat.groupMetadata.serialize();
}
return res;
};
window.WWebJS.getChat = chatId => {
window.WWebJS.getChat = async chatId => {
const chat = window.Store.Chat.get(chatId);
return window.WWebJS.getChatModel(chat);
return await window.WWebJS.getChatModel(chat);
};
window.WWebJS.getChats = () => {
window.WWebJS.getChats = async () => {
const chats = window.Store.Chat.models;
return chats.map(chat => window.WWebJS.getChatModel(chat));
const chatPromises = chats.map(chat => window.WWebJS.getChatModel(chat));
return await Promise.all(chatPromises);
};
window.WWebJS.getContactModel = contact => {
@@ -284,7 +300,7 @@ exports.LoadUtils = () => {
};
window.WWebJS.sendChatstate = async (state, chatId) => {
switch(state) {
switch (state) {
case 'typing':
await window.Store.Wap.sendChatstateComposing(chatId);
break;
@@ -297,10 +313,10 @@ exports.LoadUtils = () => {
default:
throw 'Invalid chatstate';
}
return true;
};
};
};
exports.MarkAllRead = () => {

View File

@@ -0,0 +1,56 @@
'use strict';
/**
* Interface Controller
*/
class InterfaceController {
constructor(props) {
this.pupPage = props.pupPage;
}
/**
* Opens the Chat Window
* @param {string} chatId ID of the chat window that will be opened
*/
async openChatWindow(chatId) {
await this.pupPage.evaluate(async chatId => {
let chat = await window.Store.Chat.get(chatId);
await window.Store.Cmd.openChatAt(chat);
}, chatId);
}
/**
* Opens the Chat Drawer
* @param {string} chatId ID of the chat drawer that will be opened
*/
async openChatDrawer(chatId) {
await this.pupPage.evaluate(async chatId => {
let chat = await window.Store.Chat.get(chatId);
await window.Store.Cmd.chatInfoDrawer(chat);
}, chatId);
}
/**
* Opens the Message Drawer
* @param {string} msgId ID of the message drawer that will be opened
*/
async openMessageDrawer(msgId) {
await this.pupPage.evaluate(async msgId => {
let msg = await window.Store.Msg.get(msgId);
await window.Store.Cmd.msgInfoDrawer(msg);
}, msgId);
}
/**
* Closes the Right Drawer
*/
async closeRightDrawer() {
await this.pupPage.evaluate(async () => {
await window.Store.Cmd.closeDrawerRight();
});
}
}
module.exports = InterfaceController;