mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
Compare commits
112 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93c8a2b05e | ||
|
|
70ca073f38 | ||
|
|
7e36cceaf0 | ||
|
|
303ea3ab6b | ||
|
|
4aae8b0f32 | ||
|
|
64803c2ba6 | ||
|
|
aa9e19a19e | ||
|
|
7631400de1 | ||
|
|
d7478de68a | ||
|
|
a9b2a1aab8 | ||
|
|
3b4632201d | ||
|
|
2200390d4c | ||
|
|
b1f7ff01bc | ||
|
|
21d565154a | ||
|
|
09cbee0e65 | ||
|
|
fa9f5aba38 | ||
|
|
c859ac39ce | ||
|
|
221d29736a | ||
|
|
078933f061 | ||
|
|
f149516d0d | ||
|
|
2f1c894a34 | ||
|
|
32e47d818a | ||
|
|
20aee44c3b | ||
|
|
bb2ef88e0a | ||
|
|
6878598a5d | ||
|
|
4e6a00dffe | ||
|
|
b93c7b4b76 | ||
|
|
a37ff69692 | ||
|
|
3705d1fea9 | ||
|
|
7950aae5d1 | ||
|
|
bdff59fb44 | ||
|
|
d05803074a | ||
|
|
d86c39de3c | ||
|
|
46ba9c5e9a | ||
|
|
d7a493e68a | ||
|
|
da95d927b9 | ||
|
|
92bc5e62ab | ||
|
|
73a3e28a4b | ||
|
|
4f376fc2fa | ||
|
|
a20c8ef8f8 | ||
|
|
2052e0479d | ||
|
|
c55db82f73 | ||
|
|
4e837b00f9 | ||
|
|
89a06b15a8 | ||
|
|
55247576da | ||
|
|
8a1f6f0648 | ||
|
|
254ca884aa | ||
|
|
3958105926 | ||
|
|
818bf48e5d | ||
|
|
d71544566c | ||
|
|
187aa50131 | ||
|
|
e11e00d938 | ||
|
|
d9dd89ccaf | ||
|
|
3aa0e4f7b3 | ||
|
|
d82cf448d9 | ||
|
|
3f576c990c | ||
|
|
d44a525b02 | ||
|
|
d8217029ba | ||
|
|
2a7337b142 | ||
|
|
1fcfaa0362 | ||
|
|
c434e04e41 | ||
|
|
97a1d399ee | ||
|
|
dbf9bf2158 | ||
|
|
353af130d0 | ||
|
|
06107af67d | ||
|
|
4338664590 | ||
|
|
95facee885 | ||
|
|
1f38b762ed | ||
|
|
b60029ed09 | ||
|
|
ab415ff9be | ||
|
|
7beeff4901 | ||
|
|
022c87f3c7 | ||
|
|
e527fe74fd | ||
|
|
7597608f9d | ||
|
|
be018e651d | ||
|
|
64189d2d67 | ||
|
|
38e31a07cf | ||
|
|
40cec51956 | ||
|
|
d9ccb6f276 | ||
|
|
628b6e4d49 | ||
|
|
8e56aef3ce | ||
|
|
cd774bef17 | ||
|
|
9c2592e164 | ||
|
|
ae6d61bda9 | ||
|
|
98acd2312d | ||
|
|
62c7c15f44 | ||
|
|
e12c53f6ce | ||
|
|
811008da4b | ||
|
|
863284c9d1 | ||
|
|
ec95483518 | ||
|
|
ff2eb95751 | ||
|
|
1b5e9d2392 | ||
|
|
340e9764fe | ||
|
|
084525ddfa | ||
|
|
3398501ee6 | ||
|
|
cdede835af | ||
|
|
449d0f01d8 | ||
|
|
4ed9312eb7 | ||
|
|
76deaad2fd | ||
|
|
284903dce4 | ||
|
|
a03cc41d22 | ||
|
|
04d2308bbc | ||
|
|
dc9b7e5f3d | ||
|
|
cc7a729223 | ||
|
|
2ec46f674a | ||
|
|
22993fc23d | ||
|
|
cd52075447 | ||
|
|
54a07fa22f | ||
|
|
1d49f74ab4 | ||
|
|
ea4dfb17f3 | ||
|
|
efa6cf98d2 | ||
|
|
9d715735ed |
2
.env.example
Normal file
2
.env.example
Normal file
@@ -0,0 +1,2 @@
|
||||
WWEBJS_TEST_SESSION_PATH=test_session.json
|
||||
WWEBJS_TEST_REMOTE_ID=XXXXXXXXXX@c.us
|
||||
@@ -5,7 +5,7 @@
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"extends": ["eslint:recommended", "plugin:mocha/recommended"],
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
@@ -13,6 +13,7 @@
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020
|
||||
},
|
||||
"plugins": ["mocha"],
|
||||
"ignorePatterns": ["docs"],
|
||||
"rules": {
|
||||
"indent": [
|
||||
|
||||
3
.github/ISSUE_TEMPLATE/bug_report.md
vendored
3
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -34,5 +34,8 @@ If applicable, add code snippets to help explain your problem.
|
||||
- npm or yarn version (`npm -v`):
|
||||
- whatsapp-web.js version:
|
||||
|
||||
**Other**
|
||||
- Operating system (the one running node) [Linux / MacOS / Windows]:
|
||||
- Operating system version (ex. Windows 10):
|
||||
### Additional context
|
||||
Add any other context about the problem here.
|
||||
|
||||
7
.github/dependabot.yml
vendored
Normal file
7
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
open-pull-requests-limit: 10
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
39
.github/workflows/update.yml
vendored
Normal file
39
.github/workflows/update.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
name: Update
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0/15 * * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./tools/version-checker
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install node v16
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- name: Run Updater
|
||||
run: ./update-version
|
||||
- name: Store WA Version
|
||||
run: echo WA_VERSION=`cat ./.version` >> $GITHUB_ENV
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
with:
|
||||
branch: auto-wa-web-update/patch
|
||||
delete-branch: true
|
||||
commit-message: Update supported WhatsApp Web version to v${{ env.WA_VERSION }}
|
||||
title: Update WhatsApp Web Version (${{ env.WA_VERSION }})
|
||||
body: |
|
||||
A new version of WhatsApp Web has been detected!
|
||||
|
||||
Tests should be run against this new version before merging.
|
||||
labels: WhatsApp Change
|
||||
reviewers: pedroslopez
|
||||
@@ -12,3 +12,6 @@ yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
*session.json
|
||||
.env
|
||||
tools/
|
||||
tests/
|
||||
|
||||
55
README.md
55
README.md
@@ -1,4 +1,4 @@
|
||||
[](https://www.npmjs.com/package/whatsapp-web.js) [](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765)  [](https://discord.gg/H7DqQs4)
|
||||
[](https://www.npmjs.com/package/whatsapp-web.js) [](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765)  [](https://discord.gg/H7DqQs4)
|
||||
|
||||
# whatsapp-web.js
|
||||
A WhatsApp API client that connects through the WhatsApp Web browser app
|
||||
@@ -7,16 +7,24 @@ It uses Puppeteer to run a real instance of Whatsapp Web to avoid getting blocke
|
||||
|
||||
**NOTE:** I can't guarantee you will not be blocked by using this method, although it has worked for me. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [Guide / Getting Started](https://wwebjs.dev/guide) _(work in progress)_
|
||||
* [Reference documentation](https://docs.wwebjs.dev/)
|
||||
* [GitHub](https://github.com/pedroslopez/whatsapp-web.js)
|
||||
* [npm](https://npmjs.org/package/whatsapp-web.js)
|
||||
|
||||
## Installation
|
||||
|
||||
The module is now available on npm! `npm i whatsapp-web.js`
|
||||
|
||||
Please note that Node v14+ is required.
|
||||
Please note that Node v12+ is required.
|
||||
|
||||
## Example usage
|
||||
|
||||
```js
|
||||
const { Client } = require('whatsapp-web.js');
|
||||
|
||||
const client = new Client();
|
||||
|
||||
client.on('qr', (qr) => {
|
||||
@@ -39,6 +47,39 @@ client.initialize();
|
||||
|
||||
Take a look at [example.js](https://github.com/pedroslopez/whatsapp-web.js/blob/master/example.js) for another example with more use cases.
|
||||
|
||||
## Remote Access
|
||||
|
||||
You could also connect to any previously existing browser instance:
|
||||
|
||||
```js
|
||||
const client = new Client({
|
||||
puppeteer: {
|
||||
browserWSEndpoint: `ws://localhost:3000`
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Docker
|
||||
|
||||
1) Installing a browser using browserless:
|
||||
|
||||
```
|
||||
docker run \
|
||||
--rm \
|
||||
-p 3000:3000 \
|
||||
-e "MAX_CONCURRENT_SESSIONS=1" \
|
||||
browserless/chrome:latest
|
||||
```
|
||||
|
||||
Reference: https://docs.browserless.io/docs/docker-quickstart.html
|
||||
|
||||
### Remote Debugging
|
||||
|
||||
2) Running a browser with websocket remote debugging enabled:
|
||||
> chrome.exe --remote-debugging-port=9222
|
||||
|
||||
After that check the following webpage and check http://127.0.0.1:9220/json and get the **webSocketDebuggerUrl**
|
||||
|
||||
## Supported features
|
||||
|
||||
| Feature | Status |
|
||||
@@ -46,11 +87,13 @@ Take a look at [example.js](https://github.com/pedroslopez/whatsapp-web.js/blob/
|
||||
| Send messages | ✅ |
|
||||
| Receive messages | ✅ |
|
||||
| Send media (images/audio/documents) | ✅ |
|
||||
| Send media (video) | ✅ [(requires google chrome)](https://waguide.pedroslopez.me/features/handling-attachments#caveat-for-sending-videos-and-gifs) |
|
||||
| Send media (video) | ✅ [(requires google chrome)](https://wwebjs.dev/guide/handling-attachments.html#caveat-for-sending-videos-and-gifs) |
|
||||
| Send stickers | ✅ |
|
||||
| Receive media (images/audio/video/documents) | ✅ |
|
||||
| Send contact cards | ✅ |
|
||||
| Send location | ✅ |
|
||||
| Send buttons | ✅ |
|
||||
| Send lists | ✅ (business accounts not supported) |
|
||||
| Receive location | ✅ |
|
||||
| Message replies | ✅ |
|
||||
| Join groups by invite | ✅ |
|
||||
@@ -69,12 +112,6 @@ Take a look at [example.js](https://github.com/pedroslopez/whatsapp-web.js/blob/
|
||||
|
||||
Something missing? Make an issue and let us know!
|
||||
|
||||
## Links
|
||||
|
||||
* [Reference](https://pedroslopez.me/whatsapp-web.js)
|
||||
* [Guide](https://waguide.pedroslopez.me/) _(work in progress)_
|
||||
* [GitHub](https://github.com/pedroslopez/whatsapp-web.js)
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests are welcome! If you see something you'd like to add, please do. For drastic changes, please open an issue first.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: Base</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: BusinessContact</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -104,11 +104,17 @@
|
||||
<dt><a href="BusinessContact.html#getAbout">getAbout()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<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#getChat">getChat()</a></dt>
|
||||
<dt><a href="BusinessContact.html#getCountryCode">getCountryCode()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#getFormattedNumber">getFormattedNumber()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
@@ -263,6 +269,24 @@
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getCountryCode"><span class="symbol-name">getCountryCode</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's countrycode, (1541859685@c.us) => (1)</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getCountryCode">Contact#getCountryCode</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getFormattedNumber"><span class="symbol-name">getFormattedNumber</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901)</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getFormattedNumber">Contact#getFormattedNumber</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> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||
<dl class="dl-compact">
|
||||
@@ -290,7 +314,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
249
docs/Buttons.html
Normal file
249
docs/Buttons.html
Normal file
@@ -0,0 +1,249 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.5 » Class: Buttons</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>15.<wbr>5</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">Buttons</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_Buttons.js.html#source-line-23">structures/<wbr>Buttons.<wbr>js:23</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Message type buttons</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Properties</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Buttons.html#body">body</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Buttons.html#buttons">buttons</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Buttons.html#footer">footer</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Buttons.html#title">title</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</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="Buttons.html#_format">_format(buttons)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="Buttons">new <span class="symbol-name">Buttons</span><span class="signature"><span class="signature-params">(body, buttons, title, footer)</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>body</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>buttons</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>See <a href="global.html#ButtonSpec"><code>ButtonSpec</code></a></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>title</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>footer</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="body"><span class="symbol-name">body</span><small class="property-type">
|
||||
(string or <a href="MessageMedia.html">MessageMedia</a>)</small></h3>
|
||||
<p>Message body</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="buttons"><span class="symbol-name">buttons</span><small class="property-type">
|
||||
Array of <a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></small></h3>
|
||||
<p>buttons of message</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="footer"><span class="symbol-name">footer</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>footer of message</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="title"><span class="symbol-name">title</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>title of message</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Method</h2>
|
||||
<section>
|
||||
<h3 id="_format"><span class="symbol-name">_format</span><span class="signature"><span class="signature-params">(buttons)</span> → <span class="signature-returns"> Array of <a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></span></span></h3>
|
||||
<p>Creates button array from simple array</p>
|
||||
<section>
|
||||
<h4>
|
||||
Example
|
||||
</h4>
|
||||
<div>
|
||||
<pre class="prettyprint"><code>Input: [{id:'customId',body:'button1'},{body:'button2'},{body:'button3'},{body:'button4'}]
|
||||
Returns: [{ buttonId:'customId',buttonText:{'displayText':'button1'},type: 1 },{buttonId:'n3XKsL',buttonText:{'displayText':'button2'},type:1},{buttonId:'NDJk0a',buttonText:{'displayText':'button3'},type:1}]</code></pre>
|
||||
</div>
|
||||
</section>
|
||||
<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>buttons</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Array of <a href="global.html#ButtonSpec">ButtonSpec</a></p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Array of <a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></code> </p>
|
||||
</dd>
|
||||
</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.7 on February 6, 2022.
|
||||
</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>
|
||||
1
docs/CNAME
Normal file
1
docs/CNAME
Normal file
@@ -0,0 +1 @@
|
||||
docs.wwebjs.dev
|
||||
159
docs/Call.html
Normal file
159
docs/Call.html
Normal file
@@ -0,0 +1,159 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.5 » Class: Call</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>15.<wbr>5</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">Call</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_Call.js.html#source-line-9">structures/<wbr>Call.<wbr>js:9</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Call on WhatsApp</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Properties</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Call.html#canHandleLocally">canHandleLocally</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Call.html#from">from</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Call.html#fromMe">fromMe</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Call.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Call.html#isGroup">isGroup</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Call.html#isVideo">isVideo</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Call.html#participants">participants</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Call.html#timestamp">timestamp</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Call.html#webClientShouldHandle">webClientShouldHandle</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="Call">new <span class="symbol-name">Call</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
<dt>Extends</dt>
|
||||
<dd><a href="Base.html">Base</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="canHandleLocally"><span class="symbol-name">canHandleLocally</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the call can be handled in waweb</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="from"><span class="symbol-name">from</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>From</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="fromMe"><span class="symbol-name">fromMe</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the call was sent by the current user</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Call ID</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isGroup"><span class="symbol-name">isGroup</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Is Group</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isVideo"><span class="symbol-name">isVideo</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Is video</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="participants"><span class="symbol-name">participants</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>Object with participants</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Unix timestamp for when the call was created</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="webClientShouldHandle"><span class="symbol-name">webClientShouldHandle</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the call Should be handled in waweb</p>
|
||||
<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.7 on February 6, 2022.
|
||||
</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>
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: Chat</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -176,7 +176,7 @@
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isMuted"><span class="symbol-name">isMuted</span><small class="property-type">
|
||||
number</small></h3>
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the chat is muted or not</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
@@ -224,7 +224,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Boolean</code> <p>result</p>
|
||||
<p><code>Promise containing Boolean</code>
|
||||
<p>result</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -239,7 +240,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Boolean</code> <p>result</p>
|
||||
<p><code>Promise containing Boolean</code>
|
||||
<p>result</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -292,8 +294,7 @@
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>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.</p>
|
||||
<p>Defaults to <code>50</code>.</p>
|
||||
<p>The amount of messages to return. If no limit is specified, the available messages will be returned. 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.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -334,7 +335,7 @@
|
||||
</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>
|
||||
<p>Mutes this chat forever, unless a date is specified</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
@@ -358,7 +359,8 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Date at which the Chat will be unmuted</p>
|
||||
<p>Date at which the Chat will be unmuted, leave as is to mute forever</p>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -372,7 +374,8 @@
|
||||
<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><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>
|
||||
@@ -423,7 +426,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="Message.html">Message</a></code> <p>Message that was just sent</p>
|
||||
<p><code>Promise containing <a href="Message.html">Message</a></code>
|
||||
<p>Message that was just sent</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -433,7 +437,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Boolean</code> <p>result</p>
|
||||
<p><code>Promise containing Boolean</code>
|
||||
<p>result</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -463,7 +468,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing boolean</code> <p>New pin state</p>
|
||||
<p><code>Promise containing boolean</code>
|
||||
<p>New pin state</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -477,7 +483,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
324
docs/Client.html
324
docs/Client.html
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: Client</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</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-52">Client.<wbr>js:52</a></p>
|
||||
<p class="source-link">Source: <a href="Client.js.html#source-line-53">Client.<wbr>js:53</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Starting point for interacting with the WhatsApp Web API</p>
|
||||
</div>
|
||||
@@ -70,6 +70,9 @@
|
||||
<dt><a href="Client.html#destroy">destroy()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#getBlockedContacts">getBlockedContacts()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#getChatById">getChatById(chatId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -88,13 +91,19 @@
|
||||
<dt><a href="Client.html#getContacts">getContacts()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#getInviteInfo">getInviteInfo(inviteCode)</a></dt>
|
||||
<dt><a href="Client.html#getCountryCode">getCountryCode(number)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Client.html#getFormattedNumber">getFormattedNumber(number)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#getInviteInfo">getInviteInfo(inviteCode)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#getLabelById">getLabelById(labelId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -128,13 +137,13 @@
|
||||
<dt><a href="Client.html#muteChat">muteChat(chatId, unmuteDate)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#pinChat">pinChat()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Client.html#pinChat">pinChat()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#resetState">resetState()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -202,6 +211,9 @@
|
||||
<dt><a href="Client.html#event:group_update">group_update</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#event:incoming_call">incoming_call</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#event:media_uploaded">media_uploaded</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -211,13 +223,13 @@
|
||||
<dt><a href="Client.html#event:message_ack">message_ack</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#event:message_create">message_create</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Client.html#event:message_create">message_create</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#event:message_revoke_everyone">message_revoke_everyone</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -328,6 +340,20 @@
|
||||
<p>Timeout for qr code selector in puppeteer</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>qrMaxRetries</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>How many times should the qrcode be refreshed before giving up</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>restartOnAuthFail</p>
|
||||
@@ -591,7 +617,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing string</code> <p>Id of the joined Chat</p>
|
||||
<p><code>Promise containing string</code>
|
||||
<p>Id of the joined Chat</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -653,15 +680,18 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Object</code> <p>createRes</p>
|
||||
<p><code>Object</code>
|
||||
<p>createRes</p>
|
||||
</p>
|
||||
</dd>
|
||||
<dd>
|
||||
<p><code>string</code> <p>createRes.gid - ID for the group that was just created</p>
|
||||
<p><code>string</code>
|
||||
<p>createRes.gid - ID for the group that was just created</p>
|
||||
</p>
|
||||
</dd>
|
||||
<dd>
|
||||
<p><code>Object with string properties</code> <p>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.</p>
|
||||
<p><code>Object with string properties</code>
|
||||
<p>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.</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -671,6 +701,15 @@
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getBlockedContacts"><span class="symbol-name">getBlockedContacts</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of <a href="Contact.html">Contact</a></span></span></h3>
|
||||
<p>Gets all blocked contacts by host account</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Array of <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="getChatById"><span class="symbol-name">getChatById</span><span class="signature"><span class="signature-params">(chatId)</span> → <span class="signature-returns"> Promise containing <a href="Chat.html">Chat</a></span></span></h3>
|
||||
<p>Get chat instance by ID</p>
|
||||
<section>
|
||||
@@ -837,6 +876,82 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getCountryCode"><span class="symbol-name">getCountryCode</span><span class="signature"><span class="signature-params">(number)</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Get the country code of a WhatsApp ID.</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>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Number or ID</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing string</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getFormattedNumber"><span class="symbol-name">getFormattedNumber</span><span class="signature"><span class="signature-params">(number)</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Get the formatted number of a WhatsApp ID.</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>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Number or ID</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing string</code> </p>
|
||||
</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> → <span class="signature-returns"> Promise containing object</span></span></h3>
|
||||
<p>Returns an object with information about the invite code's group</p>
|
||||
<section>
|
||||
@@ -870,7 +985,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing object</code> <p>Invite information</p>
|
||||
<p><code>Promise containing object</code>
|
||||
<p>Invite information</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1099,7 +1215,7 @@
|
||||
</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>
|
||||
<p>Mutes this chat forever, unless a date is specified</p>
|
||||
<section>
|
||||
<h4>Parameters</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
@@ -1137,7 +1253,8 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Date when the chat will be unmuted</p>
|
||||
<p>Date when the chat will be unmuted, leave as is to mute forever</p>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -1151,7 +1268,8 @@
|
||||
<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><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>
|
||||
@@ -1295,7 +1413,7 @@
|
||||
<p>content</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>(string, <a href="MessageMedia.html">MessageMedia</a>, <a href="Location.html">Location</a>, <a href="Contact.html">Contact</a>, or Array of <a href="Contact.html">Contact</a>)</p>
|
||||
<p>(string, <a href="MessageMedia.html">MessageMedia</a>, <a href="Location.html">Location</a>, <a href="Contact.html">Contact</a>, Array of <a href="Contact.html">Contact</a>, <a href="Buttons.html">Buttons</a>, or <a href="List.html">List</a>)</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
@@ -1323,7 +1441,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="Message.html">Message</a></code> <p>Message that was just sent</p>
|
||||
<p><code>Promise containing <a href="Message.html">Message</a></code>
|
||||
<p>Message that was just sent</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1366,7 +1485,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing boolean</code> <p>result</p>
|
||||
<p><code>Promise containing boolean</code>
|
||||
<p>result</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1488,7 +1608,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing boolean</code> <p>New pin state</p>
|
||||
<p><code>Promise containing boolean</code>
|
||||
<p>New pin state</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -1863,6 +1984,163 @@
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="event:incoming_call"><span class="symbol-name">incoming_call</span></h3>
|
||||
<p>Emitted when a call is received</p>
|
||||
<section>
|
||||
<h4>Parameters</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>call</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Values in <code>call</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>id</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Call id</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>peerJid</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Who called</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>isVideo</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>if is video</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>isGroup</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>if is group</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>canHandleLocally</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>if we can handle in waweb</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>outgoing</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>if is outgoing</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>webClientShouldHandle</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>If Waweb should handle</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>participants</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Participants</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="event:media_uploaded"><span class="symbol-name">media_uploaded</span></h3>
|
||||
<p>Emitted when media has been uploaded for a message sent by the client.</p>
|
||||
<section>
|
||||
@@ -2138,7 +2416,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: Client.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -42,7 +42,7 @@ const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./ut
|
||||
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
||||
const ChatFactory = require('./factories/ChatFactory');
|
||||
const ContactFactory = require('./factories/ContactFactory');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label } = require('./structures');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label, Call, Buttons, List} = require('./structures');
|
||||
/**
|
||||
* Starting point for interacting with the WhatsApp Web API
|
||||
* @extends {EventEmitter}
|
||||
@@ -51,6 +51,7 @@ const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification
|
||||
* @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 {number} options.qrMaxRetries - How many times should the qrcode be refreshed before giving up
|
||||
* @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
|
||||
@@ -96,13 +97,26 @@ class Client extends EventEmitter {
|
||||
* Sets up events and requirements, kicks off authentication request
|
||||
*/
|
||||
async initialize() {
|
||||
const browser = await puppeteer.launch(this.options.puppeteer);
|
||||
const page = (await browser.pages())[0];
|
||||
page.setUserAgent(this.options.userAgent);
|
||||
let [browser, page] = [null, null];
|
||||
|
||||
if(this.options.puppeteer &amp;&amp; this.options.puppeteer.browserWSEndpoint) {
|
||||
browser = await puppeteer.connect(this.options.puppeteer);
|
||||
page = await browser.newPage();
|
||||
} else {
|
||||
browser = await puppeteer.launch(this.options.puppeteer);
|
||||
page = (await browser.pages())[0];
|
||||
}
|
||||
|
||||
await page.setUserAgent(this.options.userAgent);
|
||||
|
||||
this.pupBrowser = browser;
|
||||
this.pupPage = page;
|
||||
|
||||
// remember me
|
||||
await page.evaluateOnNewDocument(() => {
|
||||
localStorage.setItem('remember-me', 'true');
|
||||
});
|
||||
|
||||
if (this.options.session) {
|
||||
await page.evaluateOnNewDocument(
|
||||
session => {
|
||||
@@ -123,10 +137,10 @@ class Client extends EventEmitter {
|
||||
timeout: 0,
|
||||
});
|
||||
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-icon="intro-md-beta-logo-dark"], [data-icon="intro-md-beta-logo-light"], [data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||
|
||||
if (this.options.session) {
|
||||
// Check if session restore was successfull
|
||||
// Check if session restore was successful
|
||||
try {
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: this.options.authTimeoutMs });
|
||||
} catch (err) {
|
||||
@@ -150,6 +164,8 @@ class Client extends EventEmitter {
|
||||
}
|
||||
|
||||
} else {
|
||||
let qrRetries = 0;
|
||||
|
||||
const getQrCode = async () => {
|
||||
// Check if retry button is present
|
||||
var QR_RETRY_SELECTOR = 'div[data-ref] > span > button';
|
||||
@@ -170,19 +186,39 @@ class Client extends EventEmitter {
|
||||
* @param {string} qr QR Code
|
||||
*/
|
||||
this.emit(Events.QR_RECEIVED, qr);
|
||||
|
||||
if (this.options.qrMaxRetries > 0) {
|
||||
qrRetries++;
|
||||
if (qrRetries > this.options.qrMaxRetries) {
|
||||
this.emit(Events.DISCONNECTED, 'Max qrcode retries reached');
|
||||
await this.destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
getQrCode();
|
||||
this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
|
||||
|
||||
// Wait for code scan
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
this._qrRefreshInterval = undefined;
|
||||
try {
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
this._qrRefreshInterval = undefined;
|
||||
} catch(error) {
|
||||
if (
|
||||
error.name === 'ProtocolError' &amp;&amp;
|
||||
error.message &amp;&amp;
|
||||
error.message.match(/Target closed/)
|
||||
) {
|
||||
// something has called .destroy() while waiting
|
||||
return;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
await page.evaluate(ExposeStore, moduleRaid.toString());
|
||||
|
||||
|
||||
// Get session tokens
|
||||
const localStorage = JSON.parse(await page.evaluate(() => {
|
||||
return JSON.stringify(window.localStorage);
|
||||
@@ -209,6 +245,14 @@ class Client extends EventEmitter {
|
||||
// Check window.Store Injection
|
||||
await page.waitForFunction('window.Store != undefined');
|
||||
|
||||
const isMD = await page.evaluate(() => {
|
||||
return window.Store.Features.features.MD_BACKEND;
|
||||
});
|
||||
|
||||
if(isMD) {
|
||||
throw new Error('Multi-device is not yet supported by whatsapp-web.js. Please check out https://github.com/pedroslopez/whatsapp-web.js/pull/889 to follow the progress.');
|
||||
}
|
||||
|
||||
//Load util functions (serializers, helper functions)
|
||||
await page.evaluate(LoadUtils);
|
||||
|
||||
@@ -226,8 +270,6 @@ class Client extends EventEmitter {
|
||||
|
||||
// Register events
|
||||
await page.exposeFunction('onAddMessageEvent', msg => {
|
||||
if (!msg.isNewMsg) return;
|
||||
|
||||
if (msg.type === 'gp2') {
|
||||
const notification = new GroupNotification(this, msg);
|
||||
if (msg.subtype === 'add' || msg.subtype === 'invite') {
|
||||
@@ -393,8 +435,25 @@ class Client extends EventEmitter {
|
||||
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
|
||||
});
|
||||
|
||||
await page.exposeFunction('onIncomingCall', (call) => {
|
||||
/**
|
||||
* Emitted when a call is received
|
||||
* @event Client#incoming_call
|
||||
* @param {object} call
|
||||
* @param {number} call.id - Call id
|
||||
* @param {string} call.peerJid - Who called
|
||||
* @param {boolean} call.isVideo - if is video
|
||||
* @param {boolean} call.isGroup - if is group
|
||||
* @param {boolean} call.canHandleLocally - if we can handle in waweb
|
||||
* @param {boolean} call.outgoing - if is outgoing
|
||||
* @param {boolean} call.webClientShouldHandle - If Waweb should handle
|
||||
* @param {object} call.participants - Participants
|
||||
*/
|
||||
const cll = new Call(this,call);
|
||||
this.emit(Events.INCOMING_CALL, cll);
|
||||
});
|
||||
|
||||
await page.evaluate(() => {
|
||||
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); });
|
||||
@@ -402,6 +461,17 @@ class Client extends EventEmitter {
|
||||
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); });
|
||||
window.Store.Call.on('add', (call) => { window.onIncomingCall(call); });
|
||||
window.Store.Msg.on('add', (msg) => {
|
||||
if (msg.isNewMsg) {
|
||||
if(msg.type === 'ciphertext') {
|
||||
// defer message event until ciphertext is resolved (type changed)
|
||||
msg.once('change:type', (_msg) => window.onAddMessageEvent(window.WWebJS.getMessageModel(_msg)));
|
||||
} else {
|
||||
window.onAddMessageEvent(window.WWebJS.getMessageModel(msg));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -410,11 +480,13 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
this.emit(Events.READY);
|
||||
|
||||
// Disconnect when navigating away
|
||||
// Because WhatsApp Web now reloads when logging out from the device, this also covers that case
|
||||
// Disconnect when navigating away when in PAIRING state (detect logout)
|
||||
this.pupPage.on('framenavigated', async () => {
|
||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||
await this.destroy();
|
||||
const appState = await this.getState();
|
||||
if(appState === WAState.PAIRING) {
|
||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||
await this.destroy();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -483,7 +555,7 @@ class Client extends EventEmitter {
|
||||
/**
|
||||
* Send a message to a specific chatId
|
||||
* @param {string} chatId
|
||||
* @param {string|MessageMedia|Location|Contact|Array&lt;Contact>} content
|
||||
* @param {string|MessageMedia|Location|Contact|Array&lt;Contact>|Buttons|List} content
|
||||
* @param {MessageSendOptions} [options] - Options used when sending the message
|
||||
*
|
||||
* @returns {Promise&lt;Message>} Message that was just sent
|
||||
@@ -499,7 +571,7 @@ class Client extends EventEmitter {
|
||||
quotedMessageId: options.quotedMessageId,
|
||||
parseVCards: options.parseVCards === false ? false : true,
|
||||
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : [],
|
||||
...options.extra
|
||||
extraOptions: options.extra
|
||||
};
|
||||
|
||||
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
||||
@@ -520,6 +592,13 @@ class Client extends EventEmitter {
|
||||
} else if(Array.isArray(content) &amp;&amp; content.length > 0 &amp;&amp; content[0] instanceof Contact) {
|
||||
internalOptions.contactCardList = content.map(contact => contact.id._serialized);
|
||||
content = '';
|
||||
} else if(content instanceof Buttons){
|
||||
if(content.type !== 'chat'){internalOptions.attachment = content.body;}
|
||||
internalOptions.buttons = content;
|
||||
content = '';
|
||||
} else if(content instanceof List){
|
||||
internalOptions.list = content;
|
||||
content = '';
|
||||
}
|
||||
|
||||
if (internalOptions.sendMediaAsSticker &amp;&amp; internalOptions.attachment) {
|
||||
@@ -700,7 +779,7 @@ class Client extends EventEmitter {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, true);
|
||||
return chat.archive;
|
||||
return true;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
@@ -712,7 +791,7 @@ class Client extends EventEmitter {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, false);
|
||||
return chat.archive;
|
||||
return false;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
@@ -754,15 +833,16 @@ class Client extends EventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutes the Chat until a specified date
|
||||
* Mutes this chat forever, unless a date is specified
|
||||
* @param {string} chatId ID of the chat that will be muted
|
||||
* @param {Date} unmuteDate Date when the chat will be unmuted
|
||||
* @param {?Date} unmuteDate Date when the chat will be unmuted, leave as is to mute forever
|
||||
*/
|
||||
async muteChat(chatId, unmuteDate) {
|
||||
unmuteDate = unmuteDate ? unmuteDate.getTime() / 1000 : -1;
|
||||
await this.pupPage.evaluate(async (chatId, timestamp) => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await chat.mute.mute(timestamp, !0);
|
||||
}, chatId, unmuteDate.getTime() / 1000);
|
||||
}, chatId, unmuteDate || -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -828,10 +908,7 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise&lt;Object|null>}
|
||||
*/
|
||||
async getNumberId(number) {
|
||||
if(!number.endsWith('@c.us')) {
|
||||
number += '@c.us';
|
||||
}
|
||||
|
||||
if (!number.endsWith('@c.us')) number += '@c.us';
|
||||
try {
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.WWebJS.getNumberId(numberId);
|
||||
@@ -841,6 +918,33 @@ class Client extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted number of a WhatsApp ID.
|
||||
* @param {string} number Number or ID
|
||||
* @returns {Promise&lt;string>}
|
||||
*/
|
||||
async getFormattedNumber(number) {
|
||||
if(!number.endsWith('@s.whatsapp.net')) number = number.replace('c.us', 's.whatsapp.net');
|
||||
if(!number.includes('@s.whatsapp.net')) number = `${number}@s.whatsapp.net`;
|
||||
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.Store.NumberInfo.formattedPhoneNumber(numberId);
|
||||
}, number);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the country code of a WhatsApp ID.
|
||||
* @param {string} number Number or ID
|
||||
* @returns {Promise&lt;string>}
|
||||
*/
|
||||
async getCountryCode(number) {
|
||||
number = number.replace(' ', '').replace('+', '').replace('@c.us', '');
|
||||
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.Store.NumberInfo.findCC(numberId);
|
||||
}, number);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new group
|
||||
* @param {string} name group title
|
||||
@@ -935,6 +1039,19 @@ class Client extends EventEmitter {
|
||||
|
||||
return Promise.all(chatIds.map(id => this.getChatById(id)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all blocked contacts by host account
|
||||
* @returns {Promise&lt;Array&lt;Contact>>}
|
||||
*/
|
||||
async getBlockedContacts() {
|
||||
const blockedContacts = await this.pupPage.evaluate(() => {
|
||||
let chatIds = window.Store.Blocklist.models.map(a => a.id._serialized);
|
||||
return Promise.all(chatIds.map(id => window.WWebJS.getContact(id)));
|
||||
});
|
||||
|
||||
return blockedContacts.map(contact => ContactFactory.create(this.client, contact));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
@@ -948,7 +1065,7 @@ module.exports = Client;
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: ClientInfo</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -213,15 +213,18 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>object</code> <p>batteryStatus</p>
|
||||
<p><code>object</code>
|
||||
<p>batteryStatus</p>
|
||||
</p>
|
||||
</dd>
|
||||
<dd>
|
||||
<p><code>number</code> <p>batteryStatus.battery - The current battery percentage</p>
|
||||
<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><code>boolean</code>
|
||||
<p>batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -235,7 +238,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: Contact</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -101,11 +101,17 @@
|
||||
<dt><a href="Contact.html#getAbout">getAbout()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<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#getChat">getChat()</a></dt>
|
||||
<dt><a href="Contact.html#getCountryCode">getCountryCode()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#getFormattedNumber">getFormattedNumber()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
@@ -230,6 +236,24 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getCountryCode"><span class="symbol-name">getCountryCode</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's countrycode, (1541859685@c.us) => (1)</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing string</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getFormattedNumber"><span class="symbol-name">getFormattedNumber</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901)</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing string</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> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||
<dl class="dl-compact">
|
||||
@@ -257,7 +281,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: GroupChat</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -405,7 +405,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing {status: number}</code> <p>Object with status code indicating if the operation was successful</p>
|
||||
<p><code>Promise containing {status: number}</code>
|
||||
<p>Object with status code indicating if the operation was successful</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -458,8 +459,7 @@
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>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.</p>
|
||||
<p>Defaults to <code>50</code>.</p>
|
||||
<p>The amount of messages to return. If no limit is specified, the available messages will be returned. 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.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -490,7 +490,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing string</code> <p>Group's invite code</p>
|
||||
<p><code>Promise containing string</code>
|
||||
<p>Group's invite code</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -521,7 +522,7 @@
|
||||
</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>
|
||||
<p>Mutes this chat forever, unless a date is specified</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
@@ -545,7 +546,8 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Date at which the Chat will be unmuted</p>
|
||||
<p>Date at which the Chat will be unmuted, leave as is to mute forever</p>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -600,7 +602,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing {status: number}</code> <p>Object with status code indicating if the operation was successful</p>
|
||||
<p><code>Promise containing {status: number}</code>
|
||||
<p>Object with status code indicating if the operation was successful</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -800,7 +803,8 @@
|
||||
<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><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>
|
||||
@@ -840,7 +844,8 @@
|
||||
<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><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>
|
||||
@@ -916,7 +921,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: GroupNotification</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: InterfaceController</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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">
|
||||
@@ -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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -382,7 +382,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: Label</title>
|
||||
<title>whatsapp-web.js 1.15.5 » Class: Label</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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -163,7 +163,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
271
docs/List.html
Normal file
271
docs/List.html
Normal file
@@ -0,0 +1,271 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.5 » Class: List</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>15.<wbr>5</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">List</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_List.js.html#source-line-8">structures/<wbr>List.<wbr>js:8</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Message type List</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Properties</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="List.html#buttonText">buttonText</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="List.html#description">description</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="List.html#footer">footer</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="List.html#sections">sections</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="List.html#title">title</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</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="List.html#_format">_format(sections)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="List">new <span class="symbol-name">List</span><span class="signature"><span class="signature-params">(body, buttonText, sections, title, footer)</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>body</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>buttonText</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>sections</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>title</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>footer</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="buttonText"><span class="symbol-name">buttonText</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>List button text</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="description"><span class="symbol-name">description</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Message body</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="footer"><span class="symbol-name">footer</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>footer of message</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="sections"><span class="symbol-name">sections</span><small class="property-type">
|
||||
Array of any</small></h3>
|
||||
<p>sections of message</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="title"><span class="symbol-name">title</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>title of message</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Method</h2>
|
||||
<section>
|
||||
<h3 id="_format"><span class="symbol-name">_format</span><span class="signature"><span class="signature-params">(sections)</span> → <span class="signature-returns"> Array of any</span></span></h3>
|
||||
<p>Creates section array from simple array</p>
|
||||
<section>
|
||||
<h4>
|
||||
Example
|
||||
</h4>
|
||||
<div>
|
||||
<pre class="prettyprint"><code>Input: [{title:'sectionTitle',rows:[{id:'customId', title:'ListItem2', description: 'desc'},{title:'ListItem2'}]}}]
|
||||
Returns: [{'title':'sectionTitle','rows':[{'rowId':'customId','title':'ListItem1','description':'desc'},{'rowId':'oGSRoD','title':'ListItem2','description':''}]}]</code></pre>
|
||||
</div>
|
||||
</section>
|
||||
<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>sections</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Array of any</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Array of any</code> </p>
|
||||
</dd>
|
||||
</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.7 on February 6, 2022.
|
||||
</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>
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: Location</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: Message</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</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">Message</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_Message.js.html#source-line-13">structures/<wbr>Message.<wbr>js:13</a></p>
|
||||
<p class="source-link">Source: <a href="structures_Message.js.html#source-line-14">structures/<wbr>Message.<wbr>js:14</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Message on WhatsApp</p>
|
||||
</div>
|
||||
@@ -54,6 +54,9 @@
|
||||
<dt><a href="Message.html#deviceType">deviceType</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#forwardingScore">forwardingScore</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#from">from</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -76,9 +79,15 @@
|
||||
<dt><a href="Message.html#inviteV4">inviteV4</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#isEphemeral">isEphemeral</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#isForwarded">isForwarded</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#isGif">isGif</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#isStarred">isStarred</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -88,13 +97,13 @@
|
||||
<dt><a href="Message.html#links">links</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#location">location</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Message.html#location">location</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#mediaKey">mediaKey</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -159,13 +168,16 @@
|
||||
<dt><a href="Message.html#getOrder">getOrder()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#getQuotedMessage">getQuotedMessage()</a></dt>
|
||||
<dt><a href="Message.html#getPayment">getPayment()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<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>
|
||||
@@ -215,6 +227,12 @@
|
||||
<p>String that represents from which device type the message was sent</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="forwardingScore"><span class="symbol-name">forwardingScore</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Indicates how many times the message was forwarded.</p>
|
||||
<p>The maximum value is 127.</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="from"><span class="symbol-name">from</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>ID for the Chat that this message was sent to, except if the message was sent by the current user.</p>
|
||||
@@ -245,11 +263,21 @@
|
||||
<p>Group Invite Data</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isEphemeral"><span class="symbol-name">isEphemeral</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the message will disappear after it expires</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isForwarded"><span class="symbol-name">isForwarded</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the message was forwarded</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isGif"><span class="symbol-name">isGif</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates whether the message is a Gif</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isStarred"><span class="symbol-name">isStarred</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the message was starred</p>
|
||||
@@ -261,7 +289,7 @@
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="links"><span class="symbol-name">links</span><small class="property-type">
|
||||
Array of string</small></h3>
|
||||
Array of {link: string, isSuspicious: boolean}</small></h3>
|
||||
<p>Links included in the message.</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
@@ -450,6 +478,15 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getPayment"><span class="symbol-name">getPayment</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Payment.html">Payment</a></span></span></h3>
|
||||
<p>Gets the payment details associated with a given message</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="Payment.html">Payment</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getQuotedMessage"><span class="symbol-name">getQuotedMessage</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<p>Returns the quoted message, if any</p>
|
||||
<dl class="dl-compact">
|
||||
@@ -543,7 +580,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: MessageMedia</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</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">MessageMedia</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_MessageMedia.js.html#source-line-13">structures/<wbr>MessageMedia.<wbr>js:13</a></p>
|
||||
<p class="source-link">Source: <a href="structures_MessageMedia.js.html#source-line-15">structures/<wbr>MessageMedia.<wbr>js:15</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Media attached to a message</p>
|
||||
</div>
|
||||
@@ -61,7 +61,7 @@
|
||||
</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">
|
||||
@@ -71,6 +71,11 @@
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="MessageMedia.html#.fromUrl">fromUrl(url[, options])</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
@@ -159,7 +164,7 @@
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Method</h2>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-static">static</span></div>
|
||||
<h3 id=".fromFilePath"><span class="symbol-name">fromFilePath</span><span class="signature"><span class="signature-params">(filePath)</span> → <span class="signature-returns"> <a href="MessageMedia.html">MessageMedia</a></span></span></h3>
|
||||
@@ -198,6 +203,136 @@
|
||||
<p><code><a href="MessageMedia.html">MessageMedia</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span> <span class="label label-static">static</span></div>
|
||||
<h3 id=".fromUrl"><span class="symbol-name">fromUrl</span><span class="signature"><span class="signature-params">(url[, options])</span> → <span class="signature-returns"> Promise containing <a href="MessageMedia.html">MessageMedia</a></span></span></h3>
|
||||
<p>Creates a MessageMedia instance from a URL</p>
|
||||
<section>
|
||||
<h4>Parameters</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>url</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>options</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<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>unsafeMime</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Defaults to <code>false</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>filename</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>client</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>reqOptions</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>reqOptions.size</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Defaults to <code>0</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
@@ -208,7 +343,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: Order</title>
|
||||
<title>whatsapp-web.js 1.15.5 » Class: Order</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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -102,7 +102,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: PrivateChat</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -318,8 +318,7 @@
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>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.</p>
|
||||
<p>Defaults to <code>50</code>.</p>
|
||||
<p>The amount of messages to return. If no limit is specified, the available messages will be returned. 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.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -362,7 +361,7 @@
|
||||
</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>
|
||||
<p>Mutes this chat forever, unless a date is specified</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
@@ -386,7 +385,8 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Date at which the Chat will be unmuted</p>
|
||||
<p>Date at which the Chat will be unmuted, leave as is to mute forever</p>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -519,7 +519,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: PrivateContact</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -101,11 +101,17 @@
|
||||
<dt><a href="PrivateContact.html#getAbout">getAbout()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<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#getChat">getChat()</a></dt>
|
||||
<dt><a href="PrivateContact.html#getCountryCode">getCountryCode()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#getFormattedNumber">getFormattedNumber()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
@@ -256,6 +262,24 @@
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getCountryCode"><span class="symbol-name">getCountryCode</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's countrycode, (1541859685@c.us) => (1)</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getCountryCode">Contact#getCountryCode</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getFormattedNumber"><span class="symbol-name">getFormattedNumber</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901)</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getFormattedNumber">Contact#getFormattedNumber</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> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||
<dl class="dl-compact">
|
||||
@@ -283,7 +307,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: Product</title>
|
||||
<title>whatsapp-web.js 1.15.5 » Class: Product</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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -127,7 +127,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Class: Util</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -104,7 +104,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> <p>media in webp format</p>
|
||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code>
|
||||
<p>media in webp format</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -155,7 +156,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> <p>media in webp format</p>
|
||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code>
|
||||
<p>media in webp format</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -193,7 +195,8 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> <p>media in webp format</p>
|
||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code>
|
||||
<p>media in webp format</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -240,7 +243,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
393
docs/global.html
393
docs/global.html
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Globals</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -68,16 +68,22 @@
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="global.html#ButtonSpec">ButtonSpec</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="global.html#ContactId">ContactId</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="global.html#GroupParticipant">GroupParticipant</a></dt>
|
||||
<dt><a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="global.html#GroupParticipant">GroupParticipant</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="global.html#MessageInfo">MessageInfo</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -383,6 +389,19 @@
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>INCOMING_CALL</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
@@ -836,6 +855,266 @@
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>LIST</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>LIST_RESPONSE</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>BUTTONS_RESPONSE</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>PAYMENT</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>BROADCAST_NOTIFICATION</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>CALL_LOG</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>CIPHERTEXT</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>DEBUG</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>E2E_NOTIFICATION</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>GP2</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>GROUP_NOTIFICATION</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>HSM</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>INTERACTIVE</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>NATIVE_FLOW</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>NOTIFICATION</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>NOTIFICATION_TEMPLATE</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>OVERSIZED</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>PROTOCOL</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>REACTION</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>TEMPLATE_BUTTON_REPLY</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
@@ -1081,6 +1360,54 @@
|
||||
</section>
|
||||
<h2>Abstract types</h2>
|
||||
<section>
|
||||
<h3 id="ButtonSpec"><span class="symbol-name">ButtonSpec</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<p>Button spec used in Buttons constructor</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>id</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Custom ID to set on the button. A random one will be generated if one is not passed.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>body</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>The text to show on the button.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="ContactId"><span class="symbol-name">ContactId</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<p>ID that represents a contact</p>
|
||||
@@ -1140,6 +1467,64 @@
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="FormattedButtonSpec"><span class="symbol-name">FormattedButtonSpec</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<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>buttonId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>type</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>buttonText</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="GroupParticipant"><span class="symbol-name">GroupParticipant</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<p>Group participant information</p>
|
||||
@@ -1595,7 +1980,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
546
docs/index.html
546
docs/index.html
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Home</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -27,20 +27,28 @@
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>
|
||||
whatsapp-web.js 1.13.2
|
||||
whatsapp-web.js 1.15.5
|
||||
</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.2126.10-brightgreen.svg" alt="WhatsApp_Web 2.2126.10"> <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.2202.12-brightgreen.svg" alt="WhatsApp_Web 2.2202.12"> <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>Quick Links</h2>
|
||||
<ul>
|
||||
<li><a href="https://wwebjs.dev/guide">Guide / Getting Started</a> <em>(work in progress)</em></li>
|
||||
<li><a href="https://docs.wwebjs.dev/">Reference documentation</a></li>
|
||||
<li><a href="https://github.com/pedroslopez/whatsapp-web.js">GitHub</a></li>
|
||||
<li><a href="https://npmjs.org/package/whatsapp-web.js">npm</a></li>
|
||||
</ul>
|
||||
<h2>Installation</h2>
|
||||
<p>The module is now available on npm! <code>npm i whatsapp-web.js</code></p>
|
||||
<p>Please note that Node v14+ is required.</p>
|
||||
<p>Please note that Node v12+ is required.</p>
|
||||
<h2>Example usage</h2>
|
||||
<pre class="prettyprint source lang-js"><code>const { Client } = require('whatsapp-web.js');
|
||||
|
||||
const client = new Client();
|
||||
|
||||
client.on('qr', (qr) => {
|
||||
@@ -61,6 +69,33 @@ client.on('message', msg => {
|
||||
client.initialize();
|
||||
</code></pre>
|
||||
<p>Take a look at <a href="https://github.com/pedroslopez/whatsapp-web.js/blob/master/example.js">example.js</a> for another example with more use cases.</p>
|
||||
<h2>Remote Access</h2>
|
||||
<p>You could also connect to any previously existing browser instance:</p>
|
||||
<pre class="prettyprint source lang-js"><code>const client = new Client({
|
||||
puppeteer: {
|
||||
browserWSEndpoint: `ws://localhost:3000`
|
||||
}
|
||||
});
|
||||
</code></pre>
|
||||
<h3>Docker</h3>
|
||||
<ol>
|
||||
<li>Installing a browser using browserless:</li>
|
||||
</ol>
|
||||
<pre class="prettyprint source"><code>docker run \
|
||||
--rm \
|
||||
-p 3000:3000 \
|
||||
-e "MAX_CONCURRENT_SESSIONS=1" \
|
||||
browserless/chrome:latest
|
||||
</code></pre>
|
||||
<p>Reference: https://docs.browserless.io/docs/docker-quickstart.html</p>
|
||||
<h3>Remote Debugging</h3>
|
||||
<ol start="2">
|
||||
<li>Running a browser with websocket remote debugging enabled:</li>
|
||||
</ol>
|
||||
<blockquote>
|
||||
<p>chrome.exe --remote-debugging-port=9222</p>
|
||||
</blockquote>
|
||||
<p>After that check the following webpage and check http://127.0.0.1:9220/json and get the <strong>webSocketDebuggerUrl</strong></p>
|
||||
<h2>Supported features</h2>
|
||||
<table>
|
||||
<thead>
|
||||
@@ -84,7 +119,7 @@ client.initialize();
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Send media (video)</td>
|
||||
<td>✅ <a href="https://waguide.pedroslopez.me/features/handling-attachments#caveat-for-sending-videos-and-gifs">(requires google chrome)</a></td>
|
||||
<td>✅ <a href="https://wwebjs.dev/guide/handling-attachments.html#caveat-for-sending-videos-and-gifs">(requires google chrome)</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Send stickers</td>
|
||||
@@ -102,6 +137,14 @@ client.initialize();
|
||||
<td>Send location</td>
|
||||
<td>✅</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Send buttons</td>
|
||||
<td>✅</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Send lists</td>
|
||||
<td>✅ (business accounts not supported)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Receive location</td>
|
||||
<td>✅</td>
|
||||
@@ -165,12 +208,6 @@ client.initialize();
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Something missing? Make an issue and let us know!</p>
|
||||
<h2>Links</h2>
|
||||
<ul>
|
||||
<li><a href="https://pedroslopez.me/whatsapp-web.js">Reference</a></li>
|
||||
<li><a href="https://waguide.pedroslopez.me/">Guide</a> <em>(work in progress)</em></li>
|
||||
<li><a href="https://github.com/pedroslopez/whatsapp-web.js">GitHub</a></li>
|
||||
</ul>
|
||||
<h2>Contributing</h2>
|
||||
<p>Pull requests are welcome! If you see something you'd like to add, please do. For drastic changes, please open an issue first.</p>
|
||||
<h2>Donating</h2>
|
||||
@@ -246,12 +283,17 @@ client.initialize();
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="BusinessContact.html#getProfilePicUrl" class="!symbol-index-name">BusinessContact#<wbr>getProfilePicUrl()</a>
|
||||
<a href="BusinessContact.html#getCountryCode" class="!symbol-index-name">BusinessContact#<wbr>getCountryCode()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="BusinessContact.html#id" class="!symbol-index-name">BusinessContact#<wbr>id</a>
|
||||
<a href="BusinessContact.html#getFormattedNumber" class="!symbol-index-name">BusinessContact#<wbr>getFormattedNumber()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="BusinessContact.html#getProfilePicUrl" class="!symbol-index-name">BusinessContact#<wbr>getProfilePicUrl()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -259,6 +301,11 @@ client.initialize();
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="BusinessContact.html#id" class="!symbol-index-name">BusinessContact#<wbr>id</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="BusinessContact.html#isBlocked" class="!symbol-index-name">BusinessContact#<wbr>isBlocked</a>
|
||||
</dt>
|
||||
@@ -333,6 +380,124 @@ client.initialize();
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="Buttons">Buttons</h2>
|
||||
<div class="symbol-index-section">
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Buttons.html" class="!symbol-index-name">Buttons(body, buttons, title, footer)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Buttons.html#_format" class="!symbol-index-name">Buttons#<wbr>_format(buttons)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Buttons.html#body" class="!symbol-index-name">Buttons#<wbr>body</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Buttons.html#buttons" class="!symbol-index-name">Buttons#<wbr>buttons</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Buttons.html#footer" class="!symbol-index-name">Buttons#<wbr>footer</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Buttons.html#title" class="!symbol-index-name">Buttons#<wbr>title</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="Call">Call</h2>
|
||||
<div class="symbol-index-section">
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Call.html" class="!symbol-index-name">Call()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Call.html#canHandleLocally" class="!symbol-index-name">Call#<wbr>canHandleLocally</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Call.html#from" class="!symbol-index-name">Call#<wbr>from</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Call.html#fromMe" class="!symbol-index-name">Call#<wbr>fromMe</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Call.html#id" class="!symbol-index-name">Call#<wbr>id</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Call.html#isGroup" class="!symbol-index-name">Call#<wbr>isGroup</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Call.html#isVideo" class="!symbol-index-name">Call#<wbr>isVideo</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Call.html#participants" class="!symbol-index-name">Call#<wbr>participants</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Call.html#timestamp" class="!symbol-index-name">Call#<wbr>timestamp</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Call.html#webClientShouldHandle" class="!symbol-index-name">Call#<wbr>webClientShouldHandle</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="Chat">Chat</h2>
|
||||
@@ -602,6 +767,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#event:incoming_call" class="!symbol-index-name">Client#<wbr>event:incoming_call</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#event:media_uploaded" class="!symbol-index-name">Client#<wbr>event:media_uploaded</a>
|
||||
</dt>
|
||||
@@ -646,6 +816,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#getBlockedContacts" class="!symbol-index-name">Client#<wbr>getBlockedContacts()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#getChatById" class="!symbol-index-name">Client#<wbr>getChatById(chatId)</a>
|
||||
</dt>
|
||||
@@ -676,6 +851,16 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#getCountryCode" class="!symbol-index-name">Client#<wbr>getCountryCode(number)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#getFormattedNumber" class="!symbol-index-name">Client#<wbr>getFormattedNumber(number)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#getInviteInfo" class="!symbol-index-name">Client#<wbr>getInviteInfo(inviteCode)</a>
|
||||
</dt>
|
||||
@@ -706,6 +891,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#getWWebVersion" class="!symbol-index-name">Client#<wbr>getWWebVersion()</a>
|
||||
</dt>
|
||||
@@ -716,10 +905,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#initialize" class="!symbol-index-name">Client#<wbr>initialize()</a>
|
||||
</dt>
|
||||
@@ -885,11 +1070,25 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Contact.html#getCountryCode" class="!symbol-index-name">Contact#<wbr>getCountryCode()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Contact.html#getFormattedNumber" class="!symbol-index-name">Contact#<wbr>getFormattedNumber()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Contact.html#getProfilePicUrl" class="!symbol-index-name">Contact#<wbr>getProfilePicUrl()</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#id" class="!symbol-index-name">Contact#<wbr>id</a>
|
||||
</dt>
|
||||
@@ -900,10 +1099,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="Contact.html#isBusiness" class="!symbol-index-name">Contact#<wbr>isBusiness</a>
|
||||
</dt>
|
||||
@@ -929,6 +1124,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="Contact.html#isUser" class="!symbol-index-name">Contact#<wbr>isUser</a>
|
||||
</dt>
|
||||
@@ -939,10 +1138,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="Contact.html#name" class="!symbol-index-name">Contact#<wbr>name</a>
|
||||
</dt>
|
||||
@@ -1018,6 +1213,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#Events#.INCOMING_CALL" class="!symbol-index-name">Events.<wbr>INCOMING_CALL</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#Events#.MEDIA_UPLOADED" class="!symbol-index-name">Events.<wbr>MEDIA_UPLOADED</a>
|
||||
</dt>
|
||||
@@ -1038,15 +1238,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="global.html#Events#.MESSAGE_REVOKED_EVERYONE" class="!symbol-index-name">Events.<wbr>MESSAGE_REVOKED_EVERYONE</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#Events#.MESSAGE_REVOKED_ME" class="!symbol-index-name">Events.<wbr>MESSAGE_REVOKED_ME</a>
|
||||
</dt>
|
||||
@@ -1567,6 +1767,60 @@ client.initialize();
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="List">List</h2>
|
||||
<div class="symbol-index-section">
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="List.html" class="!symbol-index-name">List(body, buttonText, sections, title, footer)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="List.html#_format" class="!symbol-index-name">List#<wbr>_format(sections)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="List.html#buttonText" class="!symbol-index-name">List#<wbr>buttonText</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="List.html#description" class="!symbol-index-name">List#<wbr>description</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="List.html#footer" class="!symbol-index-name">List#<wbr>footer</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="List.html#sections" class="!symbol-index-name">List#<wbr>sections</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="List.html#title" class="!symbol-index-name">List#<wbr>title</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="Location">Location</h2>
|
||||
@@ -1662,6 +1916,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#forwardingScore" class="!symbol-index-name">Message#<wbr>forwardingScore</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#from" class="!symbol-index-name">Message#<wbr>from</a>
|
||||
</dt>
|
||||
@@ -1701,6 +1960,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#getPayment" class="!symbol-index-name">Message#<wbr>getPayment()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#getQuotedMessage" class="!symbol-index-name">Message#<wbr>getQuotedMessage()</a>
|
||||
</dt>
|
||||
@@ -1726,16 +1990,30 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#isEphemeral" class="!symbol-index-name">Message#<wbr>isEphemeral</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#isForwarded" class="!symbol-index-name">Message#<wbr>isForwarded</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#isGif" class="!symbol-index-name">Message#<wbr>isGif</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#isStarred" class="!symbol-index-name">Message#<wbr>isStarred</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#isStatus" class="!symbol-index-name">Message#<wbr>isStatus</a>
|
||||
</dt>
|
||||
@@ -1746,10 +2024,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="Message.html#location" class="!symbol-index-name">Message#<wbr>location</a>
|
||||
</dt>
|
||||
@@ -1885,12 +2159,12 @@ client.initialize();
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="MessageMedia.html#data" class="!symbol-index-name">MessageMedia#<wbr>data</a>
|
||||
<a href="MessageMedia.html#.fromUrl" class="!symbol-index-name">MessageMedia.<wbr>fromUrl(url[, options])</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="MessageMedia.html#filename" class="!symbol-index-name">MessageMedia#<wbr>filename</a>
|
||||
<a href="MessageMedia.html#data" class="!symbol-index-name">MessageMedia#<wbr>data</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -1898,6 +2172,11 @@ client.initialize();
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="MessageMedia.html#filename" class="!symbol-index-name">MessageMedia#<wbr>filename</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="MessageMedia.html#mimetype" class="!symbol-index-name">MessageMedia#<wbr>mimetype</a>
|
||||
</dt>
|
||||
@@ -1919,6 +2198,26 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.BROADCAST_NOTIFICATION" class="!symbol-index-name">MessageTypes.<wbr>BROADCAST_NOTIFICATION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.BUTTONS_RESPONSE" class="!symbol-index-name">MessageTypes.<wbr>BUTTONS_RESPONSE</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.CALL_LOG" class="!symbol-index-name">MessageTypes.<wbr>CALL_LOG</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.CIPHERTEXT" class="!symbol-index-name">MessageTypes.<wbr>CIPHERTEXT</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.CONTACT_CARD" class="!symbol-index-name">MessageTypes.<wbr>CONTACT_CARD</a>
|
||||
</dt>
|
||||
@@ -1929,11 +2228,26 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.DEBUG" class="!symbol-index-name">MessageTypes.<wbr>DEBUG</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.DOCUMENT" class="!symbol-index-name">MessageTypes.<wbr>DOCUMENT</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.E2E_NOTIFICATION" class="!symbol-index-name">MessageTypes.<wbr>E2E_NOTIFICATION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.GP2" class="!symbol-index-name">MessageTypes.<wbr>GP2</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.GROUP_INVITE" class="!symbol-index-name">MessageTypes.<wbr>GROUP_INVITE</a>
|
||||
</dt>
|
||||
@@ -1943,40 +2257,105 @@ client.initialize();
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.GROUP_NOTIFICATION" class="!symbol-index-name">MessageTypes.<wbr>GROUP_NOTIFICATION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.HSM" class="!symbol-index-name">MessageTypes.<wbr>HSM</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.IMAGE" class="!symbol-index-name">MessageTypes.<wbr>IMAGE</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.INTERACTIVE" class="!symbol-index-name">MessageTypes.<wbr>INTERACTIVE</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.LIST" class="!symbol-index-name">MessageTypes.<wbr>LIST</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.LIST_RESPONSE" class="!symbol-index-name">MessageTypes.<wbr>LIST_RESPONSE</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.LOCATION" class="!symbol-index-name">MessageTypes.<wbr>LOCATION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.NATIVE_FLOW" class="!symbol-index-name">MessageTypes.<wbr>NATIVE_FLOW</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.NOTIFICATION" class="!symbol-index-name">MessageTypes.<wbr>NOTIFICATION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.NOTIFICATION_TEMPLATE" class="!symbol-index-name">MessageTypes.<wbr>NOTIFICATION_TEMPLATE</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.ORDER" class="!symbol-index-name">MessageTypes.<wbr>ORDER</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.OVERSIZED" class="!symbol-index-name">MessageTypes.<wbr>OVERSIZED</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.PAYMENT" class="!symbol-index-name">MessageTypes.<wbr>PAYMENT</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.PRODUCT" class="!symbol-index-name">MessageTypes.<wbr>PRODUCT</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.PROTOCOL" class="!symbol-index-name">MessageTypes.<wbr>PROTOCOL</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.REACTION" class="!symbol-index-name">MessageTypes.<wbr>REACTION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.REVOKED" class="!symbol-index-name">MessageTypes.<wbr>REVOKED</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.STICKER" class="!symbol-index-name">MessageTypes.<wbr>STICKER</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.TEMPLATE_BUTTON_REPLY" class="!symbol-index-name">MessageTypes.<wbr>TEMPLATE_BUTTON_REPLY</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.TEXT" class="!symbol-index-name">MessageTypes.<wbr>TEXT</a>
|
||||
</dt>
|
||||
@@ -2046,6 +2425,65 @@ client.initialize();
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="Payment">Payment</h2>
|
||||
<div class="symbol-index-section">
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Payment.html#id" class="!symbol-index-name">Payment#<wbr>id</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Payment.html#paymentAmount1000" class="!symbol-index-name">Payment#<wbr>paymentAmount1000</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Payment.html#paymentCurrency" class="!symbol-index-name">Payment#<wbr>paymentCurrency</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Payment.html#paymentMessageReceiverJid" class="!symbol-index-name">Payment#<wbr>paymentMessageReceiverJid</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Payment.html#paymentNote" class="!symbol-index-name">Payment#<wbr>paymentNote</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Payment.html#paymentStatus" class="!symbol-index-name">Payment#<wbr>paymentStatus</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Payment.html#paymentTransactionTimestamp" class="!symbol-index-name">Payment#<wbr>paymentTransactionTimestamp</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Payment.html#paymentTxnStatus" class="!symbol-index-name">Payment#<wbr>paymentTxnStatus</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="PrivateChat">PrivateChat</h2>
|
||||
@@ -2231,11 +2669,25 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="PrivateContact.html#getCountryCode" class="!symbol-index-name">PrivateContact#<wbr>getCountryCode()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="PrivateContact.html#getFormattedNumber" class="!symbol-index-name">PrivateContact#<wbr>getFormattedNumber()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="PrivateContact.html#getProfilePicUrl" class="!symbol-index-name">PrivateContact#<wbr>getProfilePicUrl()</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#id" class="!symbol-index-name">PrivateContact#<wbr>id</a>
|
||||
</dt>
|
||||
@@ -2246,10 +2698,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="PrivateContact.html#isBusiness" class="!symbol-index-name">PrivateContact#<wbr>isBusiness</a>
|
||||
</dt>
|
||||
@@ -2275,6 +2723,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="PrivateContact.html#isUser" class="!symbol-index-name">PrivateContact#<wbr>isUser</a>
|
||||
</dt>
|
||||
@@ -2285,10 +2737,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="PrivateContact.html#name" class="!symbol-index-name">PrivateContact#<wbr>name</a>
|
||||
</dt>
|
||||
@@ -2583,7 +3031,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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
treeNode.tree({
|
||||
autoEscape: false,
|
||||
closedIcon: '⇢',
|
||||
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=\"Label.html\">Label</a>","id":"Label","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=\"Order.html\">Order</a>","id":"Order","children":[]},{"label":"<a href=\"PrivateChat.html\">PrivateChat</a>","id":"PrivateChat","children":[]},{"label":"<a href=\"PrivateContact.html\">PrivateContact</a>","id":"PrivateContact","children":[]},{"label":"<a href=\"Product.html\">Product</a>","id":"Product","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=\"Buttons.html\">Buttons</a>","id":"Buttons","children":[]},{"label":"<a href=\"Call.html\">Call</a>","id":"Call","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=\"Label.html\">Label</a>","id":"Label","children":[]},{"label":"<a href=\"List.html\">List</a>","id":"List","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=\"Order.html\">Order</a>","id":"Order","children":[]},{"label":"<a href=\"PrivateChat.html\">PrivateChat</a>","id":"PrivateChat","children":[]},{"label":"<a href=\"PrivateContact.html\">PrivateContact</a>","id":"PrivateContact","children":[]},{"label":"<a href=\"Product.html\">Product</a>","id":"Product","children":[]},{"label":"<a href=\"Util.html\">Util</a>","id":"Util","children":[]}],
|
||||
openedIcon: ' ⇣',
|
||||
saveState: false,
|
||||
useContextMenu: false
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/Base.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -60,7 +60,7 @@ module.exports = 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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/BusinessContact.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -59,7 +59,7 @@ module.exports = 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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
135
docs/structures_Buttons.js.html
Normal file
135
docs/structures_Buttons.js.html
Normal file
@@ -0,0 +1,135 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.5 » Source: structures/Buttons.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>15.<wbr>5</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: structures/Buttons.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const MessageMedia = require('./MessageMedia');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
* Button spec used in Buttons constructor
|
||||
* @typedef {Object} ButtonSpec
|
||||
* @property {string=} id - Custom ID to set on the button. A random one will be generated if one is not passed.
|
||||
* @property {string} body - The text to show on the button.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} FormattedButtonSpec
|
||||
* @property {string} buttonId
|
||||
* @property {number} type
|
||||
* @property {Object} buttonText
|
||||
*/
|
||||
|
||||
/**
|
||||
* Message type buttons
|
||||
*/
|
||||
class Buttons {
|
||||
/**
|
||||
* @param {string|MessageMedia} body
|
||||
* @param {ButtonSpec[]} buttons - See {@link ButtonSpec}
|
||||
* @param {string?} title
|
||||
* @param {string?} footer
|
||||
*/
|
||||
constructor(body, buttons, title, footer) {
|
||||
/**
|
||||
* Message body
|
||||
* @type {string|MessageMedia}
|
||||
*/
|
||||
this.body = body;
|
||||
|
||||
/**
|
||||
* title of message
|
||||
* @type {string}
|
||||
*/
|
||||
this.title = title;
|
||||
|
||||
/**
|
||||
* footer of message
|
||||
* @type {string}
|
||||
*/
|
||||
this.footer = footer;
|
||||
|
||||
if (body instanceof MessageMedia) {
|
||||
this.type = 'media';
|
||||
this.title = '';
|
||||
}else{
|
||||
this.type = 'chat';
|
||||
}
|
||||
|
||||
/**
|
||||
* buttons of message
|
||||
* @type {FormattedButtonSpec[]}
|
||||
*/
|
||||
this.buttons = this._format(buttons);
|
||||
if(!this.buttons.length){ throw '[BT01] No buttons';}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates button array from simple array
|
||||
* @param {ButtonSpec[]} buttons
|
||||
* @returns {FormattedButtonSpec[]}
|
||||
* @example
|
||||
* Input: [{id:'customId',body:'button1'},{body:'button2'},{body:'button3'},{body:'button4'}]
|
||||
* Returns: [{ buttonId:'customId',buttonText:{'displayText':'button1'},type: 1 },{buttonId:'n3XKsL',buttonText:{'displayText':'button2'},type:1},{buttonId:'NDJk0a',buttonText:{'displayText':'button3'},type:1}]
|
||||
*/
|
||||
_format(buttons){
|
||||
buttons = buttons.slice(0,3); // phone users can only see 3 buttons, so lets limit this
|
||||
return buttons.map((btn) => {
|
||||
return {'buttonId':btn.id ? String(btn.id) : Util.generateHash(6),'buttonText':{'displayText':btn.body},'type':1};
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Buttons;</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.7 on February 6, 2022.
|
||||
</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>
|
||||
121
docs/structures_Call.js.html
Normal file
121
docs/structures_Call.js.html
Normal file
@@ -0,0 +1,121 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.5 » Source: structures/Call.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>15.<wbr>5</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: structures/Call.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Represents a Call on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class Call extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* Call ID
|
||||
* @type {string}
|
||||
*/
|
||||
this.id = data.id;
|
||||
/**
|
||||
* From
|
||||
* @type {string}
|
||||
*/
|
||||
this.from = data.peerJid;
|
||||
/**
|
||||
* Unix timestamp for when the call was created
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.offerTime;
|
||||
/**
|
||||
* Is video
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isVideo = data.isVideo;
|
||||
/**
|
||||
* Is Group
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isGroup = data.isGroup;
|
||||
/**
|
||||
* Indicates if the call was sent by the current user
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.fromMe = data.outgoing;
|
||||
/**
|
||||
* Indicates if the call can be handled in waweb
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.canHandleLocally = data.canHandleLocally;
|
||||
/**
|
||||
* Indicates if the call Should be handled in waweb
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.webClientShouldHandle = data.webClientShouldHandle;
|
||||
/**
|
||||
* Object with participants
|
||||
* @type {object}
|
||||
*/
|
||||
this.participants = data.participants;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Call;</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.7 on February 6, 2022.
|
||||
</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>
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/Chat.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -96,7 +96,7 @@ class Chat extends Base {
|
||||
|
||||
/**
|
||||
* Indicates if the chat is muted or not
|
||||
* @type {number}
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isMuted = data.isMuted;
|
||||
|
||||
@@ -178,8 +178,8 @@ class Chat extends Base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutes this chat until a specified date
|
||||
* @param {Date} unmuteDate Date at which the Chat will be unmuted
|
||||
* Mutes this chat forever, unless a date is specified
|
||||
* @param {?Date} unmuteDate Date at which the Chat will be unmuted, leave as is to mute forever
|
||||
*/
|
||||
async mute(unmuteDate) {
|
||||
return this.client.muteChat(this.id._serialized, unmuteDate);
|
||||
@@ -202,30 +202,32 @@ class Chat extends Base {
|
||||
/**
|
||||
* Loads chat messages, sorted from earliest to latest.
|
||||
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
||||
* @param {Number} [searchOptions.limit=50] 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.
|
||||
* @param {Number} [searchOptions.limit] The amount of messages to return. If no limit is specified, the available messages will be returned. 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.
|
||||
* @returns {Promise&lt;Array&lt;Message>>}
|
||||
*/
|
||||
async fetchMessages(searchOptions) {
|
||||
if (!searchOptions || !searchOptions.limit) {
|
||||
searchOptions = { limit: 50 };
|
||||
}
|
||||
let messages = await this.client.pupPage.evaluate(async (chatId, limit) => {
|
||||
let messages = await this.client.pupPage.evaluate(async (chatId, searchOptions) => {
|
||||
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 &lt; limit) {
|
||||
const loadedMessages = await chat.loadEarlierMsgs();
|
||||
if (!loadedMessages) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
if (searchOptions &amp;&amp; searchOptions.limit > 0) {
|
||||
while (msgs.length &lt; searchOptions.limit) {
|
||||
const loadedMessages = await chat.loadEarlierMsgs();
|
||||
if (!loadedMessages) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
}
|
||||
|
||||
if (msgs.length > searchOptions.limit) {
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
msgs = msgs.splice(msgs.length - searchOptions.limit);
|
||||
}
|
||||
}
|
||||
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
if (msgs.length > limit) msgs = msgs.splice(msgs.length - limit);
|
||||
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
||||
|
||||
}, this.id._serialized, searchOptions.limit);
|
||||
}, this.id._serialized, searchOptions);
|
||||
|
||||
return messages.map(m => new Message(this.client, m));
|
||||
}
|
||||
@@ -288,7 +290,7 @@ module.exports = 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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/ClientInfo.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -108,7 +108,7 @@ module.exports = 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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/Contact.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -139,7 +139,7 @@ class Contact extends Base {
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isBlocked = data.isBlocked;
|
||||
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
@@ -151,6 +151,22 @@ class Contact extends Base {
|
||||
return await this.client.getProfilePicUrl(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901)
|
||||
* @returns {Promise&lt;string>}
|
||||
*/
|
||||
async getFormattedNumber() {
|
||||
return await this.client.getFormattedNumber(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contact's countrycode, (1541859685@c.us) => (1)
|
||||
* @returns {Promise&lt;string>}
|
||||
*/
|
||||
async getCountryCode() {
|
||||
return await this.client.getCountryCode(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Chat that corresponds to this Contact.
|
||||
* Will return null when getting chat for currently logged in user.
|
||||
@@ -209,7 +225,8 @@ class Contact extends Base {
|
||||
|
||||
}
|
||||
|
||||
module.exports = Contact;</code></pre>
|
||||
module.exports = Contact;
|
||||
</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
@@ -219,7 +236,7 @@ module.exports = 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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/GroupChat.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -239,7 +239,7 @@ module.exports = 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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/GroupNotification.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -74,7 +74,7 @@ class GroupNotification extends Base {
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.chatId = typeof (data.from) === 'object' ? data.from._serialized : data.from;
|
||||
this.chatId = typeof (data.to) === 'object' ? data.to._serialized : data.to;
|
||||
|
||||
/**
|
||||
* ContactId for the user that produced the GroupNotification.
|
||||
@@ -143,7 +143,7 @@ module.exports = 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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/Label.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » Source: structures/Label.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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -88,7 +88,7 @@ module.exports = Label;</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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
133
docs/structures_List.js.html
Normal file
133
docs/structures_List.js.html
Normal file
@@ -0,0 +1,133 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.5 » Source: structures/List.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>15.<wbr>5</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: structures/List.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
* Message type List
|
||||
*/
|
||||
class List {
|
||||
/**
|
||||
* @param {string} body
|
||||
* @param {string} buttonText
|
||||
* @param {Array&lt;any>} sections
|
||||
* @param {string?} title
|
||||
* @param {string?} footer
|
||||
*/
|
||||
constructor(body, buttonText, sections, title, footer) {
|
||||
/**
|
||||
* Message body
|
||||
* @type {string}
|
||||
*/
|
||||
this.description = body;
|
||||
|
||||
/**
|
||||
* List button text
|
||||
* @type {string}
|
||||
*/
|
||||
this.buttonText = buttonText;
|
||||
|
||||
/**
|
||||
* title of message
|
||||
* @type {string}
|
||||
*/
|
||||
this.title = title;
|
||||
|
||||
|
||||
/**
|
||||
* footer of message
|
||||
* @type {string}
|
||||
*/
|
||||
this.footer = footer;
|
||||
|
||||
/**
|
||||
* sections of message
|
||||
* @type {Array&lt;any>}
|
||||
*/
|
||||
this.sections = this._format(sections);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates section array from simple array
|
||||
* @param {Array&lt;any>} sections
|
||||
* @returns {Array&lt;any>}
|
||||
* @example
|
||||
* Input: [{title:'sectionTitle',rows:[{id:'customId', title:'ListItem2', description: 'desc'},{title:'ListItem2'}]}}]
|
||||
* Returns: [{'title':'sectionTitle','rows':[{'rowId':'customId','title':'ListItem1','description':'desc'},{'rowId':'oGSRoD','title':'ListItem2','description':''}]}]
|
||||
*/
|
||||
_format(sections){
|
||||
if(!sections.length){throw '[LT02] List without sections';}
|
||||
if(sections.length > 1 &amp;&amp; sections.filter(s => typeof s.title == 'undefined').length > 1){throw '[LT05] You can\'t have more than one empty title.';}
|
||||
return sections.map( (section) =>{
|
||||
if(!section.rows.length){throw '[LT03] Section without rows';}
|
||||
return {
|
||||
title: section.title ? section.title : undefined,
|
||||
rows: section.rows.map( (row) => {
|
||||
if(!row.title){throw '[LT04] Row without title';}
|
||||
return {
|
||||
rowId: row.id ? row.id : Util.generateHash(6),
|
||||
title: row.title,
|
||||
description: row.description ? row.description : ''
|
||||
};
|
||||
})
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = List;
|
||||
</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.7 on February 6, 2022.
|
||||
</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>
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/Location.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -71,7 +71,7 @@ module.exports = 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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/Message.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -35,6 +35,7 @@ const Base = require('./Base');
|
||||
const MessageMedia = require('./MessageMedia');
|
||||
const Location = require('./Location');
|
||||
const Order = require('./Order');
|
||||
const Payment = require('./Payment');
|
||||
const { MessageTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
@@ -125,6 +126,14 @@ class Message extends Base {
|
||||
*/
|
||||
this.isForwarded = data.isForwarded;
|
||||
|
||||
/**
|
||||
* Indicates how many times the message was forwarded.
|
||||
*
|
||||
* The maximum value is 127.
|
||||
* @type {number}
|
||||
*/
|
||||
this.forwardingScore = data.forwardingScore || 0;
|
||||
|
||||
/**
|
||||
* Indicates if the message is a status update
|
||||
* @type {boolean}
|
||||
@@ -201,6 +210,18 @@ class Message extends Base {
|
||||
*/
|
||||
this.token = data.token ? data.token : undefined;
|
||||
|
||||
/**
|
||||
* Indicates whether the message is a Gif
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isGif = Boolean(data.isGif);
|
||||
|
||||
/**
|
||||
* Indicates if the message will disappear after it expires
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isEphemeral = data.isEphemeral;
|
||||
|
||||
/** Title */
|
||||
if (data.title) {
|
||||
this.title = data.title;
|
||||
@@ -223,10 +244,26 @@ class Message extends Base {
|
||||
|
||||
/**
|
||||
* Links included in the message.
|
||||
* @type {Array&lt;string>}
|
||||
* @type {Array&lt;{link: string, isSuspicious: boolean}>}
|
||||
*
|
||||
*/
|
||||
this.links = data.links;
|
||||
|
||||
/** Buttons */
|
||||
if (data.dynamicReplyButtons) {
|
||||
this.dynamicReplyButtons = data.dynamicReplyButtons;
|
||||
}
|
||||
|
||||
/** Selected Button Id **/
|
||||
if (data.selectedButtonId) {
|
||||
this.selectedButtonId = data.selectedButtonId;
|
||||
}
|
||||
|
||||
/** Selected List row Id **/
|
||||
if (data.listResponse &amp;&amp; data.listResponse.singleSelectReply.selectedRowId) {
|
||||
this.selectedRowId = data.listResponse.singleSelectReply.selectedRowId;
|
||||
}
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
@@ -335,32 +372,39 @@ class Message extends Base {
|
||||
|
||||
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
||||
// try to resolve media
|
||||
await msg.downloadMedia(true, 1);
|
||||
await msg.downloadMedia({
|
||||
downloadEvenIfExpensive: true,
|
||||
rmrReason: 1
|
||||
});
|
||||
}
|
||||
|
||||
if (msg.mediaData.mediaStage.includes('ERROR')) {
|
||||
if (msg.mediaData.mediaStage.includes('ERROR') || msg.mediaData.mediaStage === 'FETCHING') {
|
||||
// media could not be downloaded
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const decryptedMedia = await window.Store.DownloadManager.downloadAndDecrypt({
|
||||
directPath: msg.directPath,
|
||||
encFilehash: msg.encFilehash,
|
||||
filehash: msg.filehash,
|
||||
mediaKey: msg.mediaKey,
|
||||
mediaKeyTimestamp: msg.mediaKeyTimestamp,
|
||||
type: msg.type,
|
||||
signal: (new AbortController).signal
|
||||
});
|
||||
|
||||
const data = window.WWebJS.arrayBufferToBase64(decryptedMedia);
|
||||
|
||||
return {
|
||||
data,
|
||||
mimetype: msg.mimetype,
|
||||
filename: msg.filename
|
||||
};
|
||||
|
||||
try {
|
||||
const decryptedMedia = await window.Store.DownloadManager.downloadAndDecrypt({
|
||||
directPath: msg.directPath,
|
||||
encFilehash: msg.encFilehash,
|
||||
filehash: msg.filehash,
|
||||
mediaKey: msg.mediaKey,
|
||||
mediaKeyTimestamp: msg.mediaKeyTimestamp,
|
||||
type: msg.type,
|
||||
signal: (new AbortController).signal
|
||||
});
|
||||
|
||||
const data = window.WWebJS.arrayBufferToBase64(decryptedMedia);
|
||||
|
||||
return {
|
||||
data,
|
||||
mimetype: msg.mimetype,
|
||||
filename: msg.filename
|
||||
};
|
||||
} catch (e) {
|
||||
if(e.status &amp;&amp; e.status === 404) return undefined;
|
||||
throw e;
|
||||
}
|
||||
}, this.id._serialized);
|
||||
|
||||
if (!result) return undefined;
|
||||
@@ -375,7 +419,7 @@ class Message extends Base {
|
||||
await this.client.pupPage.evaluate((msgId, everyone) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if (everyone &amp;&amp; msg.id.fromMe &amp;&amp; msg.canRevoke()) {
|
||||
if (everyone &amp;&amp; msg.id.fromMe &amp;&amp; msg._canRevoke()) {
|
||||
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], true);
|
||||
}
|
||||
|
||||
@@ -453,6 +497,21 @@ class Message extends Base {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
/**
|
||||
* Gets the payment details associated with a given message
|
||||
* @return {Promise&lt;Payment>}
|
||||
*/
|
||||
async getPayment() {
|
||||
if (this.type === MessageTypes.PAYMENT) {
|
||||
const msg = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
if(!msg) return null;
|
||||
return msg.serialize();
|
||||
}, this.id._serialized);
|
||||
return new Payment(this.client, msg);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Message;
|
||||
@@ -466,7 +525,7 @@ module.exports = Message;
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/MessageMedia.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -34,6 +34,8 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const mime = require('mime');
|
||||
const fetch = require('node-fetch');
|
||||
const { URL } = require('url');
|
||||
|
||||
/**
|
||||
* Media attached to a message
|
||||
@@ -74,9 +76,63 @@ class MessageMedia {
|
||||
|
||||
return new MessageMedia(mimetype, b64data, filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a MessageMedia instance from a URL
|
||||
* @param {string} url
|
||||
* @param {Object} [options]
|
||||
* @param {boolean} [options.unsafeMime=false]
|
||||
* @param {string} [options.filename]
|
||||
* @param {object} [options.client]
|
||||
* @param {object} [options.reqOptions]
|
||||
* @param {number} [options.reqOptions.size=0]
|
||||
* @returns {Promise&lt;MessageMedia>}
|
||||
*/
|
||||
static async fromUrl(url, options = {}) {
|
||||
const pUrl = new URL(url);
|
||||
let mimetype = mime.getType(pUrl.pathname);
|
||||
|
||||
if (!mimetype &amp;&amp; !options.unsafeMime)
|
||||
throw new Error('Unable to determine MIME type using URL. Set unsafeMime to true to download it anyway.');
|
||||
|
||||
async function fetchData (url, options) {
|
||||
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
||||
const response = await fetch(url, reqOptions);
|
||||
const mime = response.headers.get('Content-Type');
|
||||
|
||||
const contentDisposition = response.headers.get('Content-Disposition');
|
||||
const name = contentDisposition ? contentDisposition.match(/((?&lt;=filename=")(.*)(?="))/) : null;
|
||||
|
||||
let data = '';
|
||||
if (response.buffer) {
|
||||
data = (await response.buffer()).toString('base64');
|
||||
} else {
|
||||
const bArray = new Uint8Array(await response.arrayBuffer());
|
||||
bArray.forEach((b) => {
|
||||
data += String.fromCharCode(b);
|
||||
});
|
||||
data = btoa(data);
|
||||
}
|
||||
|
||||
return { data, mime, name };
|
||||
}
|
||||
|
||||
const res = options.client
|
||||
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
|
||||
: (await fetchData(url, options.reqOptions));
|
||||
|
||||
const filename = options.filename ||
|
||||
(res.name ? res.name[0] : (pUrl.pathname.split('/').pop() || 'file'));
|
||||
|
||||
if (!mimetype)
|
||||
mimetype = res.mime;
|
||||
|
||||
return new MessageMedia(mimetype, res.data, filename);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MessageMedia;</code></pre>
|
||||
module.exports = MessageMedia;
|
||||
</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
@@ -86,7 +142,7 @@ module.exports = 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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/Order.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » Source: structures/Order.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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -90,7 +90,7 @@ module.exports = Order;</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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
133
docs/structures_Payment.js.html
Normal file
133
docs/structures_Payment.js.html
Normal file
@@ -0,0 +1,133 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.5 » Source: structures/Payment.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>15.<wbr>5</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: structures/Payment.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>const Base = require('./Base');
|
||||
|
||||
class Payment extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* The payment Id
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
/**
|
||||
* The payment currency
|
||||
* @type {string}
|
||||
*/
|
||||
this.paymentCurrency = data.paymentCurrency;
|
||||
|
||||
/**
|
||||
* The payment ammount ( R$ 1.00 = 1000 )
|
||||
* @type {number}
|
||||
*/
|
||||
this.paymentAmount1000 = data.paymentAmount1000;
|
||||
|
||||
/**
|
||||
* The payment receiver
|
||||
* @type {object}
|
||||
*/
|
||||
this.paymentMessageReceiverJid = data.paymentMessageReceiverJid;
|
||||
|
||||
/**
|
||||
* The payment transaction timestamp
|
||||
* @type {number}
|
||||
*/
|
||||
this.paymentTransactionTimestamp = data.paymentTransactionTimestamp;
|
||||
|
||||
/**
|
||||
* The paymentStatus
|
||||
*
|
||||
* Possible Status
|
||||
* 0:UNKNOWN_STATUS
|
||||
* 1:PROCESSING
|
||||
* 2:SENT
|
||||
* 3:NEED_TO_ACCEPT
|
||||
* 4:COMPLETE
|
||||
* 5:COULD_NOT_COMPLETE
|
||||
* 6:REFUNDED
|
||||
* 7:EXPIRED
|
||||
* 8:REJECTED
|
||||
* 9:CANCELLED
|
||||
* 10:WAITING_FOR_PAYER
|
||||
* 11:WAITING
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
this.paymentStatus = data.paymentStatus;
|
||||
|
||||
/**
|
||||
* Integer that represents the payment Text
|
||||
* @type {number}
|
||||
*/
|
||||
this.paymentTxnStatus = data.paymentTxnStatus;
|
||||
|
||||
/**
|
||||
* The note sent with the payment
|
||||
* @type {string}
|
||||
*/
|
||||
this.paymentNote = !data.paymentNoteMsg ? undefined : data.paymentNoteMsg.body ? data.paymentNoteMsg.body : undefined ;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Payment;
|
||||
</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.7 on February 6, 2022.
|
||||
</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>
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/PrivateChat.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -51,7 +51,7 @@ module.exports = 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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/PrivateContact.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -51,7 +51,7 @@ module.exports = 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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/Product.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » Source: structures/Product.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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -106,7 +106,7 @@ module.exports = Product;</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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: structures/ProductMetadata.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » Source: structures/ProductMetadata.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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -63,7 +63,7 @@ module.exports = ProductMetadata;</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.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: util/Constants.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -42,6 +42,7 @@ exports.DefaultOptions = {
|
||||
qrTimeoutMs: 45000,
|
||||
qrRefreshIntervalMs: 20000,
|
||||
authTimeoutMs: 45000,
|
||||
qrMaxRetries: 0,
|
||||
takeoverOnConflict: false,
|
||||
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',
|
||||
@@ -81,7 +82,8 @@ exports.Events = {
|
||||
QR_RECEIVED: 'qr',
|
||||
DISCONNECTED: 'disconnected',
|
||||
STATE_CHANGED: 'change_state',
|
||||
BATTERY_CHANGED: 'change_battery'
|
||||
BATTERY_CHANGED: 'change_battery',
|
||||
INCOMING_CALL: 'incoming_call'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -104,7 +106,27 @@ exports.MessageTypes = {
|
||||
REVOKED: 'revoked',
|
||||
PRODUCT: 'product',
|
||||
UNKNOWN: 'unknown',
|
||||
GROUP_INVITE: 'groups_v4_invite'
|
||||
GROUP_INVITE: 'groups_v4_invite',
|
||||
LIST: 'list',
|
||||
LIST_RESPONSE: 'list_response',
|
||||
BUTTONS_RESPONSE: 'buttons_response',
|
||||
PAYMENT: 'payment',
|
||||
BROADCAST_NOTIFICATION: 'broadcast_notification',
|
||||
CALL_LOG: 'call_log',
|
||||
CIPHERTEXT: 'ciphertext',
|
||||
DEBUG: 'debug',
|
||||
E2E_NOTIFICATION: 'e2e_notification',
|
||||
GP2: 'gp2',
|
||||
GROUP_NOTIFICATION: 'group_notification',
|
||||
HSM: 'hsm',
|
||||
INTERACTIVE: 'interactive',
|
||||
NATIVE_FLOW: 'native_flow',
|
||||
NOTIFICATION: 'notification',
|
||||
NOTIFICATION_TEMPLATE: 'notification_template',
|
||||
OVERSIZED: 'oversized',
|
||||
PROTOCOL: 'protocol',
|
||||
REACTION: 'reaction',
|
||||
TEMPLATE_BUTTON_REPLY: 'template_button_reply',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -178,7 +200,7 @@ exports.MessageAck = {
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: util/InterfaceController.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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">
|
||||
@@ -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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -59,7 +59,7 @@ class InterfaceController {
|
||||
async openChatDrawer(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.chatInfoDrawer(chat);
|
||||
await window.Store.Cmd.openDrawerMid(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ module.exports = InterfaceController;
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.13.2 » Source: util/Util.js</title>
|
||||
<title>whatsapp-web.js 1.15.5 » 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>13.<wbr>2</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>15.<wbr>5</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -214,9 +214,9 @@ class Util {
|
||||
let jsonBuffer = Buffer.from(JSON.stringify(json), 'utf8');
|
||||
let exif = Buffer.concat([exifAttr, jsonBuffer]);
|
||||
exif.writeUIntLE(jsonBuffer.length, 14, 4);
|
||||
await img.loadBuffer(Buffer.from(webpMedia.data, 'base64'));
|
||||
await img.load(Buffer.from(webpMedia.data, 'base64'));
|
||||
img.exif = exif;
|
||||
webpMedia.data = (await img.saveBuffer()).toString('base64');
|
||||
webpMedia.data = (await img.save(null)).toString('base64');
|
||||
}
|
||||
|
||||
return webpMedia;
|
||||
@@ -242,7 +242,7 @@ module.exports = Util;
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on July 9, 2021.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on February 6, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
16
example.js
16
example.js
@@ -1,5 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const { Client, Location } = require('./index');
|
||||
const { Client, Location, List, Buttons } = require('./index');
|
||||
|
||||
const SESSION_FILE_PATH = './session.json';
|
||||
let sessionCfg;
|
||||
@@ -11,6 +11,13 @@ const client = new Client({ puppeteer: { headless: false }, session: sessionCfg
|
||||
// You can use an existing session and avoid scanning a QR code by adding a "session" object to the client options.
|
||||
// This object must include WABrowserId, WASecretBundle, WAToken1 and WAToken2.
|
||||
|
||||
// You also could connect to an existing instance of a browser
|
||||
// {
|
||||
// puppeteer: {
|
||||
// browserWSEndpoint: `ws://localhost:3000`
|
||||
// }
|
||||
// }
|
||||
|
||||
client.initialize();
|
||||
|
||||
client.on('qr', (qr) => {
|
||||
@@ -197,6 +204,13 @@ client.on('message', async msg => {
|
||||
const quotedMsg = await msg.getQuotedMessage();
|
||||
client.interface.openChatWindowAt(quotedMsg.id._serialized);
|
||||
}
|
||||
} else if (msg.body === '!buttons') {
|
||||
let button = new Buttons('Button body',[{body:'bt1'},{body:'bt2'},{body:'bt3'}],'title','footer');
|
||||
client.sendMessage(msg.from, button);
|
||||
} else if (msg.body === '!list') {
|
||||
let sections = [{title:'sectionTitle',rows:[{title:'ListItem1', description: 'desc'},{title:'ListItem2'}]}];
|
||||
let list = new List('List body','btnText',sections,'Title','footer');
|
||||
client.sendMessage(msg.from, list);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
220
index.d.ts
vendored
220
index.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
|
||||
import { EventEmitter } from 'events'
|
||||
import puppeteer = require('puppeteer')
|
||||
import { RequestInit } from 'node-fetch'
|
||||
import puppeteer from 'puppeteer'
|
||||
|
||||
declare namespace WAWebJS {
|
||||
|
||||
@@ -47,6 +48,9 @@ declare namespace WAWebJS {
|
||||
/** Logs out the client, closing the current session */
|
||||
logout(): Promise<void>
|
||||
|
||||
/** Get all blocked contacts by host account */
|
||||
getBlockedContacts(): Promise<Contact[]>
|
||||
|
||||
/** Get chat instance by ID */
|
||||
getChatById(chatId: string): Promise<Chat>
|
||||
|
||||
@@ -58,6 +62,12 @@ declare namespace WAWebJS {
|
||||
|
||||
/** Get all current contact instances */
|
||||
getContacts(): Promise<Contact[]>
|
||||
|
||||
/** Get the country code of a WhatsApp ID. (154185968@c.us) => (1) */
|
||||
getCountryCode(number: string): Promise<string>
|
||||
|
||||
/** Get the formatted number of a WhatsApp ID. (12345678901@c.us) => (+1 (234) 5678-901) */
|
||||
getFormattedNumber(number: string): Promise<string>
|
||||
|
||||
/** Get all current Labels */
|
||||
getLabels(): Promise<Label[]>
|
||||
@@ -90,11 +100,11 @@ declare namespace WAWebJS {
|
||||
getNumberId(number: string): Promise<ContactId | null>
|
||||
|
||||
/**
|
||||
* Mutes the Chat until a specified date
|
||||
* Mutes this chat forever, unless a date is specified
|
||||
* @param chatId ID of the chat that will be muted
|
||||
* @param unmuteDate Date when the chat will be unmuted
|
||||
* @param unmuteDate Date when the chat will be unmuted, leave as is to mute forever
|
||||
*/
|
||||
muteChat(chatId: string, unmuteDate: Date): Promise<void>
|
||||
muteChat(chatId: string, unmuteDate?: Date): Promise<void>
|
||||
|
||||
/** Force reset of connection state for the client */
|
||||
resetState(): Promise<void>
|
||||
@@ -227,6 +237,12 @@ declare namespace WAWebJS {
|
||||
qr: string
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a call is received */
|
||||
on(event: 'call', listener: (
|
||||
/** The call that started */
|
||||
call: Call
|
||||
) => void): this
|
||||
|
||||
/** Emitted when the client has initialized and is ready to receive messages */
|
||||
on(event: 'ready', listener: () => void): this
|
||||
}
|
||||
@@ -271,13 +287,16 @@ declare namespace WAWebJS {
|
||||
* @default 45000 */
|
||||
authTimeoutMs?: number,
|
||||
/** Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/ */
|
||||
puppeteer?: puppeteer.LaunchOptions
|
||||
puppeteer?: puppeteer.LaunchOptions & puppeteer.BrowserLaunchArgumentOptions & puppeteer.BrowserConnectOptions
|
||||
/** 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,
|
||||
/** How many times should the qrcode be refreshed before giving up
|
||||
* @default 0 (disabled) */
|
||||
qrMaxRetries?: number,
|
||||
/** Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||
* @default false */
|
||||
restartOnAuthFail?: boolean
|
||||
@@ -349,7 +368,7 @@ declare namespace WAWebJS {
|
||||
reply: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** whatsapp web url */
|
||||
export const WhatsWebURL: string
|
||||
|
||||
@@ -421,8 +440,29 @@ declare namespace WAWebJS {
|
||||
REVOKED = 'revoked',
|
||||
ORDER = 'order',
|
||||
PRODUCT = 'product',
|
||||
PAYMENT = 'payment',
|
||||
UNKNOWN = 'unknown',
|
||||
GROUP_INVITE = 'groups_v4_invite',
|
||||
LIST = 'list',
|
||||
LIST_RESPONSE = 'list_response',
|
||||
BUTTONS_RESPONSE = 'buttons_response',
|
||||
PAYMENT = 'payment',
|
||||
BROADCAST_NOTIFICATION = 'broadcast_notification',
|
||||
CALL_LOG = 'call_log',
|
||||
CIPHERTEXT = 'ciphertext',
|
||||
DEBUG = 'debug',
|
||||
E2E_NOTIFICATION = 'e2e_notification',
|
||||
GP2 = 'gp2',
|
||||
GROUP_NOTIFICATION = 'group_notification',
|
||||
HSM = 'hsm',
|
||||
INTERACTIVE = 'interactive',
|
||||
NATIVE_FLOW = 'native_flow',
|
||||
NOTIFICATION = 'notification',
|
||||
NOTIFICATION_TEMPLATE = 'notification_template',
|
||||
OVERSIZED = 'oversized',
|
||||
PROTOCOL = 'protocol',
|
||||
REACTION = 'reaction',
|
||||
TEMPLATE_BUTTON_REPLY = 'template_button_reply',
|
||||
}
|
||||
|
||||
/** Client status */
|
||||
@@ -505,6 +545,10 @@ declare namespace WAWebJS {
|
||||
broadcast: boolean,
|
||||
/** Indicates if the message was a status update */
|
||||
isStatus: boolean,
|
||||
/** Indicates if the message is a Gif */
|
||||
isGif: boolean,
|
||||
/** Indicates if the message will disappear after it expires */
|
||||
isEphemeral: 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 */
|
||||
@@ -517,6 +561,11 @@ declare namespace WAWebJS {
|
||||
id: MessageId,
|
||||
/** Indicates if the message was forwarded */
|
||||
isForwarded: boolean,
|
||||
/**
|
||||
* Indicates how many times the message was forwarded.
|
||||
* The maximum value is 127.
|
||||
*/
|
||||
forwardingScore: number,
|
||||
/** Indicates if the message was starred */
|
||||
isStarred: boolean,
|
||||
/** Location information contained in the message, if the message is type "location" */
|
||||
@@ -540,7 +589,10 @@ declare namespace WAWebJS {
|
||||
/** Message type */
|
||||
type: MessageTypes,
|
||||
/** Links included in the message. */
|
||||
links: string[],
|
||||
links: Array<{
|
||||
link: string,
|
||||
isSuspicious: boolean
|
||||
}>,
|
||||
/** Order ID */
|
||||
orderId: string,
|
||||
/** title */
|
||||
@@ -551,6 +603,12 @@ declare namespace WAWebJS {
|
||||
businessOwnerJid?: string,
|
||||
/** Product JID */
|
||||
productId?: string,
|
||||
/** Message buttons */
|
||||
dynamicReplyButtons?: object,
|
||||
/** Selected button ID */
|
||||
selectedButtonId?: string,
|
||||
/** Selected list row ID */
|
||||
selectedRowId?: string,
|
||||
/** Accept the Group V4 Invite in message */
|
||||
acceptGroupV4Invite: () => Promise<{status: number}>,
|
||||
/** Deletes the message from the chat */
|
||||
@@ -585,6 +643,10 @@ declare namespace WAWebJS {
|
||||
* Gets the order associated with a given message
|
||||
*/
|
||||
getOrder: () => Order,
|
||||
/**
|
||||
* Gets the payment details associated with a given message
|
||||
*/
|
||||
getPayment: () => Payment,
|
||||
}
|
||||
|
||||
/** ID that represents a message */
|
||||
@@ -595,10 +657,13 @@ declare namespace WAWebJS {
|
||||
_serialized: string,
|
||||
}
|
||||
|
||||
export interface Location {
|
||||
description?: string | null,
|
||||
latitude: string,
|
||||
longitude: string,
|
||||
/** Location information */
|
||||
export class Location {
|
||||
description?: string | null
|
||||
latitude: string
|
||||
longitude: string
|
||||
|
||||
constructor(latitude: number, longitude: number, description?: string)
|
||||
}
|
||||
|
||||
export interface Label {
|
||||
@@ -647,6 +712,13 @@ declare namespace WAWebJS {
|
||||
stickerCategories?: string[]
|
||||
}
|
||||
|
||||
export interface MediaFromURLOptions {
|
||||
client?: Client
|
||||
filename?: string
|
||||
unsafeMime?: boolean
|
||||
reqOptions?: RequestInit
|
||||
}
|
||||
|
||||
/** Media attached to a message */
|
||||
export class MessageMedia {
|
||||
/** MIME type of the attachment */
|
||||
@@ -665,9 +737,12 @@ declare namespace WAWebJS {
|
||||
|
||||
/** Creates a MessageMedia instance from a local file path */
|
||||
static fromFilePath: (filePath: string) => MessageMedia
|
||||
|
||||
/** Creates a MessageMedia instance from a URL */
|
||||
static fromUrl: (url: string, options?: MediaFromURLOptions) => Promise<MessageMedia>
|
||||
}
|
||||
|
||||
export type MessageContent = string | MessageMedia | Location | Contact | Contact[]
|
||||
export type MessageContent = string | MessageMedia | Location | Contact | Contact[] | List | Buttons
|
||||
|
||||
/**
|
||||
* Represents a Contact on WhatsApp
|
||||
@@ -745,9 +820,16 @@ declare namespace WAWebJS {
|
||||
* Will return null when getting chat for currently logged in user.
|
||||
*/
|
||||
getChat: () => Promise<Chat>,
|
||||
|
||||
|
||||
/** Returns the contact's countrycode, (1541859685@c.us) => (1) */
|
||||
getCountryCode(): Promise<string>,
|
||||
|
||||
/** Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901) */
|
||||
getFormattedNumber(): Promise<string>,
|
||||
|
||||
/** Blocks this contact from WhatsApp */
|
||||
block: () => Promise<boolean>,
|
||||
|
||||
/** Unlocks this contact from WhatsApp */
|
||||
unblock: () => Promise<boolean>,
|
||||
|
||||
@@ -826,8 +908,8 @@ declare namespace WAWebJS {
|
||||
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>,
|
||||
/** Mutes this chat forever, unless a date is specified */
|
||||
mute: (unmuteDate?: Date) => Promise<void>,
|
||||
/** Send a message to this chat */
|
||||
sendMessage: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
|
||||
/** Set the message as seen */
|
||||
@@ -850,10 +932,9 @@ declare namespace WAWebJS {
|
||||
|
||||
export interface MessageSearchOptions {
|
||||
/**
|
||||
* The amount of messages to return.
|
||||
* The amount of messages to return. If no limit is specified, the available messages will be returned.
|
||||
* 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
|
||||
}
|
||||
@@ -1033,6 +1114,111 @@ declare namespace WAWebJS {
|
||||
/** Order Created At*/
|
||||
createdAt: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Payment on WhatsApp
|
||||
*
|
||||
* @example
|
||||
* {
|
||||
* id: {
|
||||
* fromMe: true,
|
||||
* remote: {
|
||||
* server: 'c.us',
|
||||
* user: '5511999999999',
|
||||
* _serialized: '5511999999999@c.us'
|
||||
* },
|
||||
* id: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
||||
* _serialized: 'true_5511999999999@c.us_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
||||
* },
|
||||
* paymentCurrency: 'BRL',
|
||||
* paymentAmount1000: 1000,
|
||||
* paymentMessageReceiverJid: {
|
||||
* server: 'c.us',
|
||||
* user: '5511999999999',
|
||||
* _serialized: '5511999999999@c.us'
|
||||
* },
|
||||
* paymentTransactionTimestamp: 1623463058,
|
||||
* paymentStatus: 4,
|
||||
* paymentTxnStatus: 4,
|
||||
* paymentNote: 'note'
|
||||
* }
|
||||
*/
|
||||
export interface Payment {
|
||||
/** Payment Id*/
|
||||
id: object,
|
||||
/** Payment currency */
|
||||
paymentCurrency: string,
|
||||
/** Payment ammount */
|
||||
paymentAmount1000 : number,
|
||||
/** Payment receiver */
|
||||
paymentMessageReceiverJid : object,
|
||||
/** Payment transaction timestamp */
|
||||
paymentTransactionTimestamp : number,
|
||||
/** Payment paymentStatus */
|
||||
paymentStatus : number,
|
||||
/** Integer that represents the payment Text */
|
||||
paymentTxnStatus : number,
|
||||
/** The note sent with the payment */
|
||||
paymentNote : string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Call on WhatsApp
|
||||
*
|
||||
* @example
|
||||
* Call {
|
||||
* id: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
||||
* from: '5511999999@c.us',
|
||||
* timestamp: 1625003709,
|
||||
* isVideo: false,
|
||||
* isGroup: false,
|
||||
* fromMe: false,
|
||||
* canHandleLocally: false,
|
||||
* webClientShouldHandle: false,
|
||||
* participants: []
|
||||
* }
|
||||
*/
|
||||
export interface Call {
|
||||
/** Call Id */
|
||||
id: string,
|
||||
/** from */
|
||||
from?: string,
|
||||
/** Unix timestamp for when the call was created*/
|
||||
timestamp: number,
|
||||
/** Is video */
|
||||
isVideo: boolean,
|
||||
/** Is Group */
|
||||
isGroup: boolean,
|
||||
/** Indicates if the call was sent by the current user */
|
||||
fromMe: boolean,
|
||||
/** indicates if the call can be handled in waweb */
|
||||
canHandleLocally: boolean,
|
||||
/** indicates if the call should be handled in waweb */
|
||||
webClientShouldHandle: boolean,
|
||||
/** Object with participants */
|
||||
participants: object
|
||||
}
|
||||
|
||||
/** Message type List */
|
||||
export class List {
|
||||
body: string
|
||||
buttonText: string
|
||||
sections: Array<any>
|
||||
title?: string | null
|
||||
footer?: string | null
|
||||
|
||||
constructor(body: string, buttonText: string, sections: Array<any>, title?: string | null, footer?: string | null)
|
||||
}
|
||||
|
||||
/** Message type buttons */
|
||||
export class Buttons {
|
||||
body: string | MessageMedia
|
||||
buttons: Array<{ buttonId: string; buttonText: {displayText: string}; type: number }>
|
||||
title?: string | null
|
||||
footer?: string | null
|
||||
|
||||
constructor(body: string, buttons: Array<{ id?: string; body: string }>, title?: string | null, footer?: string | null)
|
||||
}
|
||||
}
|
||||
|
||||
export = WAWebJS
|
||||
|
||||
2
index.js
2
index.js
@@ -19,5 +19,7 @@ module.exports = {
|
||||
ClientInfo: require('./src/structures/ClientInfo'),
|
||||
Location: require('./src/structures/Location'),
|
||||
ProductMetadata: require('./src/structures/ProductMetadata'),
|
||||
List: require('./src/structures/List'),
|
||||
Buttons: require('./src/structures/Buttons'),
|
||||
...Constants
|
||||
};
|
||||
|
||||
31
package.json
31
package.json
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "whatsapp-web.js",
|
||||
"version": "1.13.2",
|
||||
"version": "1.15.5",
|
||||
"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",
|
||||
"test": "mocha tests --recursive",
|
||||
"test-single": "mocha",
|
||||
"shell": "node --experimental-repl-await ./shell.js",
|
||||
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
|
||||
},
|
||||
@@ -26,19 +27,29 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/pedroslopez/whatsapp-web.js/issues"
|
||||
},
|
||||
"homepage": "https://waguide.pedroslopez.me/",
|
||||
"homepage": "https://wwebjs.dev/",
|
||||
"dependencies": {
|
||||
"@pedroslopez/moduleraid": "^5.0.1",
|
||||
"@pedroslopez/moduleraid": "^5.0.2",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"jsqr": "^1.3.1",
|
||||
"mime": "^2.4.5",
|
||||
"node-webpmux": "^2.0.0",
|
||||
"puppeteer": "^5.2.1",
|
||||
"sharp": "^0.26.3"
|
||||
"mime": "^3.0.0",
|
||||
"node-fetch": "^2.6.5",
|
||||
"node-webpmux": "^3.1.0",
|
||||
"puppeteer": "^13.0.0",
|
||||
"sharp": "^0.28.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.27.0",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"chai": "^4.3.4",
|
||||
"dotenv": "^16.0.0",
|
||||
"eslint": "^8.4.1",
|
||||
"eslint-plugin-mocha": "^10.0.3",
|
||||
"jsdoc": "^3.6.4",
|
||||
"jsdoc-baseline": "^0.1.5"
|
||||
"jsdoc-baseline": "^0.1.5",
|
||||
"mocha": "^9.0.2",
|
||||
"sinon": "^13.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
173
src/Client.js
173
src/Client.js
@@ -11,7 +11,7 @@ const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./util/Constan
|
||||
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
||||
const ChatFactory = require('./factories/ChatFactory');
|
||||
const ContactFactory = require('./factories/ContactFactory');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label } = require('./structures');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label, Call, Buttons, List} = require('./structures');
|
||||
/**
|
||||
* Starting point for interacting with the WhatsApp Web API
|
||||
* @extends {EventEmitter}
|
||||
@@ -20,6 +20,7 @@ const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification
|
||||
* @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 {number} options.qrMaxRetries - How many times should the qrcode be refreshed before giving up
|
||||
* @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
|
||||
@@ -65,13 +66,26 @@ class Client extends EventEmitter {
|
||||
* Sets up events and requirements, kicks off authentication request
|
||||
*/
|
||||
async initialize() {
|
||||
const browser = await puppeteer.launch(this.options.puppeteer);
|
||||
const page = (await browser.pages())[0];
|
||||
page.setUserAgent(this.options.userAgent);
|
||||
let [browser, page] = [null, null];
|
||||
|
||||
if(this.options.puppeteer && this.options.puppeteer.browserWSEndpoint) {
|
||||
browser = await puppeteer.connect(this.options.puppeteer);
|
||||
page = await browser.newPage();
|
||||
} else {
|
||||
browser = await puppeteer.launch(this.options.puppeteer);
|
||||
page = (await browser.pages())[0];
|
||||
}
|
||||
|
||||
await page.setUserAgent(this.options.userAgent);
|
||||
|
||||
this.pupBrowser = browser;
|
||||
this.pupPage = page;
|
||||
|
||||
// remember me
|
||||
await page.evaluateOnNewDocument(() => {
|
||||
localStorage.setItem('remember-me', 'true');
|
||||
});
|
||||
|
||||
if (this.options.session) {
|
||||
await page.evaluateOnNewDocument(
|
||||
session => {
|
||||
@@ -92,10 +106,10 @@ class Client extends EventEmitter {
|
||||
timeout: 0,
|
||||
});
|
||||
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-icon="intro-md-beta-logo-dark"], [data-icon="intro-md-beta-logo-light"], [data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||
|
||||
if (this.options.session) {
|
||||
// Check if session restore was successfull
|
||||
// Check if session restore was successful
|
||||
try {
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: this.options.authTimeoutMs });
|
||||
} catch (err) {
|
||||
@@ -119,6 +133,8 @@ class Client extends EventEmitter {
|
||||
}
|
||||
|
||||
} else {
|
||||
let qrRetries = 0;
|
||||
|
||||
const getQrCode = async () => {
|
||||
// Check if retry button is present
|
||||
var QR_RETRY_SELECTOR = 'div[data-ref] > span > button';
|
||||
@@ -139,19 +155,39 @@ class Client extends EventEmitter {
|
||||
* @param {string} qr QR Code
|
||||
*/
|
||||
this.emit(Events.QR_RECEIVED, qr);
|
||||
|
||||
if (this.options.qrMaxRetries > 0) {
|
||||
qrRetries++;
|
||||
if (qrRetries > this.options.qrMaxRetries) {
|
||||
this.emit(Events.DISCONNECTED, 'Max qrcode retries reached');
|
||||
await this.destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
getQrCode();
|
||||
this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
|
||||
|
||||
// Wait for code scan
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
this._qrRefreshInterval = undefined;
|
||||
try {
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
this._qrRefreshInterval = undefined;
|
||||
} catch(error) {
|
||||
if (
|
||||
error.name === 'ProtocolError' &&
|
||||
error.message &&
|
||||
error.message.match(/Target closed/)
|
||||
) {
|
||||
// something has called .destroy() while waiting
|
||||
return;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
await page.evaluate(ExposeStore, moduleRaid.toString());
|
||||
|
||||
|
||||
// Get session tokens
|
||||
const localStorage = JSON.parse(await page.evaluate(() => {
|
||||
return JSON.stringify(window.localStorage);
|
||||
@@ -178,6 +214,14 @@ class Client extends EventEmitter {
|
||||
// Check window.Store Injection
|
||||
await page.waitForFunction('window.Store != undefined');
|
||||
|
||||
const isMD = await page.evaluate(() => {
|
||||
return window.Store.Features.features.MD_BACKEND;
|
||||
});
|
||||
|
||||
if(isMD) {
|
||||
throw new Error('Multi-device is not yet supported by whatsapp-web.js. Please check out https://github.com/pedroslopez/whatsapp-web.js/pull/889 to follow the progress.');
|
||||
}
|
||||
|
||||
//Load util functions (serializers, helper functions)
|
||||
await page.evaluate(LoadUtils);
|
||||
|
||||
@@ -195,8 +239,6 @@ class Client extends EventEmitter {
|
||||
|
||||
// Register events
|
||||
await page.exposeFunction('onAddMessageEvent', msg => {
|
||||
if (!msg.isNewMsg) return;
|
||||
|
||||
if (msg.type === 'gp2') {
|
||||
const notification = new GroupNotification(this, msg);
|
||||
if (msg.subtype === 'add' || msg.subtype === 'invite') {
|
||||
@@ -362,8 +404,25 @@ class Client extends EventEmitter {
|
||||
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
|
||||
});
|
||||
|
||||
await page.exposeFunction('onIncomingCall', (call) => {
|
||||
/**
|
||||
* Emitted when a call is received
|
||||
* @event Client#incoming_call
|
||||
* @param {object} call
|
||||
* @param {number} call.id - Call id
|
||||
* @param {string} call.peerJid - Who called
|
||||
* @param {boolean} call.isVideo - if is video
|
||||
* @param {boolean} call.isGroup - if is group
|
||||
* @param {boolean} call.canHandleLocally - if we can handle in waweb
|
||||
* @param {boolean} call.outgoing - if is outgoing
|
||||
* @param {boolean} call.webClientShouldHandle - If Waweb should handle
|
||||
* @param {object} call.participants - Participants
|
||||
*/
|
||||
const cll = new Call(this,call);
|
||||
this.emit(Events.INCOMING_CALL, cll);
|
||||
});
|
||||
|
||||
await page.evaluate(() => {
|
||||
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); });
|
||||
@@ -371,6 +430,17 @@ class Client extends EventEmitter {
|
||||
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); });
|
||||
window.Store.Call.on('add', (call) => { window.onIncomingCall(call); });
|
||||
window.Store.Msg.on('add', (msg) => {
|
||||
if (msg.isNewMsg) {
|
||||
if(msg.type === 'ciphertext') {
|
||||
// defer message event until ciphertext is resolved (type changed)
|
||||
msg.once('change:type', (_msg) => window.onAddMessageEvent(window.WWebJS.getMessageModel(_msg)));
|
||||
} else {
|
||||
window.onAddMessageEvent(window.WWebJS.getMessageModel(msg));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -379,11 +449,13 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
this.emit(Events.READY);
|
||||
|
||||
// Disconnect when navigating away
|
||||
// Because WhatsApp Web now reloads when logging out from the device, this also covers that case
|
||||
// Disconnect when navigating away when in PAIRING state (detect logout)
|
||||
this.pupPage.on('framenavigated', async () => {
|
||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||
await this.destroy();
|
||||
const appState = await this.getState();
|
||||
if(appState === WAState.PAIRING) {
|
||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||
await this.destroy();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -452,7 +524,7 @@ class Client extends EventEmitter {
|
||||
/**
|
||||
* Send a message to a specific chatId
|
||||
* @param {string} chatId
|
||||
* @param {string|MessageMedia|Location|Contact|Array<Contact>} content
|
||||
* @param {string|MessageMedia|Location|Contact|Array<Contact>|Buttons|List} content
|
||||
* @param {MessageSendOptions} [options] - Options used when sending the message
|
||||
*
|
||||
* @returns {Promise<Message>} Message that was just sent
|
||||
@@ -468,7 +540,7 @@ class Client extends EventEmitter {
|
||||
quotedMessageId: options.quotedMessageId,
|
||||
parseVCards: options.parseVCards === false ? false : true,
|
||||
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : [],
|
||||
...options.extra
|
||||
extraOptions: options.extra
|
||||
};
|
||||
|
||||
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
||||
@@ -489,6 +561,13 @@ class Client extends EventEmitter {
|
||||
} else if(Array.isArray(content) && content.length > 0 && content[0] instanceof Contact) {
|
||||
internalOptions.contactCardList = content.map(contact => contact.id._serialized);
|
||||
content = '';
|
||||
} else if(content instanceof Buttons){
|
||||
if(content.type !== 'chat'){internalOptions.attachment = content.body;}
|
||||
internalOptions.buttons = content;
|
||||
content = '';
|
||||
} else if(content instanceof List){
|
||||
internalOptions.list = content;
|
||||
content = '';
|
||||
}
|
||||
|
||||
if (internalOptions.sendMediaAsSticker && internalOptions.attachment) {
|
||||
@@ -669,7 +748,7 @@ class Client extends EventEmitter {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, true);
|
||||
return chat.archive;
|
||||
return true;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
@@ -681,7 +760,7 @@ class Client extends EventEmitter {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, false);
|
||||
return chat.archive;
|
||||
return false;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
@@ -723,15 +802,16 @@ class Client extends EventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutes the Chat until a specified date
|
||||
* Mutes this chat forever, unless a date is specified
|
||||
* @param {string} chatId ID of the chat that will be muted
|
||||
* @param {Date} unmuteDate Date when the chat will be unmuted
|
||||
* @param {?Date} unmuteDate Date when the chat will be unmuted, leave as is to mute forever
|
||||
*/
|
||||
async muteChat(chatId, unmuteDate) {
|
||||
unmuteDate = unmuteDate ? unmuteDate.getTime() / 1000 : -1;
|
||||
await this.pupPage.evaluate(async (chatId, timestamp) => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await chat.mute.mute(timestamp, !0);
|
||||
}, chatId, unmuteDate.getTime() / 1000);
|
||||
}, chatId, unmuteDate || -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -797,10 +877,7 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise<Object|null>}
|
||||
*/
|
||||
async getNumberId(number) {
|
||||
if(!number.endsWith('@c.us')) {
|
||||
number += '@c.us';
|
||||
}
|
||||
|
||||
if (!number.endsWith('@c.us')) number += '@c.us';
|
||||
try {
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.WWebJS.getNumberId(numberId);
|
||||
@@ -810,6 +887,33 @@ class Client extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted number of a WhatsApp ID.
|
||||
* @param {string} number Number or ID
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getFormattedNumber(number) {
|
||||
if(!number.endsWith('@s.whatsapp.net')) number = number.replace('c.us', 's.whatsapp.net');
|
||||
if(!number.includes('@s.whatsapp.net')) number = `${number}@s.whatsapp.net`;
|
||||
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.Store.NumberInfo.formattedPhoneNumber(numberId);
|
||||
}, number);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the country code of a WhatsApp ID.
|
||||
* @param {string} number Number or ID
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getCountryCode(number) {
|
||||
number = number.replace(' ', '').replace('+', '').replace('@c.us', '');
|
||||
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.Store.NumberInfo.findCC(numberId);
|
||||
}, number);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new group
|
||||
* @param {string} name group title
|
||||
@@ -904,6 +1008,19 @@ class Client extends EventEmitter {
|
||||
|
||||
return Promise.all(chatIds.map(id => this.getChatById(id)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all blocked contacts by host account
|
||||
* @returns {Promise<Array<Contact>>}
|
||||
*/
|
||||
async getBlockedContacts() {
|
||||
const blockedContacts = await this.pupPage.evaluate(() => {
|
||||
let chatIds = window.Store.Blocklist.models.map(a => a.id._serialized);
|
||||
return Promise.all(chatIds.map(id => window.WWebJS.getContact(id)));
|
||||
});
|
||||
|
||||
return blockedContacts.map(contact => ContactFactory.create(this.client, contact));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
|
||||
82
src/structures/Buttons.js
Normal file
82
src/structures/Buttons.js
Normal file
@@ -0,0 +1,82 @@
|
||||
'use strict';
|
||||
|
||||
const MessageMedia = require('./MessageMedia');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
* Button spec used in Buttons constructor
|
||||
* @typedef {Object} ButtonSpec
|
||||
* @property {string=} id - Custom ID to set on the button. A random one will be generated if one is not passed.
|
||||
* @property {string} body - The text to show on the button.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} FormattedButtonSpec
|
||||
* @property {string} buttonId
|
||||
* @property {number} type
|
||||
* @property {Object} buttonText
|
||||
*/
|
||||
|
||||
/**
|
||||
* Message type buttons
|
||||
*/
|
||||
class Buttons {
|
||||
/**
|
||||
* @param {string|MessageMedia} body
|
||||
* @param {ButtonSpec[]} buttons - See {@link ButtonSpec}
|
||||
* @param {string?} title
|
||||
* @param {string?} footer
|
||||
*/
|
||||
constructor(body, buttons, title, footer) {
|
||||
/**
|
||||
* Message body
|
||||
* @type {string|MessageMedia}
|
||||
*/
|
||||
this.body = body;
|
||||
|
||||
/**
|
||||
* title of message
|
||||
* @type {string}
|
||||
*/
|
||||
this.title = title;
|
||||
|
||||
/**
|
||||
* footer of message
|
||||
* @type {string}
|
||||
*/
|
||||
this.footer = footer;
|
||||
|
||||
if (body instanceof MessageMedia) {
|
||||
this.type = 'media';
|
||||
this.title = '';
|
||||
}else{
|
||||
this.type = 'chat';
|
||||
}
|
||||
|
||||
/**
|
||||
* buttons of message
|
||||
* @type {FormattedButtonSpec[]}
|
||||
*/
|
||||
this.buttons = this._format(buttons);
|
||||
if(!this.buttons.length){ throw '[BT01] No buttons';}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates button array from simple array
|
||||
* @param {ButtonSpec[]} buttons
|
||||
* @returns {FormattedButtonSpec[]}
|
||||
* @example
|
||||
* Input: [{id:'customId',body:'button1'},{body:'button2'},{body:'button3'},{body:'button4'}]
|
||||
* Returns: [{ buttonId:'customId',buttonText:{'displayText':'button1'},type: 1 },{buttonId:'n3XKsL',buttonText:{'displayText':'button2'},type:1},{buttonId:'NDJk0a',buttonText:{'displayText':'button3'},type:1}]
|
||||
*/
|
||||
_format(buttons){
|
||||
buttons = buttons.slice(0,3); // phone users can only see 3 buttons, so lets limit this
|
||||
return buttons.map((btn) => {
|
||||
return {'buttonId':btn.id ? String(btn.id) : Util.generateHash(6),'buttonText':{'displayText':btn.body},'type':1};
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Buttons;
|
||||
68
src/structures/Call.js
Normal file
68
src/structures/Call.js
Normal file
@@ -0,0 +1,68 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Represents a Call on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class Call extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* Call ID
|
||||
* @type {string}
|
||||
*/
|
||||
this.id = data.id;
|
||||
/**
|
||||
* From
|
||||
* @type {string}
|
||||
*/
|
||||
this.from = data.peerJid;
|
||||
/**
|
||||
* Unix timestamp for when the call was created
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.offerTime;
|
||||
/**
|
||||
* Is video
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isVideo = data.isVideo;
|
||||
/**
|
||||
* Is Group
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isGroup = data.isGroup;
|
||||
/**
|
||||
* Indicates if the call was sent by the current user
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.fromMe = data.outgoing;
|
||||
/**
|
||||
* Indicates if the call can be handled in waweb
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.canHandleLocally = data.canHandleLocally;
|
||||
/**
|
||||
* Indicates if the call Should be handled in waweb
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.webClientShouldHandle = data.webClientShouldHandle;
|
||||
/**
|
||||
* Object with participants
|
||||
* @type {object}
|
||||
*/
|
||||
this.participants = data.participants;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Call;
|
||||
@@ -65,7 +65,7 @@ class Chat extends Base {
|
||||
|
||||
/**
|
||||
* Indicates if the chat is muted or not
|
||||
* @type {number}
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isMuted = data.isMuted;
|
||||
|
||||
@@ -147,8 +147,8 @@ class Chat extends Base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutes this chat until a specified date
|
||||
* @param {Date} unmuteDate Date at which the Chat will be unmuted
|
||||
* Mutes this chat forever, unless a date is specified
|
||||
* @param {?Date} unmuteDate Date at which the Chat will be unmuted, leave as is to mute forever
|
||||
*/
|
||||
async mute(unmuteDate) {
|
||||
return this.client.muteChat(this.id._serialized, unmuteDate);
|
||||
@@ -171,30 +171,32 @@ class Chat extends Base {
|
||||
/**
|
||||
* Loads chat messages, sorted from earliest to latest.
|
||||
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
||||
* @param {Number} [searchOptions.limit=50] 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.
|
||||
* @param {Number} [searchOptions.limit] The amount of messages to return. If no limit is specified, the available messages will be returned. 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.
|
||||
* @returns {Promise<Array<Message>>}
|
||||
*/
|
||||
async fetchMessages(searchOptions) {
|
||||
if (!searchOptions || !searchOptions.limit) {
|
||||
searchOptions = { limit: 50 };
|
||||
}
|
||||
let messages = await this.client.pupPage.evaluate(async (chatId, limit) => {
|
||||
let messages = await this.client.pupPage.evaluate(async (chatId, searchOptions) => {
|
||||
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) {
|
||||
const loadedMessages = await chat.loadEarlierMsgs();
|
||||
if (!loadedMessages) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
if (searchOptions && searchOptions.limit > 0) {
|
||||
while (msgs.length < searchOptions.limit) {
|
||||
const loadedMessages = await chat.loadEarlierMsgs();
|
||||
if (!loadedMessages) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
}
|
||||
|
||||
if (msgs.length > searchOptions.limit) {
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
msgs = msgs.splice(msgs.length - searchOptions.limit);
|
||||
}
|
||||
}
|
||||
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
if (msgs.length > limit) msgs = msgs.splice(msgs.length - limit);
|
||||
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
||||
|
||||
}, this.id._serialized, searchOptions.limit);
|
||||
}, this.id._serialized, searchOptions);
|
||||
|
||||
return messages.map(m => new Message(this.client, m));
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ class Contact extends Base {
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isBlocked = data.isBlocked;
|
||||
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,22 @@ class Contact extends Base {
|
||||
return await this.client.getProfilePicUrl(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901)
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getFormattedNumber() {
|
||||
return await this.client.getFormattedNumber(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contact's countrycode, (1541859685@c.us) => (1)
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getCountryCode() {
|
||||
return await this.client.getCountryCode(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Chat that corresponds to this Contact.
|
||||
* Will return null when getting chat for currently logged in user.
|
||||
@@ -178,4 +194,4 @@ class Contact extends Base {
|
||||
|
||||
}
|
||||
|
||||
module.exports = Contact;
|
||||
module.exports = Contact;
|
||||
|
||||
@@ -43,7 +43,7 @@ class GroupNotification extends Base {
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.chatId = typeof (data.from) === 'object' ? data.from._serialized : data.from;
|
||||
this.chatId = typeof (data.to) === 'object' ? data.to._serialized : data.to;
|
||||
|
||||
/**
|
||||
* ContactId for the user that produced the GroupNotification.
|
||||
|
||||
79
src/structures/List.js
Normal file
79
src/structures/List.js
Normal file
@@ -0,0 +1,79 @@
|
||||
'use strict';
|
||||
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
* Message type List
|
||||
*/
|
||||
class List {
|
||||
/**
|
||||
* @param {string} body
|
||||
* @param {string} buttonText
|
||||
* @param {Array<any>} sections
|
||||
* @param {string?} title
|
||||
* @param {string?} footer
|
||||
*/
|
||||
constructor(body, buttonText, sections, title, footer) {
|
||||
/**
|
||||
* Message body
|
||||
* @type {string}
|
||||
*/
|
||||
this.description = body;
|
||||
|
||||
/**
|
||||
* List button text
|
||||
* @type {string}
|
||||
*/
|
||||
this.buttonText = buttonText;
|
||||
|
||||
/**
|
||||
* title of message
|
||||
* @type {string}
|
||||
*/
|
||||
this.title = title;
|
||||
|
||||
|
||||
/**
|
||||
* footer of message
|
||||
* @type {string}
|
||||
*/
|
||||
this.footer = footer;
|
||||
|
||||
/**
|
||||
* sections of message
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
this.sections = this._format(sections);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates section array from simple array
|
||||
* @param {Array<any>} sections
|
||||
* @returns {Array<any>}
|
||||
* @example
|
||||
* Input: [{title:'sectionTitle',rows:[{id:'customId', title:'ListItem2', description: 'desc'},{title:'ListItem2'}]}}]
|
||||
* Returns: [{'title':'sectionTitle','rows':[{'rowId':'customId','title':'ListItem1','description':'desc'},{'rowId':'oGSRoD','title':'ListItem2','description':''}]}]
|
||||
*/
|
||||
_format(sections){
|
||||
if(!sections.length){throw '[LT02] List without sections';}
|
||||
if(sections.length > 1 && sections.filter(s => typeof s.title == 'undefined').length > 1){throw '[LT05] You can\'t have more than one empty title.';}
|
||||
return sections.map( (section) =>{
|
||||
if(!section.rows.length){throw '[LT03] Section without rows';}
|
||||
return {
|
||||
title: section.title ? section.title : undefined,
|
||||
rows: section.rows.map( (row) => {
|
||||
if(!row.title){throw '[LT04] Row without title';}
|
||||
return {
|
||||
rowId: row.id ? row.id : Util.generateHash(6),
|
||||
title: row.title,
|
||||
description: row.description ? row.description : ''
|
||||
};
|
||||
})
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = List;
|
||||
@@ -4,6 +4,7 @@ const Base = require('./Base');
|
||||
const MessageMedia = require('./MessageMedia');
|
||||
const Location = require('./Location');
|
||||
const Order = require('./Order');
|
||||
const Payment = require('./Payment');
|
||||
const { MessageTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
@@ -94,6 +95,14 @@ class Message extends Base {
|
||||
*/
|
||||
this.isForwarded = data.isForwarded;
|
||||
|
||||
/**
|
||||
* Indicates how many times the message was forwarded.
|
||||
*
|
||||
* The maximum value is 127.
|
||||
* @type {number}
|
||||
*/
|
||||
this.forwardingScore = data.forwardingScore || 0;
|
||||
|
||||
/**
|
||||
* Indicates if the message is a status update
|
||||
* @type {boolean}
|
||||
@@ -170,6 +179,18 @@ class Message extends Base {
|
||||
*/
|
||||
this.token = data.token ? data.token : undefined;
|
||||
|
||||
/**
|
||||
* Indicates whether the message is a Gif
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isGif = Boolean(data.isGif);
|
||||
|
||||
/**
|
||||
* Indicates if the message will disappear after it expires
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isEphemeral = data.isEphemeral;
|
||||
|
||||
/** Title */
|
||||
if (data.title) {
|
||||
this.title = data.title;
|
||||
@@ -192,10 +213,26 @@ class Message extends Base {
|
||||
|
||||
/**
|
||||
* Links included in the message.
|
||||
* @type {Array<string>}
|
||||
* @type {Array<{link: string, isSuspicious: boolean}>}
|
||||
*
|
||||
*/
|
||||
this.links = data.links;
|
||||
|
||||
/** Buttons */
|
||||
if (data.dynamicReplyButtons) {
|
||||
this.dynamicReplyButtons = data.dynamicReplyButtons;
|
||||
}
|
||||
|
||||
/** Selected Button Id **/
|
||||
if (data.selectedButtonId) {
|
||||
this.selectedButtonId = data.selectedButtonId;
|
||||
}
|
||||
|
||||
/** Selected List row Id **/
|
||||
if (data.listResponse && data.listResponse.singleSelectReply.selectedRowId) {
|
||||
this.selectedRowId = data.listResponse.singleSelectReply.selectedRowId;
|
||||
}
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
@@ -304,32 +341,39 @@ class Message extends Base {
|
||||
|
||||
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
||||
// try to resolve media
|
||||
await msg.downloadMedia(true, 1);
|
||||
await msg.downloadMedia({
|
||||
downloadEvenIfExpensive: true,
|
||||
rmrReason: 1
|
||||
});
|
||||
}
|
||||
|
||||
if (msg.mediaData.mediaStage.includes('ERROR')) {
|
||||
if (msg.mediaData.mediaStage.includes('ERROR') || msg.mediaData.mediaStage === 'FETCHING') {
|
||||
// media could not be downloaded
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const decryptedMedia = await window.Store.DownloadManager.downloadAndDecrypt({
|
||||
directPath: msg.directPath,
|
||||
encFilehash: msg.encFilehash,
|
||||
filehash: msg.filehash,
|
||||
mediaKey: msg.mediaKey,
|
||||
mediaKeyTimestamp: msg.mediaKeyTimestamp,
|
||||
type: msg.type,
|
||||
signal: (new AbortController).signal
|
||||
});
|
||||
|
||||
const data = window.WWebJS.arrayBufferToBase64(decryptedMedia);
|
||||
|
||||
return {
|
||||
data,
|
||||
mimetype: msg.mimetype,
|
||||
filename: msg.filename
|
||||
};
|
||||
|
||||
try {
|
||||
const decryptedMedia = await window.Store.DownloadManager.downloadAndDecrypt({
|
||||
directPath: msg.directPath,
|
||||
encFilehash: msg.encFilehash,
|
||||
filehash: msg.filehash,
|
||||
mediaKey: msg.mediaKey,
|
||||
mediaKeyTimestamp: msg.mediaKeyTimestamp,
|
||||
type: msg.type,
|
||||
signal: (new AbortController).signal
|
||||
});
|
||||
|
||||
const data = window.WWebJS.arrayBufferToBase64(decryptedMedia);
|
||||
|
||||
return {
|
||||
data,
|
||||
mimetype: msg.mimetype,
|
||||
filename: msg.filename
|
||||
};
|
||||
} catch (e) {
|
||||
if(e.status && e.status === 404) return undefined;
|
||||
throw e;
|
||||
}
|
||||
}, this.id._serialized);
|
||||
|
||||
if (!result) return undefined;
|
||||
@@ -344,7 +388,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -422,6 +466,21 @@ class Message extends Base {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
/**
|
||||
* Gets the payment details associated with a given message
|
||||
* @return {Promise<Payment>}
|
||||
*/
|
||||
async getPayment() {
|
||||
if (this.type === MessageTypes.PAYMENT) {
|
||||
const msg = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
if(!msg) return null;
|
||||
return msg.serialize();
|
||||
}, this.id._serialized);
|
||||
return new Payment(this.client, msg);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Message;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const mime = require('mime');
|
||||
const fetch = require('node-fetch');
|
||||
const { URL } = require('url');
|
||||
|
||||
/**
|
||||
* Media attached to a message
|
||||
@@ -43,6 +45,59 @@ class MessageMedia {
|
||||
|
||||
return new MessageMedia(mimetype, b64data, filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a MessageMedia instance from a URL
|
||||
* @param {string} url
|
||||
* @param {Object} [options]
|
||||
* @param {boolean} [options.unsafeMime=false]
|
||||
* @param {string} [options.filename]
|
||||
* @param {object} [options.client]
|
||||
* @param {object} [options.reqOptions]
|
||||
* @param {number} [options.reqOptions.size=0]
|
||||
* @returns {Promise<MessageMedia>}
|
||||
*/
|
||||
static async fromUrl(url, options = {}) {
|
||||
const pUrl = new URL(url);
|
||||
let mimetype = mime.getType(pUrl.pathname);
|
||||
|
||||
if (!mimetype && !options.unsafeMime)
|
||||
throw new Error('Unable to determine MIME type using URL. Set unsafeMime to true to download it anyway.');
|
||||
|
||||
async function fetchData (url, options) {
|
||||
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
||||
const response = await fetch(url, reqOptions);
|
||||
const mime = response.headers.get('Content-Type');
|
||||
|
||||
const contentDisposition = response.headers.get('Content-Disposition');
|
||||
const name = contentDisposition ? contentDisposition.match(/((?<=filename=")(.*)(?="))/) : null;
|
||||
|
||||
let data = '';
|
||||
if (response.buffer) {
|
||||
data = (await response.buffer()).toString('base64');
|
||||
} else {
|
||||
const bArray = new Uint8Array(await response.arrayBuffer());
|
||||
bArray.forEach((b) => {
|
||||
data += String.fromCharCode(b);
|
||||
});
|
||||
data = btoa(data);
|
||||
}
|
||||
|
||||
return { data, mime, name };
|
||||
}
|
||||
|
||||
const res = options.client
|
||||
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
|
||||
: (await fetchData(url, options.reqOptions));
|
||||
|
||||
const filename = options.filename ||
|
||||
(res.name ? res.name[0] : (pUrl.pathname.split('/').pop() || 'file'));
|
||||
|
||||
if (!mimetype)
|
||||
mimetype = res.mime;
|
||||
|
||||
return new MessageMedia(mimetype, res.data, filename);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MessageMedia;
|
||||
module.exports = MessageMedia;
|
||||
|
||||
79
src/structures/Payment.js
Normal file
79
src/structures/Payment.js
Normal file
@@ -0,0 +1,79 @@
|
||||
const Base = require('./Base');
|
||||
|
||||
class Payment extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* The payment Id
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
/**
|
||||
* The payment currency
|
||||
* @type {string}
|
||||
*/
|
||||
this.paymentCurrency = data.paymentCurrency;
|
||||
|
||||
/**
|
||||
* The payment ammount ( R$ 1.00 = 1000 )
|
||||
* @type {number}
|
||||
*/
|
||||
this.paymentAmount1000 = data.paymentAmount1000;
|
||||
|
||||
/**
|
||||
* The payment receiver
|
||||
* @type {object}
|
||||
*/
|
||||
this.paymentMessageReceiverJid = data.paymentMessageReceiverJid;
|
||||
|
||||
/**
|
||||
* The payment transaction timestamp
|
||||
* @type {number}
|
||||
*/
|
||||
this.paymentTransactionTimestamp = data.paymentTransactionTimestamp;
|
||||
|
||||
/**
|
||||
* The paymentStatus
|
||||
*
|
||||
* Possible Status
|
||||
* 0:UNKNOWN_STATUS
|
||||
* 1:PROCESSING
|
||||
* 2:SENT
|
||||
* 3:NEED_TO_ACCEPT
|
||||
* 4:COMPLETE
|
||||
* 5:COULD_NOT_COMPLETE
|
||||
* 6:REFUNDED
|
||||
* 7:EXPIRED
|
||||
* 8:REJECTED
|
||||
* 9:CANCELLED
|
||||
* 10:WAITING_FOR_PAYER
|
||||
* 11:WAITING
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
this.paymentStatus = data.paymentStatus;
|
||||
|
||||
/**
|
||||
* Integer that represents the payment Text
|
||||
* @type {number}
|
||||
*/
|
||||
this.paymentTxnStatus = data.paymentTxnStatus;
|
||||
|
||||
/**
|
||||
* The note sent with the payment
|
||||
* @type {string}
|
||||
*/
|
||||
this.paymentNote = !data.paymentNoteMsg ? undefined : data.paymentNoteMsg.body ? data.paymentNoteMsg.body : undefined ;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Payment;
|
||||
@@ -13,5 +13,9 @@ module.exports = {
|
||||
GroupNotification: require('./GroupNotification'),
|
||||
Label: require('./Label.js'),
|
||||
Order: require('./Order'),
|
||||
Product: require('./Product')
|
||||
};
|
||||
Product: require('./Product'),
|
||||
Call: require('./Call'),
|
||||
Buttons: require('./Buttons'),
|
||||
List: require('./List'),
|
||||
Payment: require('./Payment')
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ exports.DefaultOptions = {
|
||||
qrTimeoutMs: 45000,
|
||||
qrRefreshIntervalMs: 20000,
|
||||
authTimeoutMs: 45000,
|
||||
qrMaxRetries: 0,
|
||||
takeoverOnConflict: false,
|
||||
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',
|
||||
@@ -50,7 +51,8 @@ exports.Events = {
|
||||
QR_RECEIVED: 'qr',
|
||||
DISCONNECTED: 'disconnected',
|
||||
STATE_CHANGED: 'change_state',
|
||||
BATTERY_CHANGED: 'change_battery'
|
||||
BATTERY_CHANGED: 'change_battery',
|
||||
INCOMING_CALL: 'incoming_call'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -73,7 +75,27 @@ exports.MessageTypes = {
|
||||
REVOKED: 'revoked',
|
||||
PRODUCT: 'product',
|
||||
UNKNOWN: 'unknown',
|
||||
GROUP_INVITE: 'groups_v4_invite'
|
||||
GROUP_INVITE: 'groups_v4_invite',
|
||||
LIST: 'list',
|
||||
LIST_RESPONSE: 'list_response',
|
||||
BUTTONS_RESPONSE: 'buttons_response',
|
||||
PAYMENT: 'payment',
|
||||
BROADCAST_NOTIFICATION: 'broadcast_notification',
|
||||
CALL_LOG: 'call_log',
|
||||
CIPHERTEXT: 'ciphertext',
|
||||
DEBUG: 'debug',
|
||||
E2E_NOTIFICATION: 'e2e_notification',
|
||||
GP2: 'gp2',
|
||||
GROUP_NOTIFICATION: 'group_notification',
|
||||
HSM: 'hsm',
|
||||
INTERACTIVE: 'interactive',
|
||||
NATIVE_FLOW: 'native_flow',
|
||||
NOTIFICATION: 'notification',
|
||||
NOTIFICATION_TEMPLATE: 'notification_template',
|
||||
OVERSIZED: 'oversized',
|
||||
PROTOCOL: 'protocol',
|
||||
REACTION: 'reaction',
|
||||
TEMPLATE_BUTTON_REPLY: 'template_button_reply',
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,15 +5,14 @@ exports.ExposeStore = (moduleRaidStr) => {
|
||||
eval('var moduleRaid = ' + moduleRaidStr);
|
||||
// eslint-disable-next-line no-undef
|
||||
window.mR = moduleRaid();
|
||||
window.Store = window.mR.findModule('Chat')[0].default;
|
||||
window.Store.AppState = window.mR.findModule('STREAM')[0].default;
|
||||
window.Store.Conn = window.mR.findModule('Conn')[0].default;
|
||||
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
|
||||
window.Store.Wap = window.mR.findModule('Wap')[0].default;
|
||||
window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
|
||||
window.Store.AppState = window.mR.findModule('STREAM')[0].Socket;
|
||||
window.Store.Conn = window.mR.findModule('Conn')[0].Conn;
|
||||
window.Store.Wap = window.mR.findModule('queryLinkPreview')[0].default;
|
||||
window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
|
||||
window.Store.SendClear = window.mR.findModule('sendClear')[0];
|
||||
window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
|
||||
window.Store.genId = window.mR.findModule('randomId')[0].default;
|
||||
window.Store.genId = window.mR.findModule('randomId')[0].randomId;
|
||||
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];
|
||||
@@ -21,7 +20,8 @@ exports.ExposeStore = (moduleRaidStr) => {
|
||||
window.Store.MediaPrep = window.mR.findModule('MediaPrep')[0];
|
||||
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
|
||||
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
|
||||
window.Store.Cmd = window.mR.findModule('Cmd')[0].default;
|
||||
window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
|
||||
window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
|
||||
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
|
||||
window.Store.VCard = window.mR.findModule('vcardFromContactModel')[0];
|
||||
window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
|
||||
@@ -29,13 +29,22 @@ exports.ExposeStore = (moduleRaidStr) => {
|
||||
window.Store.WidFactory = window.mR.findModule('createWid')[0];
|
||||
window.Store.BlockContact = window.mR.findModule('blockContact')[0];
|
||||
window.Store.GroupMetadata = window.mR.findModule((module) => module.default && module.default.handlePendingInvite)[0].default;
|
||||
window.Store.Sticker = window.mR.findModule('Sticker')[0].default.Sticker;
|
||||
window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
|
||||
window.Store.Label = window.mR.findModule('LabelCollection')[0].default;
|
||||
window.Store.Features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0].default;
|
||||
window.Store.Label = window.mR.findModule('LabelCollection')[0].LabelCollection;
|
||||
window.Store.Features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0].GK;
|
||||
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
|
||||
window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
|
||||
window.Store.DownloadManager = window.mR.findModule('DownloadManager')[0].default;
|
||||
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;
|
||||
window.Store.Call = window.mR.findModule('CallCollection')[0].CallCollection;
|
||||
|
||||
if(!window.Store.Chat._find) {
|
||||
window.Store.Chat._find = e => {
|
||||
const target = window.Store.Chat.get(e);
|
||||
return target ? Promise.resolve(target) : Promise.resolve({
|
||||
id: e
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
exports.LoadUtils = () => {
|
||||
@@ -143,13 +152,62 @@ exports.LoadUtils = () => {
|
||||
options = { ...options, ...preview };
|
||||
}
|
||||
}
|
||||
|
||||
let buttonOptions = {};
|
||||
if(options.buttons){
|
||||
let caption;
|
||||
if(options.buttons.type === 'chat') {
|
||||
content = options.buttons.body;
|
||||
caption = content;
|
||||
}else{
|
||||
caption = options.caption ? options.caption : ' '; //Caption can't be empty
|
||||
}
|
||||
buttonOptions = {
|
||||
productHeaderImageRejected: false,
|
||||
isFromTemplate: false,
|
||||
isDynamicReplyButtonsMsg: true,
|
||||
title: options.buttons.title ? options.buttons.title : undefined,
|
||||
footer: options.buttons.footer ? options.buttons.footer : undefined,
|
||||
dynamicReplyButtons: options.buttons.buttons,
|
||||
replyButtons: options.buttons.buttons,
|
||||
caption: caption
|
||||
};
|
||||
delete options.buttons;
|
||||
}
|
||||
|
||||
let listOptions = {};
|
||||
if(options.list){
|
||||
if(window.Store.Conn.platform === 'smba' || window.Store.Conn.platform === 'smbi'){
|
||||
throw '[LT01] Whatsapp business can\'t send this yet';
|
||||
}
|
||||
listOptions = {
|
||||
type: 'list',
|
||||
footer: options.list.footer,
|
||||
list: {
|
||||
...options.list,
|
||||
listType: 1
|
||||
},
|
||||
body: options.list.description
|
||||
};
|
||||
delete options.list;
|
||||
delete listOptions.list.footer;
|
||||
}
|
||||
|
||||
const newMsgId = new window.Store.MsgKey({
|
||||
fromMe: true,
|
||||
remote: chat.id,
|
||||
id: window.Store.genId(),
|
||||
});
|
||||
|
||||
const extraOptions = options.extraOptions || {};
|
||||
delete options.extraOptions;
|
||||
|
||||
const ephemeralSettings = {
|
||||
ephemeralDuration: chat.isEphemeralSettingOn() ? chat.getEphemeralSetting() : undefined,
|
||||
ephemeralSettingTimestamp: chat.getEphemeralSettingTimestamp() || undefined,
|
||||
disappearingModeInitiator: chat.getDisappearingModeInitiator() || undefined,
|
||||
};
|
||||
|
||||
const message = {
|
||||
...options,
|
||||
id: newMsgId,
|
||||
@@ -162,10 +220,14 @@ exports.LoadUtils = () => {
|
||||
t: parseInt(new Date().getTime() / 1000),
|
||||
isNewMsg: true,
|
||||
type: 'chat',
|
||||
...ephemeralSettings,
|
||||
...locationOptions,
|
||||
...attOptions,
|
||||
...quotedMsgOptions,
|
||||
...vcardOptions
|
||||
...vcardOptions,
|
||||
...buttonOptions,
|
||||
...listOptions,
|
||||
...extraOptions
|
||||
};
|
||||
|
||||
await window.Store.SendMessage.addAndSendMsgToChat(chat, message);
|
||||
@@ -263,18 +325,33 @@ exports.LoadUtils = () => {
|
||||
window.WWebJS.getMessageModel = message => {
|
||||
const msg = message.serialize();
|
||||
|
||||
msg.isEphemeral = message.isEphemeral;
|
||||
msg.isStatusV3 = message.isStatusV3;
|
||||
msg.links = (message.getLinks()).map(link => link.href);
|
||||
msg.links = (message.getLinks()).map(link => ({
|
||||
link: link.href,
|
||||
isSuspicious: Boolean(link.suspiciousCharacters && link.suspiciousCharacters.size)
|
||||
}));
|
||||
|
||||
if (msg.buttons) {
|
||||
msg.buttons = msg.buttons.serialize();
|
||||
}
|
||||
if (msg.dynamicReplyButtons) {
|
||||
msg.dynamicReplyButtons = JSON.parse(JSON.stringify(msg.dynamicReplyButtons));
|
||||
}
|
||||
if(msg.replyButtons) {
|
||||
msg.replyButtons = JSON.parse(JSON.stringify(msg.replyButtons));
|
||||
}
|
||||
|
||||
if(typeof msg.id.remote === 'object') {
|
||||
msg.id = Object.assign({}, msg.id, {remote: msg.id.remote._serialized});
|
||||
}
|
||||
|
||||
delete msg.pendingAckUpdate;
|
||||
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
window.WWebJS.getChatModel = async chat => {
|
||||
let res = chat.serialize();
|
||||
res.isGroup = chat.isGroup;
|
||||
@@ -294,7 +371,8 @@ exports.LoadUtils = () => {
|
||||
};
|
||||
|
||||
window.WWebJS.getChat = async chatId => {
|
||||
const chat = window.Store.Chat.get(chatId);
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = await window.Store.Chat.find(chatWid);
|
||||
return await window.WWebJS.getChatModel(chat);
|
||||
};
|
||||
|
||||
@@ -324,8 +402,9 @@ exports.LoadUtils = () => {
|
||||
return res;
|
||||
};
|
||||
|
||||
window.WWebJS.getContact = contactId => {
|
||||
const contact = window.Store.Contact.get(contactId);
|
||||
window.WWebJS.getContact = async contactId => {
|
||||
const wid = window.Store.WidFactory.createWid(contactId);
|
||||
const contact = await window.Store.Contact.find(wid);
|
||||
return window.WWebJS.getContactModel(contact);
|
||||
};
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class InterfaceController {
|
||||
async openChatDrawer(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.chatInfoDrawer(chat);
|
||||
await window.Store.Cmd.openDrawerMid(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
|
||||
@@ -183,9 +183,9 @@ class Util {
|
||||
let jsonBuffer = Buffer.from(JSON.stringify(json), 'utf8');
|
||||
let exif = Buffer.concat([exifAttr, jsonBuffer]);
|
||||
exif.writeUIntLE(jsonBuffer.length, 14, 4);
|
||||
await img.loadBuffer(Buffer.from(webpMedia.data, 'base64'));
|
||||
await img.load(Buffer.from(webpMedia.data, 'base64'));
|
||||
img.exif = exif;
|
||||
webpMedia.data = (await img.saveBuffer()).toString('base64');
|
||||
webpMedia.data = (await img.save(null)).toString('base64');
|
||||
}
|
||||
|
||||
return webpMedia;
|
||||
|
||||
10
tests/README.md
Normal file
10
tests/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
## Running tests
|
||||
|
||||
These tests require an authenticated WhatsApp Web session, as well as an additional phone that you can send messages to.
|
||||
|
||||
This can be configured using the following environment variables:
|
||||
- `WWEBJS_TEST_SESSION`: A JSON-formatted string with the session details. Must include `WABrowserId`, `WASecretBundle`, `WAToken1` and `WAToken2`.
|
||||
- `WWEBJS_TEST_SESSION_PATH`: Path to a JSON file that contains the session details. Must include `WABrowserId`, `WASecretBundle`, `WAToken1` and `WAToken2`.
|
||||
- `WWEBJS_TEST_REMOTE_ID`: A valid WhatsApp ID that you can send messages to, e.g. `123456789@c.us`. It should be different from the ID used by the provided session.
|
||||
|
||||
You *must* set `WWEBJS_TEST_REMOTE_ID` **and** either `WWEBJS_TEST_SESSION` or `WWEBJS_TEST_SESSION_PATH` for the tests to run properly.
|
||||
584
tests/client.js
Normal file
584
tests/client.js
Normal file
@@ -0,0 +1,584 @@
|
||||
const {expect} = require('chai');
|
||||
const sinon = require('sinon');
|
||||
|
||||
const helper = require('./helper');
|
||||
const Chat = require('../src/structures/Chat');
|
||||
const Contact = require('../src/structures/Contact');
|
||||
const Message = require('../src/structures/Message');
|
||||
const MessageMedia = require('../src/structures/MessageMedia');
|
||||
const Location = require('../src/structures/Location');
|
||||
const { MessageTypes, WAState } = require('../src/util/Constants');
|
||||
|
||||
const remoteId = helper.remoteId;
|
||||
|
||||
describe('Client', function() {
|
||||
describe('Authentication', function() {
|
||||
it('should emit QR code if not authenticated', async function() {
|
||||
this.timeout(25000);
|
||||
const callback = sinon.spy();
|
||||
|
||||
const client = helper.createClient();
|
||||
client.on('qr', callback);
|
||||
client.initialize();
|
||||
|
||||
await helper.sleep(20000);
|
||||
|
||||
expect(callback.called).to.equal(true);
|
||||
expect(callback.args[0][0]).to.have.lengthOf(152);
|
||||
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
it('should disconnect after reaching max qr retries', async function () {
|
||||
this.timeout(50000);
|
||||
|
||||
const qrCallback = sinon.spy();
|
||||
const disconnectedCallback = sinon.spy();
|
||||
|
||||
const client = helper.createClient({options: {qrMaxRetries: 2}});
|
||||
client.on('qr', qrCallback);
|
||||
client.on('disconnected', disconnectedCallback);
|
||||
|
||||
client.initialize();
|
||||
|
||||
await helper.sleep(45000);
|
||||
|
||||
expect(qrCallback.calledThrice).to.eql(true);
|
||||
expect(disconnectedCallback.calledOnceWith('Max qrcode retries reached')).to.eql(true);
|
||||
});
|
||||
|
||||
it('should fail auth if session is invalid', async function() {
|
||||
this.timeout(40000);
|
||||
|
||||
const authFailCallback = sinon.spy();
|
||||
const qrCallback = sinon.spy();
|
||||
const readyCallback = sinon.spy();
|
||||
|
||||
const client = helper.createClient({
|
||||
options: {
|
||||
session: {
|
||||
WABrowserId: 'invalid',
|
||||
WASecretBundle: 'invalid',
|
||||
WAToken1: 'invalid',
|
||||
WAToken2: 'invalid'
|
||||
},
|
||||
authTimeoutMs: 10000,
|
||||
restartOnAuthFail: false
|
||||
}
|
||||
});
|
||||
|
||||
client.on('qr', qrCallback);
|
||||
client.on('auth_failure', authFailCallback);
|
||||
client.on('ready', readyCallback);
|
||||
|
||||
client.initialize();
|
||||
|
||||
await helper.sleep(25000);
|
||||
|
||||
expect(authFailCallback.called).to.equal(true);
|
||||
expect(authFailCallback.args[0][0]).to.equal('Unable to log in. Are the session details valid?');
|
||||
|
||||
expect(readyCallback.called).to.equal(false);
|
||||
expect(qrCallback.called).to.equal(false);
|
||||
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
it('can restart without a session if session was invalid and restartOnAuthFail=true', async function() {
|
||||
this.timeout(40000);
|
||||
|
||||
const authFailCallback = sinon.spy();
|
||||
const qrCallback = sinon.spy();
|
||||
|
||||
const client = helper.createClient({
|
||||
options:{
|
||||
session: {
|
||||
WABrowserId: 'invalid',
|
||||
WASecretBundle: 'invalid',
|
||||
WAToken1: 'invalid',
|
||||
WAToken2: 'invalid'
|
||||
},
|
||||
authTimeoutMs: 10000,
|
||||
restartOnAuthFail: true
|
||||
}
|
||||
});
|
||||
|
||||
client.on('auth_failure', authFailCallback);
|
||||
client.on('qr', qrCallback);
|
||||
|
||||
client.initialize();
|
||||
|
||||
await helper.sleep(35000);
|
||||
|
||||
expect(authFailCallback.called).to.equal(true);
|
||||
expect(qrCallback.called).to.equal(true);
|
||||
expect(qrCallback.args[0][0]).to.have.lengthOf(152);
|
||||
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
it('should authenticate with existing session', async function() {
|
||||
this.timeout(40000);
|
||||
|
||||
const authenticatedCallback = sinon.spy();
|
||||
const qrCallback = sinon.spy();
|
||||
const readyCallback = sinon.spy();
|
||||
|
||||
const client = helper.createClient({withSession: true});
|
||||
client.on('qr', qrCallback);
|
||||
client.on('authenticated', authenticatedCallback);
|
||||
client.on('ready', readyCallback);
|
||||
|
||||
await client.initialize();
|
||||
|
||||
expect(authenticatedCallback.called).to.equal(true);
|
||||
const newSession = authenticatedCallback.args[0][0];
|
||||
expect(newSession).to.have.key([
|
||||
'WABrowserId',
|
||||
'WASecretBundle',
|
||||
'WAToken1',
|
||||
'WAToken2'
|
||||
]);
|
||||
expect(authenticatedCallback.called).to.equal(true);
|
||||
expect(readyCallback.called).to.equal(true);
|
||||
expect(qrCallback.called).to.equal(false);
|
||||
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
it('can take over if client was logged in somewhere else with takeoverOnConflict=true', async function() {
|
||||
this.timeout(40000);
|
||||
|
||||
const readyCallback1 = sinon.spy();
|
||||
const readyCallback2 = sinon.spy();
|
||||
const disconnectedCallback1 = sinon.spy();
|
||||
const disconnectedCallback2 = sinon.spy();
|
||||
|
||||
const client1 = helper.createClient({
|
||||
withSession: true,
|
||||
options: { takeoverOnConflict: true, takeoverTimeoutMs: 5000 }
|
||||
});
|
||||
const client2 = helper.createClient({withSession: true});
|
||||
|
||||
client1.on('ready', readyCallback1);
|
||||
client2.on('ready', readyCallback2);
|
||||
client1.on('disconnected', disconnectedCallback1);
|
||||
client2.on('disconnected', disconnectedCallback2);
|
||||
|
||||
await client1.initialize();
|
||||
expect(readyCallback1.called).to.equal(true);
|
||||
expect(readyCallback2.called).to.equal(false);
|
||||
expect(disconnectedCallback1.called).to.equal(false);
|
||||
expect(disconnectedCallback2.called).to.equal(false);
|
||||
|
||||
await client2.initialize();
|
||||
expect(readyCallback2.called).to.equal(true);
|
||||
expect(disconnectedCallback1.called).to.equal(false);
|
||||
expect(disconnectedCallback2.called).to.equal(false);
|
||||
|
||||
// wait for takeoverTimeoutMs to kick in
|
||||
await helper.sleep(5200);
|
||||
expect(disconnectedCallback1.called).to.equal(false);
|
||||
expect(disconnectedCallback2.called).to.equal(true);
|
||||
expect(disconnectedCallback2.calledWith(WAState.CONFLICT)).to.equal(true);
|
||||
|
||||
await client1.destroy();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe('Authenticated', function() {
|
||||
let client;
|
||||
|
||||
before(async function() {
|
||||
this.timeout(35000);
|
||||
client = helper.createClient({withSession: true});
|
||||
await client.initialize();
|
||||
});
|
||||
|
||||
after(async function () {
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
it('can get current WhatsApp Web version', async function () {
|
||||
const version = await client.getWWebVersion();
|
||||
expect(typeof version).to.equal('string');
|
||||
console.log(`WA Version: ${version}`);
|
||||
});
|
||||
|
||||
describe('Expose Store', function() {
|
||||
it('exposes the store', async function() {
|
||||
const exposed = await client.pupPage.evaluate(() => {
|
||||
return Boolean(window.Store);
|
||||
});
|
||||
|
||||
expect(exposed).to.equal(true);
|
||||
});
|
||||
|
||||
it('exposes all required WhatsApp Web internal models', async function() {
|
||||
const expectedModules = [
|
||||
'AppState',
|
||||
'BlockContact',
|
||||
'Call',
|
||||
'Chat',
|
||||
'Cmd',
|
||||
'Conn',
|
||||
'Contact',
|
||||
'DownloadManager',
|
||||
'Features',
|
||||
'GroupMetadata',
|
||||
'Invite',
|
||||
'Label',
|
||||
'MediaObject',
|
||||
'MediaPrep',
|
||||
'MediaTypes',
|
||||
'MediaUpload',
|
||||
'Msg',
|
||||
'MsgKey',
|
||||
'OpaqueData',
|
||||
'QueryOrder',
|
||||
'QueryProduct',
|
||||
'SendClear',
|
||||
'SendDelete',
|
||||
'SendMessage',
|
||||
'SendSeen',
|
||||
'Sticker',
|
||||
'UploadUtils',
|
||||
'UserConstructor',
|
||||
'VCard',
|
||||
'Validators',
|
||||
'Wap',
|
||||
'WidFactory',
|
||||
'genId'
|
||||
];
|
||||
|
||||
const loadedModules = await client.pupPage.evaluate((expectedModules) => {
|
||||
return expectedModules.filter(m => Boolean(window.Store[m]));
|
||||
}, expectedModules);
|
||||
|
||||
expect(loadedModules).to.have.members(expectedModules);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Send Messages', function () {
|
||||
it('can send a message', async function() {
|
||||
const msg = await client.sendMessage(remoteId, 'hello world');
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.TEXT);
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.body).to.equal('hello world');
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
});
|
||||
|
||||
it('can send a media message', async function() {
|
||||
const media = new MessageMedia(
|
||||
'image/png',
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAV4AAACWBAMAAABkyf1EAAAAG1BMVEXMzMyWlpacnJyqqqrFxcWxsbGjo6O3t7e+vr6He3KoAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEcElEQVR4nO2aTW/bRhCGh18ij1zKknMkbbf2UXITIEeyMhIfRaF1exQLA/JRclslRykO+rs7s7s0VwytNmhJtsA8gHZEcox9PTs7uysQgGEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmGYr2OWRK/ReIKI8Zt7Hb19wTcQ0uTkGh13bQupcw7gPOvdo12/5CzNtNR7xLUtNtT3CGBQ6g3InjY720pvofUec22LJPr8PhEp2OMPyI40PdwWUdronCu9yQpdPx53bQlfLKnfOVhlnDYRBXve4Ov+IZTeMgdedm0NR+xoXJeQvdJ3CvziykSukwil16W/Oe7aGjIjqc/9ib4jQlJy0uArtN4A0+cvXFvDkmUJ47sJ1Y1ATLDNVXZkNPIepQzxy1ki9fqiwbUj/I+64zxWNzyZnPuhvohJ9K70VvXBixpcu2SAHU+Xd9EKdEJDNpYP3AQr3bQSpPQ6Y6/4dl1z7ZDbArsszjA7L0g7ibB0CDcidUWVoErvIMKZh2Xs0LUzcLW6V5NfiUgNEbaYmAVL6bXl0nJRc+1S72ua/D/cTjGPlQj7eUqd7A096rYlRjdPYlhz7VIvxpVG3cemDKF+WAwLY/6XelOZKTXXzsC4xvDjjtSN6kHLhLke6PrwM8h1raf40qjrGO7H9aTEbduucjS04ZrYU/4iuS5Z2Hdt0rvCLFdmLEXcU30AGddST62o+sLcf5l6k7CP+ru4pLYqX/VFyxbm/utQbx/r22ZEbTb2f5I2kns1Y1OQR8ZyofX+TjJxj1Rz7QQVnf1QzR26Oth0ueJVYcRP6ZUPac/Rx/5M6ixO1dhSrT3Y1DpiYmx3tF4ZUdpz9LD/dSg9PXES0LB71BwcGjKROuV28lnvnv7HHJsezheBGH5+X2CfSfRbMKW+5aGs3JFjMrjGibJc0S7TJzqjHrh2hDybj9XRXNZa89Aro55XBdbW5wti2c/5WJ7jJ1RolVUn/HWpb0I58Tziup6Rx7Dm2hnbRP1GM9PW/NFmQ4PtVRVN63Wvxfmu5sowDMMwDMMwDMMwDMMwDMMwDMMwzL+CpT//F/6beoV8zb2Jmt4Qryx6lTUCsENQ75HOkhXAO3EPVgyQtKtUy3C/e+FJg17Zjnew1Xrdb9InbG4WqfUAftG+WhLwPVyfg536+MU7m4C1CMk4ZznpXZzDYI1PDL2nS1hpvc5cNd7E2sJg05Fe7/7d3Fln8Cvc3bwB616auxsKl4WPghjemHrDqyDWeu1UNW5s2btPnSQ75oOdunEwWazfwgVG0kqluYCM9OIjWOGnfA2b9G4Ha63XKpvQ8perTvTifJNhi6+WMWmi7smEZf6G8MmhlyGq+NqP8GV84TLuJr7UIQVx+bDEoEpRZIz42gs40OuN4Mv8hXzelV7KX1isH+ewTWckikyVv+CfHuqVF7I16gN0VKypX6wPsE+zFPzkinolU9UH8OMGvSpnZqKsv13p/RsMun6X5x/y2LeAr8O66lsBwzBMP/wJfyGq8pgBk6IAAAAASUVORK5CYII='
|
||||
);
|
||||
|
||||
const msg = await client.sendMessage(remoteId, media, {caption: 'here\'s my media'});
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.IMAGE);
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.hasMedia).to.equal(true);
|
||||
expect(msg.body).to.equal('here\'s my media');
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
});
|
||||
|
||||
it('can send a media message from URL', async function() {
|
||||
const media = await MessageMedia.fromUrl('https://via.placeholder.com/350x150.png');
|
||||
|
||||
const msg = await client.sendMessage(remoteId, media);
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.IMAGE);
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.hasMedia).to.equal(true);
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
});
|
||||
|
||||
it('can send a media message as a document', async function() {
|
||||
const media = new MessageMedia(
|
||||
'image/png',
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAV4AAACWBAMAAABkyf1EAAAAG1BMVEXMzMyWlpacnJyqqqrFxcWxsbGjo6O3t7e+vr6He3KoAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEcElEQVR4nO2aTW/bRhCGh18ij1zKknMkbbf2UXITIEeyMhIfRaF1exQLA/JRclslRykO+rs7s7s0VwytNmhJtsA8gHZEcox9PTs7uysQgGEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmGYr2OWRK/ReIKI8Zt7Hb19wTcQ0uTkGh13bQupcw7gPOvdo12/5CzNtNR7xLUtNtT3CGBQ6g3InjY720pvofUec22LJPr8PhEp2OMPyI40PdwWUdronCu9yQpdPx53bQlfLKnfOVhlnDYRBXve4Ov+IZTeMgdedm0NR+xoXJeQvdJ3CvziykSukwil16W/Oe7aGjIjqc/9ib4jQlJy0uArtN4A0+cvXFvDkmUJ47sJ1Y1ATLDNVXZkNPIepQzxy1ki9fqiwbUj/I+64zxWNzyZnPuhvohJ9K70VvXBixpcu2SAHU+Xd9EKdEJDNpYP3AQr3bQSpPQ6Y6/4dl1z7ZDbArsszjA7L0g7ibB0CDcidUWVoErvIMKZh2Xs0LUzcLW6V5NfiUgNEbaYmAVL6bXl0nJRc+1S72ua/D/cTjGPlQj7eUqd7A096rYlRjdPYlhz7VIvxpVG3cemDKF+WAwLY/6XelOZKTXXzsC4xvDjjtSN6kHLhLke6PrwM8h1raf40qjrGO7H9aTEbduucjS04ZrYU/4iuS5Z2Hdt0rvCLFdmLEXcU30AGddST62o+sLcf5l6k7CP+ru4pLYqX/VFyxbm/utQbx/r22ZEbTb2f5I2kns1Y1OQR8ZyofX+TjJxj1Rz7QQVnf1QzR26Oth0ueJVYcRP6ZUPac/Rx/5M6ixO1dhSrT3Y1DpiYmx3tF4ZUdpz9LD/dSg9PXES0LB71BwcGjKROuV28lnvnv7HHJsezheBGH5+X2CfSfRbMKW+5aGs3JFjMrjGibJc0S7TJzqjHrh2hDybj9XRXNZa89Aro55XBdbW5wti2c/5WJ7jJ1RolVUn/HWpb0I58Tziup6Rx7Dm2hnbRP1GM9PW/NFmQ4PtVRVN63Wvxfmu5sowDMMwDMMwDMMwDMMwDMMwDMMwzL+CpT//F/6beoV8zb2Jmt4Qryx6lTUCsENQ75HOkhXAO3EPVgyQtKtUy3C/e+FJg17Zjnew1Xrdb9InbG4WqfUAftG+WhLwPVyfg536+MU7m4C1CMk4ZznpXZzDYI1PDL2nS1hpvc5cNd7E2sJg05Fe7/7d3Fln8Cvc3bwB616auxsKl4WPghjemHrDqyDWeu1UNW5s2btPnSQ75oOdunEwWazfwgVG0kqluYCM9OIjWOGnfA2b9G4Ha63XKpvQ8perTvTifJNhi6+WMWmi7smEZf6G8MmhlyGq+NqP8GV84TLuJr7UIQVx+bDEoEpRZIz42gs40OuN4Mv8hXzelV7KX1isH+ewTWckikyVv+CfHuqVF7I16gN0VKypX6wPsE+zFPzkinolU9UH8OMGvSpnZqKsv13p/RsMun6X5x/y2LeAr8O66lsBwzBMP/wJfyGq8pgBk6IAAAAASUVORK5CYII=',
|
||||
'this is my filename.png'
|
||||
);
|
||||
|
||||
const msg = await client.sendMessage(remoteId, media, { sendMediaAsDocument: true});
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.DOCUMENT);
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.hasMedia).to.equal(true);
|
||||
expect(msg.body).to.equal('this is my filename.png');
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
});
|
||||
|
||||
it('can send a sticker message', async function() {
|
||||
const media = new MessageMedia(
|
||||
'image/png',
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAV4AAACWBAMAAABkyf1EAAAAG1BMVEXMzMyWlpacnJyqqqrFxcWxsbGjo6O3t7e+vr6He3KoAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEcElEQVR4nO2aTW/bRhCGh18ij1zKknMkbbf2UXITIEeyMhIfRaF1exQLA/JRclslRykO+rs7s7s0VwytNmhJtsA8gHZEcox9PTs7uysQgGEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmGYr2OWRK/ReIKI8Zt7Hb19wTcQ0uTkGh13bQupcw7gPOvdo12/5CzNtNR7xLUtNtT3CGBQ6g3InjY720pvofUec22LJPr8PhEp2OMPyI40PdwWUdronCu9yQpdPx53bQlfLKnfOVhlnDYRBXve4Ov+IZTeMgdedm0NR+xoXJeQvdJ3CvziykSukwil16W/Oe7aGjIjqc/9ib4jQlJy0uArtN4A0+cvXFvDkmUJ47sJ1Y1ATLDNVXZkNPIepQzxy1ki9fqiwbUj/I+64zxWNzyZnPuhvohJ9K70VvXBixpcu2SAHU+Xd9EKdEJDNpYP3AQr3bQSpPQ6Y6/4dl1z7ZDbArsszjA7L0g7ibB0CDcidUWVoErvIMKZh2Xs0LUzcLW6V5NfiUgNEbaYmAVL6bXl0nJRc+1S72ua/D/cTjGPlQj7eUqd7A096rYlRjdPYlhz7VIvxpVG3cemDKF+WAwLY/6XelOZKTXXzsC4xvDjjtSN6kHLhLke6PrwM8h1raf40qjrGO7H9aTEbduucjS04ZrYU/4iuS5Z2Hdt0rvCLFdmLEXcU30AGddST62o+sLcf5l6k7CP+ru4pLYqX/VFyxbm/utQbx/r22ZEbTb2f5I2kns1Y1OQR8ZyofX+TjJxj1Rz7QQVnf1QzR26Oth0ueJVYcRP6ZUPac/Rx/5M6ixO1dhSrT3Y1DpiYmx3tF4ZUdpz9LD/dSg9PXES0LB71BwcGjKROuV28lnvnv7HHJsezheBGH5+X2CfSfRbMKW+5aGs3JFjMrjGibJc0S7TJzqjHrh2hDybj9XRXNZa89Aro55XBdbW5wti2c/5WJ7jJ1RolVUn/HWpb0I58Tziup6Rx7Dm2hnbRP1GM9PW/NFmQ4PtVRVN63Wvxfmu5sowDMMwDMMwDMMwDMMwDMMwDMMwzL+CpT//F/6beoV8zb2Jmt4Qryx6lTUCsENQ75HOkhXAO3EPVgyQtKtUy3C/e+FJg17Zjnew1Xrdb9InbG4WqfUAftG+WhLwPVyfg536+MU7m4C1CMk4ZznpXZzDYI1PDL2nS1hpvc5cNd7E2sJg05Fe7/7d3Fln8Cvc3bwB616auxsKl4WPghjemHrDqyDWeu1UNW5s2btPnSQ75oOdunEwWazfwgVG0kqluYCM9OIjWOGnfA2b9G4Ha63XKpvQ8perTvTifJNhi6+WMWmi7smEZf6G8MmhlyGq+NqP8GV84TLuJr7UIQVx+bDEoEpRZIz42gs40OuN4Mv8hXzelV7KX1isH+ewTWckikyVv+CfHuqVF7I16gN0VKypX6wPsE+zFPzkinolU9UH8OMGvSpnZqKsv13p/RsMun6X5x/y2LeAr8O66lsBwzBMP/wJfyGq8pgBk6IAAAAASUVORK5CYII='
|
||||
);
|
||||
|
||||
const msg = await client.sendMessage(remoteId, media, {sendMediaAsSticker: true});
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.STICKER);
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.hasMedia).to.equal(true);
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
});
|
||||
|
||||
it('can send a sticker message with custom author and name', async function() {
|
||||
const media = new MessageMedia(
|
||||
'image/png',
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAV4AAACWBAMAAABkyf1EAAAAG1BMVEXMzMyWlpacnJyqqqrFxcWxsbGjo6O3t7e+vr6He3KoAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEcElEQVR4nO2aTW/bRhCGh18ij1zKknMkbbf2UXITIEeyMhIfRaF1exQLA/JRclslRykO+rs7s7s0VwytNmhJtsA8gHZEcox9PTs7uysQgGEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmGYr2OWRK/ReIKI8Zt7Hb19wTcQ0uTkGh13bQupcw7gPOvdo12/5CzNtNR7xLUtNtT3CGBQ6g3InjY720pvofUec22LJPr8PhEp2OMPyI40PdwWUdronCu9yQpdPx53bQlfLKnfOVhlnDYRBXve4Ov+IZTeMgdedm0NR+xoXJeQvdJ3CvziykSukwil16W/Oe7aGjIjqc/9ib4jQlJy0uArtN4A0+cvXFvDkmUJ47sJ1Y1ATLDNVXZkNPIepQzxy1ki9fqiwbUj/I+64zxWNzyZnPuhvohJ9K70VvXBixpcu2SAHU+Xd9EKdEJDNpYP3AQr3bQSpPQ6Y6/4dl1z7ZDbArsszjA7L0g7ibB0CDcidUWVoErvIMKZh2Xs0LUzcLW6V5NfiUgNEbaYmAVL6bXl0nJRc+1S72ua/D/cTjGPlQj7eUqd7A096rYlRjdPYlhz7VIvxpVG3cemDKF+WAwLY/6XelOZKTXXzsC4xvDjjtSN6kHLhLke6PrwM8h1raf40qjrGO7H9aTEbduucjS04ZrYU/4iuS5Z2Hdt0rvCLFdmLEXcU30AGddST62o+sLcf5l6k7CP+ru4pLYqX/VFyxbm/utQbx/r22ZEbTb2f5I2kns1Y1OQR8ZyofX+TjJxj1Rz7QQVnf1QzR26Oth0ueJVYcRP6ZUPac/Rx/5M6ixO1dhSrT3Y1DpiYmx3tF4ZUdpz9LD/dSg9PXES0LB71BwcGjKROuV28lnvnv7HHJsezheBGH5+X2CfSfRbMKW+5aGs3JFjMrjGibJc0S7TJzqjHrh2hDybj9XRXNZa89Aro55XBdbW5wti2c/5WJ7jJ1RolVUn/HWpb0I58Tziup6Rx7Dm2hnbRP1GM9PW/NFmQ4PtVRVN63Wvxfmu5sowDMMwDMMwDMMwDMMwDMMwDMMwzL+CpT//F/6beoV8zb2Jmt4Qryx6lTUCsENQ75HOkhXAO3EPVgyQtKtUy3C/e+FJg17Zjnew1Xrdb9InbG4WqfUAftG+WhLwPVyfg536+MU7m4C1CMk4ZznpXZzDYI1PDL2nS1hpvc5cNd7E2sJg05Fe7/7d3Fln8Cvc3bwB616auxsKl4WPghjemHrDqyDWeu1UNW5s2btPnSQ75oOdunEwWazfwgVG0kqluYCM9OIjWOGnfA2b9G4Ha63XKpvQ8perTvTifJNhi6+WMWmi7smEZf6G8MmhlyGq+NqP8GV84TLuJr7UIQVx+bDEoEpRZIz42gs40OuN4Mv8hXzelV7KX1isH+ewTWckikyVv+CfHuqVF7I16gN0VKypX6wPsE+zFPzkinolU9UH8OMGvSpnZqKsv13p/RsMun6X5x/y2LeAr8O66lsBwzBMP/wJfyGq8pgBk6IAAAAASUVORK5CYII='
|
||||
);
|
||||
|
||||
const msg = await client.sendMessage(remoteId, media, {
|
||||
sendMediaAsSticker: true,
|
||||
stickerAuthor: 'WWEBJS',
|
||||
stickerName: 'My Sticker'
|
||||
});
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.STICKER);
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.hasMedia).to.equal(true);
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
});
|
||||
|
||||
it('can send a location message', async function() {
|
||||
const location = new Location(37.422, -122.084, 'Googleplex\nGoogle Headquarters');
|
||||
|
||||
const msg = await client.sendMessage(remoteId, location);
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.LOCATION);
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
|
||||
expect(msg.location).to.be.instanceOf(Location);
|
||||
expect(msg.location.latitude).to.equal(37.422);
|
||||
expect(msg.location.longitude).to.equal(-122.084);
|
||||
expect(msg.location.description).to.equal('Googleplex\nGoogle Headquarters');
|
||||
});
|
||||
|
||||
it('can send a vCard as a contact card message', async function() {
|
||||
const vCard = `BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
FN;CHARSET=UTF-8:John Doe
|
||||
N;CHARSET=UTF-8:Doe;John;;;
|
||||
EMAIL;CHARSET=UTF-8;type=HOME,INTERNET:john@doe.com
|
||||
TEL;TYPE=HOME,VOICE:1234567890
|
||||
REV:2021-06-06T02:35:53.559Z
|
||||
END:VCARD`;
|
||||
|
||||
const msg = await client.sendMessage(remoteId, vCard);
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.CONTACT_CARD);
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
expect(msg.body).to.equal(vCard);
|
||||
expect(msg.vCards).to.have.lengthOf(1);
|
||||
expect(msg.vCards[0]).to.equal(vCard);
|
||||
});
|
||||
|
||||
it('can optionally turn off vCard parsing', async function() {
|
||||
const vCard = `BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
FN;CHARSET=UTF-8:John Doe
|
||||
N;CHARSET=UTF-8:Doe;John;;;
|
||||
EMAIL;CHARSET=UTF-8;type=HOME,INTERNET:john@doe.com
|
||||
TEL;TYPE=HOME,VOICE:1234567890
|
||||
REV:2021-06-06T02:35:53.559Z
|
||||
END:VCARD`;
|
||||
|
||||
const msg = await client.sendMessage(remoteId, vCard, {parseVCards: false});
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.TEXT); // not a contact card
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
expect(msg.body).to.equal(vCard);
|
||||
});
|
||||
|
||||
it('can send a Contact as a contact card message', async function() {
|
||||
const contact = await client.getContactById(remoteId);
|
||||
|
||||
const msg = await client.sendMessage(remoteId, contact);
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.CONTACT_CARD);
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
expect(msg.body).to.match(/BEGIN:VCARD/);
|
||||
expect(msg.vCards).to.have.lengthOf(1);
|
||||
expect(msg.vCards[0]).to.match(/BEGIN:VCARD/);
|
||||
});
|
||||
|
||||
it('can send multiple Contacts as a contact card message', async function () {
|
||||
const contact1 = await client.getContactById(remoteId);
|
||||
const contact2 = await client.getContactById('5511942167462@c.us'); //iFood
|
||||
|
||||
const msg = await client.sendMessage(remoteId, [contact1, contact2]);
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.CONTACT_CARD_MULTI);
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
expect(msg.vCards).to.have.lengthOf(2);
|
||||
expect(msg.vCards[0]).to.match(/BEGIN:VCARD/);
|
||||
expect(msg.vCards[1]).to.match(/BEGIN:VCARD/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Get Chats', function () {
|
||||
it('can get a chat by its ID', async function () {
|
||||
const chat = await client.getChatById(remoteId);
|
||||
expect(chat).to.be.instanceOf(Chat);
|
||||
expect(chat.id._serialized).to.eql(remoteId);
|
||||
expect(chat.isGroup).to.eql(false);
|
||||
});
|
||||
|
||||
it('can get all chats', async function () {
|
||||
const chats = await client.getChats();
|
||||
expect(chats.length).to.be.greaterThanOrEqual(1);
|
||||
|
||||
const chat = chats.find(c => c.id._serialized === remoteId);
|
||||
expect(chat).to.exist;
|
||||
expect(chat).to.be.instanceOf(Chat);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Get Contacts', function () {
|
||||
it('can get a contact by its ID', async function () {
|
||||
const contact = await client.getContactById(remoteId);
|
||||
expect(contact).to.be.instanceOf(Contact);
|
||||
expect(contact.id._serialized).to.eql(remoteId);
|
||||
expect(contact.number).to.eql(remoteId.split('@')[0]);
|
||||
});
|
||||
|
||||
it('can get all contacts', async function () {
|
||||
const contacts = await client.getContacts();
|
||||
expect(contacts.length).to.be.greaterThanOrEqual(1);
|
||||
|
||||
const contact = contacts.find(c => c.id._serialized === remoteId);
|
||||
expect(contact).to.exist;
|
||||
expect(contact).to.be.instanceOf(Contact);
|
||||
});
|
||||
|
||||
it('can block a contact', async function () {
|
||||
const contact = await client.getContactById(remoteId);
|
||||
await contact.block();
|
||||
|
||||
const refreshedContact = await client.getContactById(remoteId);
|
||||
expect(refreshedContact.isBlocked).to.eql(true);
|
||||
});
|
||||
|
||||
it('can get a list of blocked contacts', async function () {
|
||||
const blockedContacts = await client.getBlockedContacts();
|
||||
expect(blockedContacts.length).to.be.greaterThanOrEqual(1);
|
||||
|
||||
const contact = blockedContacts.find(c => c.id._serialized === remoteId);
|
||||
expect(contact).to.exist;
|
||||
expect(contact).to.be.instanceOf(Contact);
|
||||
|
||||
});
|
||||
|
||||
it('can unblock a contact', async function () {
|
||||
const contact = await client.getContactById(remoteId);
|
||||
await contact.unblock();
|
||||
|
||||
const refreshedContact = await client.getContactById(remoteId);
|
||||
expect(refreshedContact.isBlocked).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Numbers and Users', function () {
|
||||
it('can verify that a user is registered', async function () {
|
||||
const isRegistered = await client.isRegisteredUser(remoteId);
|
||||
expect(isRegistered).to.be.true;
|
||||
});
|
||||
|
||||
it('can verify that a user is not registered', async function () {
|
||||
const isRegistered = await client.isRegisteredUser('9999999999@c.us');
|
||||
expect(isRegistered).to.be.false;
|
||||
});
|
||||
|
||||
it('can get a number\'s whatsapp id', async function () {
|
||||
const number = remoteId.split('@')[0];
|
||||
const numberId = await client.getNumberId(number);
|
||||
expect(numberId).to.eql({
|
||||
server: 'c.us',
|
||||
user: number,
|
||||
_serialized: `${number}@c.us`
|
||||
});
|
||||
});
|
||||
|
||||
it('returns null when getting an unregistered number\'s whatsapp id', async function () {
|
||||
const number = '9999999999';
|
||||
const numberId = await client.getNumberId(number);
|
||||
expect(numberId).to.eql(null);
|
||||
});
|
||||
|
||||
it('can get a number\'s country code', async function () {
|
||||
const number = '18092201111';
|
||||
const countryCode = await client.getCountryCode(number);
|
||||
expect(countryCode).to.eql('1');
|
||||
});
|
||||
|
||||
it('can get a formatted number', async function () {
|
||||
const number = '18092201111';
|
||||
const formatted = await client.getFormattedNumber(number);
|
||||
expect(formatted).to.eql('+1 (809) 220-1111');
|
||||
});
|
||||
|
||||
it('can get a formatted number from a serialized ID', async function () {
|
||||
const number = '18092201111@c.us';
|
||||
const formatted = await client.getFormattedNumber(number);
|
||||
expect(formatted).to.eql('+1 (809) 220-1111');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Search messages', function () {
|
||||
it('can search for messages', async function () {
|
||||
this.timeout(5000);
|
||||
|
||||
const m1 = await client.sendMessage(remoteId, 'I\'m searching for Super Mario Brothers');
|
||||
const m2 = await client.sendMessage(remoteId, 'This also contains Mario');
|
||||
const m3 = await client.sendMessage(remoteId, 'Nothing of interest here, just Luigi');
|
||||
|
||||
// wait for search index to catch up
|
||||
await helper.sleep(1000);
|
||||
|
||||
const msgs = await client.searchMessages('Mario', {chatId: remoteId});
|
||||
expect(msgs.length).to.be.greaterThanOrEqual(2);
|
||||
const msgIds = msgs.map(m => m.id._serialized);
|
||||
expect(msgIds).to.include.members([
|
||||
m1.id._serialized, m2.id._serialized
|
||||
]);
|
||||
expect(msgIds).to.not.include.members([m3.id._serialized]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Status/About', function () {
|
||||
let me, previousStatus;
|
||||
|
||||
before(async function () {
|
||||
me = await client.getContactById(client.info.wid._serialized);
|
||||
previousStatus = await me.getAbout();
|
||||
});
|
||||
|
||||
after(async function () {
|
||||
await client.setStatus(previousStatus);
|
||||
});
|
||||
|
||||
it('can set the status text', async function () {
|
||||
await client.setStatus('My shiny new status');
|
||||
|
||||
const status = await me.getAbout();
|
||||
expect(status).to.eql('My shiny new status');
|
||||
});
|
||||
|
||||
it('can set the status text to something else', async function () {
|
||||
await client.setStatus('Busy');
|
||||
|
||||
const status = await me.getAbout();
|
||||
expect(status).to.eql('Busy');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
40
tests/helper.js
Normal file
40
tests/helper.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const path = require('path');
|
||||
const Client = require('../src/Client');
|
||||
const Util = require('../src/util/Util');
|
||||
|
||||
require('dotenv').config();
|
||||
|
||||
const remoteId = process.env.WWEBJS_TEST_REMOTE_ID;
|
||||
if(!remoteId) throw new Error('The WWEBJS_TEST_REMOTE_ID environment variable has not been set.');
|
||||
|
||||
function getSessionFromEnv() {
|
||||
const envSession = process.env.WWEBJS_TEST_SESSION;
|
||||
if(envSession) return JSON.parse(envSession);
|
||||
|
||||
const envSessionPath = process.env.WWEBJS_TEST_SESSION_PATH;
|
||||
if(envSessionPath) {
|
||||
const absPath = path.resolve(process.cwd(), envSessionPath);
|
||||
return require(absPath);
|
||||
}
|
||||
|
||||
throw new Error('No session found in environment.');
|
||||
}
|
||||
|
||||
function createClient({withSession, options: additionalOpts}={}) {
|
||||
const options = {};
|
||||
if(withSession) {
|
||||
options.session = getSessionFromEnv();
|
||||
}
|
||||
|
||||
return new Client(Util.mergeDefault(options, additionalOpts || {}));
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
sleep,
|
||||
createClient,
|
||||
remoteId
|
||||
};
|
||||
188
tests/structures/chat.js
Normal file
188
tests/structures/chat.js
Normal file
@@ -0,0 +1,188 @@
|
||||
const { expect } = require('chai');
|
||||
|
||||
const helper = require('../helper');
|
||||
const Message = require('../../src/structures/Message');
|
||||
const { MessageTypes } = require('../../src/util/Constants');
|
||||
const { Contact } = require('../../src/structures');
|
||||
|
||||
const remoteId = helper.remoteId;
|
||||
|
||||
describe('Chat', function () {
|
||||
let client;
|
||||
let chat;
|
||||
|
||||
before(async function() {
|
||||
this.timeout(35000);
|
||||
client = helper.createClient({ withSession: true });
|
||||
await client.initialize();
|
||||
chat = await client.getChatById(remoteId);
|
||||
});
|
||||
|
||||
after(async function () {
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
it('can send a message to a chat', async function () {
|
||||
const msg = await chat.sendMessage('hello world');
|
||||
expect(msg).to.be.instanceOf(Message);
|
||||
expect(msg.type).to.equal(MessageTypes.TEXT);
|
||||
expect(msg.fromMe).to.equal(true);
|
||||
expect(msg.body).to.equal('hello world');
|
||||
expect(msg.to).to.equal(remoteId);
|
||||
});
|
||||
|
||||
it('can fetch messages sent in a chat', async function () {
|
||||
this.timeout(5000);
|
||||
await helper.sleep(1000);
|
||||
const msg = await chat.sendMessage('another message');
|
||||
|
||||
const messages = await chat.fetchMessages();
|
||||
expect(messages.length).to.be.greaterThanOrEqual(2);
|
||||
|
||||
const fetchedMsg = messages[messages.length-1];
|
||||
expect(fetchedMsg).to.be.instanceOf(Message);
|
||||
expect(fetchedMsg.type).to.equal(MessageTypes.TEXT);
|
||||
expect(fetchedMsg.id._serialized).to.equal(msg.id._serialized);
|
||||
expect(fetchedMsg.body).to.equal(msg.body);
|
||||
});
|
||||
|
||||
it('can use a limit when fetching messages sent in a chat', async function () {
|
||||
await helper.sleep(1000);
|
||||
const msg = await chat.sendMessage('yet another message');
|
||||
|
||||
const messages = await chat.fetchMessages({limit: 1});
|
||||
expect(messages).to.have.lengthOf(1);
|
||||
|
||||
const fetchedMsg = messages[0];
|
||||
expect(fetchedMsg).to.be.instanceOf(Message);
|
||||
expect(fetchedMsg.type).to.equal(MessageTypes.TEXT);
|
||||
expect(fetchedMsg.id._serialized).to.equal(msg.id._serialized);
|
||||
expect(fetchedMsg.body).to.equal(msg.body);
|
||||
});
|
||||
|
||||
it('can get the related contact', async function () {
|
||||
const contact = await chat.getContact();
|
||||
expect(contact).to.be.instanceOf(Contact);
|
||||
expect(contact.id._serialized).to.equal(chat.id._serialized);
|
||||
});
|
||||
|
||||
describe('Seen', function () {
|
||||
it('can mark a chat as unread', async function () {
|
||||
await chat.markUnread();
|
||||
await helper.sleep(500);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.unreadCount).to.equal(-1);
|
||||
});
|
||||
|
||||
it('can mark a chat as seen', async function () {
|
||||
const res = await chat.sendSeen();
|
||||
expect(res).to.equal(true);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.unreadCount).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Archiving', function (){
|
||||
it('can archive a chat', async function () {
|
||||
const res = await chat.archive();
|
||||
expect(res).to.equal(true);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.archived).to.equal(true);
|
||||
});
|
||||
|
||||
it('can unarchive a chat', async function () {
|
||||
const res = await chat.unarchive();
|
||||
expect(res).to.equal(false);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.archived).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Pinning', function () {
|
||||
it('can pin a chat', async function () {
|
||||
const res = await chat.pin();
|
||||
expect(res).to.equal(true);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.pinned).to.equal(true);
|
||||
});
|
||||
|
||||
it('can unpin a chat', async function () {
|
||||
const res = await chat.unpin();
|
||||
expect(res).to.equal(false);
|
||||
await helper.sleep(1000);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.pinned).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Muting', function () {
|
||||
it('can mute a chat forever', async function() {
|
||||
await chat.mute();
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.isMuted).to.equal(true);
|
||||
expect(chat.muteExpiration).to.equal(-1);
|
||||
});
|
||||
|
||||
it('can mute a chat until a specific date', async function() {
|
||||
const unmuteDate = new Date(new Date().getTime() + (1000*60*60));
|
||||
await chat.mute(unmuteDate);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.isMuted).to.equal(true);
|
||||
expect(chat.muteExpiration).to.equal(
|
||||
Math.round(unmuteDate.getTime() / 1000)
|
||||
);
|
||||
});
|
||||
|
||||
it('can unmute a chat', async function () {
|
||||
await chat.unmute();
|
||||
await helper.sleep(500);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.isMuted).to.equal(false);
|
||||
expect(chat.muteExpiration).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line mocha/no-skipped-tests
|
||||
describe.skip('Destructive operations', function () {
|
||||
it('can clear all messages from chat', async function () {
|
||||
this.timeout(5000);
|
||||
|
||||
const res = await chat.clearMessages();
|
||||
expect(res).to.equal(true);
|
||||
|
||||
await helper.sleep(3000);
|
||||
|
||||
const msgs = await chat.fetchMessages();
|
||||
expect(msgs).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('can delete a chat', async function () {
|
||||
const res = await chat.delete();
|
||||
expect(res).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
4
tools/changelog.sh
Executable file
4
tools/changelog.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
LAST_TAG=$(git describe --tags --abbrev=0)
|
||||
git log --pretty="%h - %s" "$LAST_TAG"..HEAD
|
||||
1
tools/version-checker/.version
Normal file
1
tools/version-checker/.version
Normal file
@@ -0,0 +1 @@
|
||||
2.2202.12
|
||||
46
tools/version-checker/update-version
Executable file
46
tools/version-checker/update-version
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
const getLatestVersion = async (currentVersion) => {
|
||||
const res = await fetch(`https://web.whatsapp.com/check-update?version=${currentVersion}&platform=web`);
|
||||
const data = await res.json();
|
||||
return data.currentVersion;
|
||||
};
|
||||
|
||||
const getCurrentVersion = () => {
|
||||
try {
|
||||
const versionFile = fs.readFileSync('./.version');
|
||||
return versionFile ? versionFile.toString().trim() : null;
|
||||
} catch(_) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const updateVersion = async (oldVersion, newVersion) => {
|
||||
const readmePath = '../../README.md';
|
||||
|
||||
const readme = fs.readFileSync(readmePath);
|
||||
const newReadme = readme.toString().replaceAll(oldVersion, newVersion);
|
||||
|
||||
fs.writeFileSync(readmePath, newReadme);
|
||||
fs.writeFileSync('./.version', newVersion);
|
||||
|
||||
};
|
||||
|
||||
(async () => {
|
||||
const currentVersion = getCurrentVersion();
|
||||
const version = await getLatestVersion(currentVersion);
|
||||
|
||||
console.log(`Current version: ${currentVersion}`);
|
||||
console.log(`Latest version: ${version}`);
|
||||
|
||||
if(currentVersion !== version) {
|
||||
console.log('Updating files...');
|
||||
await updateVersion(currentVersion, version);
|
||||
console.log('Updated!');
|
||||
} else {
|
||||
console.log('No changes.');
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user