mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
Compare commits
203 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2894832b00 | ||
|
|
6cece4a006 | ||
|
|
f1e2f32988 | ||
|
|
f564e41781 | ||
|
|
e6015162c5 | ||
|
|
bc90ffcb19 | ||
|
|
2702757dce | ||
|
|
56171f957e | ||
|
|
204a1c79af | ||
|
|
168c84250e | ||
|
|
d96e8e5eb5 | ||
|
|
0cbb0373ad | ||
|
|
1f756142e4 | ||
|
|
4047afe332 | ||
|
|
89029ac916 | ||
|
|
fa4923db98 | ||
|
|
559133c3c4 | ||
|
|
e2acd03efc | ||
|
|
c6974295a6 | ||
|
|
6590c75c8a | ||
|
|
1bdc7335d8 | ||
|
|
bb9d160f72 | ||
|
|
cea1830dde | ||
|
|
f639c53f0a | ||
|
|
3e32fe27ea | ||
|
|
5c6195738f | ||
|
|
32575490da | ||
|
|
5a0ccc8b17 | ||
|
|
1b946940f4 | ||
|
|
71dbe99023 | ||
|
|
8b101d1f3d | ||
|
|
e2a642a81b | ||
|
|
0c0a5a752b | ||
|
|
e141a5df97 | ||
|
|
576768e390 | ||
|
|
87cb5a0519 | ||
|
|
274d24002b | ||
|
|
563f73d290 | ||
|
|
4b3079d2c1 | ||
|
|
7b0e356fcc | ||
|
|
467f2af7d8 | ||
|
|
19b1b9fdef | ||
|
|
a1d09e0e21 | ||
|
|
d86ccec5d1 | ||
|
|
f359ad40ee | ||
|
|
db7a8bcd3b | ||
|
|
edbf4139e7 | ||
|
|
709c43cc9f | ||
|
|
054ef4a84f | ||
|
|
c9bc0a1c8b | ||
|
|
6b3c8465e9 | ||
|
|
43aa6b3716 | ||
|
|
7738f7910b | ||
|
|
fc7a1a9974 | ||
|
|
b0465ceeff | ||
|
|
2abe4a157d | ||
|
|
e520a96b20 | ||
|
|
75296b652b | ||
|
|
b15ec768d3 | ||
|
|
42dd866a53 | ||
|
|
20e07c43d7 | ||
|
|
9b096db784 | ||
|
|
668106be2d | ||
|
|
cc5d85b2b1 | ||
|
|
3d06babed9 | ||
|
|
0ca909233d | ||
|
|
f4a2c44ed7 | ||
|
|
604656cf73 | ||
|
|
aedf41b762 | ||
|
|
bf2775d1f0 | ||
|
|
0b112004d5 | ||
|
|
336fb9b551 | ||
|
|
ba6ec7feab | ||
|
|
51a1028588 | ||
|
|
1c31139434 | ||
|
|
ee21e14547 | ||
|
|
cbf8fb7cf5 | ||
|
|
c7d5eb67ee | ||
|
|
7fcd43f100 | ||
|
|
a60f0ce139 | ||
|
|
ab0db80063 | ||
|
|
e7c76fe069 | ||
|
|
233382ce7a | ||
|
|
e08dd7d835 | ||
|
|
a1e8e8cf51 | ||
|
|
a1e0970e1e | ||
|
|
c827b32328 | ||
|
|
2345b5c4ee | ||
|
|
8627fc3d71 | ||
|
|
502b22f6d7 | ||
|
|
590ecc2351 | ||
|
|
7da8345722 | ||
|
|
4344df6152 | ||
|
|
382259488b | ||
|
|
7180beda2e | ||
|
|
34aa136bf9 | ||
|
|
2a58cfe8e2 | ||
|
|
9da553ecb9 | ||
|
|
97705b1865 | ||
|
|
fbdfd2c4dd | ||
|
|
5c84a1651d | ||
|
|
bfea74f567 | ||
|
|
a10b458cd5 | ||
|
|
de2c441870 | ||
|
|
bff60bc9f6 | ||
|
|
9cc668e4d9 | ||
|
|
753b6772ab | ||
|
|
300b367fa0 | ||
|
|
b0baeaa8da | ||
|
|
ad9ae1f703 | ||
|
|
b89f0e146f | ||
|
|
6c7a3f9899 | ||
|
|
d7459eac23 | ||
|
|
2abd3729d8 | ||
|
|
810ff4603b | ||
|
|
4d5619019c | ||
|
|
84213cc781 | ||
|
|
bf94d20db3 | ||
|
|
2e3b2f2a43 | ||
|
|
9c9b3c4441 | ||
|
|
832e402671 | ||
|
|
47011a32a5 | ||
|
|
a7ca628775 | ||
|
|
aa60e89911 | ||
|
|
d922e4df2f | ||
|
|
c032ea4387 | ||
|
|
a80fcfa740 | ||
|
|
44f837c42a | ||
|
|
4beeab9b2c | ||
|
|
cca74ec8b9 | ||
|
|
8b656c2caf | ||
|
|
4d09a4b60c | ||
|
|
7d2c89cf84 | ||
|
|
0928f48762 | ||
|
|
eb82e80343 | ||
|
|
f5a0de7def | ||
|
|
d6637d662a | ||
|
|
4188734839 | ||
|
|
207ea200b4 | ||
|
|
b062f9f82f | ||
|
|
4d7a6ee4c2 | ||
|
|
e528e8c50e | ||
|
|
bcd02aa5e4 | ||
|
|
686c99f0c7 | ||
|
|
59ee68b227 | ||
|
|
f40c8d4ffe | ||
|
|
bab54aea8b | ||
|
|
f0a1e05600 | ||
|
|
303d814376 | ||
|
|
044f62216b | ||
|
|
2b3c3e971a | ||
|
|
8528d9b0b6 | ||
|
|
7eb7fa8e28 | ||
|
|
8714e90df9 | ||
|
|
478f7136d9 | ||
|
|
20bbe3d0c4 | ||
|
|
33db17e67d | ||
|
|
1c2b4592b5 | ||
|
|
ce0a80383c | ||
|
|
97e488b10a | ||
|
|
ef507fcb95 | ||
|
|
8e011e0233 | ||
|
|
470c7aea04 | ||
|
|
f92f1ec6bf | ||
|
|
702a0ab103 | ||
|
|
d9fb5693d1 | ||
|
|
3cbf1e9c2f | ||
|
|
93a617336a | ||
|
|
1780436b93 | ||
|
|
7acbd3d800 | ||
|
|
67435b2244 | ||
|
|
743ac93f6e | ||
|
|
0a7412cf17 | ||
|
|
d1e357d23b | ||
|
|
3610cef926 | ||
|
|
4e5eeace2f | ||
|
|
6c43a2d2ed | ||
|
|
001c045c08 | ||
|
|
c3ba79464b | ||
|
|
237331b656 | ||
|
|
9d0b58a847 | ||
|
|
842c4f0e06 | ||
|
|
2dddc781c5 | ||
|
|
d8cd2d1d83 | ||
|
|
80d5783f22 | ||
|
|
cb54487197 | ||
|
|
d08b343815 | ||
|
|
ec1a80dfb4 | ||
|
|
56ed020d65 | ||
|
|
25b96378c7 | ||
|
|
5934ec531f | ||
|
|
65542f6025 | ||
|
|
00c603e623 | ||
|
|
bcd18428eb | ||
|
|
995abbf4a6 | ||
|
|
8599a6d918 | ||
|
|
5e9deff8a9 | ||
|
|
539849732c | ||
|
|
4fe7fa93b9 | ||
|
|
2820d3e72a | ||
|
|
cde5719bb6 | ||
|
|
8bdecadba4 | ||
|
|
b41414cfbf |
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Is something not working as intended? Report it here.
|
||||
title: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Bug description
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
### Reproduction steps
|
||||
Steps to reproduce the behavior:
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
...
|
||||
|
||||
### Expected behavior
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
### Relevant code
|
||||
If applicable, add code snippets to help explain your problem.
|
||||
|
||||
### Environment (please complete the following information):
|
||||
**WhatsApp**
|
||||
- Account type [Standard / Business]:
|
||||
- Device OS [iOS / Android]:
|
||||
- WhatsApp Web version [run `await client.getWWebVersion()`]:
|
||||
|
||||
**Library**
|
||||
- Browser [Chrome / Chromium]:
|
||||
- NodeJS version (`node -v`):
|
||||
- npm or yarn version (`npm -v`):
|
||||
- whatsapp-web.js version:
|
||||
|
||||
### Additional context
|
||||
Add any other context about the problem here.
|
||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Official WWebJS Discord Server
|
||||
url: https://discord.gg/H7DqQs4
|
||||
about: Please ask and answer questions here.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -36,6 +36,10 @@ build/Release
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Lock files
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
@@ -59,3 +63,9 @@ typings/
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# macOS Thumbnails
|
||||
._*
|
||||
|
||||
# Test sessions
|
||||
*session.json
|
||||
14
.npmignore
Normal file
14
.npmignore
Normal file
@@ -0,0 +1,14 @@
|
||||
docs/*
|
||||
.github/*
|
||||
|
||||
.eslintrc.json
|
||||
.jsdoc.json
|
||||
.editorconfig
|
||||
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
*session.json
|
||||
40
README.md
40
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://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
|
||||
@@ -11,7 +11,7 @@ It uses Puppeteer to run a real instance of Whatsapp Web to avoid getting blocke
|
||||
|
||||
The module is now available on npm! `npm i whatsapp-web.js`
|
||||
|
||||
Please note that Node v8+ is required due to Puppeteer.
|
||||
Please note that Node v10.18.1+ is required due to Puppeteer.
|
||||
|
||||
## Example usage
|
||||
|
||||
@@ -46,20 +46,23 @@ 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) |
|
||||
| Send stickers | _pending_ |
|
||||
| Send media (video) | ✅ [(requires google chrome)](https://waguide.pedroslopez.me/features/handling-attachments#caveat-for-sending-videos-and-gifs) |
|
||||
| Send stickers | ✅ |
|
||||
| Receive media (images/audio/video/documents) | ✅ |
|
||||
| Send contact cards | _pending_ |
|
||||
| Send contact cards | ✅ |
|
||||
| Send location | ✅ |
|
||||
| Receive location | ✅ |
|
||||
| Message replies | ✅ |
|
||||
| Join groups by invite | ✅ |
|
||||
| Get invite for group | ✅ |
|
||||
| Modify group info (subject, description) | ✅ |
|
||||
| Modify group settings (send messages, edit info) | ✅ |
|
||||
| Add group participants | ✅ |
|
||||
| Kick group participants | ✅ |
|
||||
| Promote/demote group participants | ✅ |
|
||||
| Mention users | ✅ |
|
||||
| Mute/unmute chats | ✅ |
|
||||
| Block/unblock contacts | ✅ |
|
||||
| Get contact info | ✅ |
|
||||
| Get profile pictures | ✅ |
|
||||
| Set user status message | ✅ |
|
||||
@@ -68,9 +71,34 @@ Something missing? Make an issue and let us know!
|
||||
|
||||
## Links
|
||||
|
||||
* [Documentation](https://pedroslopez.me/whatsapp-web.js) _(preview)_
|
||||
* [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.
|
||||
|
||||
## Donating
|
||||
|
||||
You can support the maintainer of this project through the link below
|
||||
|
||||
[](https://www.paypal.me/psla/)
|
||||
|
||||
## Disclaimer
|
||||
|
||||
This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found at https://whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2019 Pedro S Lopez
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this project except in compliance with the License.
|
||||
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: Base</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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">Base</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_Base.js.html#source-line-7">structures/<wbr>Base.<wbr>js:7</a></p>
|
||||
<p class="source-link">Source: <a href="structures_Base.js.html#source-line-6">structures/<wbr>Base.<wbr>js:6</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a WhatsApp data structure</p>
|
||||
</div>
|
||||
@@ -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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: BusinessContact</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -45,19 +45,22 @@
|
||||
<dt><a href="BusinessContact.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#isBlocked">isBlocked</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#isBusiness">isBusiness</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#isEnterprise">isEnterprise</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#isGroup">isGroup</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="BusinessContact.html#isGroup">isGroup</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#isMe">isMe</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -70,13 +73,13 @@
|
||||
<dt><a href="BusinessContact.html#isWAContact">isWAContact</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="BusinessContact.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#number">number</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -91,18 +94,34 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Method</h2>
|
||||
<h2 class="summary-callout-heading">Methods</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="BusinessContact.html#block">block()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#getAbout">getAbout()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="BusinessContact.html#getChat">getChat()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="BusinessContact.html#unblock">unblock()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -128,6 +147,13 @@
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#id">Contact#id</a></dd>
|
||||
</dl>
|
||||
<h3 id="isBlocked"><span class="symbol-name">isBlocked</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if you have blocked this contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isBlocked">Contact#isBlocked</a></dd>
|
||||
</dl>
|
||||
<h3 id="isBusiness"><span class="symbol-name">isBusiness</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the contact is a business contact</p>
|
||||
@@ -206,8 +232,36 @@
|
||||
<dd><a href="Contact.html#shortName">Contact#shortName</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Method</h2>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="block"><span class="symbol-name">block</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Blocks this contact from WhatsApp</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#block">Contact#block</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getAbout"><span class="symbol-name">getAbout</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing nullable string</span></span></h3>
|
||||
<p>Gets the Contact's current "about" info. Returns null if you don't have permission to read their status.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getAbout">Contact#getAbout</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getChat"><span class="symbol-name">getChat</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Chat.html">Chat</a></span></span></h3>
|
||||
<p>Returns the Chat that corresponds to this Contact.
|
||||
Will return null when getting chat for currently logged in user.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getChat">Contact#getChat</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||
@@ -217,6 +271,15 @@
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="unblock"><span class="symbol-name">unblock</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Unblocks this contact from WhatsApp</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#unblock">Contact#unblock</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
@@ -227,7 +290,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
157
docs/Chat.html
157
docs/Chat.html
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: Chat</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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">Chat</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_Chat.js.html#source-line-11">structures/<wbr>Chat.<wbr>js:11</a></p>
|
||||
<p class="source-link">Source: <a href="structures_Chat.js.html#source-line-10">structures/<wbr>Chat.<wbr>js:10</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Chat on WhatsApp</p>
|
||||
</div>
|
||||
@@ -48,6 +48,9 @@
|
||||
<dt><a href="Chat.html#isGroup">isGroup</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#isMuted">isMuted</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
@@ -55,16 +58,22 @@
|
||||
<dt><a href="Chat.html#isReadOnly">isReadOnly</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#muteExpiration">muteExpiration</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#timestamp">timestamp</a></dt>
|
||||
<dt><a href="Chat.html#pinned">pinned</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Chat.html#timestamp">timestamp</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#unreadCount">unreadCount</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -89,32 +98,53 @@
|
||||
<dt><a href="Chat.html#delete">delete()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#fetchMessages">fetchMessages(searchOptions)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#getContact">getContact()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Chat.html#fetchMessages">fetchMessages(searchOptions)</a></dt>
|
||||
<dt><a href="Chat.html#getLabels">getLabels()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#sendMessage">sendMessage(content, options)</a></dt>
|
||||
<dt><a href="Chat.html#markUnread">markUnread()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#mute">mute(unmuteDate)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#pin">pin()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#sendMessage">sendMessage(content[, options])</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#sendSeen">sendSeen()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#sendStateRecording">sendStateRecording()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Chat.html#sendStateRecording">sendStateRecording()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#sendStateTyping">sendStateTyping()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#unarchive">unarchive()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#unmute">unmute()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#unpin">unpin()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
@@ -145,19 +175,34 @@
|
||||
<p>Indicates if the Chat is a Group Chat</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isMuted"><span class="symbol-name">isMuted</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Indicates if the chat is muted or not</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isReadOnly"><span class="symbol-name">isReadOnly</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the Chat is readonly</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="muteExpiration"><span class="symbol-name">muteExpiration</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Unix timestamp for when the mute expires</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="name"><span class="symbol-name">name</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Title of the chat</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="pinned"><span class="symbol-name">pinned</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the Chat is pinned</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Unix timestamp for when the chat was created</p>
|
||||
<p>Unix timestamp for when the last activity occurred</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="unreadCount"><span class="symbol-name">unreadCount</span><small class="property-type">
|
||||
@@ -265,7 +310,74 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content, options)</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<h3 id="getContact"><span class="symbol-name">getContact</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Contact.html">Contact</a></span></span></h3>
|
||||
<p>Returns the Contact that corresponds to this Chat.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="Contact.html">Contact</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getLabels"><span class="symbol-name">getLabels</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of <a href="Label.html">Label</a></span></span></h3>
|
||||
<p>Returns array of all Labels assigned to this Chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Array of <a href="Label.html">Label</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="markUnread"><span class="symbol-name">markUnread</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Mark this chat as unread</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="mute"><span class="symbol-name">mute</span><span class="signature"><span class="signature-params">(unmuteDate)</span></span></h3>
|
||||
<p>Mutes this chat until a specified date</p>
|
||||
<section>
|
||||
<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>unmuteDate</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Date</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Date at which the Chat will be unmuted</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="pin"><span class="symbol-name">pin</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Pins this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing boolean</code> <p>New pin state. Could be false if the max number of pinned chats was reached.</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content[, options])</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<p>Send a message to this chat</p>
|
||||
<section>
|
||||
<h4>Parameters</h4>
|
||||
@@ -297,10 +409,10 @@
|
||||
<p>options</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</p>
|
||||
<p><a href="global.html#MessageSendOptions">MessageSendOptions</a></p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
@@ -340,6 +452,21 @@
|
||||
<p>un-archives this chat</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="unmute"><span class="symbol-name">unmute</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Unmutes this chat</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="unpin"><span class="symbol-name">unpin</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Unpins this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing boolean</code> <p>New pin state</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
@@ -350,7 +477,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
1073
docs/Client.html
1073
docs/Client.html
File diff suppressed because it is too large
Load Diff
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: Client.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -33,18 +33,35 @@
|
||||
|
||||
const EventEmitter = require('events');
|
||||
const puppeteer = require('puppeteer');
|
||||
const moduleRaid = require('moduleraid/moduleraid');
|
||||
const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
|
||||
const jsQR = require('jsqr');
|
||||
|
||||
const Util = require('./util/Util');
|
||||
const { WhatsWebURL, UserAgent, DefaultOptions, Events, WAState } = require('./util/Constants');
|
||||
const InterfaceController = require('./util/InterfaceController');
|
||||
const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./util/Constants');
|
||||
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
||||
const ChatFactory = require('./factories/ChatFactory');
|
||||
const ContactFactory = require('./factories/ContactFactory');
|
||||
const { ClientInfo, Message, MessageMedia, Location, GroupNotification } = require('./structures');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label } = require('./structures');
|
||||
/**
|
||||
* Starting point for interacting with the WhatsApp Web API
|
||||
* @extends {EventEmitter}
|
||||
* @param {object} options - Client options
|
||||
* @param {number} options.authTimeoutMs - Timeout for authentication selector in puppeteer
|
||||
* @param {object} options.puppeteer - Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/
|
||||
* @param {number} options.qrRefreshIntervalMs - Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
|
||||
* @param {number} options.qrTimeoutMs - Timeout for qr code selector in puppeteer
|
||||
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
|
||||
* @param {string} options.session.WABrowserId
|
||||
* @param {string} options.session.WASecretBundle
|
||||
* @param {string} options.session.WAToken1
|
||||
* @param {string} options.session.WAToken2
|
||||
* @param {number} options.takeoverOnConflict - If another whatsapp web session is detected (another browser), take over the session in the current browser
|
||||
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
|
||||
* @param {string} options.userAgent - User agent to use in puppeteer
|
||||
* @param {string} options.ffmpegPath - Ffmpeg path to use when formating videos to webp while sending stickers
|
||||
*
|
||||
* @fires Client#qr
|
||||
* @fires Client#authenticated
|
||||
* @fires Client#auth_failure
|
||||
@@ -54,11 +71,13 @@ const { ClientInfo, Message, MessageMedia, Location, GroupNotification } =
|
||||
* @fires Client#message_create
|
||||
* @fires Client#message_revoke_me
|
||||
* @fires Client#message_revoke_everyone
|
||||
* @fires Client#media_uploaded
|
||||
* @fires Client#group_join
|
||||
* @fires Client#group_leave
|
||||
* @fires Client#group_update
|
||||
* @fires Client#disconnected
|
||||
* @fires Client#change_state
|
||||
* @fires Client#change_battery
|
||||
*/
|
||||
class Client extends EventEmitter {
|
||||
constructor(options = {}) {
|
||||
@@ -68,6 +87,8 @@ class Client extends EventEmitter {
|
||||
|
||||
this.pupBrowser = null;
|
||||
this.pupPage = null;
|
||||
|
||||
Util.setFfmpegPath(this.options.ffmpegPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +97,10 @@ class Client extends EventEmitter {
|
||||
async initialize() {
|
||||
const browser = await puppeteer.launch(this.options.puppeteer);
|
||||
const page = (await browser.pages())[0];
|
||||
page.setUserAgent(UserAgent);
|
||||
page.setUserAgent(this.options.userAgent);
|
||||
|
||||
this.pupBrowser = browser;
|
||||
this.pupPage = page;
|
||||
|
||||
if (this.options.session) {
|
||||
await page.evaluateOnNewDocument(
|
||||
@@ -89,14 +113,17 @@ class Client extends EventEmitter {
|
||||
}, this.options.session);
|
||||
}
|
||||
|
||||
await page.goto(WhatsWebURL);
|
||||
await page.goto(WhatsWebURL, {
|
||||
waitUntil: 'load',
|
||||
timeout: 0,
|
||||
});
|
||||
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image="true"]';
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||
|
||||
if (this.options.session) {
|
||||
// Check if session restore was successfull
|
||||
try {
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 15000 });
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: this.options.authTimeoutMs });
|
||||
} catch (err) {
|
||||
if (err.name === 'TimeoutError') {
|
||||
/**
|
||||
@@ -106,7 +133,11 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATION_FAILURE, 'Unable to log in. Are the session details valid?');
|
||||
browser.close();
|
||||
|
||||
if (this.options.restartOnAuthFail) {
|
||||
// session restore failed so try again but without session to force new authentication
|
||||
this.options.session = null;
|
||||
this.initialize();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,18 +147,18 @@ class Client extends EventEmitter {
|
||||
} else {
|
||||
const getQrCode = async () => {
|
||||
// Check if retry button is present
|
||||
var QR_RETRY_SELECTOR = 'div[data-ref] > span > div';
|
||||
var QR_RETRY_SELECTOR = 'div[data-ref] > span > button';
|
||||
var qrRetry = await page.$(QR_RETRY_SELECTOR);
|
||||
if (qrRetry) {
|
||||
await qrRetry.click();
|
||||
}
|
||||
|
||||
// Wait for QR Code
|
||||
|
||||
const QR_CANVAS_SELECTOR = 'canvas';
|
||||
await page.waitForSelector(QR_CANVAS_SELECTOR);
|
||||
await page.waitForSelector(QR_CANVAS_SELECTOR, { timeout: this.options.qrTimeoutMs });
|
||||
const qrImgData = await page.$eval(QR_CANVAS_SELECTOR, canvas => [].slice.call(canvas.getContext('2d').getImageData(0, 0, 264, 264).data));
|
||||
const qr = jsQR(qrImgData, 264, 264).data;
|
||||
|
||||
/**
|
||||
* Emitted when the QR code is received
|
||||
* @event Client#qr
|
||||
@@ -136,11 +167,12 @@ class Client extends EventEmitter {
|
||||
this.emit(Events.QR_RECEIVED, qr);
|
||||
};
|
||||
getQrCode();
|
||||
let retryInterval = setInterval(getQrCode, 20000); // check for qr code every 20 seconds
|
||||
this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
|
||||
|
||||
// Wait for code scan
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||
clearInterval(retryInterval);
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
this._qrRefreshInterval = undefined;
|
||||
|
||||
}
|
||||
|
||||
@@ -162,6 +194,10 @@ class Client extends EventEmitter {
|
||||
* Emitted when authentication is successful
|
||||
* @event Client#authenticated
|
||||
* @param {object} session Object containing session information. Can be used to restore the session.
|
||||
* @param {string} session.WABrowserId
|
||||
* @param {string} session.WASecretBundle
|
||||
* @param {string} session.WAToken1
|
||||
* @param {string} session.WAToken2
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATED, session);
|
||||
|
||||
@@ -172,10 +208,17 @@ class Client extends EventEmitter {
|
||||
await page.evaluate(LoadUtils);
|
||||
|
||||
// Expose client info
|
||||
/**
|
||||
* Current connection information
|
||||
* @type {ClientInfo}
|
||||
*/
|
||||
this.info = new ClientInfo(this, await page.evaluate(() => {
|
||||
return window.Store.Conn.serialize();
|
||||
}));
|
||||
|
||||
// Add InterfaceController
|
||||
this.interface = new InterfaceController(this);
|
||||
|
||||
// Register events
|
||||
await page.exposeFunction('onAddMessageEvent', msg => {
|
||||
if (!msg.isNewMsg) return;
|
||||
@@ -206,7 +249,7 @@ class Client extends EventEmitter {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
||||
/**
|
||||
@@ -275,7 +318,7 @@ class Client extends EventEmitter {
|
||||
await page.exposeFunction('onMessageAckEvent', (msg, ack) => {
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
||||
|
||||
/**
|
||||
* Emitted when an ack event occurrs on message type.
|
||||
* @event Client#message_ack
|
||||
@@ -286,7 +329,19 @@ class Client extends EventEmitter {
|
||||
|
||||
});
|
||||
|
||||
await page.exposeFunction('onAppStateChangedEvent', (_AppState, state) => {
|
||||
await page.exposeFunction('onMessageMediaUploadedEvent', (msg) => {
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
||||
/**
|
||||
* Emitted when media has been uploaded for a message sent by the client.
|
||||
* @event Client#media_uploaded
|
||||
* @param {Message} message The message with media that was uploaded
|
||||
*/
|
||||
this.emit(Events.MEDIA_UPLOADED, message);
|
||||
});
|
||||
|
||||
await page.exposeFunction('onAppStateChangedEvent', (state) => {
|
||||
|
||||
/**
|
||||
* Emitted when the connection state changes
|
||||
@@ -296,42 +351,97 @@ class Client extends EventEmitter {
|
||||
this.emit(Events.STATE_CHANGED, state);
|
||||
|
||||
const ACCEPTED_STATES = [WAState.CONNECTED, WAState.OPENING, WAState.PAIRING, WAState.TIMEOUT];
|
||||
|
||||
if (this.options.takeoverOnConflict) {
|
||||
ACCEPTED_STATES.push(WAState.CONFLICT);
|
||||
|
||||
if (state === WAState.CONFLICT) {
|
||||
setTimeout(() => {
|
||||
this.pupPage.evaluate(() => window.Store.AppState.takeover());
|
||||
}, this.options.takeoverTimeoutMs);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ACCEPTED_STATES.includes(state)) {
|
||||
/**
|
||||
* Emitted when the client has been disconnected
|
||||
* @event Client#disconnected
|
||||
* @param {WAState} reason state that caused the disconnect
|
||||
* @param {WAState|"NAVIGATION"} reason reason that caused the disconnect
|
||||
*/
|
||||
this.emit(Events.DISCONNECTED, state);
|
||||
this.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
await page.evaluate(() => {
|
||||
window.Store.Msg.on('add', window.onAddMessageEvent);
|
||||
window.Store.Msg.on('change', window.onChangeMessageEvent);
|
||||
window.Store.Msg.on('change:type', window.onChangeMessageTypeEvent);
|
||||
window.Store.Msg.on('change:ack', window.onMessageAckEvent);
|
||||
window.Store.Msg.on('remove', window.onRemoveMessageEvent);
|
||||
window.Store.AppState.on('change:state', window.onAppStateChangedEvent);
|
||||
await page.exposeFunction('onBatteryStateChangedEvent', (state) => {
|
||||
const { battery, plugged } = state;
|
||||
|
||||
if (battery === undefined) return;
|
||||
|
||||
/**
|
||||
* Emitted when the battery percentage for the attached device changes
|
||||
* @event Client#change_battery
|
||||
* @param {object} batteryInfo
|
||||
* @param {number} batteryInfo.battery - The current battery percentage
|
||||
* @param {boolean} batteryInfo.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||
*/
|
||||
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
|
||||
});
|
||||
|
||||
this.pupBrowser = browser;
|
||||
this.pupPage = page;
|
||||
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); });
|
||||
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if (msg.id.fromMe &amp;&amp; !unsent) window.onMessageMediaUploadedEvent(window.WWebJS.getMessageModel(msg)); });
|
||||
window.Store.Msg.on('remove', (msg) => { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
||||
window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); });
|
||||
window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); });
|
||||
});
|
||||
|
||||
/**
|
||||
* Emitted when the client has initialized and is ready to receive messages.
|
||||
* @event Client#ready
|
||||
*/
|
||||
this.emit(Events.READY);
|
||||
|
||||
// Disconnect when navigating away
|
||||
// Because WhatsApp Web now reloads when logging out from the device, this also covers that case
|
||||
this.pupPage.on('framenavigated', async () => {
|
||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||
await this.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the client
|
||||
*/
|
||||
async destroy() {
|
||||
if (this._qrRefreshInterval) {
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
}
|
||||
await this.pupBrowser.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the client, closing the current session
|
||||
*/
|
||||
async logout() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Store.AppState.logout();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of WhatsApp Web currently being run
|
||||
* @returns {Promise&lt;string>}
|
||||
*/
|
||||
async getWWebVersion() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Debug.VERSION;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark as seen for the Chat
|
||||
* @param {string} chatId
|
||||
@@ -345,20 +455,42 @@ class Client extends EventEmitter {
|
||||
}, chatId);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message options.
|
||||
* @typedef {Object} MessageSendOptions
|
||||
* @property {boolean} [linkPreview=true] - Show links preview
|
||||
* @property {boolean} [sendAudioAsVoice=false] - Send audio as voice message
|
||||
* @property {boolean} [sendMediaAsSticker=false] - Send media as a sticker
|
||||
* @property {boolean} [sendMediaAsDocument=false] - Send media as a document
|
||||
* @property {boolean} [parseVCards=true] - Automatically parse vCards and send them as contacts
|
||||
* @property {string} [caption] - Image or video caption
|
||||
* @property {string} [quotedMessageId] - Id of the message that is being quoted (or replied to)
|
||||
* @property {Contact[]} [mentions] - Contacts that are being mentioned in the message
|
||||
* @property {boolean} [sendSeen=true] - Mark the conversation as seen after sending the message
|
||||
* @property {MessageMedia} [media] - Media to be sent
|
||||
*/
|
||||
|
||||
/**
|
||||
* Send a message to a specific chatId
|
||||
* @param {string} chatId
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {object} options
|
||||
* @param {string|MessageMedia|Location|Contact|Array&lt;Contact>} content
|
||||
* @param {MessageSendOptions} [options] - Options used when sending the message
|
||||
*
|
||||
* @returns {Promise&lt;Message>} Message that was just sent
|
||||
*/
|
||||
async sendMessage(chatId, content, options = {}) {
|
||||
let internalOptions = {
|
||||
linkPreview: options.linkPreview === false ? undefined : true,
|
||||
sendAudioAsVoice: options.sendAudioAsVoice,
|
||||
sendMediaAsSticker: options.sendMediaAsSticker,
|
||||
sendMediaAsDocument: options.sendMediaAsDocument,
|
||||
caption: options.caption,
|
||||
quotedMessageId: options.quotedMessageId,
|
||||
parseVCards: options.parseVCards === false ? false : true,
|
||||
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : []
|
||||
};
|
||||
|
||||
|
||||
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
||||
|
||||
if (content instanceof MessageMedia) {
|
||||
@@ -367,38 +499,31 @@ class Client extends EventEmitter {
|
||||
} else if (options.media instanceof MessageMedia) {
|
||||
internalOptions.attachment = options.media;
|
||||
internalOptions.caption = content;
|
||||
content = '';
|
||||
} else if (content instanceof Location) {
|
||||
internalOptions.location = content;
|
||||
content = '';
|
||||
} else if(content instanceof Contact) {
|
||||
internalOptions.contactCard = content.id._serialized;
|
||||
content = '';
|
||||
} 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 = '';
|
||||
}
|
||||
|
||||
if (internalOptions.sendMediaAsSticker &amp;&amp; internalOptions.attachment) {
|
||||
internalOptions.attachment = await Util.formatToWebpSticker(internalOptions.attachment);
|
||||
}
|
||||
|
||||
const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
let msg;
|
||||
if (!chat) { // The chat is not available in the previously chatted list
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = await window.Store.Chat.find(chatWid);
|
||||
|
||||
let newChatId = await window.WWebJS.getNumberId(chatId);
|
||||
if (newChatId) {
|
||||
//get the topmost chat object and assign the new chatId to it .
|
||||
//This is just a workaround.May cause problem if there are no chats at all. Need to dig in and emulate how whatsapp web does
|
||||
let chat = window.Store.Chat.models[0];
|
||||
if (!chat)
|
||||
throw 'Chat List empty! Need at least one open conversation with any of your contact';
|
||||
|
||||
let originalChatObjId = chat.id;
|
||||
chat.id = newChatId;
|
||||
|
||||
msg = await window.WWebJS.sendMessage(chat, message, options);
|
||||
chat.id = originalChatObjId; //replace the chat with its original id
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(sendSeen) {
|
||||
window.WWebJS.sendSeen(chatId);
|
||||
}
|
||||
|
||||
msg = await window.WWebJS.sendMessage(chat, message, options, sendSeen);
|
||||
if (sendSeen) {
|
||||
window.WWebJS.sendSeen(chatId);
|
||||
}
|
||||
|
||||
const msg = await window.WWebJS.sendMessage(chat, message, options, sendSeen);
|
||||
return msg.serialize();
|
||||
}, chatId, content, internalOptions, sendSeen);
|
||||
|
||||
@@ -410,8 +535,8 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise&lt;Array&lt;Chat>>}
|
||||
*/
|
||||
async getChats() {
|
||||
let chats = await this.pupPage.evaluate(() => {
|
||||
return window.WWebJS.getChats();
|
||||
let chats = await this.pupPage.evaluate(async () => {
|
||||
return await window.WWebJS.getChats();
|
||||
});
|
||||
|
||||
return chats.map(chat => ChatFactory.create(this, chat));
|
||||
@@ -423,8 +548,8 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise&lt;Chat>}
|
||||
*/
|
||||
async getChatById(chatId) {
|
||||
let chat = await this.pupPage.evaluate(chatId => {
|
||||
return window.WWebJS.getChat(chatId);
|
||||
let chat = await this.pupPage.evaluate(async chatId => {
|
||||
return await window.WWebJS.getChat(chatId);
|
||||
}, chatId);
|
||||
|
||||
return ChatFactory.create(this, chat);
|
||||
@@ -455,9 +580,21 @@ class Client extends EventEmitter {
|
||||
return ContactFactory.create(this, contact);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object with information about the invite code's group
|
||||
* @param {string} inviteCode
|
||||
* @returns {Promise&lt;object>} Invite information
|
||||
*/
|
||||
async getInviteInfo(inviteCode) {
|
||||
return await this.pupPage.evaluate(inviteCode => {
|
||||
return window.Store.Wap.groupInviteInfo(inviteCode);
|
||||
}, inviteCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts an invitation to join a group
|
||||
* @param {string} inviteCode Invitation code
|
||||
* @returns {Promise&lt;string>} Id of the joined Chat
|
||||
*/
|
||||
async acceptInvite(inviteCode) {
|
||||
const chatId = await this.pupPage.evaluate(async inviteCode => {
|
||||
@@ -477,6 +614,17 @@ class Client extends EventEmitter {
|
||||
}, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current user's display name.
|
||||
* This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
|
||||
* @param {string} displayName New display name
|
||||
*/
|
||||
async setDisplayName(displayName) {
|
||||
await this.pupPage.evaluate(async displayName => {
|
||||
return await window.Store.Wap.setPushname(displayName);
|
||||
}, displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current connection state for the client
|
||||
* @returns {WAState}
|
||||
@@ -487,6 +635,15 @@ class Client extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the client as online
|
||||
*/
|
||||
async sendPresenceAvailable() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Store.Wap.sendPresenceAvailable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables and returns the archive state of the Chat
|
||||
* @returns {boolean}
|
||||
@@ -511,15 +668,225 @@ class Client extends EventEmitter {
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pins the Chat
|
||||
* @returns {Promise&lt;boolean>} New pin state. Could be false if the max number of pinned chats was reached.
|
||||
*/
|
||||
async pinChat(chatId) {
|
||||
return this.pupPage.evaluate(async chatId => {
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
if (chat.pin) {
|
||||
return true;
|
||||
}
|
||||
const MAX_PIN_COUNT = 3;
|
||||
if (window.Store.Chat.models.length > MAX_PIN_COUNT) {
|
||||
let maxPinned = window.Store.Chat.models[MAX_PIN_COUNT - 1].pin;
|
||||
if (maxPinned) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
await window.Store.Cmd.pinChat(chat, true);
|
||||
return true;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpins the Chat
|
||||
* @returns {Promise&lt;boolean>} New pin state
|
||||
*/
|
||||
async unpinChat(chatId) {
|
||||
return this.pupPage.evaluate(async chatId => {
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
if (!chat.pin) {
|
||||
return false;
|
||||
}
|
||||
await window.Store.Cmd.pinChat(chat, false);
|
||||
return false;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutes the Chat until a specified date
|
||||
* @param {string} chatId ID of the chat that will be muted
|
||||
* @param {Date} unmuteDate Date when the chat will be unmuted
|
||||
*/
|
||||
async muteChat(chatId, unmuteDate) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmutes the Chat
|
||||
* @param {string} chatId ID of the chat that will be unmuted
|
||||
*/
|
||||
async unmuteChat(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.muteChat(chat, false);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the Chat as unread
|
||||
* @param {string} chatId ID of the chat that will be marked as unread
|
||||
*/
|
||||
async markChatUnread(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.markChatUnread(chat, true);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contact ID's profile picture URL, if privacy settings allow it
|
||||
* @param {string} contactId the whatsapp user's ID
|
||||
* @returns {Promise&lt;string>}
|
||||
*/
|
||||
async getProfilePicUrl(contactId) {
|
||||
const profilePic = await this.pupPage.evaluate((contactId) => {
|
||||
return window.Store.Wap.profilePicFind(contactId);
|
||||
}, contactId);
|
||||
|
||||
return profilePic ? profilePic.eurl : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force reset of connection state for the client
|
||||
*/
|
||||
async resetState(){
|
||||
async resetState() {
|
||||
await this.pupPage.evaluate(() => {
|
||||
window.Store.AppState.phoneWatchdog.shiftTimer.forceRunNow();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given ID is registered in whatsapp
|
||||
* @param {string} id the whatsapp user's ID
|
||||
* @returns {Promise&lt;Boolean>}
|
||||
*/
|
||||
async isRegisteredUser(id) {
|
||||
return await this.pupPage.evaluate(async (id) => {
|
||||
let result = await window.Store.Wap.queryExist(id);
|
||||
return result.jid !== undefined;
|
||||
}, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the registered WhatsApp ID for a number.
|
||||
* Will return null if the number is not registered on WhatsApp.
|
||||
* @param {string} number Number or ID ("@c.us" will be automatically appended if not specified)
|
||||
* @returns {Promise&lt;Object|null>}
|
||||
*/
|
||||
async getNumberId(number) {
|
||||
if(!number.endsWith('@c.us')) {
|
||||
number += '@c.us';
|
||||
}
|
||||
|
||||
try {
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.WWebJS.getNumberId(numberId);
|
||||
}, number);
|
||||
} catch(_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new group
|
||||
* @param {string} name group title
|
||||
* @param {Array&lt;Contact|string>} participants an array of Contacts or contact IDs to add to the group
|
||||
* @returns {Object} createRes
|
||||
* @returns {string} createRes.gid - ID for the group that was just created
|
||||
* @returns {Object.&lt;string,string>} createRes.missingParticipants - participants that were not added to the group. Keys represent the ID for participant that was not added and its value is a status code that represents the reason why participant could not be added. This is usually 403 if the user's privacy settings don't allow you to add them to groups.
|
||||
*/
|
||||
async createGroup(name, participants) {
|
||||
if (!Array.isArray(participants) || participants.length == 0) {
|
||||
throw 'You need to add at least one other participant to the group';
|
||||
}
|
||||
|
||||
if (participants.every(c => c instanceof Contact)) {
|
||||
participants = participants.map(c => c.id._serialized);
|
||||
}
|
||||
|
||||
const createRes = await this.pupPage.evaluate(async (name, participantIds) => {
|
||||
const res = await window.Store.Wap.createGroup(name, participantIds);
|
||||
console.log(res);
|
||||
if (!res.status === 200) {
|
||||
throw 'An error occurred while creating the group!';
|
||||
}
|
||||
|
||||
return res;
|
||||
}, name, participants);
|
||||
|
||||
const missingParticipants = createRes.participants.reduce(((missing, c) => {
|
||||
const id = Object.keys(c)[0];
|
||||
const statusCode = c[id].code;
|
||||
if (statusCode != 200) return Object.assign(missing, { [id]: statusCode });
|
||||
return missing;
|
||||
}), {});
|
||||
|
||||
return { gid: createRes.gid, missingParticipants };
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all current Labels
|
||||
* @returns {Promise&lt;Array&lt;Label>>}
|
||||
*/
|
||||
async getLabels() {
|
||||
const labels = await this.pupPage.evaluate(async () => {
|
||||
return window.WWebJS.getLabels();
|
||||
});
|
||||
|
||||
return labels.map(data => new Label(this , data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Label instance by ID
|
||||
* @param {string} labelId
|
||||
* @returns {Promise&lt;Label>}
|
||||
*/
|
||||
async getLabelById(labelId) {
|
||||
const label = await this.pupPage.evaluate(async (labelId) => {
|
||||
return window.WWebJS.getLabel(labelId);
|
||||
}, labelId);
|
||||
|
||||
return new Label(this, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Labels assigned to a chat
|
||||
* @param {string} chatId
|
||||
* @returns {Promise&lt;Array&lt;Label>>}
|
||||
*/
|
||||
async getChatLabels(chatId){
|
||||
const labels = await this.pupPage.evaluate(async (chatId) => {
|
||||
return window.WWebJS.getChatLabels(chatId);
|
||||
}, chatId);
|
||||
|
||||
return labels.map(data => new Label(this, data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Chats for a specific Label
|
||||
* @param {string} labelId
|
||||
* @returns {Promise&lt;Array&lt;Chat>>}
|
||||
*/
|
||||
async getChatsByLabelId(labelId){
|
||||
const chatIds = await this.pupPage.evaluate(async (labelId) => {
|
||||
const label = window.Store.Label.get(labelId);
|
||||
const labelItems = label.labelItemCollection.models;
|
||||
return labelItems.reduce((result, item) => {
|
||||
if(item.parentType === 'Chat'){
|
||||
result.push(item.parentId);
|
||||
}
|
||||
return result;
|
||||
},[]);
|
||||
}, labelId);
|
||||
|
||||
return Promise.all(chatIds.map(id => this.getChatById(id)));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
@@ -533,7 +900,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: ClientInfo</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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">ClientInfo</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_ClientInfo.js.html#source-line-10">structures/<wbr>ClientInfo.<wbr>js:10</a></p>
|
||||
<p class="source-link">Source: <a href="structures_ClientInfo.js.html#source-line-9">structures/<wbr>ClientInfo.<wbr>js:9</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Current connection information</p>
|
||||
</div>
|
||||
@@ -57,6 +57,27 @@
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="ClientInfo.html#wid">wid</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="ClientInfo.html#getBatteryStatus">getBatteryStatus()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
@@ -74,8 +95,9 @@
|
||||
<section>
|
||||
<h3 id="me"><span class="symbol-name">me</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>Current user ID</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Deprecated</dt>
|
||||
<dd>Use .wid instead</dd>
|
||||
</dl>
|
||||
<h3 id="phone"><span class="symbol-name">phone</span><small class="property-type">
|
||||
object</small></h3>
|
||||
@@ -177,6 +199,32 @@
|
||||
<p>Name configured to be shown in push notifications</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="wid"><span class="symbol-name">wid</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>Current user ID</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Method</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getBatteryStatus"><span class="symbol-name">getBatteryStatus</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> (object, number, or boolean)</span></span></h3>
|
||||
<p>Get current battery percentage and charging status for the attached device</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>object</code> <p>batteryStatus</p>
|
||||
</p>
|
||||
</dd>
|
||||
<dd>
|
||||
<p><code>number</code> <p>batteryStatus.battery - The current battery percentage</p>
|
||||
</p>
|
||||
</dd>
|
||||
<dd>
|
||||
<p><code>boolean</code> <p>batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
@@ -187,7 +235,7 @@
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: Contact</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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">Contact</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_Contact.js.html#source-line-10">structures/<wbr>Contact.<wbr>js:10</a></p>
|
||||
<p class="source-link">Source: <a href="structures_Contact.js.html#source-line-17">structures/<wbr>Contact.<wbr>js:17</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Contact on WhatsApp</p>
|
||||
</div>
|
||||
@@ -42,6 +42,9 @@
|
||||
<dt><a href="Contact.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#isBlocked">isBlocked</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#isBusiness">isBusiness</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -67,13 +70,13 @@
|
||||
<dt><a href="Contact.html#isWAContact">isWAContact</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Contact.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#number">number</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -88,18 +91,34 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Method</h2>
|
||||
<h2 class="summary-callout-heading">Methods</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Contact.html#block">block()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#getAbout">getAbout()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Contact.html#getChat">getChat()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Contact.html#unblock">unblock()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -115,10 +134,15 @@
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<a href="global.html#ContactId">ContactId</a></small></h3>
|
||||
<p>ID that represents the contact</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isBlocked"><span class="symbol-name">isBlocked</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if you have blocked this contact</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isBusiness"><span class="symbol-name">isBusiness</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the contact is a business contact</p>
|
||||
@@ -175,8 +199,36 @@
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Method</h2>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="block"><span class="symbol-name">block</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Blocks this contact from WhatsApp</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing boolean</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getAbout"><span class="symbol-name">getAbout</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing nullable string</span></span></h3>
|
||||
<p>Gets the Contact's current "about" info. Returns null if you don't have permission to read their status.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing nullable string</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getChat"><span class="symbol-name">getChat</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Chat.html">Chat</a></span></span></h3>
|
||||
<p>Returns the Chat that corresponds to this Contact.
|
||||
Will return null when getting chat for currently logged in user.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="Chat.html">Chat</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||
@@ -186,6 +238,15 @@
|
||||
<p><code>Promise containing string</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="unblock"><span class="symbol-name">unblock</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Unblocks this contact from WhatsApp</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing boolean</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
@@ -196,7 +257,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: GroupChat</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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">GroupChat</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_GroupChat.js.html#source-line-9">structures/<wbr>GroupChat.<wbr>js:9</a></p>
|
||||
<p class="source-link">Source: <a href="structures_GroupChat.js.html#source-line-17">structures/<wbr>GroupChat.<wbr>js:17</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Group Chat on WhatsApp</p>
|
||||
</div>
|
||||
@@ -51,16 +51,22 @@
|
||||
<dt><a href="GroupChat.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#isGroup">isGroup</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupChat.html#isGroup">isGroup</a></dt>
|
||||
<dt><a href="GroupChat.html#isMuted">isMuted</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#isReadOnly">isReadOnly</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#muteExpiration">muteExpiration</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -74,6 +80,9 @@
|
||||
<dt><a href="GroupChat.html#participants">participants</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#pinned">pinned</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#timestamp">timestamp</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -89,12 +98,6 @@
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupChat.html#.getInviteInfo">getInviteInfo(inviteCode)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#.join">join(inviteCode)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#addParticipants">addParticipants(participantIds)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -110,22 +113,37 @@
|
||||
<dt><a href="GroupChat.html#delete">delete()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupChat.html#demoteParticipants">demoteParticipants(participantIds)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#fetchMessages">fetchMessages(searchOptions)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#getContact">getContact()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#getInviteCode">getInviteCode()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#getLabels">getLabels()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupChat.html#leave">leave()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#markUnread">markUnread()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#mute">mute(unmuteDate)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#pin">pin()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#promoteParticipants">promoteParticipants(participantIds)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -135,11 +153,7 @@
|
||||
<dt><a href="GroupChat.html#revokeInvite">revokeInvite()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupChat.html#sendMessage">sendMessage(content, options)</a></dt>
|
||||
<dt><a href="GroupChat.html#sendMessage">sendMessage(content[, options])</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#sendSeen">sendSeen()</a></dt>
|
||||
@@ -148,18 +162,34 @@
|
||||
<dt><a href="GroupChat.html#sendStateRecording">sendStateRecording()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupChat.html#sendStateTyping">sendStateTyping()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#setDescription">setDescription(description)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#setInfoAdminsOnly">setInfoAdminsOnly([adminsOnly])</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#setMessagesAdminsOnly">setMessagesAdminsOnly([adminsOnly])</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#setSubject">setSubject(subject)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#unarchive">unarchive()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#unmute">unmute()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#unpin">unpin()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
@@ -206,6 +236,13 @@
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#isGroup">Chat#isGroup</a></dd>
|
||||
</dl>
|
||||
<h3 id="isMuted"><span class="symbol-name">isMuted</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the chat is muted or not</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#isMuted">Chat#isMuted</a></dd>
|
||||
</dl>
|
||||
<h3 id="isReadOnly"><span class="symbol-name">isReadOnly</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the Chat is readonly</p>
|
||||
@@ -213,6 +250,13 @@
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#isReadOnly">Chat#isReadOnly</a></dd>
|
||||
</dl>
|
||||
<h3 id="muteExpiration"><span class="symbol-name">muteExpiration</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Unix timestamp for when the mute expires</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#muteExpiration">Chat#muteExpiration</a></dd>
|
||||
</dl>
|
||||
<h3 id="name"><span class="symbol-name">name</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Title of the chat</p>
|
||||
@@ -220,18 +264,26 @@
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#name">Chat#name</a></dd>
|
||||
</dl>
|
||||
<h3 id="owner"><span class="symbol-name">owner</span></h3>
|
||||
<h3 id="owner"><span class="symbol-name">owner</span><small class="property-type">
|
||||
<a href="global.html#ContactId">ContactId</a></small></h3>
|
||||
<p>Gets the group owner</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="participants"><span class="symbol-name">participants</span><small class="property-type">
|
||||
array</small></h3>
|
||||
Array of <a href="global.html#GroupParticipant">GroupParticipant</a></small></h3>
|
||||
<p>Gets the group participants</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="pinned"><span class="symbol-name">pinned</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the Chat is pinned</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#pinned">Chat#pinned</a></dd>
|
||||
</dl>
|
||||
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Unix timestamp for when the chat was created</p>
|
||||
<p>Unix timestamp for when the last activity occurred</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#timestamp">Chat#timestamp</a></dd>
|
||||
@@ -246,79 +298,8 @@
|
||||
</section>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span> <span class="label label-static">static</span></div>
|
||||
<h3 id=".getInviteInfo"><span class="symbol-name">getInviteInfo</span><span class="signature"><span class="signature-params">(inviteCode)</span> → <span class="signature-returns"> Promise containing object</span></span></h3>
|
||||
<p>Returns an object with information about the invite code's group</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>inviteCode</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing object</code> <p>Invite information</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span> <span class="label label-static">static</span></div>
|
||||
<h3 id=".join"><span class="symbol-name">join</span><span class="signature"><span class="signature-params">(inviteCode)</span></span></h3>
|
||||
<p>Joins a group with an invite code</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>inviteCode</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="addParticipants"><span class="symbol-name">addParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span></span></h3>
|
||||
<h3 id="addParticipants"><span class="symbol-name">addParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span> → <span class="signature-returns"> Promise containing Object</span></span></h3>
|
||||
<p>Adds a list of participants by ID to the group</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
@@ -349,6 +330,10 @@
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Object</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="archive"><span class="symbol-name">archive</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
@@ -387,7 +372,7 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="demoteParticipants"><span class="symbol-name">demoteParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span></span></h3>
|
||||
<h3 id="demoteParticipants"><span class="symbol-name">demoteParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span> → <span class="signature-returns"> Promise containing {status: number}</span></span></h3>
|
||||
<p>Demotes participants by IDs to regular users</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
@@ -418,6 +403,11 @@
|
||||
</table>
|
||||
</section>
|
||||
<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>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="fetchMessages"><span class="symbol-name">fetchMessages</span><span class="signature"><span class="signature-params">(searchOptions)</span> → <span class="signature-returns"> Promise containing Array of <a href="Message.html">Message</a></span></span></h3>
|
||||
@@ -486,17 +476,98 @@
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getInviteCode"><span class="symbol-name">getInviteCode</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<h3 id="getContact"><span class="symbol-name">getContact</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Contact.html">Contact</a></span></span></h3>
|
||||
<p>Returns the Contact that corresponds to this Chat.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#getContact">Chat#getContact</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getInviteCode"><span class="symbol-name">getInviteCode</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Gets the invite code for a specific group</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing string</code> <p>Group's invite code</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="leave"><span class="symbol-name">leave</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<h3 id="getLabels"><span class="symbol-name">getLabels</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of <a href="Label.html">Label</a></span></span></h3>
|
||||
<p>Returns array of all Labels assigned to this Chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#getLabels">Chat#getLabels</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="leave"><span class="symbol-name">leave</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||
<p>Makes the bot leave the group</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="promoteParticipants"><span class="symbol-name">promoteParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span></span></h3>
|
||||
<h3 id="markUnread"><span class="symbol-name">markUnread</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Mark this chat as unread</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#markUnread">Chat#markUnread</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="mute"><span class="symbol-name">mute</span><span class="signature"><span class="signature-params">(unmuteDate)</span></span></h3>
|
||||
<p>Mutes this chat until a specified date</p>
|
||||
<section>
|
||||
<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>unmuteDate</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Date at which the Chat will be unmuted</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#mute">Chat#mute</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="pin"><span class="symbol-name">pin</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Pins this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#pin">Chat#pin</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>New pin state. Could be false if the max number of pinned chats was reached.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="promoteParticipants"><span class="symbol-name">promoteParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span> → <span class="signature-returns"> Promise containing {status: number}</span></span></h3>
|
||||
<p>Promotes participants by IDs to admins</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
@@ -527,9 +598,14 @@
|
||||
</table>
|
||||
</section>
|
||||
<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>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="removeParticipants"><span class="symbol-name">removeParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span></span></h3>
|
||||
<h3 id="removeParticipants"><span class="symbol-name">removeParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span> → <span class="signature-returns"> Promise containing Object</span></span></h3>
|
||||
<p>Removes a list of participants by ID to the group</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
@@ -560,14 +636,22 @@
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Object</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="revokeInvite"><span class="symbol-name">revokeInvite</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<h3 id="revokeInvite"><span class="symbol-name">revokeInvite</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||
<p>Invalidates the current group invite code and generates a new one</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content, options)</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content[, options])</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<p>Send a message to this chat</p>
|
||||
<section>
|
||||
<h4>Parameters</h4>
|
||||
@@ -602,7 +686,7 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
@@ -644,7 +728,7 @@
|
||||
<dd><a href="Chat.html#sendStateTyping">Chat#sendStateTyping</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="setDescription"><span class="symbol-name">setDescription</span><span class="signature"><span class="signature-params">(description)</span></span></h3>
|
||||
<h3 id="setDescription"><span class="symbol-name">setDescription</span><span class="signature"><span class="signature-params">(description)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||
<p>Updates the group description</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
@@ -675,9 +759,93 @@
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="setSubject"><span class="symbol-name">setSubject</span><span class="signature"><span class="signature-params">(subject)</span></span></h3>
|
||||
<h3 id="setInfoAdminsOnly"><span class="symbol-name">setInfoAdminsOnly</span><span class="signature"><span class="signature-params">([adminsOnly])</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Updates the group settings to only allow admins to edit group info (title, description, photo).</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>adminsOnly</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Enable or disable this option</p>
|
||||
<p>Defaults to <code>true</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing boolean</code> <p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="setMessagesAdminsOnly"><span class="symbol-name">setMessagesAdminsOnly</span><span class="signature"><span class="signature-params">([adminsOnly])</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Updates the group settings to only allow admins to send messages.</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>adminsOnly</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Enable or disable this option</p>
|
||||
<p>Defaults to <code>true</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing boolean</code> <p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="setSubject"><span class="symbol-name">setSubject</span><span class="signature"><span class="signature-params">(subject)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||
<p>Updates the group subject</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
@@ -708,6 +876,10 @@
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="unarchive"><span class="symbol-name">unarchive</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
@@ -716,6 +888,24 @@
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#unarchive">Chat#unarchive</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="unmute"><span class="symbol-name">unmute</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Unmutes this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#unmute">Chat#unmute</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="unpin"><span class="symbol-name">unpin</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Unpins this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#unpin">Chat#unpin</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>New pin state</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
@@ -726,7 +916,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: GroupNotification</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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">GroupNotification</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_GroupNotification.js.html#source-line-10">structures/<wbr>GroupNotification.<wbr>js:10</a></p>
|
||||
<p class="source-link">Source: <a href="structures_GroupNotification.js.html#source-line-9">structures/<wbr>GroupNotification.<wbr>js:9</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a GroupNotification on WhatsApp</p>
|
||||
</div>
|
||||
@@ -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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
278
docs/InterfaceController.html
Normal file
278
docs/InterfaceController.html
Normal file
@@ -0,0 +1,278 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.12.6 » Class: InterfaceController</title>
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||
<link href="css/baseline.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body onload="prettyPrint()">
|
||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||
<div id="jsdoc-navbar-container">
|
||||
<div id="jsdoc-navbar-content">
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">InterfaceController</span></h1>
|
||||
<p class="source-link">Source: <a href="util_InterfaceController.js.html#source-line-6">util/<wbr>InterfaceController.<wbr>js:6</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Interface Controller</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Methods</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="InterfaceController.html#closeRightDrawer">closeRightDrawer()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="InterfaceController.html#openChatDrawer">openChatDrawer(chatId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="InterfaceController.html#openChatSearch">openChatSearch(chatId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="InterfaceController.html#openChatWindow">openChatWindow(chatId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="InterfaceController.html#openChatWindowAt">openChatWindowAt(msgId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="InterfaceController.html#openMessageDrawer">openMessageDrawer(msgId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="InterfaceController">new <span class="symbol-name">InterfaceController</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="closeRightDrawer"><span class="symbol-name">closeRightDrawer</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Closes the Right Drawer</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="openChatDrawer"><span class="symbol-name">openChatDrawer</span><span class="signature"><span class="signature-params">(chatId)</span></span></h3>
|
||||
<p>Opens the Chat Drawer</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>chatId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>ID of the chat drawer that will be opened</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="openChatSearch"><span class="symbol-name">openChatSearch</span><span class="signature"><span class="signature-params">(chatId)</span></span></h3>
|
||||
<p>Opens the Chat Search</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>chatId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>ID of the chat search that will be opened</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="openChatWindow"><span class="symbol-name">openChatWindow</span><span class="signature"><span class="signature-params">(chatId)</span></span></h3>
|
||||
<p>Opens the Chat Window</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>chatId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>ID of the chat window that will be opened</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="openChatWindowAt"><span class="symbol-name">openChatWindowAt</span><span class="signature"><span class="signature-params">(msgId)</span></span></h3>
|
||||
<p>Opens or Scrolls the Chat Window to the position of the message</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>msgId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>ID of the message that will be scrolled to</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="openMessageDrawer"><span class="symbol-name">openMessageDrawer</span><span class="signature"><span class="signature-params">(msgId)</span></span></h3>
|
||||
<p>Opens the Message Drawer</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>msgId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>ID of the message drawer that will be opened</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</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>
|
||||
178
docs/Label.html
Normal file
178
docs/Label.html
Normal file
@@ -0,0 +1,178 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.12.6 » 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">
|
||||
<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>12.<wbr>6</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">Label</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_Label.js.html#source-line-10">structures/<wbr>Label.<wbr>js:10</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>WhatsApp Business Label information</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="Label.html#hexColor">hexColor</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Label.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Label.html#name">name</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="Label.html#getChats">getChats()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="Label">new <span class="symbol-name">Label</span><span class="signature"><span class="signature-params">(client, labelData)</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>client</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>labelData</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="hexColor"><span class="symbol-name">hexColor</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Label hex color</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Label ID</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="name"><span class="symbol-name">name</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Label name</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Method</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getChats"><span class="symbol-name">getChats</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of <a href="Chat.html">Chat</a></span></span></h3>
|
||||
<p>Get all chats that have been assigned this Label</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Array of <a href="Chat.html">Chat</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.6 on April 20, 2021.
|
||||
</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>
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: Location</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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">Location</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_Location.js.html#source-line-12">structures/<wbr>Location.<wbr>js:12</a></p>
|
||||
<p class="source-link">Source: <a href="structures_Location.js.html#source-line-6">structures/<wbr>Location.<wbr>js:6</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Location information</p>
|
||||
</div>
|
||||
@@ -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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: Message</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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-12">structures/<wbr>Message.<wbr>js:12</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Message on WhatsApp</p>
|
||||
</div>
|
||||
@@ -39,6 +39,9 @@
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Message.html#ack">ack</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#author">author</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -54,13 +57,13 @@
|
||||
<dt><a href="Message.html#fromMe">fromMe</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#hasMedia">hasMedia</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Message.html#hasMedia">hasMedia</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#hasQuotedMsg">hasQuotedMsg</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -70,6 +73,15 @@
|
||||
<dt><a href="Message.html#isForwarded">isForwarded</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#isStarred">isStarred</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#isStatus">isStatus</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#links">links</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#location">location</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -77,6 +89,9 @@
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Message.html#mediaKey">mediaKey</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#mentionedIds">mentionedIds</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -89,6 +104,9 @@
|
||||
<dt><a href="Message.html#type">type</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#vCards">vCards</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
@@ -104,6 +122,9 @@
|
||||
<dt><a href="Message.html#downloadMedia">downloadMedia()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#forward">forward(chat)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#getChat">getChat()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -114,6 +135,9 @@
|
||||
<dt><a href="Message.html#getContact">getContact()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#getInfo">getInfo()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#getMentions">getMentions()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -124,7 +148,13 @@
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Message.html#reply">reply(content, chatId, options)</a></dt>
|
||||
<dt><a href="Message.html#reply">reply(content[, chatId][, options])</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#star">star()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#unstar">unstar()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -142,6 +172,11 @@
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="ack"><span class="symbol-name">ack</span><small class="property-type">
|
||||
<a href="global.html#MessageAck">MessageAck</a></small></h3>
|
||||
<p>ACK status for the message</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="author"><span class="symbol-name">author</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>If the message was sent to a group, this field will contain the user that sent the message.</p>
|
||||
@@ -187,11 +222,31 @@
|
||||
<p>Indicates if the message was forwarded</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>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isStatus"><span class="symbol-name">isStatus</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the message is a status update</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="links"><span class="symbol-name">links</span><small class="property-type">
|
||||
Array of string</small></h3>
|
||||
<p>Links included in the message.</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="location"><span class="symbol-name">location</span><small class="property-type">
|
||||
<a href="Location.html">Location</a></small></h3>
|
||||
<p>Location information contained in the message, if the message is type "location"</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="mediaKey"><span class="symbol-name">mediaKey</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>MediaKey that represents the sticker 'ID'</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="mentionedIds"><span class="symbol-name">mentionedIds</span><small class="property-type">
|
||||
Array of string</small></h3>
|
||||
<p>Indicates the mentions in the message body.</p>
|
||||
@@ -214,6 +269,11 @@
|
||||
<p>Message type</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="vCards"><span class="symbol-name">vCards</span><small class="property-type">
|
||||
Array of string</small></h3>
|
||||
<p>List of vCards contained in the message.</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
@@ -261,6 +321,44 @@
|
||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="forward"><span class="symbol-name">forward</span><span class="signature"><span class="signature-params">(chat)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||
<p>Forwards this message to another chat</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>chat</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>(string or <a href="Chat.html">Chat</a>)</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Chat model or chat ID to which the message will be forwarded</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<h3 id="getChat"><span class="symbol-name">getChat</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Chat.html">Chat</a></span></span></h3>
|
||||
<p>Returns the Chat this message was sent in</p>
|
||||
<dl class="dl-compact">
|
||||
@@ -278,6 +376,15 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getInfo"><span class="symbol-name">getInfo</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing nullable <a href="global.html#MessageInfo">MessageInfo</a></span></span></h3>
|
||||
<p>Get information about message delivery status. May return null if the message does not exist or is not sent by you.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing nullable <a href="global.html#MessageInfo">MessageInfo</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getMentions"><span class="symbol-name">getMentions</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>Returns the Contacts mentioned in this message</p>
|
||||
<dl class="dl-compact">
|
||||
@@ -296,7 +403,7 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="reply"><span class="symbol-name">reply</span><span class="signature"><span class="signature-params">(content, chatId, options)</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<h3 id="reply"><span class="symbol-name">reply</span><span class="signature"><span class="signature-params">(content[, chatId][, options])</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<p>Sends a message as a reply to this message. If chatId is specified, it will be sent
|
||||
through the specified Chat. If not, it will send the message
|
||||
in the same Chat as the original message was sent.</p>
|
||||
@@ -333,10 +440,9 @@
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -344,10 +450,10 @@
|
||||
<p>options</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</p>
|
||||
<p><a href="global.html#MessageSendOptions">MessageSendOptions</a></p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
@@ -361,6 +467,16 @@
|
||||
<p><code>Promise containing <a href="Message.html">Message</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="star"><span class="symbol-name">star</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Stars this message</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="unstar"><span class="symbol-name">unstar</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Unstars this message</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
@@ -371,7 +487,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: MessageMedia</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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-10">structures/<wbr>MessageMedia.<wbr>js:10</a></p>
|
||||
<p class="source-link">Source: <a href="structures_MessageMedia.js.html#source-line-13">structures/<wbr>MessageMedia.<wbr>js:13</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Media attached to a message</p>
|
||||
</div>
|
||||
@@ -60,6 +60,22 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Method</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="MessageMedia.html#.fromFilePath">fromFilePath(filePath)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="MessageMedia">new <span class="symbol-name">MessageMedia</span><span class="signature"><span class="signature-params">(mimetype, data, filename)</span></span></h2>
|
||||
@@ -143,6 +159,46 @@
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Method</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>
|
||||
<p>Creates a MessageMedia instance from a local file path</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>filePath</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code><a href="MessageMedia.html">MessageMedia</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
@@ -152,7 +208,7 @@
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: PrivateChat</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -48,6 +48,9 @@
|
||||
<dt><a href="PrivateChat.html#isGroup">isGroup</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#isMuted">isMuted</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
@@ -55,16 +58,22 @@
|
||||
<dt><a href="PrivateChat.html#isReadOnly">isReadOnly</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#muteExpiration">muteExpiration</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#timestamp">timestamp</a></dt>
|
||||
<dt><a href="PrivateChat.html#pinned">pinned</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateChat.html#timestamp">timestamp</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#unreadCount">unreadCount</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -89,32 +98,53 @@
|
||||
<dt><a href="PrivateChat.html#delete">delete()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#fetchMessages">fetchMessages(searchOptions)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#getContact">getContact()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateChat.html#fetchMessages">fetchMessages(searchOptions)</a></dt>
|
||||
<dt><a href="PrivateChat.html#getLabels">getLabels()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#sendMessage">sendMessage(content, options)</a></dt>
|
||||
<dt><a href="PrivateChat.html#markUnread">markUnread()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#mute">mute(unmuteDate)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#pin">pin()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#sendMessage">sendMessage(content[, options])</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#sendSeen">sendSeen()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#sendStateRecording">sendStateRecording()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateChat.html#sendStateRecording">sendStateRecording()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#sendStateTyping">sendStateTyping()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#unarchive">unarchive()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#unmute">unmute()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#unpin">unpin()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
@@ -151,6 +181,13 @@
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#isGroup">Chat#isGroup</a></dd>
|
||||
</dl>
|
||||
<h3 id="isMuted"><span class="symbol-name">isMuted</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the chat is muted or not</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#isMuted">Chat#isMuted</a></dd>
|
||||
</dl>
|
||||
<h3 id="isReadOnly"><span class="symbol-name">isReadOnly</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the Chat is readonly</p>
|
||||
@@ -158,6 +195,13 @@
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#isReadOnly">Chat#isReadOnly</a></dd>
|
||||
</dl>
|
||||
<h3 id="muteExpiration"><span class="symbol-name">muteExpiration</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Unix timestamp for when the mute expires</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#muteExpiration">Chat#muteExpiration</a></dd>
|
||||
</dl>
|
||||
<h3 id="name"><span class="symbol-name">name</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Title of the chat</p>
|
||||
@@ -165,9 +209,16 @@
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#name">Chat#name</a></dd>
|
||||
</dl>
|
||||
<h3 id="pinned"><span class="symbol-name">pinned</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the Chat is pinned</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#pinned">Chat#pinned</a></dd>
|
||||
</dl>
|
||||
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Unix timestamp for when the chat was created</p>
|
||||
<p>Unix timestamp for when the last activity occurred</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#timestamp">Chat#timestamp</a></dd>
|
||||
@@ -285,7 +336,79 @@
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content, options)</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<h3 id="getContact"><span class="symbol-name">getContact</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Contact.html">Contact</a></span></span></h3>
|
||||
<p>Returns the Contact that corresponds to this Chat.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#getContact">Chat#getContact</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getLabels"><span class="symbol-name">getLabels</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of <a href="Label.html">Label</a></span></span></h3>
|
||||
<p>Returns array of all Labels assigned to this Chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#getLabels">Chat#getLabels</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="markUnread"><span class="symbol-name">markUnread</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Mark this chat as unread</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#markUnread">Chat#markUnread</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="mute"><span class="symbol-name">mute</span><span class="signature"><span class="signature-params">(unmuteDate)</span></span></h3>
|
||||
<p>Mutes this chat until a specified date</p>
|
||||
<section>
|
||||
<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>unmuteDate</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Date at which the Chat will be unmuted</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#mute">Chat#mute</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="pin"><span class="symbol-name">pin</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Pins this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#pin">Chat#pin</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>New pin state. Could be false if the max number of pinned chats was reached.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(content[, options])</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<p>Send a message to this chat</p>
|
||||
<section>
|
||||
<h4>Parameters</h4>
|
||||
@@ -320,7 +443,7 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
@@ -368,6 +491,24 @@
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#unarchive">Chat#unarchive</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="unmute"><span class="symbol-name">unmute</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Unmutes this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#unmute">Chat#unmute</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="unpin"><span class="symbol-name">unpin</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Unpins this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#unpin">Chat#unpin</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>New pin state</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
@@ -378,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: PrivateContact</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -42,6 +42,9 @@
|
||||
<dt><a href="PrivateContact.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#isBlocked">isBlocked</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#isBusiness">isBusiness</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -67,13 +70,13 @@
|
||||
<dt><a href="PrivateContact.html#isWAContact">isWAContact</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateContact.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#number">number</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -88,18 +91,34 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Method</h2>
|
||||
<h2 class="summary-callout-heading">Methods</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateContact.html#block">block()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#getAbout">getAbout()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateContact.html#getChat">getChat()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateContact.html#unblock">unblock()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -121,6 +140,13 @@
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#id">Contact#id</a></dd>
|
||||
</dl>
|
||||
<h3 id="isBlocked"><span class="symbol-name">isBlocked</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if you have blocked this contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isBlocked">Contact#isBlocked</a></dd>
|
||||
</dl>
|
||||
<h3 id="isBusiness"><span class="symbol-name">isBusiness</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the contact is a business contact</p>
|
||||
@@ -199,8 +225,36 @@
|
||||
<dd><a href="Contact.html#shortName">Contact#shortName</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Method</h2>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="block"><span class="symbol-name">block</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Blocks this contact from WhatsApp</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#block">Contact#block</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getAbout"><span class="symbol-name">getAbout</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing nullable string</span></span></h3>
|
||||
<p>Gets the Contact's current "about" info. Returns null if you don't have permission to read their status.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getAbout">Contact#getAbout</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getChat"><span class="symbol-name">getChat</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Chat.html">Chat</a></span></span></h3>
|
||||
<p>Returns the Chat that corresponds to this Contact.
|
||||
Will return null when getting chat for currently logged in user.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getChat">Contact#getChat</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||
@@ -210,6 +264,15 @@
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="unblock"><span class="symbol-name">unblock</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Unblocks this contact from WhatsApp</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#unblock">Contact#unblock</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
@@ -220,7 +283,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
187
docs/Util.html
187
docs/Util.html
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Class: Util</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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">Util</span></h1>
|
||||
<p class="source-link">Source: <a href="util_Util.js.html#source-line-10">util/<wbr>Util.<wbr>js:10</a></p>
|
||||
<p class="source-link">Source: <a href="util_Util.js.html#source-line-15">util/<wbr>Util.<wbr>js:15</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Utility methods</p>
|
||||
</div>
|
||||
@@ -34,6 +34,33 @@
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Methods</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Util.html#.formatImageToWebpSticker">formatImageToWebpSticker(media)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Util.html#.formatToWebpSticker">formatToWebpSticker(media)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Util.html#.formatVideoToWebpSticker">formatVideoToWebpSticker(media)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Util.html#.setFfmpegPath">setFfmpegPath(path)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="Util">new <span class="symbol-name">Util</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
@@ -41,6 +68,156 @@
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span> <span class="label label-static">static</span></div>
|
||||
<h3 id=".formatImageToWebpSticker"><span class="symbol-name">formatImageToWebpSticker</span><span class="signature"><span class="signature-params">(media)</span> → <span class="signature-returns"> Promise containing <a href="MessageMedia.html">MessageMedia</a></span></span></h3>
|
||||
<p>Formats a image to webp</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>media</p>
|
||||
</td>
|
||||
<td>
|
||||
<p><a href="MessageMedia.html">MessageMedia</a></p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</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>media in webp format</p>
|
||||
</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=".formatToWebpSticker"><span class="symbol-name">formatToWebpSticker</span><span class="signature"><span class="signature-params">(media)</span> → <span class="signature-returns"> Promise containing <a href="MessageMedia.html">MessageMedia</a></span></span></h3>
|
||||
<p>Formats a media to webp</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>media</p>
|
||||
</td>
|
||||
<td>
|
||||
<p><a href="MessageMedia.html">MessageMedia</a></p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</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>media in webp format</p>
|
||||
</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=".formatVideoToWebpSticker"><span class="symbol-name">formatVideoToWebpSticker</span><span class="signature"><span class="signature-params">(media)</span> → <span class="signature-returns"> Promise containing <a href="MessageMedia.html">MessageMedia</a></span></span></h3>
|
||||
<p>Formats a video to webp</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>media</p>
|
||||
</td>
|
||||
<td>
|
||||
<p><a href="MessageMedia.html">MessageMedia</a></p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</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>media in webp format</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-static">static</span></div>
|
||||
<h3 id=".setFfmpegPath"><span class="symbol-name">setFfmpegPath</span><span class="signature"><span class="signature-params">(path)</span></span></h3>
|
||||
<p>Configure ffmpeg path</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>path</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
@@ -50,7 +227,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
452
docs/global.html
452
docs/global.html
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Globals</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -63,6 +63,33 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Abstract types</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="global.html#ContactId">ContactId</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="global.html#GroupParticipant">GroupParticipant</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="global.html#MessageInfo">MessageInfo</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="global.html#MessageSendOptions">MessageSendOptions</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
@@ -247,6 +274,19 @@
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>MEDIA_UPLOADED</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>GROUP_JOIN</p>
|
||||
@@ -325,6 +365,19 @@
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>BATTERY_CHANGED</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
@@ -982,6 +1035,397 @@
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Abstract types</h2>
|
||||
<section>
|
||||
<h3 id="ContactId"><span class="symbol-name">ContactId</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<p>ID that represents a contact</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>server</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>user</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>_serialized</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</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>
|
||||
<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><a href="global.html#ContactId">ContactId</a></p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>isAdmin</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>isSuperAdmin</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="MessageInfo"><span class="symbol-name">MessageInfo</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<p>Message Info</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>delivery</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Array of {id: <a href="global.html#ContactId">ContactId</a>, t: number}</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Contacts to which the message has been delivered to</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>deliveryRemaining</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Amount of people to whom the message has not been delivered to</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>played</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Array of {id: <a href="global.html#ContactId">ContactId</a>, t: number}</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Contacts who have listened to the voice message</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>playedRemaining</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Amount of people who have not listened to the message</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>read</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Array of {id: <a href="global.html#ContactId">ContactId</a>, t: number}</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Contacts who have read the message</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>readRemaining</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Amount of people who have not read the message</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="MessageSendOptions"><span class="symbol-name">MessageSendOptions</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<p>Message options.</p>
|
||||
<section>
|
||||
<h4>Properties</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>linkPreview</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Show links preview</p>
|
||||
<p>Defaults to <code>true</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>sendAudioAsVoice</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Send audio as voice message</p>
|
||||
<p>Defaults to <code>false</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>sendMediaAsSticker</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Send media as a sticker</p>
|
||||
<p>Defaults to <code>false</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>sendMediaAsDocument</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Send media as a document</p>
|
||||
<p>Defaults to <code>false</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>parseVCards</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Automatically parse vCards and send them as contacts</p>
|
||||
<p>Defaults to <code>true</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>caption</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Image or video caption</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>quotedMessageId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Id of the message that is being quoted (or replied to)</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>mentions</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Array of <a href="Contact.html">Contact</a></p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Contacts that are being mentioned in the message</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>sendSeen</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Mark the conversation as seen after sending the message</p>
|
||||
<p>Defaults to <code>true</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>media</p>
|
||||
</td>
|
||||
<td>
|
||||
<p><a href="MessageMedia.html">MessageMedia</a></p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Media to be sent</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
@@ -991,7 +1435,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
697
docs/index.html
697
docs/index.html
File diff suppressed because it is too large
Load Diff
@@ -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=\"Location.html\">Location</a>","id":"Location","children":[]},{"label":"<a href=\"Message.html\">Message</a>","id":"Message","children":[]},{"label":"<a href=\"MessageMedia.html\">MessageMedia</a>","id":"MessageMedia","children":[]},{"label":"<a href=\"PrivateChat.html\">PrivateChat</a>","id":"PrivateChat","children":[]},{"label":"<a href=\"PrivateContact.html\">PrivateContact</a>","id":"PrivateContact","children":[]},{"label":"<a href=\"Util.html\">Util</a>","id":"Util","children":[]}],
|
||||
data: [{"label":"<a href=\"global.html\">Globals</a>","id":"global","children":[]},{"label":"<a href=\"Base.html\">Base</a>","id":"Base","children":[]},{"label":"<a href=\"BusinessContact.html\">BusinessContact</a>","id":"BusinessContact","children":[]},{"label":"<a href=\"Chat.html\">Chat</a>","id":"Chat","children":[]},{"label":"<a href=\"Client.html\">Client</a>","id":"Client","children":[]},{"label":"<a href=\"ClientInfo.html\">ClientInfo</a>","id":"ClientInfo","children":[]},{"label":"<a href=\"Contact.html\">Contact</a>","id":"Contact","children":[]},{"label":"<a href=\"GroupChat.html\">GroupChat</a>","id":"GroupChat","children":[]},{"label":"<a href=\"GroupNotification.html\">GroupNotification</a>","id":"GroupNotification","children":[]},{"label":"<a href=\"InterfaceController.html\">InterfaceController</a>","id":"InterfaceController","children":[]},{"label":"<a href=\"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=\"PrivateChat.html\">PrivateChat</a>","id":"PrivateChat","children":[]},{"label":"<a href=\"PrivateContact.html\">PrivateContact</a>","id":"PrivateContact","children":[]},{"label":"<a href=\"Util.html\">Util</a>","id":"Util","children":[]}],
|
||||
openedIcon: ' ⇣',
|
||||
saveState: false,
|
||||
useContextMenu: false
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/Base.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/BusinessContact.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/Chat.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -77,7 +77,7 @@ class Chat extends Base {
|
||||
this.unreadCount = data.unreadCount;
|
||||
|
||||
/**
|
||||
* Unix timestamp for when the chat was created
|
||||
* Unix timestamp for when the last activity occurred
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.t;
|
||||
@@ -88,13 +88,31 @@ class Chat extends Base {
|
||||
*/
|
||||
this.archived = data.archive;
|
||||
|
||||
/**
|
||||
* Indicates if the Chat is pinned
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.pinned = !!data.pin;
|
||||
|
||||
/**
|
||||
* Indicates if the chat is muted or not
|
||||
* @type {number}
|
||||
*/
|
||||
this.isMuted = data.isMuted;
|
||||
|
||||
/**
|
||||
* Unix timestamp for when the mute expires
|
||||
* @type {number}
|
||||
*/
|
||||
this.muteExpiration = data.muteExpiration;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to this chat
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {object} options
|
||||
* @param {MessageSendOptions} [options]
|
||||
* @returns {Promise&lt;Message>} Message that was just sent
|
||||
*/
|
||||
async sendMessage(content, options) {
|
||||
@@ -143,6 +161,44 @@ class Chat extends Base {
|
||||
return this.client.unarchiveChat(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pins this chat
|
||||
* @returns {Promise&lt;boolean>} New pin state. Could be false if the max number of pinned chats was reached.
|
||||
*/
|
||||
async pin() {
|
||||
return this.client.pinChat(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpins this chat
|
||||
* @returns {Promise&lt;boolean>} New pin state
|
||||
*/
|
||||
async unpin() {
|
||||
return this.client.unpinChat(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutes this chat until a specified date
|
||||
* @param {Date} unmuteDate Date at which the Chat will be unmuted
|
||||
*/
|
||||
async mute(unmuteDate) {
|
||||
return this.client.muteChat(this.id._serialized, unmuteDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmutes this chat
|
||||
*/
|
||||
async unmute() {
|
||||
return this.client.unmuteChat(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark this chat as unread
|
||||
*/
|
||||
async markUnread(){
|
||||
return this.client.markChatUnread(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads chat messages, sorted from earliest to latest.
|
||||
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
||||
@@ -150,29 +206,30 @@ class Chat extends Base {
|
||||
* @returns {Promise&lt;Array&lt;Message>>}
|
||||
*/
|
||||
async fetchMessages(searchOptions) {
|
||||
if(!searchOptions || !searchOptions.limit) {
|
||||
searchOptions = {limit: 50};
|
||||
if (!searchOptions || !searchOptions.limit) {
|
||||
searchOptions = { limit: 50 };
|
||||
}
|
||||
let messages = await this.client.pupPage.evaluate(async (chatId, limit) => {
|
||||
const msgFilter = m => !m.isNotification; // dont include notification messages
|
||||
|
||||
|
||||
const chat = window.Store.Chat.get(chatId);
|
||||
let msgs = chat.msgs.models.filter(msgFilter);
|
||||
|
||||
while(msgs.length &lt; limit) {
|
||||
|
||||
while (msgs.length &lt; limit) {
|
||||
const loadedMessages = await chat.loadEarlierMsgs();
|
||||
if(!loadedMessages) break;
|
||||
if (!loadedMessages) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
}
|
||||
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
return msgs.splice(msgs.length - limit).map(m => m.serialize());
|
||||
if (msgs.length > limit) msgs = msgs.splice(msgs.length - limit);
|
||||
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
||||
|
||||
}, this.id._serialized, searchOptions.limit);
|
||||
|
||||
return messages.map(m => new Message(this.client, m));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Simulate typing in chat. This will last for 25 seconds.
|
||||
*/
|
||||
@@ -182,7 +239,7 @@ class Chat extends Base {
|
||||
return true;
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Simulate recording audio in chat. This will last for 25 seconds.
|
||||
*/
|
||||
@@ -202,6 +259,22 @@ class Chat extends Base {
|
||||
return true;
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Contact that corresponds to this Chat.
|
||||
* @returns {Promise&lt;Contact>}
|
||||
*/
|
||||
async getContact() {
|
||||
return await this.client.getContactById(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of all Labels assigned to this Chat
|
||||
* @returns {Promise&lt;Array&lt;Label>>}
|
||||
*/
|
||||
async getLabels() {
|
||||
return this.client.getChatLabels(this.id._serialized);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Chat;
|
||||
@@ -215,7 +288,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/ClientInfo.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -41,7 +41,7 @@ class ClientInfo extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
@@ -51,11 +51,17 @@ class ClientInfo extends Base {
|
||||
*/
|
||||
this.pushname = data.pushname;
|
||||
|
||||
/**
|
||||
* @type {object}
|
||||
* @deprecated Use .wid instead
|
||||
*/
|
||||
this.me = data.wid;
|
||||
|
||||
/**
|
||||
* Current user ID
|
||||
* @type {object}
|
||||
*/
|
||||
this.me = data.me;
|
||||
this.wid = data.wid;
|
||||
|
||||
/**
|
||||
* Information about the phone this client is connected to
|
||||
@@ -77,6 +83,19 @@ class ClientInfo extends Base {
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current battery percentage and charging status for the attached device
|
||||
* @returns {object} batteryStatus
|
||||
* @returns {number} batteryStatus.battery - The current battery percentage
|
||||
* @returns {boolean} batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||
*/
|
||||
async getBatteryStatus() {
|
||||
return await this.client.pupPage.evaluate(() => {
|
||||
const { battery, plugged } = window.Store.Conn;
|
||||
return { battery, plugged };
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ClientInfo;</code></pre>
|
||||
@@ -89,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/Contact.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -33,6 +33,14 @@
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* ID that represents a contact
|
||||
* @typedef {Object} ContactId
|
||||
* @property {string} server
|
||||
* @property {string} user
|
||||
* @property {string} _serialized
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a Contact on WhatsApp
|
||||
* @extends {Base}
|
||||
@@ -47,7 +55,7 @@ class Contact extends Base {
|
||||
_patch(data) {
|
||||
/**
|
||||
* ID that represents the contact
|
||||
* @type {object}
|
||||
* @type {ContactId}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
@@ -126,6 +134,12 @@ class Contact extends Base {
|
||||
*/
|
||||
this.isMyContact = data.isMyContact;
|
||||
|
||||
/**
|
||||
* Indicates if you have blocked this contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isBlocked = data.isBlocked;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
@@ -134,11 +148,63 @@ class Contact extends Base {
|
||||
* @returns {Promise&lt;string>}
|
||||
*/
|
||||
async getProfilePicUrl() {
|
||||
const profilePic = await this.client.pupPage.evaluate((contactId) => {
|
||||
return window.Store.Wap.profilePicFind(contactId);
|
||||
return await this.client.getProfilePicUrl(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Chat that corresponds to this Contact.
|
||||
* Will return null when getting chat for currently logged in user.
|
||||
* @returns {Promise&lt;Chat>}
|
||||
*/
|
||||
async getChat() {
|
||||
if(this.isMe) return null;
|
||||
|
||||
return await this.client.getChatById(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks this contact from WhatsApp
|
||||
* @returns {Promise&lt;boolean>}
|
||||
*/
|
||||
async block() {
|
||||
if(this.isGroup) return false;
|
||||
|
||||
await this.client.pupPage.evaluate(async (contactId) => {
|
||||
const contact = window.Store.Contact.get(contactId);
|
||||
await window.Store.BlockContact.blockContact(contact);
|
||||
}, this.id._serialized);
|
||||
|
||||
return profilePic ? profilePic.eurl : undefined;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unblocks this contact from WhatsApp
|
||||
* @returns {Promise&lt;boolean>}
|
||||
*/
|
||||
async unblock() {
|
||||
if(this.isGroup) return false;
|
||||
|
||||
await this.client.pupPage.evaluate(async (contactId) => {
|
||||
const contact = window.Store.Contact.get(contactId);
|
||||
await window.Store.BlockContact.unblockContact(contact);
|
||||
}, this.id._serialized);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Contact's current "about" info. Returns null if you don't have permission to read their status.
|
||||
* @returns {Promise&lt;?string>}
|
||||
*/
|
||||
async getAbout() {
|
||||
const about = await this.client.pupPage.evaluate(async (contactId) => {
|
||||
return window.Store.Wap.statusFind(contactId);
|
||||
}, this.id._serialized);
|
||||
|
||||
if (typeof about.status !== 'string')
|
||||
return null;
|
||||
|
||||
return about.status;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -153,7 +219,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/GroupChat.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -33,6 +33,14 @@
|
||||
|
||||
const Chat = require('./Chat');
|
||||
|
||||
/**
|
||||
* Group participant information
|
||||
* @typedef {Object} GroupParticipant
|
||||
* @property {ContactId} id
|
||||
* @property {boolean} isAdmin
|
||||
* @property {boolean} isSuperAdmin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a Group Chat on WhatsApp
|
||||
* @extends {Chat}
|
||||
@@ -46,6 +54,7 @@ class GroupChat extends Chat {
|
||||
|
||||
/**
|
||||
* Gets the group owner
|
||||
* @type {ContactId}
|
||||
*/
|
||||
get owner() {
|
||||
return this.groupMetadata.owner;
|
||||
@@ -66,9 +75,10 @@ class GroupChat extends Chat {
|
||||
get description() {
|
||||
return this.groupMetadata.desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the group participants
|
||||
* @type {array}
|
||||
* @type {Array&lt;GroupParticipant>}
|
||||
*/
|
||||
get participants() {
|
||||
return this.groupMetadata.participants;
|
||||
@@ -77,6 +87,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Adds a list of participants by ID to the group
|
||||
* @param {Array&lt;string>} participantIds
|
||||
* @returns {Promise&lt;Object>}
|
||||
*/
|
||||
async addParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
@@ -87,6 +98,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Removes a list of participants by ID to the group
|
||||
* @param {Array&lt;string>} participantIds
|
||||
* @returns {Promise&lt;Object>}
|
||||
*/
|
||||
async removeParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
@@ -97,6 +109,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Promotes participants by IDs to admins
|
||||
* @param {Array&lt;string>} participantIds
|
||||
* @returns {Promise&lt;{ status: number }>} Object with status code indicating if the operation was successful
|
||||
*/
|
||||
async promoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
@@ -107,6 +120,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Demotes participants by IDs to regular users
|
||||
* @param {Array&lt;string>} participantIds
|
||||
* @returns {Promise&lt;{ status: number }>} Object with status code indicating if the operation was successful
|
||||
*/
|
||||
async demoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
@@ -117,6 +131,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Updates the group subject
|
||||
* @param {string} subject
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async setSubject(subject) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, subject) => {
|
||||
@@ -131,6 +146,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Updates the group description
|
||||
* @param {string} description
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async setDescription(description) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, description) => {
|
||||
@@ -143,8 +159,41 @@ class GroupChat extends Chat {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the group settings to only allow admins to send messages.
|
||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||
* @returns {Promise&lt;boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setMessagesAdminsOnly(adminsOnly=true) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||
return window.Store.Wap.setGroupProperty(chatId, 'announcement', value);
|
||||
}, this.id._serialized, adminsOnly);
|
||||
|
||||
if (res.status !== 200) return false;
|
||||
|
||||
this.groupMetadata.announce = adminsOnly;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the group settings to only allow admins to edit group info (title, description, photo).
|
||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||
* @returns {Promise&lt;boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setInfoAdminsOnly(adminsOnly=true) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||
return window.Store.Wap.setGroupProperty(chatId, 'restrict', value);
|
||||
}, this.id._serialized, adminsOnly);
|
||||
|
||||
if (res.status !== 200) return false;
|
||||
|
||||
this.groupMetadata.restrict = adminsOnly;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the invite code for a specific group
|
||||
* @returns {Promise&lt;string>} Group's invite code
|
||||
*/
|
||||
async getInviteCode() {
|
||||
let res = await this.client.pupPage.evaluate(chatId => {
|
||||
@@ -160,6 +209,7 @@ class GroupChat extends Chat {
|
||||
|
||||
/**
|
||||
* Invalidates the current group invite code and generates a new one
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async revokeInvite() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
@@ -167,29 +217,9 @@ class GroupChat extends Chat {
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object with information about the invite code's group
|
||||
* @param {string} inviteCode
|
||||
* @returns {Promise&lt;object>} Invite information
|
||||
*/
|
||||
static async getInviteInfo(inviteCode) {
|
||||
return await this.client.pupPage.evaluate(inviteCode => {
|
||||
return window.Store.Wap.groupInviteInfo(inviteCode);
|
||||
}, inviteCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins a group with an invite code
|
||||
* @param {string} inviteCode
|
||||
*/
|
||||
static async join(inviteCode) {
|
||||
return await this.client.pupPage.evaluate(inviteCode => {
|
||||
return window.Store.Wap.acceptGroupInvite(inviteCode);
|
||||
}, inviteCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the bot leave the group
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async leave() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
@@ -209,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/GroupNotification.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -74,7 +74,7 @@ class GroupNotification extends Base {
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.chatId = typeof (data.to) === 'object' ? data.to._serialized : data.to;
|
||||
this.chatId = typeof (data.from) === 'object' ? data.from._serialized : data.from;
|
||||
|
||||
/**
|
||||
* 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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
103
docs/structures_Label.js.html
Normal file
103
docs/structures_Label.js.html
Normal file
@@ -0,0 +1,103 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.12.6 » 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">
|
||||
<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>12.<wbr>6</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/Label.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Chat = require('./Chat');
|
||||
|
||||
/**
|
||||
* WhatsApp Business Label information
|
||||
*/
|
||||
class Label extends Base {
|
||||
/**
|
||||
* @param {Base} client
|
||||
* @param {object} labelData
|
||||
*/
|
||||
constructor(client, labelData){
|
||||
super(client);
|
||||
|
||||
if(labelData) this._patch(labelData);
|
||||
}
|
||||
|
||||
_patch(labelData){
|
||||
/**
|
||||
* Label ID
|
||||
* @type {string}
|
||||
*/
|
||||
this.id = labelData.id;
|
||||
|
||||
/**
|
||||
* Label name
|
||||
* @type {string}
|
||||
*/
|
||||
this.name = labelData.name;
|
||||
|
||||
/**
|
||||
* Label hex color
|
||||
* @type {string}
|
||||
*/
|
||||
this.hexColor = labelData.hexColor;
|
||||
}
|
||||
/**
|
||||
* Get all chats that have been assigned this Label
|
||||
* @returns {Promise&lt;Array&lt;Chat>>}
|
||||
*/
|
||||
async getChats(){
|
||||
return this.client.getChatsByLabelId(this.id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Label;</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.6 on April 20, 2021.
|
||||
</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>
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/Location.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/Message.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -44,21 +44,34 @@ class Message extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* MediaKey that represents the sticker 'ID'
|
||||
* @type {string}
|
||||
*/
|
||||
this.mediaKey = data.mediaKey;
|
||||
|
||||
|
||||
/**
|
||||
* ID that represents the message
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
/**
|
||||
* ACK status for the message
|
||||
* @type {MessageAck}
|
||||
*/
|
||||
this.ack = data.ack;
|
||||
|
||||
/**
|
||||
* Indicates if the message has media available for download
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.hasMedia = data.clientUrl ? true : false;
|
||||
this.hasMedia = data.clientUrl || data.deprecatedMms3Url ? true : false;
|
||||
|
||||
/**
|
||||
* Message content
|
||||
@@ -82,7 +95,7 @@ class Message extends Base {
|
||||
* ID for the Chat that this message was sent to, except if the message was sent by the current user.
|
||||
* @type {string}
|
||||
*/
|
||||
this.from = typeof (data.from) === 'object' ? data.from._serialized : data.from;
|
||||
this.from = (typeof (data.from) === 'object' &amp;&amp; data.from !== null) ? data.from._serialized : data.from;
|
||||
|
||||
/**
|
||||
* ID for who this message is for.
|
||||
@@ -91,13 +104,13 @@ class Message extends Base {
|
||||
* If the message is sent by another user, it will be the ID for the current user.
|
||||
* @type {string}
|
||||
*/
|
||||
this.to = typeof (data.to) === 'object' ? data.to._serialized : data.to;
|
||||
this.to = (typeof (data.to) === 'object' &amp;&amp; data.to !== null) ? data.to._serialized : data.to;
|
||||
|
||||
/**
|
||||
* If the message was sent to a group, this field will contain the user that sent the message.
|
||||
* @type {string}
|
||||
*/
|
||||
this.author = typeof (data.author) === 'object' ? data.author._serialized : data.author;
|
||||
this.author = (typeof (data.author) === 'object' &amp;&amp; data.author !== null) ? data.author._serialized : data.author;
|
||||
|
||||
/**
|
||||
* Indicates if the message was forwarded
|
||||
@@ -105,6 +118,18 @@ class Message extends Base {
|
||||
*/
|
||||
this.isForwarded = data.isForwarded;
|
||||
|
||||
/**
|
||||
* Indicates if the message is a status update
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isStatus = data.isStatusV3;
|
||||
|
||||
/**
|
||||
* Indicates if the message was starred
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isStarred = data.star;
|
||||
|
||||
/**
|
||||
* Indicates if the message was a broadcast
|
||||
* @type {boolean}
|
||||
@@ -116,7 +141,7 @@ class Message extends Base {
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.fromMe = data.id.fromMe;
|
||||
|
||||
|
||||
/**
|
||||
* Indicates if the message was sent as a reply to another message.
|
||||
* @type {boolean}
|
||||
@@ -129,6 +154,12 @@ class Message extends Base {
|
||||
*/
|
||||
this.location = data.type === MessageTypes.LOCATION ? new Location(data.lat, data.lng, data.loc) : undefined;
|
||||
|
||||
/**
|
||||
* List of vCards contained in the message.
|
||||
* @type {Array&lt;string>}
|
||||
*/
|
||||
this.vCards = data.type === MessageTypes.CONTACT_CARD_MULTI ? data.vcardList.map((c) => c.vcard) : data.type === MessageTypes.CONTACT_CARD ? [data.body] : [];
|
||||
|
||||
/**
|
||||
* Indicates the mentions in the message body.
|
||||
* @type {Array&lt;string>}
|
||||
@@ -139,6 +170,12 @@ class Message extends Base {
|
||||
this.mentionedIds = data.mentionedJidList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Links included in the message.
|
||||
* @type {Array&lt;string>}
|
||||
*/
|
||||
this.links = data.links;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
@@ -191,11 +228,11 @@ class Message extends Base {
|
||||
* in the same Chat as the original message was sent.
|
||||
*
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {?string} chatId
|
||||
* @param {object} options
|
||||
* @param {string} [chatId]
|
||||
* @param {MessageSendOptions} [options]
|
||||
* @returns {Promise&lt;Message>}
|
||||
*/
|
||||
async reply(content, chatId, options={}) {
|
||||
async reply(content, chatId, options = {}) {
|
||||
if (!chatId) {
|
||||
chatId = this._getChatId();
|
||||
}
|
||||
@@ -208,6 +245,23 @@ class Message extends Base {
|
||||
return this.client.sendMessage(chatId, content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forwards this message to another chat
|
||||
*
|
||||
* @param {string|Chat} chat Chat model or chat ID to which the message will be forwarded
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async forward(chat) {
|
||||
const chatId = typeof chat === 'string' ? chat : chat.id._serialized;
|
||||
|
||||
await this.client.pupPage.evaluate(async (msgId, chatId) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
|
||||
return await chat.forwardMessages([msg]);
|
||||
}, this.id._serialized, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the attatched message media
|
||||
* @returns {Promise&lt;MessageMedia>}
|
||||
@@ -217,12 +271,25 @@ class Message extends Base {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const {data, mimetype, filename} = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const result = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
const buffer = await window.WWebJS.downloadBuffer(msg.clientUrl);
|
||||
|
||||
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
||||
// try to resolve media
|
||||
await msg.downloadMedia(true, 1);
|
||||
}
|
||||
|
||||
if (msg.mediaData.mediaStage.includes('ERROR')) {
|
||||
// media could not be downloaded
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const mediaUrl = msg.clientUrl || msg.deprecatedMms3Url;
|
||||
|
||||
const buffer = await window.WWebJS.downloadBuffer(mediaUrl);
|
||||
const decrypted = await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
|
||||
const data = await window.WWebJS.readBlobAsync(decrypted._blob);
|
||||
|
||||
|
||||
return {
|
||||
data: data.split(',')[1],
|
||||
mimetype: msg.mimetype,
|
||||
@@ -231,7 +298,8 @@ class Message extends Base {
|
||||
|
||||
}, this.id._serialized);
|
||||
|
||||
return new MessageMedia(mimetype, data, filename);
|
||||
if (!result) return undefined;
|
||||
return new MessageMedia(result.mimetype, result.data, result.filename);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,13 +310,69 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
||||
}, this.id._serialized, everyone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stars this message
|
||||
*/
|
||||
async star() {
|
||||
await this.client.pupPage.evaluate((msgId) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if (msg.canStar()) {
|
||||
return msg.chat.sendStarMsgs([msg], true);
|
||||
}
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unstars this message
|
||||
*/
|
||||
async unstar() {
|
||||
await this.client.pupPage.evaluate((msgId) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if (msg.canStar()) {
|
||||
return msg.chat.sendStarMsgs([msg], false);
|
||||
}
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Message Info
|
||||
* @typedef {Object} MessageInfo
|
||||
* @property {Array&lt;{id: ContactId, t: number}>} delivery Contacts to which the message has been delivered to
|
||||
* @property {number} deliveryRemaining Amount of people to whom the message has not been delivered to
|
||||
* @property {Array&lt;{id: ContactId, t: number}>} played Contacts who have listened to the voice message
|
||||
* @property {number} playedRemaining Amount of people who have not listened to the message
|
||||
* @property {Array&lt;{id: ContactId, t: number}>} read Contacts who have read the message
|
||||
* @property {number} readRemaining Amount of people who have not read the message
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get information about message delivery status. May return null if the message does not exist or is not sent by you.
|
||||
* @returns {Promise&lt;?MessageInfo>}
|
||||
*/
|
||||
async getInfo() {
|
||||
const info = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
if(!msg) return null;
|
||||
|
||||
return await window.Store.Wap.queryMsgInfo(msg.id);
|
||||
}, this.id._serialized);
|
||||
|
||||
if(info.status) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Message;
|
||||
@@ -262,7 +386,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/MessageMedia.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -31,6 +31,10 @@
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const mime = require('mime');
|
||||
|
||||
/**
|
||||
* Media attached to a message
|
||||
* @param {string} mimetype MIME type of the attachment
|
||||
@@ -57,6 +61,19 @@ class MessageMedia {
|
||||
*/
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a MessageMedia instance from a local file path
|
||||
* @param {string} filePath
|
||||
* @returns {MessageMedia}
|
||||
*/
|
||||
static fromFilePath(filePath) {
|
||||
const b64data = fs.readFileSync(filePath, {encoding: 'base64'});
|
||||
const mimetype = mime.getType(filePath);
|
||||
const filename = path.basename(filePath);
|
||||
|
||||
return new MessageMedia(mimetype, b64data, filename);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MessageMedia;</code></pre>
|
||||
@@ -69,7 +86,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/PrivateChat.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: structures/PrivateContact.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: util/Constants.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -33,13 +33,19 @@
|
||||
|
||||
exports.WhatsWebURL = 'https://web.whatsapp.com/';
|
||||
|
||||
exports.UserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36';
|
||||
|
||||
exports.DefaultOptions = {
|
||||
puppeteer: {
|
||||
headless: true
|
||||
headless: true,
|
||||
defaultViewport: null
|
||||
},
|
||||
session: false
|
||||
session: false,
|
||||
qrTimeoutMs: 45000,
|
||||
qrRefreshIntervalMs: 20000,
|
||||
authTimeoutMs: 45000,
|
||||
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',
|
||||
ffmpegPath: 'ffmpeg'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -67,12 +73,14 @@ exports.Events = {
|
||||
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
|
||||
MESSAGE_REVOKED_ME: 'message_revoke_me',
|
||||
MESSAGE_ACK: 'message_ack',
|
||||
MEDIA_UPLOADED: 'media_uploaded',
|
||||
GROUP_JOIN: 'group_join',
|
||||
GROUP_LEAVE: 'group_leave',
|
||||
GROUP_UPDATE: 'group_update',
|
||||
QR_RECEIVED: 'qr',
|
||||
DISCONNECTED: 'disconnected',
|
||||
STATE_CHANGED: 'change_state',
|
||||
BATTERY_CHANGED: 'change_battery'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -166,7 +174,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.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
131
docs/util_InterfaceController.js.html
Normal file
131
docs/util_InterfaceController.js.html
Normal file
@@ -0,0 +1,131 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.12.6 » Source: util/InterfaceController.js</title>
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||
<link href="css/baseline.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body onload="prettyPrint()">
|
||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||
<div id="jsdoc-navbar-container">
|
||||
<div id="jsdoc-navbar-content">
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: util/InterfaceController.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
/**
|
||||
* Interface Controller
|
||||
*/
|
||||
class InterfaceController {
|
||||
|
||||
constructor(props) {
|
||||
this.pupPage = props.pupPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Chat Window
|
||||
* @param {string} chatId ID of the chat window that will be opened
|
||||
*/
|
||||
async openChatWindow(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.openChatAt(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Chat Drawer
|
||||
* @param {string} chatId ID of the chat drawer that will be opened
|
||||
*/
|
||||
async openChatDrawer(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.chatInfoDrawer(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Chat Search
|
||||
* @param {string} chatId ID of the chat search that will be opened
|
||||
*/
|
||||
async openChatSearch(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.chatSearch(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens or Scrolls the Chat Window to the position of the message
|
||||
* @param {string} msgId ID of the message that will be scrolled to
|
||||
*/
|
||||
async openChatWindowAt(msgId) {
|
||||
await this.pupPage.evaluate(async msgId => {
|
||||
let msg = await window.Store.Msg.get(msgId);
|
||||
await window.Store.Cmd.openChatAt(msg.chat, msg.chat.getSearchContext(msg));
|
||||
}, msgId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Message Drawer
|
||||
* @param {string} msgId ID of the message drawer that will be opened
|
||||
*/
|
||||
async openMessageDrawer(msgId) {
|
||||
await this.pupPage.evaluate(async msgId => {
|
||||
let msg = await window.Store.Msg.get(msgId);
|
||||
await window.Store.Cmd.msgInfoDrawer(msg);
|
||||
}, msgId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the Right Drawer
|
||||
*/
|
||||
async closeRightDrawer() {
|
||||
await this.pupPage.evaluate(async () => {
|
||||
await window.Store.Cmd.closeDrawerRight();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = InterfaceController;</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.6 on April 20, 2021.
|
||||
</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>
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.3">
|
||||
<meta name="generator" content="JSDoc 3.6.6">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.2.1 » Source: util/Util.js</title>
|
||||
<title>whatsapp-web.js 1.12.6 » 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>2.<wbr>1</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>12.<wbr>6</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -31,6 +31,13 @@
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const sharp = require('sharp');
|
||||
const path = require('path');
|
||||
const Crypto = require('crypto');
|
||||
const { tmpdir } = require('os');
|
||||
const ffmpeg = require('fluent-ffmpeg');
|
||||
const fs = require('fs').promises;
|
||||
|
||||
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
||||
|
||||
/**
|
||||
@@ -61,6 +68,123 @@ class Util {
|
||||
|
||||
return given;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a image to webp
|
||||
* @param {MessageMedia} media
|
||||
*
|
||||
* @returns {Promise&lt;MessageMedia>} media in webp format
|
||||
*/
|
||||
static async formatImageToWebpSticker(media) {
|
||||
if (!media.mimetype.includes('image'))
|
||||
throw new Error('media is not a image');
|
||||
|
||||
if (media.mimetype.includes('webp')) {
|
||||
return media;
|
||||
}
|
||||
|
||||
const buff = Buffer.from(media.data, 'base64');
|
||||
|
||||
let sharpImg = sharp(buff);
|
||||
sharpImg = sharpImg.webp();
|
||||
|
||||
sharpImg = sharpImg.resize(512, 512, {
|
||||
fit: 'contain',
|
||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||
});
|
||||
|
||||
let webpBase64 = (await sharpImg.toBuffer()).toString('base64');
|
||||
|
||||
return {
|
||||
mimetype: 'image/webp',
|
||||
data: webpBase64,
|
||||
filename: media.filename,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a video to webp
|
||||
* @param {MessageMedia} media
|
||||
*
|
||||
* @returns {Promise&lt;MessageMedia>} media in webp format
|
||||
*/
|
||||
static async formatVideoToWebpSticker(media) {
|
||||
if (!media.mimetype.includes('video'))
|
||||
throw new Error('media is not a video');
|
||||
|
||||
const videoType = media.mimetype.split('/')[1];
|
||||
|
||||
const tempFile = path.join(
|
||||
tmpdir(),
|
||||
`${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`
|
||||
);
|
||||
|
||||
const stream = new (require('stream').Readable)();
|
||||
const buffer = Buffer.from(
|
||||
media.data.replace(`data:${media.mimetype};base64,`, ''),
|
||||
'base64'
|
||||
);
|
||||
stream.push(buffer);
|
||||
stream.push(null);
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
ffmpeg(stream)
|
||||
.inputFormat(videoType)
|
||||
.on('error', reject)
|
||||
.on('end', () => resolve(true))
|
||||
.addOutputOptions([
|
||||
'-vcodec',
|
||||
'libwebp',
|
||||
'-vf',
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
'scale=\'iw*min(300/iw\,300/ih)\':\'ih*min(300/iw\,300/ih)\',format=rgba,pad=300:300:\'(300-iw)/2\':\'(300-ih)/2\':\'#00000000\',setsar=1,fps=10',
|
||||
'-loop',
|
||||
'0',
|
||||
'-ss',
|
||||
'00:00:00.0',
|
||||
'-t',
|
||||
'00:00:05.0',
|
||||
'-preset',
|
||||
'default',
|
||||
'-an',
|
||||
'-vsync',
|
||||
'0',
|
||||
'-s',
|
||||
'512:512',
|
||||
])
|
||||
.toFormat('webp')
|
||||
.save(tempFile);
|
||||
});
|
||||
|
||||
const data = await fs.readFile(tempFile, 'base64');
|
||||
await fs.unlink(tempFile);
|
||||
|
||||
return {
|
||||
mimetype: 'image/webp',
|
||||
data: data,
|
||||
filename: media.filename,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a media to webp
|
||||
* @param {MessageMedia} media
|
||||
*
|
||||
* @returns {Promise&lt;MessageMedia>} media in webp format
|
||||
*/
|
||||
static async formatToWebpSticker(media) {
|
||||
if (media.mimetype.includes('image')) return this.formatImageToWebpSticker(media);
|
||||
else if (media.mimetype.includes('video')) return this.formatVideoToWebpSticker(media);
|
||||
else throw new Error('Invalid media format');
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure ffmpeg path
|
||||
* @param {string} path
|
||||
*/
|
||||
static setFfmpegPath(path) {
|
||||
ffmpeg.setFfmpegPath(path);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Util;</code></pre>
|
||||
@@ -73,7 +197,7 @@ module.exports = Util;</code></pre>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.3 on March 5, 2020.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.6 on April 20, 2021.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
68
example.js
68
example.js
@@ -40,11 +40,11 @@ client.on('ready', () => {
|
||||
client.on('message', async msg => {
|
||||
console.log('MESSAGE RECEIVED', msg);
|
||||
|
||||
if (msg.body == '!ping reply') {
|
||||
if (msg.body === '!ping reply') {
|
||||
// Send a new message as a reply to the current one
|
||||
msg.reply('pong');
|
||||
|
||||
} else if (msg.body == '!ping') {
|
||||
} else if (msg.body === '!ping') {
|
||||
// Send a new message to the same chat
|
||||
client.sendMessage(msg.from, 'pong');
|
||||
|
||||
@@ -79,7 +79,7 @@ client.on('message', async msg => {
|
||||
} else {
|
||||
msg.reply('This command can only be used in a group!');
|
||||
}
|
||||
} else if (msg.body == '!leave') {
|
||||
} else if (msg.body === '!leave') {
|
||||
// Leave the group
|
||||
let chat = await msg.getChat();
|
||||
if (chat.isGroup) {
|
||||
@@ -95,7 +95,7 @@ client.on('message', async msg => {
|
||||
} catch (e) {
|
||||
msg.reply('That invite code seems to be invalid.');
|
||||
}
|
||||
} else if (msg.body == '!groupinfo') {
|
||||
} else if (msg.body === '!groupinfo') {
|
||||
let chat = await msg.getChat();
|
||||
if (chat.isGroup) {
|
||||
msg.reply(`
|
||||
@@ -109,10 +109,10 @@ client.on('message', async msg => {
|
||||
} else {
|
||||
msg.reply('This command can only be used in a group!');
|
||||
}
|
||||
} else if (msg.body == '!chats') {
|
||||
} else if (msg.body === '!chats') {
|
||||
const chats = await client.getChats();
|
||||
client.sendMessage(msg.from, `The bot has ${chats.length} chats open.`);
|
||||
} else if (msg.body == '!info') {
|
||||
} else if (msg.body === '!info') {
|
||||
let info = client.info;
|
||||
client.sendMessage(msg.from, `
|
||||
*Connection info*
|
||||
@@ -121,7 +121,7 @@ client.on('message', async msg => {
|
||||
Platform: ${info.platform}
|
||||
WhatsApp version: ${info.phone.wa_version}
|
||||
`);
|
||||
} else if (msg.body == '!mediainfo' && msg.hasMedia) {
|
||||
} else if (msg.body === '!mediainfo' && msg.hasMedia) {
|
||||
const attachmentData = await msg.downloadMedia();
|
||||
msg.reply(`
|
||||
*Media info*
|
||||
@@ -129,7 +129,7 @@ client.on('message', async msg => {
|
||||
Filename: ${attachmentData.filename}
|
||||
Data (length): ${attachmentData.data.length}
|
||||
`);
|
||||
} else if (msg.body == '!quoteinfo' && msg.hasQuotedMsg) {
|
||||
} else if (msg.body === '!quoteinfo' && msg.hasQuotedMsg) {
|
||||
const quotedMsg = await msg.getQuotedMessage();
|
||||
|
||||
quotedMsg.reply(`
|
||||
@@ -139,13 +139,13 @@ client.on('message', async msg => {
|
||||
Timestamp: ${quotedMsg.timestamp}
|
||||
Has Media? ${quotedMsg.hasMedia}
|
||||
`);
|
||||
} else if (msg.body == '!resendmedia' && msg.hasQuotedMsg) {
|
||||
} else if (msg.body === '!resendmedia' && msg.hasQuotedMsg) {
|
||||
const quotedMsg = await msg.getQuotedMessage();
|
||||
if (quotedMsg.hasMedia) {
|
||||
const attachmentData = await quotedMsg.downloadMedia();
|
||||
client.sendMessage(msg.from, attachmentData, { caption: 'Here\'s your requested media.' });
|
||||
}
|
||||
} else if (msg.body == '!location') {
|
||||
} else if (msg.body === '!location') {
|
||||
msg.reply(new Location(37.422, -122.084, 'Googleplex\nGoogle Headquarters'));
|
||||
} else if (msg.location) {
|
||||
msg.reply(msg.location);
|
||||
@@ -153,34 +153,50 @@ client.on('message', async msg => {
|
||||
const newStatus = msg.body.split(' ')[1];
|
||||
await client.setStatus(newStatus);
|
||||
msg.reply(`Status was updated to *${newStatus}*`);
|
||||
} else if (msg.body == '!mention') {
|
||||
} else if (msg.body === '!mention') {
|
||||
const contact = await msg.getContact();
|
||||
const chat = await msg.getChat();
|
||||
chat.sendMessage(`Hi @${contact.number}!`, {
|
||||
mentions: [contact]
|
||||
});
|
||||
} else if (msg.body == '!delete' && msg.hasQuotedMsg) {
|
||||
const quotedMsg = await msg.getQuotedMessage();
|
||||
if (quotedMsg.fromMe) {
|
||||
quotedMsg.delete(true);
|
||||
} else {
|
||||
msg.reply('I can only delete my own messages');
|
||||
} else if (msg.body === '!delete') {
|
||||
if (msg.hasQuotedMsg) {
|
||||
const quotedMsg = await msg.getQuotedMessage();
|
||||
if (quotedMsg.fromMe) {
|
||||
quotedMsg.delete(true);
|
||||
} else {
|
||||
msg.reply('I can only delete my own messages');
|
||||
}
|
||||
}
|
||||
} else if (msg.body === '!pin') {
|
||||
const chat = await msg.getChat();
|
||||
await chat.pin();
|
||||
} else if (msg.body === '!archive') {
|
||||
const chat = await msg.getChat();
|
||||
chat.archive();
|
||||
await chat.archive();
|
||||
} else if (msg.body === '!mute') {
|
||||
const chat = await msg.getChat();
|
||||
// mute the chat for 20 seconds
|
||||
const unmuteDate = new Date();
|
||||
unmuteDate.setSeconds(unmuteDate.getSeconds() + 20);
|
||||
await chat.mute(unmuteDate);
|
||||
} else if (msg.body === '!typing') {
|
||||
const chat = await msg.getChat();
|
||||
// simulates typing in the chat
|
||||
chat.sendStateTyping();
|
||||
chat.sendStateTyping();
|
||||
} else if (msg.body === '!recording') {
|
||||
const chat = await msg.getChat();
|
||||
// simulates recording audio in the chat
|
||||
chat.sendStateRecording();
|
||||
chat.sendStateRecording();
|
||||
} else if (msg.body === '!clearstate') {
|
||||
const chat = await msg.getChat();
|
||||
// stops typing or recording in the chat
|
||||
chat.clearState();
|
||||
chat.clearState();
|
||||
} else if (msg.body === 'jumpto') {
|
||||
if (msg.hasQuotedMsg) {
|
||||
const quotedMsg = await msg.getQuotedMessage();
|
||||
client.interface.openChatWindowAt(quotedMsg.id._serialized);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -237,6 +253,16 @@ client.on('group_update', (notification) => {
|
||||
console.log('update', notification);
|
||||
});
|
||||
|
||||
client.on('change_battery', (batteryInfo) => {
|
||||
// Battery percentage for attached device has changed
|
||||
const { battery, plugged } = batteryInfo;
|
||||
console.log(`Battery: ${battery}% - Charging? ${plugged}`);
|
||||
});
|
||||
|
||||
client.on('change_state', state => {
|
||||
console.log('CHANGE STATE', state );
|
||||
});
|
||||
|
||||
client.on('disconnected', (reason) => {
|
||||
console.log('Client was logged out', reason);
|
||||
});
|
||||
|
||||
912
index.d.ts
vendored
Normal file
912
index.d.ts
vendored
Normal file
@@ -0,0 +1,912 @@
|
||||
|
||||
import { EventEmitter } from 'events'
|
||||
import puppeteer = require('puppeteer')
|
||||
|
||||
declare namespace WAWebJS {
|
||||
|
||||
export class Client extends EventEmitter {
|
||||
constructor(options: ClientOptions)
|
||||
|
||||
/** Current connection information */
|
||||
public info: ClientInfo
|
||||
|
||||
/** Puppeteer page running WhatsApp Web */
|
||||
pupPage?: puppeteer.Page
|
||||
|
||||
/** Puppeteer browser running WhatsApp Web */
|
||||
pupBrowser?: puppeteer.Browser
|
||||
|
||||
/**Accepts an invitation to join a group */
|
||||
acceptInvite(inviteCode: string): Promise<string>
|
||||
|
||||
/**Returns an object with information about the invite code's group */
|
||||
getInviteInfo(inviteCode: string): Promise<object>
|
||||
|
||||
/** Enables and returns the archive state of the Chat */
|
||||
archiveChat(chatId: string): Promise<boolean>
|
||||
|
||||
/** Pins the Chat and returns its new Pin state */
|
||||
pinChat(chatId: string): Promise<boolean>
|
||||
|
||||
/** Unpins the Chat and returns its new Pin state */
|
||||
unpinChat(chatId: string): Promise<boolean>
|
||||
|
||||
/**
|
||||
* Create a new group
|
||||
* @param name group title
|
||||
* @param participants an array of Contacts or contact IDs to add to the group
|
||||
*/
|
||||
createGroup(name: string, participants: Contact[] | string[]): Promise<CreateGroupResult>
|
||||
|
||||
/** Closes the client */
|
||||
destroy(): Promise<void>
|
||||
|
||||
/** Logs out the client, closing the current session */
|
||||
logout(): Promise<void>
|
||||
|
||||
/** Get chat instance by ID */
|
||||
getChatById(chatId: string): Promise<Chat>
|
||||
|
||||
/** Get all current chat instances */
|
||||
getChats(): Promise<Chat[]>
|
||||
|
||||
/** Get contact instance by ID */
|
||||
getContactById(contactId: string): Promise<Contact>
|
||||
|
||||
/** Get all current contact instances */
|
||||
getContacts(): Promise<Contact[]>
|
||||
|
||||
/** Get all current Labels */
|
||||
getLabels(): Promise<Label[]>
|
||||
|
||||
/** Get Label instance by ID */
|
||||
getLabelById(labelId: string): Promise<Label>
|
||||
|
||||
/** Get all Labels assigned to a Chat */
|
||||
getChatLabels(chatId: string): Promise<Label[]>
|
||||
|
||||
/** Get all Chats for a specific Label */
|
||||
getChatsByLabelId(labelId: string): Promise<Chat[]>
|
||||
|
||||
/** Returns the contact ID's profile picture URL, if privacy settings allow it */
|
||||
getProfilePicUrl(contactId: string): Promise<string>
|
||||
|
||||
/** Gets the current connection state for the client */
|
||||
getState(): Promise<WAState>
|
||||
|
||||
/** Returns the version of WhatsApp Web currently being run */
|
||||
getWWebVersion(): Promise<string>
|
||||
|
||||
/** Sets up events and requirements, kicks off authentication request */
|
||||
initialize(): Promise<void>
|
||||
|
||||
/** Check if a given ID is registered in whatsapp */
|
||||
isRegisteredUser(contactId: string): Promise<boolean>
|
||||
|
||||
/** Get the registered WhatsApp ID for a number. Returns null if the number is not registered on WhatsApp. */
|
||||
getNumberId(number: string): Promise<ContactId | null>
|
||||
|
||||
/**
|
||||
* Mutes the Chat until a specified date
|
||||
* @param chatId ID of the chat that will be muted
|
||||
* @param unmuteDate Date when the chat will be unmuted
|
||||
*/
|
||||
muteChat(chatId: string, unmuteDate: Date): Promise<void>
|
||||
|
||||
/** Force reset of connection state for the client */
|
||||
resetState(): Promise<void>
|
||||
|
||||
/** Send a message to a specific chatId */
|
||||
sendMessage(chatId: string, content: MessageContent, options?: MessageSendOptions): Promise<Message>
|
||||
|
||||
/** Marks the client as online */
|
||||
sendPresenceAvailable(): Promise<void>
|
||||
|
||||
/** Mark as seen for the Chat */
|
||||
sendSeen(chatId: string): Promise<boolean>
|
||||
|
||||
/** Mark the Chat as unread */
|
||||
markChatUnread(chatId: string): Promise<void>
|
||||
|
||||
/**
|
||||
* Sets the current user's status message
|
||||
* @param status New status message
|
||||
*/
|
||||
setStatus(status: string): Promise<void>
|
||||
|
||||
/**
|
||||
* Sets the current user's display name
|
||||
* @param displayName New display name
|
||||
*/
|
||||
setDisplayName(displayName: string): Promise<void>
|
||||
|
||||
/** Changes and returns the archive state of the Chat */
|
||||
unarchiveChat(chatId: string): Promise<boolean>
|
||||
|
||||
/** Unmutes the Chat */
|
||||
unmuteChat(chatId: string): Promise<void>
|
||||
|
||||
/** Generic event */
|
||||
on(event: string, listener: (...args: any) => void): this
|
||||
|
||||
/** Emitted when there has been an error while trying to restore an existing session */
|
||||
on(event: 'auth_failure', listener: (message: string) => void): this
|
||||
|
||||
/** Emitted when authentication is successful */
|
||||
on(event: 'authenticated', listener: (
|
||||
/** Object containing session information. Can be used to restore the session */
|
||||
session: ClientSession
|
||||
) => void): this
|
||||
|
||||
/** Emitted when the battery percentage for the attached device changes */
|
||||
on(event: 'change_battery', listener: (batteryInfo: BatteryInfo) => void): this
|
||||
|
||||
/** Emitted when the connection state changes */
|
||||
on(event: 'change_state', listener: (
|
||||
/** the new connection state */
|
||||
state: WAState
|
||||
) => void): this
|
||||
|
||||
/** Emitted when the client has been disconnected */
|
||||
on(event: 'disconnected', listener: (
|
||||
/** reason that caused the disconnect */
|
||||
reason: WAState | "NAVIGATED"
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a user joins the chat via invite link or is added by an admin */
|
||||
on(event: 'group_join', listener: (
|
||||
/** GroupNotification with more information about the action */
|
||||
notification: GroupNotification
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a user leaves the chat or is removed by an admin */
|
||||
on(event: 'group_leave', listener: (
|
||||
/** GroupNotification with more information about the action */
|
||||
notification: GroupNotification
|
||||
) => void): this
|
||||
|
||||
/** Emitted when group settings are updated, such as subject, description or picture */
|
||||
on(event: 'group_update', listener: (
|
||||
/** GroupNotification with more information about the action */
|
||||
notification: GroupNotification
|
||||
) => void): this
|
||||
|
||||
/** Emitted when media has been uploaded for a message sent by the client */
|
||||
on(event: 'media_uploaded', listener: (
|
||||
/** The message with media that was uploaded */
|
||||
message: Message
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a new message is received */
|
||||
on(event: 'message', listener: (
|
||||
/** The message that was received */
|
||||
message: Message
|
||||
) => void): this
|
||||
|
||||
/** Emitted when an ack event occurrs on message type */
|
||||
on(event: 'message_ack', listener: (
|
||||
/** The message that was affected */
|
||||
message: Message,
|
||||
/** The new ACK value */
|
||||
ack: MessageAck
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a new message is created, which may include the current user's own messages */
|
||||
on(event: 'message_create', listener: (
|
||||
/** The message that was created */
|
||||
message: Message
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a message is deleted for everyone in the chat */
|
||||
on(event: 'message_revoke_everyone', listener: (
|
||||
/** The message that was revoked, in its current state. It will not contain the original message's data */
|
||||
message: Message,
|
||||
/**The message that was revoked, before it was revoked.
|
||||
* It will contain the message's original data.
|
||||
* Note that due to the way this data is captured,
|
||||
* it may be possible that this param will be undefined. */
|
||||
revoked_msg?: Message | null
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a message is deleted by the current user */
|
||||
on(event: 'message_revoke_me', listener: (
|
||||
/** The message that was revoked */
|
||||
message: Message
|
||||
) => void): this
|
||||
|
||||
/** Emitted when the QR code is received */
|
||||
on(event: 'qr', listener: (
|
||||
/** qr code string
|
||||
* @example ```1@9Q8tWf6bnezr8uVGwVCluyRuBOJ3tIglimzI5dHB0vQW2m4DQ0GMlCGf,f1/vGcW4Z3vBa1eDNl3tOjWqLL5DpYTI84DMVkYnQE8=,ZL7YnK2qdPN8vKo2ESxhOQ==``` */
|
||||
qr: string
|
||||
) => void): this
|
||||
|
||||
/** Emitted when the client has initialized and is ready to receive messages */
|
||||
on(event: 'ready', listener: () => void): this
|
||||
}
|
||||
|
||||
/** Current connection information */
|
||||
export interface ClientInfo {
|
||||
/**
|
||||
* Current user ID
|
||||
* @deprecated Use .wid instead
|
||||
*/
|
||||
me: ContactId
|
||||
/** Current user ID */
|
||||
wid: ContactId
|
||||
/** Information about the phone this client is connected to */
|
||||
phone: ClientInfoPhone
|
||||
/** Platform the phone is running on */
|
||||
platform: string
|
||||
/** Name configured to be shown in push notifications */
|
||||
pushname: string
|
||||
|
||||
/** Get current battery percentage and charging status for the attached device */
|
||||
getBatteryStatus: () => Promise<BatteryInfo>
|
||||
}
|
||||
|
||||
/** Information about the phone this client is connected to */
|
||||
export interface ClientInfoPhone {
|
||||
/** WhatsApp Version running on the phone */
|
||||
wa_version: string
|
||||
/** OS Version running on the phone (iOS or Android version) */
|
||||
os_version: string
|
||||
/** Device manufacturer */
|
||||
device_manufacturer: string
|
||||
/** Device model */
|
||||
device_model: string
|
||||
/** OS build number */
|
||||
os_build_number: string
|
||||
}
|
||||
|
||||
/** Options for initializing the whatsapp client */
|
||||
export interface ClientOptions {
|
||||
/** Timeout for authentication selector in puppeteer
|
||||
* @default 45000 */
|
||||
authTimeoutMs?: number,
|
||||
/** Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/ */
|
||||
puppeteer?: puppeteer.LaunchOptions
|
||||
/** Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
|
||||
* @default 20000 */
|
||||
qrRefreshIntervalMs?: number
|
||||
/** Timeout for qr code selector in puppeteer
|
||||
* @default 45000 */
|
||||
qrTimeoutMs?: number,
|
||||
/** Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||
* @default false */
|
||||
restartOnAuthFail?: boolean
|
||||
/** Whatsapp session to restore. If not set, will start a new session */
|
||||
session?: ClientSession
|
||||
/** If another whatsapp web session is detected (another browser), take over the session in the current browser
|
||||
* @default false */
|
||||
takeoverOnConflict?: boolean,
|
||||
/** How much time to wait before taking over the session
|
||||
* @default 0 */
|
||||
takeoverTimeoutMs?: number,
|
||||
/** User agent to use in puppeteer.
|
||||
* @default 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36' */
|
||||
userAgent?: string
|
||||
/** Ffmpeg path to use when formating videos to webp while sending stickers
|
||||
* @default 'ffmpeg' */
|
||||
ffmpegPath?: string
|
||||
}
|
||||
|
||||
/** Represents a Whatsapp client session */
|
||||
export interface ClientSession {
|
||||
WABrowserId: string,
|
||||
WASecretBundle: string,
|
||||
WAToken1: string,
|
||||
WAToken2: string,
|
||||
}
|
||||
|
||||
export interface BatteryInfo {
|
||||
/** The current battery percentage */
|
||||
battery: number,
|
||||
/** Indicates if the phone is plugged in (true) or not (false) */
|
||||
plugged: boolean,
|
||||
}
|
||||
|
||||
export interface CreateGroupResult {
|
||||
/** ID for the group that was just created */
|
||||
gid: string,
|
||||
/** participants that were not added to the group.
|
||||
* Keys represent the ID for participant that was not added and its value is a status code
|
||||
* that represents the reason why participant could not be added.
|
||||
* This is usually 403 if the user's privacy settings don't allow you to add them to groups. */
|
||||
missingParticipants: Record<string, string>
|
||||
}
|
||||
|
||||
export interface GroupNotification {
|
||||
/** ContactId for the user that produced the GroupNotification */
|
||||
author: string,
|
||||
/** Extra content */
|
||||
body: string,
|
||||
/** ID for the Chat that this groupNotification was sent for */
|
||||
chatId: string,
|
||||
/** ID that represents the groupNotification
|
||||
* @todo create a more specific type for the id object */
|
||||
id: object,
|
||||
/** Contact IDs for the users that were affected by this GroupNotification */
|
||||
recipientIds: string[],
|
||||
/** Unix timestamp for when the groupNotification was created */
|
||||
timestamp: number,
|
||||
/** GroupNotification type */
|
||||
type: GroupNotificationTypes,
|
||||
|
||||
/** Returns the Chat this GroupNotification was sent in */
|
||||
getChat: () => Promise<Chat>,
|
||||
/** Returns the Contact this GroupNotification was produced by */
|
||||
getContact: () => Promise<Contact>,
|
||||
/** Returns the Contacts affected by this GroupNotification */
|
||||
getRecipients: () => Promise<Contact[]>,
|
||||
/** Sends a message to the same chat this GroupNotification was produced in */
|
||||
reply: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
|
||||
|
||||
}
|
||||
|
||||
/** whatsapp web url */
|
||||
export const WhatsWebURL: string
|
||||
|
||||
/** default client options */
|
||||
export const DefaultOptions: ClientOptions
|
||||
|
||||
/** Chat types */
|
||||
export enum ChatTypes {
|
||||
SOLO = 'solo',
|
||||
GROUP = 'group',
|
||||
UNKNOWN = 'unknown',
|
||||
}
|
||||
|
||||
/** Events that can be emitted by the client */
|
||||
export enum Events {
|
||||
AUTHENTICATED = 'authenticated',
|
||||
AUTHENTICATION_FAILURE = 'auth_failure',
|
||||
READY = 'ready',
|
||||
MESSAGE_RECEIVED = 'message',
|
||||
MESSAGE_CREATE = 'message_create',
|
||||
MESSAGE_REVOKED_EVERYONE = 'message_revoke_everyone',
|
||||
MESSAGE_REVOKED_ME = 'message_revoke_me',
|
||||
MESSAGE_ACK = 'message_ack',
|
||||
MEDIA_UPLOADED = 'media_uploaded',
|
||||
GROUP_JOIN = 'group_join',
|
||||
GROUP_LEAVE = 'group_leave',
|
||||
GROUP_UPDATE = 'group_update',
|
||||
QR_RECEIVED = 'qr',
|
||||
DISCONNECTED = 'disconnected',
|
||||
STATE_CHANGED = 'change_state',
|
||||
BATTERY_CHANGED = 'change_battery',
|
||||
}
|
||||
|
||||
/** Group notification types */
|
||||
export enum GroupNotificationTypes {
|
||||
ADD = 'add',
|
||||
INVITE = 'invite',
|
||||
REMOVE = 'remove',
|
||||
LEAVE = 'leave',
|
||||
SUBJECT = 'subject',
|
||||
DESCRIPTION = 'description',
|
||||
PICTURE = 'picture',
|
||||
ANNOUNCE = 'announce',
|
||||
RESTRICT = 'restrict',
|
||||
}
|
||||
|
||||
/** Message ACK */
|
||||
export enum MessageAck {
|
||||
ACK_ERROR = -1,
|
||||
ACK_PENDING = 0,
|
||||
ACK_SERVER = 1,
|
||||
ACK_DEVICE = 2,
|
||||
ACK_READ = 3,
|
||||
ACK_PLAYED = 4,
|
||||
}
|
||||
|
||||
/** Message types */
|
||||
export enum MessageTypes {
|
||||
TEXT = 'chat',
|
||||
AUDIO = 'audio',
|
||||
VOICE = 'ptt',
|
||||
IMAGE = 'image',
|
||||
VIDEO = 'video',
|
||||
DOCUMENT = 'document',
|
||||
STICKER = 'sticker',
|
||||
LOCATION = 'location',
|
||||
CONTACT_CARD = 'vcard',
|
||||
CONTACT_CARD_MULTI = 'multi_vcard',
|
||||
REVOKED = 'revoked',
|
||||
UNKNOWN = 'unknown',
|
||||
}
|
||||
|
||||
/** Client status */
|
||||
export enum Status {
|
||||
INITIALIZING = 0,
|
||||
AUTHENTICATING = 1,
|
||||
READY = 3,
|
||||
}
|
||||
|
||||
/** WhatsApp state */
|
||||
export enum WAState {
|
||||
CONFLICT = 'CONFLICT',
|
||||
CONNECTED = 'CONNECTED',
|
||||
DEPRECATED_VERSION = 'DEPRECATED_VERSION',
|
||||
OPENING = 'OPENING',
|
||||
PAIRING = 'PAIRING',
|
||||
PROXYBLOCK = 'PROXYBLOCK',
|
||||
SMB_TOS_BLOCK = 'SMB_TOS_BLOCK',
|
||||
TIMEOUT = 'TIMEOUT',
|
||||
TOS_BLOCK = 'TOS_BLOCK',
|
||||
UNLAUNCHED = 'UNLAUNCHED',
|
||||
UNPAIRED = 'UNPAIRED',
|
||||
UNPAIRED_IDLE = 'UNPAIRED_IDLE',
|
||||
}
|
||||
|
||||
export type MessageInfo = {
|
||||
delivery: Array<{id: ContactId, t: number}>,
|
||||
deliveryRemaining: number,
|
||||
played: Array<{id: ContactId, t: number}>,
|
||||
playedRemaining: number,
|
||||
read: Array<{id: ContactId, t: number}>,
|
||||
readRemaining: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Message on WhatsApp
|
||||
*
|
||||
* @example
|
||||
* {
|
||||
* mediaKey: undefined,
|
||||
* id: {
|
||||
* fromMe: false,
|
||||
* remote: `554199999999@c.us`,
|
||||
* id: '1234567890ABCDEFGHIJ',
|
||||
* _serialized: `false_554199999999@c.us_1234567890ABCDEFGHIJ`
|
||||
* },
|
||||
* ack: -1,
|
||||
* hasMedia: false,
|
||||
* body: 'Hello!',
|
||||
* type: 'chat',
|
||||
* timestamp: 1591482682,
|
||||
* from: `554199999999@c.us`,
|
||||
* to: `554188888888@c.us`,
|
||||
* author: undefined,
|
||||
* isForwarded: false,
|
||||
* broadcast: false,
|
||||
* fromMe: false,
|
||||
* hasQuotedMsg: false,
|
||||
* location: undefined,
|
||||
* mentionedIds: []
|
||||
* }
|
||||
*/
|
||||
export interface Message {
|
||||
/** ACK status for the message */
|
||||
ack: MessageAck,
|
||||
/** If the message was sent to a group, this field will contain the user that sent the message. */
|
||||
author?: string,
|
||||
/** Message content */
|
||||
body: string,
|
||||
/** Indicates if the message was a broadcast */
|
||||
broadcast: boolean,
|
||||
/** Indicates if the message was a status update */
|
||||
isStatus: boolean,
|
||||
/** ID for the Chat that this message was sent to, except if the message was sent by the current user */
|
||||
from: string,
|
||||
/** Indicates if the message was sent by the current user */
|
||||
fromMe: boolean,
|
||||
/** Indicates if the message has media available for download */
|
||||
hasMedia: boolean,
|
||||
/** Indicates if the message was sent as a reply to another message */
|
||||
hasQuotedMsg: boolean,
|
||||
/** ID that represents the message */
|
||||
id: MessageId,
|
||||
/** Indicates if the message was forwarded */
|
||||
isForwarded: boolean,
|
||||
/** Indicates if the message was starred */
|
||||
isStarred: boolean,
|
||||
/** Location information contained in the message, if the message is type "location" */
|
||||
location: Location,
|
||||
/** List of vCards contained in the message */
|
||||
vCards: string[],
|
||||
/** MediaKey that represents the sticker 'ID' */
|
||||
mediaKey?: string,
|
||||
/** Indicates the mentions in the message body. */
|
||||
mentionedIds: [],
|
||||
/** Unix timestamp for when the message was created */
|
||||
timestamp: number,
|
||||
/**
|
||||
* ID for who this message is for.
|
||||
* If the message is sent by the current user, it will be the Chat to which the message is being sent.
|
||||
* If the message is sent by another user, it will be the ID for the current user.
|
||||
*/
|
||||
to: string,
|
||||
/** Message type */
|
||||
type: MessageTypes,
|
||||
/** Links included in the message. */
|
||||
links: string[],
|
||||
|
||||
/** Deletes the message from the chat */
|
||||
delete: (everyone?: boolean) => Promise<void>,
|
||||
/** Downloads and returns the attatched message media */
|
||||
downloadMedia: () => Promise<MessageMedia>,
|
||||
/** Returns the Chat this message was sent in */
|
||||
getChat: () => Promise<Chat>,
|
||||
/** Returns the Contact this message was sent from */
|
||||
getContact: () => Promise<Contact>,
|
||||
/** Returns the Contacts mentioned in this message */
|
||||
getMentions: () => Promise<Contact[]>,
|
||||
/** Returns the quoted message, if any */
|
||||
getQuotedMessage: () => Promise<Message>,
|
||||
/**
|
||||
* Sends a message as a reply to this message.
|
||||
* If chatId is specified, it will be sent through the specified Chat.
|
||||
* If not, it will send the message in the same Chat as the original message was sent.
|
||||
*/
|
||||
reply: (content: MessageContent, chatId?: string, options?: MessageSendOptions) => Promise<Message>,
|
||||
/**
|
||||
* Forwards this message to another chat
|
||||
*/
|
||||
forward: (chat: Chat | string) => Promise<void>,
|
||||
/** Star this message */
|
||||
star: () => Promise<void>,
|
||||
/** Unstar this message */
|
||||
unstar: () => Promise<void>,
|
||||
/** Get information about message delivery statuso */
|
||||
getInfo: () => Promise<MessageInfo | null>
|
||||
}
|
||||
|
||||
/** ID that represents a message */
|
||||
export interface MessageId {
|
||||
fromMe: boolean,
|
||||
remote: string,
|
||||
id: string,
|
||||
_serialized: string,
|
||||
}
|
||||
|
||||
export interface Location {
|
||||
description?: string | null,
|
||||
latitude: string,
|
||||
longitude: string,
|
||||
}
|
||||
|
||||
export interface Label {
|
||||
/** Label name */
|
||||
name: string,
|
||||
/** Label ID */
|
||||
id: string,
|
||||
/** Color assigned to the label */
|
||||
hexColor: string,
|
||||
|
||||
/** Get all chats that have been assigned this Label */
|
||||
getChats: () => Promise<Chat[]>
|
||||
}
|
||||
|
||||
/** Options for sending a message */
|
||||
export interface MessageSendOptions {
|
||||
/** Show links preview */
|
||||
linkPreview?: boolean
|
||||
/** Send audio as voice message */
|
||||
sendAudioAsVoice?: boolean
|
||||
/** Send media as sticker */
|
||||
sendMediaAsSticker?: boolean
|
||||
/** Send media as document */
|
||||
sendMediaAsDocument?: boolean
|
||||
/** Automatically parse vCards and send them as contacts */
|
||||
parseVCards?: boolean
|
||||
/** Image or videos caption */
|
||||
caption?: string
|
||||
/** Id of the message that is being quoted (or replied to) */
|
||||
quotedMessageId?: string
|
||||
/** Contacts that are being mentioned in the message */
|
||||
mentions?: Contact[]
|
||||
/** Send 'seen' status */
|
||||
sendSeen?: boolean
|
||||
/** Media to be sent */
|
||||
media?: MessageMedia
|
||||
}
|
||||
|
||||
/** Media attached to a message */
|
||||
export class MessageMedia {
|
||||
/** MIME type of the attachment */
|
||||
mimetype: string
|
||||
/** Base64-encoded data of the file */
|
||||
data: string
|
||||
/** Document file name. Value can be null */
|
||||
filename?: string | null
|
||||
|
||||
/**
|
||||
* @param {string} mimetype MIME type of the attachment
|
||||
* @param {string} data Base64-encoded data of the file
|
||||
* @param {?string} filename Document file name. Value can be null
|
||||
*/
|
||||
constructor(mimetype: string, data: string, filename?: string | null)
|
||||
|
||||
/** Creates a MessageMedia instance from a local file path */
|
||||
static fromFilePath: (filePath: string) => MessageMedia
|
||||
}
|
||||
|
||||
export type MessageContent = string | MessageMedia | Location | Contact | Contact[]
|
||||
|
||||
/**
|
||||
* Represents a Contact on WhatsApp
|
||||
*
|
||||
* @example
|
||||
* {
|
||||
* id: {
|
||||
* server: 'c.us',
|
||||
* user: '554199999999',
|
||||
* _serialized: `554199999999@c.us`
|
||||
* },
|
||||
* number: '554199999999',
|
||||
* isBusiness: false,
|
||||
* isEnterprise: false,
|
||||
* labels: [],
|
||||
* name: undefined,
|
||||
* pushname: 'John',
|
||||
* sectionHeader: undefined,
|
||||
* shortName: undefined,
|
||||
* statusMute: false,
|
||||
* type: 'in',
|
||||
* verifiedLevel: undefined,
|
||||
* verifiedName: undefined,
|
||||
* isMe: false,
|
||||
* isUser: true,
|
||||
* isGroup: false,
|
||||
* isWAContact: true,
|
||||
* isMyContact: false
|
||||
* }
|
||||
*/
|
||||
export interface Contact {
|
||||
/** Contact's phone number */
|
||||
number: string,
|
||||
/** Indicates if the contact is a business contact */
|
||||
isBusiness: boolean,
|
||||
/** ID that represents the contact */
|
||||
id: ContactId,
|
||||
/** Indicates if the contact is an enterprise contact */
|
||||
isEnterprise: boolean,
|
||||
/** Indicates if the contact is a group contact */
|
||||
isGroup: boolean,
|
||||
/** Indicates if the contact is the current user's contact */
|
||||
isMe: boolean,
|
||||
/** Indicates if the number is saved in the current phone's contacts */
|
||||
isMyContact: boolean
|
||||
/** Indicates if the contact is a user contact */
|
||||
isUser: boolean,
|
||||
/** Indicates if the number is registered on WhatsApp */
|
||||
isWAContact: boolean,
|
||||
/** Indicates if you have blocked this contact */
|
||||
isBlocked: boolean,
|
||||
/** @todo verify labels type. didn't have any documentation */
|
||||
labels?: string[],
|
||||
/** The contact's name, as saved by the current user */
|
||||
name?: string,
|
||||
/** The name that the contact has configured to be shown publically */
|
||||
pushname: string,
|
||||
/** @todo missing documentation */
|
||||
sectionHeader: string,
|
||||
/** A shortened version of name */
|
||||
shortName?: string,
|
||||
/** Indicates if the status from the contact is muted */
|
||||
statusMute: boolean,
|
||||
/** @todo missing documentation */
|
||||
type: string,
|
||||
/** @todo missing documentation */
|
||||
verifiedLevel?: undefined,
|
||||
/** @todo missing documentation */
|
||||
verifiedName?: undefined,
|
||||
|
||||
/** Returns the contact's profile picture URL, if privacy settings allow it */
|
||||
getProfilePicUrl: () => Promise<string>,
|
||||
|
||||
/** Returns the Chat that corresponds to this Contact.
|
||||
* Will return null when getting chat for currently logged in user.
|
||||
*/
|
||||
getChat: () => Promise<Chat>,
|
||||
|
||||
/** Blocks this contact from WhatsApp */
|
||||
block: () => Promise<boolean>,
|
||||
/** Unlocks this contact from WhatsApp */
|
||||
unblock: () => Promise<boolean>,
|
||||
|
||||
/** Gets the Contact's current "about" info. Returns null if you don't have permission to read their status. */
|
||||
getAbout: () => Promise<string | null>,
|
||||
|
||||
}
|
||||
|
||||
export interface ContactId {
|
||||
server: string,
|
||||
user: string,
|
||||
_serialized: string,
|
||||
}
|
||||
|
||||
export interface BusinessContact extends Contact {
|
||||
/**
|
||||
* The contact's business profile
|
||||
* @todo add a more specific type for the object
|
||||
*/
|
||||
businessProfile: object
|
||||
}
|
||||
|
||||
export interface PrivateContact extends Contact {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Chat on WhatsApp
|
||||
*
|
||||
* @example
|
||||
* {
|
||||
* id: {
|
||||
* server: 'c.us',
|
||||
* user: '554199999999',
|
||||
* _serialized: `554199999999@c.us`
|
||||
* },
|
||||
* name: '+55 41 9999-9999',
|
||||
* isGroup: false,
|
||||
* isReadOnly: false,
|
||||
* unreadCount: 6,
|
||||
* timestamp: 1591484087,
|
||||
* archived: false
|
||||
* }
|
||||
*/
|
||||
export interface Chat {
|
||||
/** Indicates if the Chat is archived */
|
||||
archived: boolean,
|
||||
/** ID that represents the chat */
|
||||
id: ChatId,
|
||||
/** Indicates if the Chat is a Group Chat */
|
||||
isGroup: boolean,
|
||||
/** Indicates if the Chat is readonly */
|
||||
isReadOnly: boolean,
|
||||
/** Indicates if the Chat is muted */
|
||||
isMuted: boolean,
|
||||
/** Unix timestamp for when the mute expires */
|
||||
muteExpiration: number,
|
||||
/** Title of the chat */
|
||||
name: string,
|
||||
/** Unix timestamp for when the last activity occurred */
|
||||
timestamp: number,
|
||||
/** Amount of messages unread */
|
||||
unreadCount: number,
|
||||
|
||||
/** Archives this chat */
|
||||
archive: () => Promise<void>,
|
||||
/** Pins this chat and returns its new Pin state */
|
||||
pin: () => Promise<boolean>,
|
||||
/** Unpins this chat and returns its new Pin state */
|
||||
unpin: () => Promise<boolean>,
|
||||
/** Clears all messages from the chat */
|
||||
clearMessages: () => Promise<boolean>,
|
||||
/** Stops typing or recording in chat immediately. */
|
||||
clearState: () => Promise<boolean>,
|
||||
/** Deletes the chat */
|
||||
delete: () => Promise<boolean>,
|
||||
/** Loads chat messages, sorted from earliest to latest. */
|
||||
fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>,
|
||||
/** Mutes this chat until a specified date */
|
||||
mute: (unmuteDate: Date) => Promise<void>,
|
||||
/** Send a message to this chat */
|
||||
sendMessage: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
|
||||
/** Set the message as seen */
|
||||
sendSeen: () => Promise<void>,
|
||||
/** Simulate recording audio in chat. This will last for 25 seconds */
|
||||
sendStateRecording: () => Promise<void>,
|
||||
/** Simulate typing in chat. This will last for 25 seconds. */
|
||||
sendStateTyping: () => Promise<void>,
|
||||
/** un-archives this chat */
|
||||
unarchive: () => Promise<void>,
|
||||
/** Unmutes this chat */
|
||||
unmute: () => Promise<void>,
|
||||
/** Returns the Contact that corresponds to this Chat. */
|
||||
getContact: () => Promise<Contact>,
|
||||
/** Marks this Chat as unread */
|
||||
markUnread: () => Promise<void>
|
||||
/** Returns array of all Labels assigned to this Chat */
|
||||
getLabels: () => Promise<Label[]>
|
||||
}
|
||||
|
||||
export interface MessageSearchOptions {
|
||||
/**
|
||||
* The amount of messages to return.
|
||||
* Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation.
|
||||
* Set this to Infinity to load all messages.
|
||||
* @default 50
|
||||
*/
|
||||
limit?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Id that represents the chat
|
||||
*
|
||||
* @example
|
||||
* id: {
|
||||
* server: 'c.us',
|
||||
* user: '554199999999',
|
||||
* _serialized: `554199999999@c.us`
|
||||
* },
|
||||
*/
|
||||
export interface ChatId {
|
||||
/**
|
||||
* Whatsapp server domain
|
||||
* @example `c.us`
|
||||
*/
|
||||
server: string,
|
||||
/**
|
||||
* User whatsapp number
|
||||
* @example `554199999999`
|
||||
*/
|
||||
user: string,
|
||||
/**
|
||||
* Serialized id
|
||||
* @example `554199999999@c.us`
|
||||
*/
|
||||
_serialized: string,
|
||||
}
|
||||
|
||||
export interface PrivateChat extends Chat {
|
||||
|
||||
}
|
||||
|
||||
export type GroupParticipant = {
|
||||
id: ContactId,
|
||||
isAdmin: boolean
|
||||
isSuperAdmin: boolean
|
||||
}
|
||||
|
||||
/** Promotes or demotes participants by IDs to regular users or admins */
|
||||
export type ChangeParticipantsPermisions =
|
||||
(participantIds: Array<string>) => Promise<{ status: number }>
|
||||
|
||||
/** Adds or removes a list of participants by ID to the group */
|
||||
export type ChangeGroupParticipants =
|
||||
(participantIds: Array<string>) => Promise<{
|
||||
status: number;
|
||||
participants: Array<{
|
||||
[key: string]: {
|
||||
code: number
|
||||
}
|
||||
}>
|
||||
} & {
|
||||
[key: string]: number;
|
||||
}>
|
||||
|
||||
export interface GroupChat extends Chat {
|
||||
/** Group owner */
|
||||
owner: ContactId;
|
||||
/** Date at which the group was created */
|
||||
createdAt: Date;
|
||||
/** Group description */
|
||||
description: string;
|
||||
/** Group participants */
|
||||
participants: Array<GroupParticipant>;
|
||||
/** Adds a list of participants by ID to the group */
|
||||
addParticipants: ChangeGroupParticipants;
|
||||
/** Removes a list of participants by ID to the group */
|
||||
removeParticipants: ChangeGroupParticipants;
|
||||
/** Promotes participants by IDs to admins */
|
||||
promoteParticipants: ChangeParticipantsPermisions;
|
||||
/** Demotes participants by IDs to regular users */
|
||||
demoteParticipants: ChangeParticipantsPermisions;
|
||||
/** Updates the group subject */
|
||||
setSubject: (subject: string) => Promise<void>;
|
||||
/** Updates the group description */
|
||||
setDescription: (description: string) => Promise<void>;
|
||||
/** Updates the group settings to only allow admins to send messages
|
||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
setMessagesAdminsOnly: (adminsOnly?: boolean) => Promise<boolean>;
|
||||
/**
|
||||
* Updates the group settings to only allow admins to edit group info (title, description, photo).
|
||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
setInfoAdminsOnly: (adminsOnly?: boolean) => Promise<boolean>;
|
||||
/** Gets the invite code for a specific group */
|
||||
getInviteCode: () => Promise<string>;
|
||||
/** Invalidates the current group invite code and generates a new one */
|
||||
revokeInvite: () => Promise<void>;
|
||||
/** Makes the bot leave the group */
|
||||
leave: () => Promise<void>;
|
||||
}
|
||||
}
|
||||
|
||||
export = WAWebJS
|
||||
8
index.js
8
index.js
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Constants = require('./src/util/Constants');
|
||||
|
||||
module.exports = {
|
||||
Client: require('./src/Client'),
|
||||
|
||||
@@ -15,5 +17,7 @@ module.exports = {
|
||||
PrivateContact: require('./src/structures/PrivateContact'),
|
||||
BusinessContact: require('./src/structures/BusinessContact'),
|
||||
ClientInfo: require('./src/structures/ClientInfo'),
|
||||
Location: require('./src/structures/Location')
|
||||
};
|
||||
Location: require('./src/structures/Location'),
|
||||
|
||||
...Constants
|
||||
};
|
||||
|
||||
1617
package-lock.json
generated
1617
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@@ -1,10 +1,12 @@
|
||||
{
|
||||
"name": "whatsapp-web.js",
|
||||
"version": "1.2.1",
|
||||
"version": "1.12.6",
|
||||
"description": "Library for interacting with the WhatsApp Web API ",
|
||||
"main": "./index.js",
|
||||
"typings": "./index.d.ts",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"shell": "node --experimental-repl-await ./shell.js",
|
||||
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
|
||||
},
|
||||
"repository": {
|
||||
@@ -24,15 +26,18 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/pedroslopez/whatsapp-web.js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pedroslopez/whatsapp-web.js#readme",
|
||||
"homepage": "https://waguide.pedroslopez.me/",
|
||||
"dependencies": {
|
||||
"jsqr": "^1.2.0",
|
||||
"moduleraid": "git+https://github.com/pixeldesu/moduleRaid.git",
|
||||
"puppeteer": "^2.1.1"
|
||||
"@pedroslopez/moduleraid": "^5.0.0",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"jsqr": "^1.3.1",
|
||||
"mime": "^2.4.5",
|
||||
"puppeteer": "^5.2.1",
|
||||
"sharp": "^0.26.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.8.0",
|
||||
"jsdoc": "^3.6.3",
|
||||
"jsdoc": "^3.6.4",
|
||||
"jsdoc-baseline": "^0.1.5"
|
||||
}
|
||||
}
|
||||
|
||||
39
shell.js
Normal file
39
shell.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* ==== wwebjs-shell ====
|
||||
* Used for quickly testing library features
|
||||
*
|
||||
* Running `npm run shell` will start WhatsApp Web in headless mode
|
||||
* and then drop you into Node REPL with `client` in its context.
|
||||
*/
|
||||
|
||||
const repl = require('repl');
|
||||
const fs = require('fs');
|
||||
|
||||
const { Client } = require('./index');
|
||||
|
||||
const SESSION_FILE_PATH = './session.json';
|
||||
let sessionCfg;
|
||||
if (fs.existsSync(SESSION_FILE_PATH)) {
|
||||
sessionCfg = require(SESSION_FILE_PATH);
|
||||
}
|
||||
|
||||
const client = new Client({
|
||||
puppeteer: { headless: false },
|
||||
session: sessionCfg
|
||||
});
|
||||
|
||||
console.log('Initializing...');
|
||||
|
||||
client.initialize();
|
||||
|
||||
client.on('qr', () => {
|
||||
console.log('Please scan the QR code on the browser.');
|
||||
});
|
||||
|
||||
client.on('ready', () => {
|
||||
const shell = repl.start('wwebjs> ');
|
||||
shell.context.client = client;
|
||||
shell.on('exit', async () => {
|
||||
await client.destroy();
|
||||
});
|
||||
});
|
||||
483
src/Client.js
483
src/Client.js
@@ -2,18 +2,35 @@
|
||||
|
||||
const EventEmitter = require('events');
|
||||
const puppeteer = require('puppeteer');
|
||||
const moduleRaid = require('moduleraid/moduleraid');
|
||||
const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
|
||||
const jsQR = require('jsqr');
|
||||
|
||||
const Util = require('./util/Util');
|
||||
const { WhatsWebURL, UserAgent, DefaultOptions, Events, WAState } = require('./util/Constants');
|
||||
const InterfaceController = require('./util/InterfaceController');
|
||||
const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./util/Constants');
|
||||
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
||||
const ChatFactory = require('./factories/ChatFactory');
|
||||
const ContactFactory = require('./factories/ContactFactory');
|
||||
const { ClientInfo, Message, MessageMedia, Location, GroupNotification } = require('./structures');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label } = require('./structures');
|
||||
/**
|
||||
* Starting point for interacting with the WhatsApp Web API
|
||||
* @extends {EventEmitter}
|
||||
* @param {object} options - Client options
|
||||
* @param {number} options.authTimeoutMs - Timeout for authentication selector in puppeteer
|
||||
* @param {object} options.puppeteer - Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/
|
||||
* @param {number} options.qrRefreshIntervalMs - Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
|
||||
* @param {number} options.qrTimeoutMs - Timeout for qr code selector in puppeteer
|
||||
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
|
||||
* @param {string} options.session.WABrowserId
|
||||
* @param {string} options.session.WASecretBundle
|
||||
* @param {string} options.session.WAToken1
|
||||
* @param {string} options.session.WAToken2
|
||||
* @param {number} options.takeoverOnConflict - If another whatsapp web session is detected (another browser), take over the session in the current browser
|
||||
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
|
||||
* @param {string} options.userAgent - User agent to use in puppeteer
|
||||
* @param {string} options.ffmpegPath - Ffmpeg path to use when formating videos to webp while sending stickers
|
||||
*
|
||||
* @fires Client#qr
|
||||
* @fires Client#authenticated
|
||||
* @fires Client#auth_failure
|
||||
@@ -23,11 +40,13 @@ const { ClientInfo, Message, MessageMedia, Location, GroupNotification } = requi
|
||||
* @fires Client#message_create
|
||||
* @fires Client#message_revoke_me
|
||||
* @fires Client#message_revoke_everyone
|
||||
* @fires Client#media_uploaded
|
||||
* @fires Client#group_join
|
||||
* @fires Client#group_leave
|
||||
* @fires Client#group_update
|
||||
* @fires Client#disconnected
|
||||
* @fires Client#change_state
|
||||
* @fires Client#change_battery
|
||||
*/
|
||||
class Client extends EventEmitter {
|
||||
constructor(options = {}) {
|
||||
@@ -37,6 +56,8 @@ class Client extends EventEmitter {
|
||||
|
||||
this.pupBrowser = null;
|
||||
this.pupPage = null;
|
||||
|
||||
Util.setFfmpegPath(this.options.ffmpegPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +66,10 @@ class Client extends EventEmitter {
|
||||
async initialize() {
|
||||
const browser = await puppeteer.launch(this.options.puppeteer);
|
||||
const page = (await browser.pages())[0];
|
||||
page.setUserAgent(UserAgent);
|
||||
page.setUserAgent(this.options.userAgent);
|
||||
|
||||
this.pupBrowser = browser;
|
||||
this.pupPage = page;
|
||||
|
||||
if (this.options.session) {
|
||||
await page.evaluateOnNewDocument(
|
||||
@@ -58,14 +82,17 @@ class Client extends EventEmitter {
|
||||
}, this.options.session);
|
||||
}
|
||||
|
||||
await page.goto(WhatsWebURL);
|
||||
await page.goto(WhatsWebURL, {
|
||||
waitUntil: 'load',
|
||||
timeout: 0,
|
||||
});
|
||||
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image="true"]';
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||
|
||||
if (this.options.session) {
|
||||
// Check if session restore was successfull
|
||||
try {
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 15000 });
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: this.options.authTimeoutMs });
|
||||
} catch (err) {
|
||||
if (err.name === 'TimeoutError') {
|
||||
/**
|
||||
@@ -75,7 +102,11 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATION_FAILURE, 'Unable to log in. Are the session details valid?');
|
||||
browser.close();
|
||||
|
||||
if (this.options.restartOnAuthFail) {
|
||||
// session restore failed so try again but without session to force new authentication
|
||||
this.options.session = null;
|
||||
this.initialize();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,18 +116,18 @@ class Client extends EventEmitter {
|
||||
} else {
|
||||
const getQrCode = async () => {
|
||||
// Check if retry button is present
|
||||
var QR_RETRY_SELECTOR = 'div[data-ref] > span > div';
|
||||
var QR_RETRY_SELECTOR = 'div[data-ref] > span > button';
|
||||
var qrRetry = await page.$(QR_RETRY_SELECTOR);
|
||||
if (qrRetry) {
|
||||
await qrRetry.click();
|
||||
}
|
||||
|
||||
// Wait for QR Code
|
||||
|
||||
const QR_CANVAS_SELECTOR = 'canvas';
|
||||
await page.waitForSelector(QR_CANVAS_SELECTOR);
|
||||
await page.waitForSelector(QR_CANVAS_SELECTOR, { timeout: this.options.qrTimeoutMs });
|
||||
const qrImgData = await page.$eval(QR_CANVAS_SELECTOR, canvas => [].slice.call(canvas.getContext('2d').getImageData(0, 0, 264, 264).data));
|
||||
const qr = jsQR(qrImgData, 264, 264).data;
|
||||
|
||||
/**
|
||||
* Emitted when the QR code is received
|
||||
* @event Client#qr
|
||||
@@ -105,11 +136,12 @@ class Client extends EventEmitter {
|
||||
this.emit(Events.QR_RECEIVED, qr);
|
||||
};
|
||||
getQrCode();
|
||||
let retryInterval = setInterval(getQrCode, 20000); // check for qr code every 20 seconds
|
||||
this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
|
||||
|
||||
// Wait for code scan
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||
clearInterval(retryInterval);
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
this._qrRefreshInterval = undefined;
|
||||
|
||||
}
|
||||
|
||||
@@ -131,6 +163,10 @@ class Client extends EventEmitter {
|
||||
* Emitted when authentication is successful
|
||||
* @event Client#authenticated
|
||||
* @param {object} session Object containing session information. Can be used to restore the session.
|
||||
* @param {string} session.WABrowserId
|
||||
* @param {string} session.WASecretBundle
|
||||
* @param {string} session.WAToken1
|
||||
* @param {string} session.WAToken2
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATED, session);
|
||||
|
||||
@@ -141,10 +177,17 @@ class Client extends EventEmitter {
|
||||
await page.evaluate(LoadUtils);
|
||||
|
||||
// Expose client info
|
||||
/**
|
||||
* Current connection information
|
||||
* @type {ClientInfo}
|
||||
*/
|
||||
this.info = new ClientInfo(this, await page.evaluate(() => {
|
||||
return window.Store.Conn.serialize();
|
||||
}));
|
||||
|
||||
// Add InterfaceController
|
||||
this.interface = new InterfaceController(this);
|
||||
|
||||
// Register events
|
||||
await page.exposeFunction('onAddMessageEvent', msg => {
|
||||
if (!msg.isNewMsg) return;
|
||||
@@ -175,7 +218,7 @@ class Client extends EventEmitter {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
||||
/**
|
||||
@@ -244,7 +287,7 @@ class Client extends EventEmitter {
|
||||
await page.exposeFunction('onMessageAckEvent', (msg, ack) => {
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
||||
|
||||
/**
|
||||
* Emitted when an ack event occurrs on message type.
|
||||
* @event Client#message_ack
|
||||
@@ -255,7 +298,19 @@ class Client extends EventEmitter {
|
||||
|
||||
});
|
||||
|
||||
await page.exposeFunction('onAppStateChangedEvent', (_AppState, state) => {
|
||||
await page.exposeFunction('onMessageMediaUploadedEvent', (msg) => {
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
||||
/**
|
||||
* Emitted when media has been uploaded for a message sent by the client.
|
||||
* @event Client#media_uploaded
|
||||
* @param {Message} message The message with media that was uploaded
|
||||
*/
|
||||
this.emit(Events.MEDIA_UPLOADED, message);
|
||||
});
|
||||
|
||||
await page.exposeFunction('onAppStateChangedEvent', (state) => {
|
||||
|
||||
/**
|
||||
* Emitted when the connection state changes
|
||||
@@ -265,42 +320,97 @@ class Client extends EventEmitter {
|
||||
this.emit(Events.STATE_CHANGED, state);
|
||||
|
||||
const ACCEPTED_STATES = [WAState.CONNECTED, WAState.OPENING, WAState.PAIRING, WAState.TIMEOUT];
|
||||
|
||||
if (this.options.takeoverOnConflict) {
|
||||
ACCEPTED_STATES.push(WAState.CONFLICT);
|
||||
|
||||
if (state === WAState.CONFLICT) {
|
||||
setTimeout(() => {
|
||||
this.pupPage.evaluate(() => window.Store.AppState.takeover());
|
||||
}, this.options.takeoverTimeoutMs);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ACCEPTED_STATES.includes(state)) {
|
||||
/**
|
||||
* Emitted when the client has been disconnected
|
||||
* @event Client#disconnected
|
||||
* @param {WAState} reason state that caused the disconnect
|
||||
* @param {WAState|"NAVIGATION"} reason reason that caused the disconnect
|
||||
*/
|
||||
this.emit(Events.DISCONNECTED, state);
|
||||
this.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
await page.evaluate(() => {
|
||||
window.Store.Msg.on('add', window.onAddMessageEvent);
|
||||
window.Store.Msg.on('change', window.onChangeMessageEvent);
|
||||
window.Store.Msg.on('change:type', window.onChangeMessageTypeEvent);
|
||||
window.Store.Msg.on('change:ack', window.onMessageAckEvent);
|
||||
window.Store.Msg.on('remove', window.onRemoveMessageEvent);
|
||||
window.Store.AppState.on('change:state', window.onAppStateChangedEvent);
|
||||
await page.exposeFunction('onBatteryStateChangedEvent', (state) => {
|
||||
const { battery, plugged } = state;
|
||||
|
||||
if (battery === undefined) return;
|
||||
|
||||
/**
|
||||
* Emitted when the battery percentage for the attached device changes
|
||||
* @event Client#change_battery
|
||||
* @param {object} batteryInfo
|
||||
* @param {number} batteryInfo.battery - The current battery percentage
|
||||
* @param {boolean} batteryInfo.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||
*/
|
||||
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
|
||||
});
|
||||
|
||||
this.pupBrowser = browser;
|
||||
this.pupPage = page;
|
||||
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); });
|
||||
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if (msg.id.fromMe && !unsent) window.onMessageMediaUploadedEvent(window.WWebJS.getMessageModel(msg)); });
|
||||
window.Store.Msg.on('remove', (msg) => { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
||||
window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); });
|
||||
window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); });
|
||||
});
|
||||
|
||||
/**
|
||||
* Emitted when the client has initialized and is ready to receive messages.
|
||||
* @event Client#ready
|
||||
*/
|
||||
this.emit(Events.READY);
|
||||
|
||||
// Disconnect when navigating away
|
||||
// Because WhatsApp Web now reloads when logging out from the device, this also covers that case
|
||||
this.pupPage.on('framenavigated', async () => {
|
||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||
await this.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the client
|
||||
*/
|
||||
async destroy() {
|
||||
if (this._qrRefreshInterval) {
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
}
|
||||
await this.pupBrowser.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the client, closing the current session
|
||||
*/
|
||||
async logout() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Store.AppState.logout();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of WhatsApp Web currently being run
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getWWebVersion() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Debug.VERSION;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark as seen for the Chat
|
||||
* @param {string} chatId
|
||||
@@ -314,20 +424,42 @@ class Client extends EventEmitter {
|
||||
}, chatId);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message options.
|
||||
* @typedef {Object} MessageSendOptions
|
||||
* @property {boolean} [linkPreview=true] - Show links preview
|
||||
* @property {boolean} [sendAudioAsVoice=false] - Send audio as voice message
|
||||
* @property {boolean} [sendMediaAsSticker=false] - Send media as a sticker
|
||||
* @property {boolean} [sendMediaAsDocument=false] - Send media as a document
|
||||
* @property {boolean} [parseVCards=true] - Automatically parse vCards and send them as contacts
|
||||
* @property {string} [caption] - Image or video caption
|
||||
* @property {string} [quotedMessageId] - Id of the message that is being quoted (or replied to)
|
||||
* @property {Contact[]} [mentions] - Contacts that are being mentioned in the message
|
||||
* @property {boolean} [sendSeen=true] - Mark the conversation as seen after sending the message
|
||||
* @property {MessageMedia} [media] - Media to be sent
|
||||
*/
|
||||
|
||||
/**
|
||||
* Send a message to a specific chatId
|
||||
* @param {string} chatId
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {object} options
|
||||
* @param {string|MessageMedia|Location|Contact|Array<Contact>} content
|
||||
* @param {MessageSendOptions} [options] - Options used when sending the message
|
||||
*
|
||||
* @returns {Promise<Message>} Message that was just sent
|
||||
*/
|
||||
async sendMessage(chatId, content, options = {}) {
|
||||
let internalOptions = {
|
||||
linkPreview: options.linkPreview === false ? undefined : true,
|
||||
sendAudioAsVoice: options.sendAudioAsVoice,
|
||||
sendMediaAsSticker: options.sendMediaAsSticker,
|
||||
sendMediaAsDocument: options.sendMediaAsDocument,
|
||||
caption: options.caption,
|
||||
quotedMessageId: options.quotedMessageId,
|
||||
parseVCards: options.parseVCards === false ? false : true,
|
||||
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : []
|
||||
};
|
||||
|
||||
|
||||
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
||||
|
||||
if (content instanceof MessageMedia) {
|
||||
@@ -336,38 +468,31 @@ class Client extends EventEmitter {
|
||||
} else if (options.media instanceof MessageMedia) {
|
||||
internalOptions.attachment = options.media;
|
||||
internalOptions.caption = content;
|
||||
content = '';
|
||||
} else if (content instanceof Location) {
|
||||
internalOptions.location = content;
|
||||
content = '';
|
||||
} else if(content instanceof Contact) {
|
||||
internalOptions.contactCard = content.id._serialized;
|
||||
content = '';
|
||||
} else if(Array.isArray(content) && content.length > 0 && content[0] instanceof Contact) {
|
||||
internalOptions.contactCardList = content.map(contact => contact.id._serialized);
|
||||
content = '';
|
||||
}
|
||||
|
||||
if (internalOptions.sendMediaAsSticker && internalOptions.attachment) {
|
||||
internalOptions.attachment = await Util.formatToWebpSticker(internalOptions.attachment);
|
||||
}
|
||||
|
||||
const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
let msg;
|
||||
if (!chat) { // The chat is not available in the previously chatted list
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = await window.Store.Chat.find(chatWid);
|
||||
|
||||
let newChatId = await window.WWebJS.getNumberId(chatId);
|
||||
if (newChatId) {
|
||||
//get the topmost chat object and assign the new chatId to it .
|
||||
//This is just a workaround.May cause problem if there are no chats at all. Need to dig in and emulate how whatsapp web does
|
||||
let chat = window.Store.Chat.models[0];
|
||||
if (!chat)
|
||||
throw 'Chat List empty! Need at least one open conversation with any of your contact';
|
||||
|
||||
let originalChatObjId = chat.id;
|
||||
chat.id = newChatId;
|
||||
|
||||
msg = await window.WWebJS.sendMessage(chat, message, options);
|
||||
chat.id = originalChatObjId; //replace the chat with its original id
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(sendSeen) {
|
||||
window.WWebJS.sendSeen(chatId);
|
||||
}
|
||||
|
||||
msg = await window.WWebJS.sendMessage(chat, message, options, sendSeen);
|
||||
if (sendSeen) {
|
||||
window.WWebJS.sendSeen(chatId);
|
||||
}
|
||||
|
||||
const msg = await window.WWebJS.sendMessage(chat, message, options, sendSeen);
|
||||
return msg.serialize();
|
||||
}, chatId, content, internalOptions, sendSeen);
|
||||
|
||||
@@ -379,8 +504,8 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise<Array<Chat>>}
|
||||
*/
|
||||
async getChats() {
|
||||
let chats = await this.pupPage.evaluate(() => {
|
||||
return window.WWebJS.getChats();
|
||||
let chats = await this.pupPage.evaluate(async () => {
|
||||
return await window.WWebJS.getChats();
|
||||
});
|
||||
|
||||
return chats.map(chat => ChatFactory.create(this, chat));
|
||||
@@ -392,8 +517,8 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise<Chat>}
|
||||
*/
|
||||
async getChatById(chatId) {
|
||||
let chat = await this.pupPage.evaluate(chatId => {
|
||||
return window.WWebJS.getChat(chatId);
|
||||
let chat = await this.pupPage.evaluate(async chatId => {
|
||||
return await window.WWebJS.getChat(chatId);
|
||||
}, chatId);
|
||||
|
||||
return ChatFactory.create(this, chat);
|
||||
@@ -424,9 +549,21 @@ class Client extends EventEmitter {
|
||||
return ContactFactory.create(this, contact);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object with information about the invite code's group
|
||||
* @param {string} inviteCode
|
||||
* @returns {Promise<object>} Invite information
|
||||
*/
|
||||
async getInviteInfo(inviteCode) {
|
||||
return await this.pupPage.evaluate(inviteCode => {
|
||||
return window.Store.Wap.groupInviteInfo(inviteCode);
|
||||
}, inviteCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts an invitation to join a group
|
||||
* @param {string} inviteCode Invitation code
|
||||
* @returns {Promise<string>} Id of the joined Chat
|
||||
*/
|
||||
async acceptInvite(inviteCode) {
|
||||
const chatId = await this.pupPage.evaluate(async inviteCode => {
|
||||
@@ -446,6 +583,17 @@ class Client extends EventEmitter {
|
||||
}, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current user's display name.
|
||||
* This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
|
||||
* @param {string} displayName New display name
|
||||
*/
|
||||
async setDisplayName(displayName) {
|
||||
await this.pupPage.evaluate(async displayName => {
|
||||
return await window.Store.Wap.setPushname(displayName);
|
||||
}, displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current connection state for the client
|
||||
* @returns {WAState}
|
||||
@@ -456,6 +604,15 @@ class Client extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the client as online
|
||||
*/
|
||||
async sendPresenceAvailable() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Store.Wap.sendPresenceAvailable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables and returns the archive state of the Chat
|
||||
* @returns {boolean}
|
||||
@@ -480,15 +637,225 @@ class Client extends EventEmitter {
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pins the Chat
|
||||
* @returns {Promise<boolean>} New pin state. Could be false if the max number of pinned chats was reached.
|
||||
*/
|
||||
async pinChat(chatId) {
|
||||
return this.pupPage.evaluate(async chatId => {
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
if (chat.pin) {
|
||||
return true;
|
||||
}
|
||||
const MAX_PIN_COUNT = 3;
|
||||
if (window.Store.Chat.models.length > MAX_PIN_COUNT) {
|
||||
let maxPinned = window.Store.Chat.models[MAX_PIN_COUNT - 1].pin;
|
||||
if (maxPinned) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
await window.Store.Cmd.pinChat(chat, true);
|
||||
return true;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpins the Chat
|
||||
* @returns {Promise<boolean>} New pin state
|
||||
*/
|
||||
async unpinChat(chatId) {
|
||||
return this.pupPage.evaluate(async chatId => {
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
if (!chat.pin) {
|
||||
return false;
|
||||
}
|
||||
await window.Store.Cmd.pinChat(chat, false);
|
||||
return false;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutes the Chat until a specified date
|
||||
* @param {string} chatId ID of the chat that will be muted
|
||||
* @param {Date} unmuteDate Date when the chat will be unmuted
|
||||
*/
|
||||
async muteChat(chatId, unmuteDate) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmutes the Chat
|
||||
* @param {string} chatId ID of the chat that will be unmuted
|
||||
*/
|
||||
async unmuteChat(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.muteChat(chat, false);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the Chat as unread
|
||||
* @param {string} chatId ID of the chat that will be marked as unread
|
||||
*/
|
||||
async markChatUnread(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.markChatUnread(chat, true);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contact ID's profile picture URL, if privacy settings allow it
|
||||
* @param {string} contactId the whatsapp user's ID
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getProfilePicUrl(contactId) {
|
||||
const profilePic = await this.pupPage.evaluate((contactId) => {
|
||||
return window.Store.Wap.profilePicFind(contactId);
|
||||
}, contactId);
|
||||
|
||||
return profilePic ? profilePic.eurl : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force reset of connection state for the client
|
||||
*/
|
||||
async resetState(){
|
||||
async resetState() {
|
||||
await this.pupPage.evaluate(() => {
|
||||
window.Store.AppState.phoneWatchdog.shiftTimer.forceRunNow();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given ID is registered in whatsapp
|
||||
* @param {string} id the whatsapp user's ID
|
||||
* @returns {Promise<Boolean>}
|
||||
*/
|
||||
async isRegisteredUser(id) {
|
||||
return await this.pupPage.evaluate(async (id) => {
|
||||
let result = await window.Store.Wap.queryExist(id);
|
||||
return result.jid !== undefined;
|
||||
}, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the registered WhatsApp ID for a number.
|
||||
* Will return null if the number is not registered on WhatsApp.
|
||||
* @param {string} number Number or ID ("@c.us" will be automatically appended if not specified)
|
||||
* @returns {Promise<Object|null>}
|
||||
*/
|
||||
async getNumberId(number) {
|
||||
if(!number.endsWith('@c.us')) {
|
||||
number += '@c.us';
|
||||
}
|
||||
|
||||
try {
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.WWebJS.getNumberId(numberId);
|
||||
}, number);
|
||||
} catch(_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new group
|
||||
* @param {string} name group title
|
||||
* @param {Array<Contact|string>} participants an array of Contacts or contact IDs to add to the group
|
||||
* @returns {Object} createRes
|
||||
* @returns {string} createRes.gid - ID for the group that was just created
|
||||
* @returns {Object.<string,string>} createRes.missingParticipants - participants that were not added to the group. Keys represent the ID for participant that was not added and its value is a status code that represents the reason why participant could not be added. This is usually 403 if the user's privacy settings don't allow you to add them to groups.
|
||||
*/
|
||||
async createGroup(name, participants) {
|
||||
if (!Array.isArray(participants) || participants.length == 0) {
|
||||
throw 'You need to add at least one other participant to the group';
|
||||
}
|
||||
|
||||
if (participants.every(c => c instanceof Contact)) {
|
||||
participants = participants.map(c => c.id._serialized);
|
||||
}
|
||||
|
||||
const createRes = await this.pupPage.evaluate(async (name, participantIds) => {
|
||||
const res = await window.Store.Wap.createGroup(name, participantIds);
|
||||
console.log(res);
|
||||
if (!res.status === 200) {
|
||||
throw 'An error occurred while creating the group!';
|
||||
}
|
||||
|
||||
return res;
|
||||
}, name, participants);
|
||||
|
||||
const missingParticipants = createRes.participants.reduce(((missing, c) => {
|
||||
const id = Object.keys(c)[0];
|
||||
const statusCode = c[id].code;
|
||||
if (statusCode != 200) return Object.assign(missing, { [id]: statusCode });
|
||||
return missing;
|
||||
}), {});
|
||||
|
||||
return { gid: createRes.gid, missingParticipants };
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all current Labels
|
||||
* @returns {Promise<Array<Label>>}
|
||||
*/
|
||||
async getLabels() {
|
||||
const labels = await this.pupPage.evaluate(async () => {
|
||||
return window.WWebJS.getLabels();
|
||||
});
|
||||
|
||||
return labels.map(data => new Label(this , data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Label instance by ID
|
||||
* @param {string} labelId
|
||||
* @returns {Promise<Label>}
|
||||
*/
|
||||
async getLabelById(labelId) {
|
||||
const label = await this.pupPage.evaluate(async (labelId) => {
|
||||
return window.WWebJS.getLabel(labelId);
|
||||
}, labelId);
|
||||
|
||||
return new Label(this, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Labels assigned to a chat
|
||||
* @param {string} chatId
|
||||
* @returns {Promise<Array<Label>>}
|
||||
*/
|
||||
async getChatLabels(chatId){
|
||||
const labels = await this.pupPage.evaluate(async (chatId) => {
|
||||
return window.WWebJS.getChatLabels(chatId);
|
||||
}, chatId);
|
||||
|
||||
return labels.map(data => new Label(this, data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Chats for a specific Label
|
||||
* @param {string} labelId
|
||||
* @returns {Promise<Array<Chat>>}
|
||||
*/
|
||||
async getChatsByLabelId(labelId){
|
||||
const chatIds = await this.pupPage.evaluate(async (labelId) => {
|
||||
const label = window.Store.Label.get(labelId);
|
||||
const labelItems = label.labelItemCollection.models;
|
||||
return labelItems.reduce((result, item) => {
|
||||
if(item.parentType === 'Chat'){
|
||||
result.push(item.parentId);
|
||||
}
|
||||
return result;
|
||||
},[]);
|
||||
}, labelId);
|
||||
|
||||
return Promise.all(chatIds.map(id => this.getChatById(id)));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
|
||||
@@ -46,7 +46,7 @@ class Chat extends Base {
|
||||
this.unreadCount = data.unreadCount;
|
||||
|
||||
/**
|
||||
* Unix timestamp for when the chat was created
|
||||
* Unix timestamp for when the last activity occurred
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.t;
|
||||
@@ -57,13 +57,31 @@ class Chat extends Base {
|
||||
*/
|
||||
this.archived = data.archive;
|
||||
|
||||
/**
|
||||
* Indicates if the Chat is pinned
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.pinned = !!data.pin;
|
||||
|
||||
/**
|
||||
* Indicates if the chat is muted or not
|
||||
* @type {number}
|
||||
*/
|
||||
this.isMuted = data.isMuted;
|
||||
|
||||
/**
|
||||
* Unix timestamp for when the mute expires
|
||||
* @type {number}
|
||||
*/
|
||||
this.muteExpiration = data.muteExpiration;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to this chat
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {object} options
|
||||
* @param {MessageSendOptions} [options]
|
||||
* @returns {Promise<Message>} Message that was just sent
|
||||
*/
|
||||
async sendMessage(content, options) {
|
||||
@@ -112,6 +130,44 @@ class Chat extends Base {
|
||||
return this.client.unarchiveChat(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pins this chat
|
||||
* @returns {Promise<boolean>} New pin state. Could be false if the max number of pinned chats was reached.
|
||||
*/
|
||||
async pin() {
|
||||
return this.client.pinChat(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpins this chat
|
||||
* @returns {Promise<boolean>} New pin state
|
||||
*/
|
||||
async unpin() {
|
||||
return this.client.unpinChat(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutes this chat until a specified date
|
||||
* @param {Date} unmuteDate Date at which the Chat will be unmuted
|
||||
*/
|
||||
async mute(unmuteDate) {
|
||||
return this.client.muteChat(this.id._serialized, unmuteDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmutes this chat
|
||||
*/
|
||||
async unmute() {
|
||||
return this.client.unmuteChat(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark this chat as unread
|
||||
*/
|
||||
async markUnread(){
|
||||
return this.client.markChatUnread(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads chat messages, sorted from earliest to latest.
|
||||
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
||||
@@ -119,29 +175,30 @@ class Chat extends Base {
|
||||
* @returns {Promise<Array<Message>>}
|
||||
*/
|
||||
async fetchMessages(searchOptions) {
|
||||
if(!searchOptions || !searchOptions.limit) {
|
||||
searchOptions = {limit: 50};
|
||||
if (!searchOptions || !searchOptions.limit) {
|
||||
searchOptions = { limit: 50 };
|
||||
}
|
||||
let messages = await this.client.pupPage.evaluate(async (chatId, limit) => {
|
||||
const msgFilter = m => !m.isNotification; // dont include notification messages
|
||||
|
||||
|
||||
const chat = window.Store.Chat.get(chatId);
|
||||
let msgs = chat.msgs.models.filter(msgFilter);
|
||||
|
||||
while(msgs.length < limit) {
|
||||
|
||||
while (msgs.length < limit) {
|
||||
const loadedMessages = await chat.loadEarlierMsgs();
|
||||
if(!loadedMessages) break;
|
||||
if (!loadedMessages) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
}
|
||||
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
return msgs.splice(msgs.length - limit).map(m => m.serialize());
|
||||
if (msgs.length > limit) msgs = msgs.splice(msgs.length - limit);
|
||||
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
||||
|
||||
}, this.id._serialized, searchOptions.limit);
|
||||
|
||||
return messages.map(m => new Message(this.client, m));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Simulate typing in chat. This will last for 25 seconds.
|
||||
*/
|
||||
@@ -151,7 +208,7 @@ class Chat extends Base {
|
||||
return true;
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Simulate recording audio in chat. This will last for 25 seconds.
|
||||
*/
|
||||
@@ -171,6 +228,22 @@ class Chat extends Base {
|
||||
return true;
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Contact that corresponds to this Chat.
|
||||
* @returns {Promise<Contact>}
|
||||
*/
|
||||
async getContact() {
|
||||
return await this.client.getContactById(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of all Labels assigned to this Chat
|
||||
* @returns {Promise<Array<Label>>}
|
||||
*/
|
||||
async getLabels() {
|
||||
return this.client.getChatLabels(this.id._serialized);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Chat;
|
||||
|
||||
@@ -10,7 +10,7 @@ class ClientInfo extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
@@ -20,11 +20,17 @@ class ClientInfo extends Base {
|
||||
*/
|
||||
this.pushname = data.pushname;
|
||||
|
||||
/**
|
||||
* @type {object}
|
||||
* @deprecated Use .wid instead
|
||||
*/
|
||||
this.me = data.wid;
|
||||
|
||||
/**
|
||||
* Current user ID
|
||||
* @type {object}
|
||||
*/
|
||||
this.me = data.me;
|
||||
this.wid = data.wid;
|
||||
|
||||
/**
|
||||
* Information about the phone this client is connected to
|
||||
@@ -46,6 +52,19 @@ class ClientInfo extends Base {
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current battery percentage and charging status for the attached device
|
||||
* @returns {object} batteryStatus
|
||||
* @returns {number} batteryStatus.battery - The current battery percentage
|
||||
* @returns {boolean} batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||
*/
|
||||
async getBatteryStatus() {
|
||||
return await this.client.pupPage.evaluate(() => {
|
||||
const { battery, plugged } = window.Store.Conn;
|
||||
return { battery, plugged };
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ClientInfo;
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* ID that represents a contact
|
||||
* @typedef {Object} ContactId
|
||||
* @property {string} server
|
||||
* @property {string} user
|
||||
* @property {string} _serialized
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a Contact on WhatsApp
|
||||
* @extends {Base}
|
||||
@@ -16,7 +24,7 @@ class Contact extends Base {
|
||||
_patch(data) {
|
||||
/**
|
||||
* ID that represents the contact
|
||||
* @type {object}
|
||||
* @type {ContactId}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
@@ -95,6 +103,12 @@ class Contact extends Base {
|
||||
*/
|
||||
this.isMyContact = data.isMyContact;
|
||||
|
||||
/**
|
||||
* Indicates if you have blocked this contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isBlocked = data.isBlocked;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
@@ -103,11 +117,63 @@ class Contact extends Base {
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getProfilePicUrl() {
|
||||
const profilePic = await this.client.pupPage.evaluate((contactId) => {
|
||||
return window.Store.Wap.profilePicFind(contactId);
|
||||
return await this.client.getProfilePicUrl(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Chat that corresponds to this Contact.
|
||||
* Will return null when getting chat for currently logged in user.
|
||||
* @returns {Promise<Chat>}
|
||||
*/
|
||||
async getChat() {
|
||||
if(this.isMe) return null;
|
||||
|
||||
return await this.client.getChatById(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks this contact from WhatsApp
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async block() {
|
||||
if(this.isGroup) return false;
|
||||
|
||||
await this.client.pupPage.evaluate(async (contactId) => {
|
||||
const contact = window.Store.Contact.get(contactId);
|
||||
await window.Store.BlockContact.blockContact(contact);
|
||||
}, this.id._serialized);
|
||||
|
||||
return profilePic ? profilePic.eurl : undefined;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unblocks this contact from WhatsApp
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async unblock() {
|
||||
if(this.isGroup) return false;
|
||||
|
||||
await this.client.pupPage.evaluate(async (contactId) => {
|
||||
const contact = window.Store.Contact.get(contactId);
|
||||
await window.Store.BlockContact.unblockContact(contact);
|
||||
}, this.id._serialized);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Contact's current "about" info. Returns null if you don't have permission to read their status.
|
||||
* @returns {Promise<?string>}
|
||||
*/
|
||||
async getAbout() {
|
||||
const about = await this.client.pupPage.evaluate(async (contactId) => {
|
||||
return window.Store.Wap.statusFind(contactId);
|
||||
}, this.id._serialized);
|
||||
|
||||
if (typeof about.status !== 'string')
|
||||
return null;
|
||||
|
||||
return about.status;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
const Chat = require('./Chat');
|
||||
|
||||
/**
|
||||
* Group participant information
|
||||
* @typedef {Object} GroupParticipant
|
||||
* @property {ContactId} id
|
||||
* @property {boolean} isAdmin
|
||||
* @property {boolean} isSuperAdmin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a Group Chat on WhatsApp
|
||||
* @extends {Chat}
|
||||
@@ -15,6 +23,7 @@ class GroupChat extends Chat {
|
||||
|
||||
/**
|
||||
* Gets the group owner
|
||||
* @type {ContactId}
|
||||
*/
|
||||
get owner() {
|
||||
return this.groupMetadata.owner;
|
||||
@@ -35,9 +44,10 @@ class GroupChat extends Chat {
|
||||
get description() {
|
||||
return this.groupMetadata.desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the group participants
|
||||
* @type {array}
|
||||
* @type {Array<GroupParticipant>}
|
||||
*/
|
||||
get participants() {
|
||||
return this.groupMetadata.participants;
|
||||
@@ -46,6 +56,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Adds a list of participants by ID to the group
|
||||
* @param {Array<string>} participantIds
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
async addParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
@@ -56,6 +67,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Removes a list of participants by ID to the group
|
||||
* @param {Array<string>} participantIds
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
async removeParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
@@ -66,6 +78,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Promotes participants by IDs to admins
|
||||
* @param {Array<string>} participantIds
|
||||
* @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful
|
||||
*/
|
||||
async promoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
@@ -76,6 +89,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Demotes participants by IDs to regular users
|
||||
* @param {Array<string>} participantIds
|
||||
* @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful
|
||||
*/
|
||||
async demoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
@@ -86,6 +100,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Updates the group subject
|
||||
* @param {string} subject
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async setSubject(subject) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, subject) => {
|
||||
@@ -100,6 +115,7 @@ class GroupChat extends Chat {
|
||||
/**
|
||||
* Updates the group description
|
||||
* @param {string} description
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async setDescription(description) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, description) => {
|
||||
@@ -112,8 +128,41 @@ class GroupChat extends Chat {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the group settings to only allow admins to send messages.
|
||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setMessagesAdminsOnly(adminsOnly=true) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||
return window.Store.Wap.setGroupProperty(chatId, 'announcement', value);
|
||||
}, this.id._serialized, adminsOnly);
|
||||
|
||||
if (res.status !== 200) return false;
|
||||
|
||||
this.groupMetadata.announce = adminsOnly;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the group settings to only allow admins to edit group info (title, description, photo).
|
||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setInfoAdminsOnly(adminsOnly=true) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||
return window.Store.Wap.setGroupProperty(chatId, 'restrict', value);
|
||||
}, this.id._serialized, adminsOnly);
|
||||
|
||||
if (res.status !== 200) return false;
|
||||
|
||||
this.groupMetadata.restrict = adminsOnly;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the invite code for a specific group
|
||||
* @returns {Promise<string>} Group's invite code
|
||||
*/
|
||||
async getInviteCode() {
|
||||
let res = await this.client.pupPage.evaluate(chatId => {
|
||||
@@ -129,6 +178,7 @@ class GroupChat extends Chat {
|
||||
|
||||
/**
|
||||
* Invalidates the current group invite code and generates a new one
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async revokeInvite() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
@@ -136,29 +186,9 @@ class GroupChat extends Chat {
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object with information about the invite code's group
|
||||
* @param {string} inviteCode
|
||||
* @returns {Promise<object>} Invite information
|
||||
*/
|
||||
static async getInviteInfo(inviteCode) {
|
||||
return await this.client.pupPage.evaluate(inviteCode => {
|
||||
return window.Store.Wap.groupInviteInfo(inviteCode);
|
||||
}, inviteCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins a group with an invite code
|
||||
* @param {string} inviteCode
|
||||
*/
|
||||
static async join(inviteCode) {
|
||||
return await this.client.pupPage.evaluate(inviteCode => {
|
||||
return window.Store.Wap.acceptGroupInvite(inviteCode);
|
||||
}, inviteCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the bot leave the group
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async leave() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
|
||||
@@ -43,7 +43,7 @@ class GroupNotification extends Base {
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.chatId = typeof (data.to) === 'object' ? data.to._serialized : data.to;
|
||||
this.chatId = typeof (data.from) === 'object' ? data.from._serialized : data.from;
|
||||
|
||||
/**
|
||||
* ContactId for the user that produced the GroupNotification.
|
||||
|
||||
50
src/structures/Label.js
Normal file
50
src/structures/Label.js
Normal file
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Chat = require('./Chat');
|
||||
|
||||
/**
|
||||
* WhatsApp Business Label information
|
||||
*/
|
||||
class Label extends Base {
|
||||
/**
|
||||
* @param {Base} client
|
||||
* @param {object} labelData
|
||||
*/
|
||||
constructor(client, labelData){
|
||||
super(client);
|
||||
|
||||
if(labelData) this._patch(labelData);
|
||||
}
|
||||
|
||||
_patch(labelData){
|
||||
/**
|
||||
* Label ID
|
||||
* @type {string}
|
||||
*/
|
||||
this.id = labelData.id;
|
||||
|
||||
/**
|
||||
* Label name
|
||||
* @type {string}
|
||||
*/
|
||||
this.name = labelData.name;
|
||||
|
||||
/**
|
||||
* Label hex color
|
||||
* @type {string}
|
||||
*/
|
||||
this.hexColor = labelData.hexColor;
|
||||
}
|
||||
/**
|
||||
* Get all chats that have been assigned this Label
|
||||
* @returns {Promise<Array<Chat>>}
|
||||
*/
|
||||
async getChats(){
|
||||
return this.client.getChatsByLabelId(this.id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Label;
|
||||
@@ -13,21 +13,34 @@ class Message extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* MediaKey that represents the sticker 'ID'
|
||||
* @type {string}
|
||||
*/
|
||||
this.mediaKey = data.mediaKey;
|
||||
|
||||
|
||||
/**
|
||||
* ID that represents the message
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
/**
|
||||
* ACK status for the message
|
||||
* @type {MessageAck}
|
||||
*/
|
||||
this.ack = data.ack;
|
||||
|
||||
/**
|
||||
* Indicates if the message has media available for download
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.hasMedia = data.clientUrl ? true : false;
|
||||
this.hasMedia = data.clientUrl || data.deprecatedMms3Url ? true : false;
|
||||
|
||||
/**
|
||||
* Message content
|
||||
@@ -51,7 +64,7 @@ class Message extends Base {
|
||||
* ID for the Chat that this message was sent to, except if the message was sent by the current user.
|
||||
* @type {string}
|
||||
*/
|
||||
this.from = typeof (data.from) === 'object' ? data.from._serialized : data.from;
|
||||
this.from = (typeof (data.from) === 'object' && data.from !== null) ? data.from._serialized : data.from;
|
||||
|
||||
/**
|
||||
* ID for who this message is for.
|
||||
@@ -60,13 +73,13 @@ class Message extends Base {
|
||||
* If the message is sent by another user, it will be the ID for the current user.
|
||||
* @type {string}
|
||||
*/
|
||||
this.to = typeof (data.to) === 'object' ? data.to._serialized : data.to;
|
||||
this.to = (typeof (data.to) === 'object' && data.to !== null) ? data.to._serialized : data.to;
|
||||
|
||||
/**
|
||||
* If the message was sent to a group, this field will contain the user that sent the message.
|
||||
* @type {string}
|
||||
*/
|
||||
this.author = typeof (data.author) === 'object' ? data.author._serialized : data.author;
|
||||
this.author = (typeof (data.author) === 'object' && data.author !== null) ? data.author._serialized : data.author;
|
||||
|
||||
/**
|
||||
* Indicates if the message was forwarded
|
||||
@@ -74,6 +87,18 @@ class Message extends Base {
|
||||
*/
|
||||
this.isForwarded = data.isForwarded;
|
||||
|
||||
/**
|
||||
* Indicates if the message is a status update
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isStatus = data.isStatusV3;
|
||||
|
||||
/**
|
||||
* Indicates if the message was starred
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isStarred = data.star;
|
||||
|
||||
/**
|
||||
* Indicates if the message was a broadcast
|
||||
* @type {boolean}
|
||||
@@ -85,7 +110,7 @@ class Message extends Base {
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.fromMe = data.id.fromMe;
|
||||
|
||||
|
||||
/**
|
||||
* Indicates if the message was sent as a reply to another message.
|
||||
* @type {boolean}
|
||||
@@ -98,6 +123,12 @@ class Message extends Base {
|
||||
*/
|
||||
this.location = data.type === MessageTypes.LOCATION ? new Location(data.lat, data.lng, data.loc) : undefined;
|
||||
|
||||
/**
|
||||
* List of vCards contained in the message.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
this.vCards = data.type === MessageTypes.CONTACT_CARD_MULTI ? data.vcardList.map((c) => c.vcard) : data.type === MessageTypes.CONTACT_CARD ? [data.body] : [];
|
||||
|
||||
/**
|
||||
* Indicates the mentions in the message body.
|
||||
* @type {Array<string>}
|
||||
@@ -108,6 +139,12 @@ class Message extends Base {
|
||||
this.mentionedIds = data.mentionedJidList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Links included in the message.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
this.links = data.links;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
@@ -160,11 +197,11 @@ class Message extends Base {
|
||||
* in the same Chat as the original message was sent.
|
||||
*
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {?string} chatId
|
||||
* @param {object} options
|
||||
* @param {string} [chatId]
|
||||
* @param {MessageSendOptions} [options]
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async reply(content, chatId, options={}) {
|
||||
async reply(content, chatId, options = {}) {
|
||||
if (!chatId) {
|
||||
chatId = this._getChatId();
|
||||
}
|
||||
@@ -177,6 +214,23 @@ class Message extends Base {
|
||||
return this.client.sendMessage(chatId, content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forwards this message to another chat
|
||||
*
|
||||
* @param {string|Chat} chat Chat model or chat ID to which the message will be forwarded
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async forward(chat) {
|
||||
const chatId = typeof chat === 'string' ? chat : chat.id._serialized;
|
||||
|
||||
await this.client.pupPage.evaluate(async (msgId, chatId) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
|
||||
return await chat.forwardMessages([msg]);
|
||||
}, this.id._serialized, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the attatched message media
|
||||
* @returns {Promise<MessageMedia>}
|
||||
@@ -186,12 +240,25 @@ class Message extends Base {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const {data, mimetype, filename} = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const result = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
const buffer = await window.WWebJS.downloadBuffer(msg.clientUrl);
|
||||
|
||||
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
||||
// try to resolve media
|
||||
await msg.downloadMedia(true, 1);
|
||||
}
|
||||
|
||||
if (msg.mediaData.mediaStage.includes('ERROR')) {
|
||||
// media could not be downloaded
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const mediaUrl = msg.clientUrl || msg.deprecatedMms3Url;
|
||||
|
||||
const buffer = await window.WWebJS.downloadBuffer(mediaUrl);
|
||||
const decrypted = await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
|
||||
const data = await window.WWebJS.readBlobAsync(decrypted._blob);
|
||||
|
||||
|
||||
return {
|
||||
data: data.split(',')[1],
|
||||
mimetype: msg.mimetype,
|
||||
@@ -200,7 +267,8 @@ class Message extends Base {
|
||||
|
||||
}, this.id._serialized);
|
||||
|
||||
return new MessageMedia(mimetype, data, filename);
|
||||
if (!result) return undefined;
|
||||
return new MessageMedia(result.mimetype, result.data, result.filename);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,13 +279,69 @@ class Message extends Base {
|
||||
await this.client.pupPage.evaluate((msgId, everyone) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if(everyone && msg.id.fromMe && msg.canRevoke()) {
|
||||
if (everyone && msg.id.fromMe && msg.canRevoke()) {
|
||||
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
||||
}, this.id._serialized, everyone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stars this message
|
||||
*/
|
||||
async star() {
|
||||
await this.client.pupPage.evaluate((msgId) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if (msg.canStar()) {
|
||||
return msg.chat.sendStarMsgs([msg], true);
|
||||
}
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unstars this message
|
||||
*/
|
||||
async unstar() {
|
||||
await this.client.pupPage.evaluate((msgId) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if (msg.canStar()) {
|
||||
return msg.chat.sendStarMsgs([msg], false);
|
||||
}
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Message Info
|
||||
* @typedef {Object} MessageInfo
|
||||
* @property {Array<{id: ContactId, t: number}>} delivery Contacts to which the message has been delivered to
|
||||
* @property {number} deliveryRemaining Amount of people to whom the message has not been delivered to
|
||||
* @property {Array<{id: ContactId, t: number}>} played Contacts who have listened to the voice message
|
||||
* @property {number} playedRemaining Amount of people who have not listened to the message
|
||||
* @property {Array<{id: ContactId, t: number}>} read Contacts who have read the message
|
||||
* @property {number} readRemaining Amount of people who have not read the message
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get information about message delivery status. May return null if the message does not exist or is not sent by you.
|
||||
* @returns {Promise<?MessageInfo>}
|
||||
*/
|
||||
async getInfo() {
|
||||
const info = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
if(!msg) return null;
|
||||
|
||||
return await window.Store.Wap.queryMsgInfo(msg.id);
|
||||
}, this.id._serialized);
|
||||
|
||||
if(info.status) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Message;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const mime = require('mime');
|
||||
|
||||
/**
|
||||
* Media attached to a message
|
||||
* @param {string} mimetype MIME type of the attachment
|
||||
@@ -26,6 +30,19 @@ class MessageMedia {
|
||||
*/
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a MessageMedia instance from a local file path
|
||||
* @param {string} filePath
|
||||
* @returns {MessageMedia}
|
||||
*/
|
||||
static fromFilePath(filePath) {
|
||||
const b64data = fs.readFileSync(filePath, {encoding: 'base64'});
|
||||
const mimetype = mime.getType(filePath);
|
||||
const filename = path.basename(filePath);
|
||||
|
||||
return new MessageMedia(mimetype, b64data, filename);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MessageMedia;
|
||||
@@ -10,4 +10,6 @@ module.exports = {
|
||||
MessageMedia: require('./MessageMedia'),
|
||||
PrivateChat: require('./PrivateChat'),
|
||||
PrivateContact: require('./PrivateContact'),
|
||||
GroupNotification: require('./GroupNotification'),
|
||||
Label: require('./Label.js')
|
||||
};
|
||||
@@ -2,13 +2,19 @@
|
||||
|
||||
exports.WhatsWebURL = 'https://web.whatsapp.com/';
|
||||
|
||||
exports.UserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36';
|
||||
|
||||
exports.DefaultOptions = {
|
||||
puppeteer: {
|
||||
headless: true
|
||||
headless: true,
|
||||
defaultViewport: null
|
||||
},
|
||||
session: false
|
||||
session: false,
|
||||
qrTimeoutMs: 45000,
|
||||
qrRefreshIntervalMs: 20000,
|
||||
authTimeoutMs: 45000,
|
||||
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',
|
||||
ffmpegPath: 'ffmpeg'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -36,12 +42,14 @@ exports.Events = {
|
||||
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
|
||||
MESSAGE_REVOKED_ME: 'message_revoke_me',
|
||||
MESSAGE_ACK: 'message_ack',
|
||||
MEDIA_UPLOADED: 'media_uploaded',
|
||||
GROUP_JOIN: 'group_join',
|
||||
GROUP_LEAVE: 'group_leave',
|
||||
GROUP_UPDATE: 'group_update',
|
||||
QR_RECEIVED: 'qr',
|
||||
DISCONNECTED: 'disconnected',
|
||||
STATE_CHANGED: 'change_state',
|
||||
BATTERY_CHANGED: 'change_battery'
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@ exports.ExposeStore = (moduleRaidStr) => {
|
||||
eval('var moduleRaid = ' + moduleRaidStr);
|
||||
// eslint-disable-next-line no-undef
|
||||
window.mR = moduleRaid();
|
||||
window.Store = window.mR.findModule('Chat')[1].default;
|
||||
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];
|
||||
@@ -13,22 +13,30 @@ exports.ExposeStore = (moduleRaidStr) => {
|
||||
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((module) => module.default && typeof module.default === 'function' && module.default.toString().match(/crypto/))[0].default;
|
||||
window.Store.genId = window.mR.findModule('randomId')[0].default;
|
||||
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
|
||||
window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
|
||||
window.Store.Invite = window.mR.findModule('sendJoinGroupViaInvite')[0];
|
||||
window.Store.OpaqueData = window.mR.findModule('getOrCreateOpaqueDataForPath')[0];
|
||||
window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
|
||||
window.Store.MediaPrep = window.mR.findModule('MediaPrep')[0];
|
||||
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
|
||||
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
|
||||
window.Store.Cmd = window.mR.findModule('Cmd')[0].default;
|
||||
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;
|
||||
|
||||
window.Store.Validators = window.mR.findModule('findLinks')[0];
|
||||
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;
|
||||
};
|
||||
|
||||
exports.LoadUtils = () => {
|
||||
window.WWebJS = {};
|
||||
|
||||
window.WWebJS.getNumberId = async (id) => {
|
||||
|
||||
let result = await window.Store.Wap.queryExist(id);
|
||||
@@ -36,6 +44,7 @@ exports.LoadUtils = () => {
|
||||
throw 'The number provided is not a registered whatsapp user';
|
||||
return result.jid;
|
||||
};
|
||||
|
||||
window.WWebJS.sendSeen = async (chatId) => {
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
if (chat !== undefined) {
|
||||
@@ -45,11 +54,21 @@ exports.LoadUtils = () => {
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
window.WWebJS.sendMessage = async (chat, content, options = {}) => {
|
||||
let attOptions = {};
|
||||
if (options.attachment) {
|
||||
attOptions = await window.WWebJS.processMediaData(options.attachment);
|
||||
attOptions = options.sendMediaAsSticker
|
||||
? await window.WWebJS.processStickerData(options.attachment)
|
||||
: await window.WWebJS.processMediaData(options.attachment, {
|
||||
forceVoice: options.sendAudioAsVoice,
|
||||
forceDocument: options.sendMediaAsDocument
|
||||
});
|
||||
|
||||
content = options.sendMediaAsSticker ? undefined : attOptions.preview;
|
||||
|
||||
delete options.attachment;
|
||||
delete options.sendMediaAsSticker;
|
||||
}
|
||||
|
||||
let quotedMsgOptions = {};
|
||||
@@ -76,9 +95,53 @@ exports.LoadUtils = () => {
|
||||
delete options.location;
|
||||
}
|
||||
|
||||
let vcardOptions = {};
|
||||
if (options.contactCard) {
|
||||
let contact = window.Store.Contact.get(options.contactCard);
|
||||
vcardOptions = {
|
||||
body: window.Store.VCard.vcardFromContactModel(contact).vcard,
|
||||
type: 'vcard',
|
||||
vcardFormattedName: contact.formattedName
|
||||
};
|
||||
delete options.contactCard;
|
||||
} else if (options.contactCardList) {
|
||||
let contacts = options.contactCardList.map(c => window.Store.Contact.get(c));
|
||||
let vcards = contacts.map(c => window.Store.VCard.vcardFromContactModel(c));
|
||||
vcardOptions = {
|
||||
type: 'multi_vcard',
|
||||
vcardList: vcards,
|
||||
body: undefined
|
||||
};
|
||||
delete options.contactCardList;
|
||||
} else if (options.parseVCards && typeof (content) === 'string' && content.startsWith('BEGIN:VCARD')) {
|
||||
delete options.parseVCards;
|
||||
try {
|
||||
const parsed = window.Store.VCard.parseVcard(content);
|
||||
if (parsed) {
|
||||
vcardOptions = {
|
||||
type: 'vcard',
|
||||
vcardFormattedName: window.Store.VCard.vcardGetNameFromParsed(parsed)
|
||||
};
|
||||
}
|
||||
} catch (_) {
|
||||
// not a vcard
|
||||
}
|
||||
}
|
||||
|
||||
if (options.linkPreview) {
|
||||
delete options.linkPreview;
|
||||
const link = window.Store.Validators.findLink(content);
|
||||
if (link) {
|
||||
const preview = await window.Store.Wap.queryLinkPreview(link.url);
|
||||
preview.preview = true;
|
||||
preview.subtype = 'url';
|
||||
options = { ...options, ...preview };
|
||||
}
|
||||
}
|
||||
|
||||
const newMsgId = new window.Store.MsgKey({
|
||||
from: window.Store.Conn.me,
|
||||
to: chat.id,
|
||||
fromMe: true,
|
||||
remote: chat.id,
|
||||
id: window.Store.genId(),
|
||||
});
|
||||
|
||||
@@ -87,7 +150,7 @@ exports.LoadUtils = () => {
|
||||
id: newMsgId,
|
||||
ack: 0,
|
||||
body: content,
|
||||
from: window.Store.Conn.me,
|
||||
from: window.Store.Conn.wid,
|
||||
to: chat.id,
|
||||
local: true,
|
||||
self: 'out',
|
||||
@@ -96,17 +159,46 @@ exports.LoadUtils = () => {
|
||||
type: 'chat',
|
||||
...locationOptions,
|
||||
...attOptions,
|
||||
...quotedMsgOptions
|
||||
...quotedMsgOptions,
|
||||
...vcardOptions
|
||||
};
|
||||
|
||||
await window.Store.SendMessage.addAndSendMsgToChat(chat, message);
|
||||
return window.Store.Msg.get(newMsgId._serialized);
|
||||
};
|
||||
|
||||
window.WWebJS.processMediaData = async (mediaInfo) => {
|
||||
window.WWebJS.processStickerData = async (mediaInfo) => {
|
||||
if (mediaInfo.mimetype !== 'image/webp') throw new Error('Invalid media type');
|
||||
|
||||
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
|
||||
const mData = await window.Store.OpaqueData.default.createFromData(file, file.type);
|
||||
const mediaPrep = window.Store.MediaPrep.prepRawMedia(mData, {});
|
||||
let filehash = await window.WWebJS.getFileHash(file);
|
||||
let mediaKey = await window.WWebJS.generateHash(32);
|
||||
|
||||
const controller = new AbortController();
|
||||
const uploadedInfo = await window.Store.UploadUtils.encryptAndUpload({
|
||||
blob: file,
|
||||
type: 'sticker',
|
||||
signal: controller.signal,
|
||||
mediaKey
|
||||
});
|
||||
|
||||
const stickerInfo = {
|
||||
...uploadedInfo,
|
||||
clientUrl: uploadedInfo.url,
|
||||
deprecatedMms3Url: uploadedInfo.url,
|
||||
uploadhash: uploadedInfo.encFilehash,
|
||||
size: file.size,
|
||||
type: 'sticker',
|
||||
filehash
|
||||
};
|
||||
|
||||
return stickerInfo;
|
||||
};
|
||||
|
||||
window.WWebJS.processMediaData = async (mediaInfo, { forceVoice, forceDocument }) => {
|
||||
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
|
||||
const mData = await window.Store.OpaqueData.createFromData(file, file.type);
|
||||
const mediaPrep = window.Store.MediaPrep.prepRawMedia(mData, { asDocument: forceDocument });
|
||||
const mediaData = await mediaPrep.waitForPrep();
|
||||
const mediaObject = window.Store.MediaObject.getOrCreateMediaObject(mediaData.filehash);
|
||||
|
||||
@@ -115,54 +207,93 @@ exports.LoadUtils = () => {
|
||||
isGif: mediaData.isGif
|
||||
});
|
||||
|
||||
if (!(mediaData.mediaBlob instanceof window.Store.OpaqueData.default)) {
|
||||
mediaData.mediaBlob = await window.Store.OpaqueData.default.createFromData(mediaData.mediaBlob, mediaData.mediaBlob.type);
|
||||
if (forceVoice && mediaData.type === 'audio') {
|
||||
mediaData.type = 'ptt';
|
||||
}
|
||||
|
||||
if (forceDocument) {
|
||||
mediaData.type = 'document';
|
||||
}
|
||||
|
||||
if (!(mediaData.mediaBlob instanceof window.Store.OpaqueData)) {
|
||||
mediaData.mediaBlob = await window.Store.OpaqueData.createFromData(mediaData.mediaBlob, mediaData.mediaBlob.type);
|
||||
}
|
||||
|
||||
mediaData.renderableUrl = mediaData.mediaBlob.url();
|
||||
mediaObject.consolidate(mediaData.toJSON());
|
||||
mediaData.mediaBlob.autorelease();
|
||||
|
||||
const uploadedMedia = await window.Store.MediaUpload.uploadMedia(mediaData.mimetype, mediaObject, mediaType);
|
||||
if (!uploadedMedia) {
|
||||
const uploadedMedia = await window.Store.MediaUpload.uploadMedia({
|
||||
mimetype: mediaData.mimetype,
|
||||
mediaObject,
|
||||
mediaType
|
||||
});
|
||||
|
||||
const mediaEntry = uploadedMedia.mediaEntry;
|
||||
if (!mediaEntry) {
|
||||
throw new Error('upload failed: media entry was not created');
|
||||
}
|
||||
|
||||
mediaData.set({
|
||||
clientUrl: uploadedMedia.mmsUrl,
|
||||
directPath: uploadedMedia.directPath,
|
||||
mediaKey: uploadedMedia.mediaKey,
|
||||
mediaKeyTimestamp: uploadedMedia.mediaKeyTimestamp,
|
||||
clientUrl: mediaEntry.mmsUrl,
|
||||
deprecatedMms3Url: mediaEntry.deprecatedMms3Url,
|
||||
directPath: mediaEntry.directPath,
|
||||
mediaKey: mediaEntry.mediaKey,
|
||||
mediaKeyTimestamp: mediaEntry.mediaKeyTimestamp,
|
||||
filehash: mediaObject.filehash,
|
||||
uploadhash: uploadedMedia.uploadHash,
|
||||
encFilehash: mediaEntry.encFilehash,
|
||||
uploadhash: mediaEntry.uploadHash,
|
||||
size: mediaObject.size,
|
||||
streamingSidecar: uploadedMedia.sidecar,
|
||||
firstFrameSidecar: uploadedMedia.firstFrameSidecar
|
||||
streamingSidecar: mediaEntry.sidecar,
|
||||
firstFrameSidecar: mediaEntry.firstFrameSidecar
|
||||
});
|
||||
|
||||
return mediaData;
|
||||
};
|
||||
|
||||
window.WWebJS.getChatModel = chat => {
|
||||
window.WWebJS.getMessageModel = message => {
|
||||
const msg = message.serialize();
|
||||
|
||||
msg.isStatusV3 = message.isStatusV3;
|
||||
msg.links = (message.getLinks()).map(link => link.href);
|
||||
|
||||
if (msg.buttons) {
|
||||
msg.buttons = msg.buttons.serialize();
|
||||
}
|
||||
|
||||
delete msg.pendingAckUpdate;
|
||||
|
||||
return msg;
|
||||
};
|
||||
|
||||
window.WWebJS.getChatModel = async chat => {
|
||||
let res = chat.serialize();
|
||||
res.isGroup = chat.isGroup;
|
||||
res.formattedTitle = chat.formattedTitle;
|
||||
res.isMuted = chat.mute && chat.mute.isMuted;
|
||||
|
||||
if (chat.groupMetadata) {
|
||||
await window.Store.GroupMetadata.update(chat.id._serialized);
|
||||
res.groupMetadata = chat.groupMetadata.serialize();
|
||||
}
|
||||
|
||||
delete res.msgs;
|
||||
delete res.msgUnsyncedButtonReplyMsgs;
|
||||
delete res.unsyncedButtonReplies;
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
window.WWebJS.getChat = chatId => {
|
||||
window.WWebJS.getChat = async chatId => {
|
||||
const chat = window.Store.Chat.get(chatId);
|
||||
return window.WWebJS.getChatModel(chat);
|
||||
return await window.WWebJS.getChatModel(chat);
|
||||
};
|
||||
|
||||
window.WWebJS.getChats = () => {
|
||||
window.WWebJS.getChats = async () => {
|
||||
const chats = window.Store.Chat.models;
|
||||
return chats.map(chat => window.WWebJS.getChatModel(chat));
|
||||
|
||||
const chatPromises = chats.map(chat => window.WWebJS.getChatModel(chat));
|
||||
return await Promise.all(chatPromises);
|
||||
};
|
||||
|
||||
window.WWebJS.getContactModel = contact => {
|
||||
@@ -178,6 +309,7 @@ exports.LoadUtils = () => {
|
||||
res.isGroup = contact.isGroup;
|
||||
res.isWAContact = contact.isWAContact;
|
||||
res.isMyContact = contact.isMyContact;
|
||||
res.isBlocked = contact.isContactBlocked;
|
||||
res.userid = contact.userid;
|
||||
|
||||
return res;
|
||||
@@ -248,6 +380,22 @@ exports.LoadUtils = () => {
|
||||
});
|
||||
};
|
||||
|
||||
window.WWebJS.getFileHash = async (data) => {
|
||||
let buffer = await data.arrayBuffer();
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
|
||||
return btoa(String.fromCharCode(...new Uint8Array(hashBuffer)));
|
||||
};
|
||||
|
||||
window.WWebJS.generateHash = async (length) => {
|
||||
var result = '';
|
||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
var charactersLength = characters.length;
|
||||
for ( var i = 0; i < length; i++ ) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
window.WWebJS.sendClearChat = async (chatId) => {
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
if (chat !== undefined) {
|
||||
@@ -267,7 +415,7 @@ exports.LoadUtils = () => {
|
||||
};
|
||||
|
||||
window.WWebJS.sendChatstate = async (state, chatId) => {
|
||||
switch(state) {
|
||||
switch (state) {
|
||||
case 'typing':
|
||||
await window.Store.Wap.sendChatstateComposing(chatId);
|
||||
break;
|
||||
@@ -280,10 +428,31 @@ exports.LoadUtils = () => {
|
||||
default:
|
||||
throw 'Invalid chatstate';
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
window.WWebJS.getLabelModel = label => {
|
||||
let res = label.serialize();
|
||||
res.hexColor = label.hexColor;
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
window.WWebJS.getLabels = () => {
|
||||
const labels = window.Store.Label.models;
|
||||
return labels.map(label => window.WWebJS.getLabelModel(label));
|
||||
};
|
||||
|
||||
window.WWebJS.getLabel = (labelId) => {
|
||||
const label = window.Store.Label.get(labelId);
|
||||
return window.WWebJS.getLabelModel(label);
|
||||
};
|
||||
|
||||
window.WWebJS.getChatLabels = async (chatId) => {
|
||||
const chat = await window.WWebJS.getChat(chatId);
|
||||
return (chat.labels || []).map(id => window.WWebJS.getLabel(id));
|
||||
};
|
||||
};
|
||||
|
||||
exports.MarkAllRead = () => {
|
||||
|
||||
78
src/util/InterfaceController.js
Normal file
78
src/util/InterfaceController.js
Normal file
@@ -0,0 +1,78 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Interface Controller
|
||||
*/
|
||||
class InterfaceController {
|
||||
|
||||
constructor(props) {
|
||||
this.pupPage = props.pupPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Chat Window
|
||||
* @param {string} chatId ID of the chat window that will be opened
|
||||
*/
|
||||
async openChatWindow(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.openChatAt(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Chat Drawer
|
||||
* @param {string} chatId ID of the chat drawer that will be opened
|
||||
*/
|
||||
async openChatDrawer(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.chatInfoDrawer(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Chat Search
|
||||
* @param {string} chatId ID of the chat search that will be opened
|
||||
*/
|
||||
async openChatSearch(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.chatSearch(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens or Scrolls the Chat Window to the position of the message
|
||||
* @param {string} msgId ID of the message that will be scrolled to
|
||||
*/
|
||||
async openChatWindowAt(msgId) {
|
||||
await this.pupPage.evaluate(async msgId => {
|
||||
let msg = await window.Store.Msg.get(msgId);
|
||||
await window.Store.Cmd.openChatAt(msg.chat, msg.chat.getSearchContext(msg));
|
||||
}, msgId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Message Drawer
|
||||
* @param {string} msgId ID of the message drawer that will be opened
|
||||
*/
|
||||
async openMessageDrawer(msgId) {
|
||||
await this.pupPage.evaluate(async msgId => {
|
||||
let msg = await window.Store.Msg.get(msgId);
|
||||
await window.Store.Cmd.msgInfoDrawer(msg);
|
||||
}, msgId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the Right Drawer
|
||||
*/
|
||||
async closeRightDrawer() {
|
||||
await this.pupPage.evaluate(async () => {
|
||||
await window.Store.Cmd.closeDrawerRight();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = InterfaceController;
|
||||
124
src/util/Util.js
124
src/util/Util.js
@@ -1,5 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const sharp = require('sharp');
|
||||
const path = require('path');
|
||||
const Crypto = require('crypto');
|
||||
const { tmpdir } = require('os');
|
||||
const ffmpeg = require('fluent-ffmpeg');
|
||||
const fs = require('fs').promises;
|
||||
|
||||
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
||||
|
||||
/**
|
||||
@@ -30,6 +37,123 @@ class Util {
|
||||
|
||||
return given;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a image to webp
|
||||
* @param {MessageMedia} media
|
||||
*
|
||||
* @returns {Promise<MessageMedia>} media in webp format
|
||||
*/
|
||||
static async formatImageToWebpSticker(media) {
|
||||
if (!media.mimetype.includes('image'))
|
||||
throw new Error('media is not a image');
|
||||
|
||||
if (media.mimetype.includes('webp')) {
|
||||
return media;
|
||||
}
|
||||
|
||||
const buff = Buffer.from(media.data, 'base64');
|
||||
|
||||
let sharpImg = sharp(buff);
|
||||
sharpImg = sharpImg.webp();
|
||||
|
||||
sharpImg = sharpImg.resize(512, 512, {
|
||||
fit: 'contain',
|
||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||
});
|
||||
|
||||
let webpBase64 = (await sharpImg.toBuffer()).toString('base64');
|
||||
|
||||
return {
|
||||
mimetype: 'image/webp',
|
||||
data: webpBase64,
|
||||
filename: media.filename,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a video to webp
|
||||
* @param {MessageMedia} media
|
||||
*
|
||||
* @returns {Promise<MessageMedia>} media in webp format
|
||||
*/
|
||||
static async formatVideoToWebpSticker(media) {
|
||||
if (!media.mimetype.includes('video'))
|
||||
throw new Error('media is not a video');
|
||||
|
||||
const videoType = media.mimetype.split('/')[1];
|
||||
|
||||
const tempFile = path.join(
|
||||
tmpdir(),
|
||||
`${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`
|
||||
);
|
||||
|
||||
const stream = new (require('stream').Readable)();
|
||||
const buffer = Buffer.from(
|
||||
media.data.replace(`data:${media.mimetype};base64,`, ''),
|
||||
'base64'
|
||||
);
|
||||
stream.push(buffer);
|
||||
stream.push(null);
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
ffmpeg(stream)
|
||||
.inputFormat(videoType)
|
||||
.on('error', reject)
|
||||
.on('end', () => resolve(true))
|
||||
.addOutputOptions([
|
||||
'-vcodec',
|
||||
'libwebp',
|
||||
'-vf',
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
'scale=\'iw*min(300/iw\,300/ih)\':\'ih*min(300/iw\,300/ih)\',format=rgba,pad=300:300:\'(300-iw)/2\':\'(300-ih)/2\':\'#00000000\',setsar=1,fps=10',
|
||||
'-loop',
|
||||
'0',
|
||||
'-ss',
|
||||
'00:00:00.0',
|
||||
'-t',
|
||||
'00:00:05.0',
|
||||
'-preset',
|
||||
'default',
|
||||
'-an',
|
||||
'-vsync',
|
||||
'0',
|
||||
'-s',
|
||||
'512:512',
|
||||
])
|
||||
.toFormat('webp')
|
||||
.save(tempFile);
|
||||
});
|
||||
|
||||
const data = await fs.readFile(tempFile, 'base64');
|
||||
await fs.unlink(tempFile);
|
||||
|
||||
return {
|
||||
mimetype: 'image/webp',
|
||||
data: data,
|
||||
filename: media.filename,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a media to webp
|
||||
* @param {MessageMedia} media
|
||||
*
|
||||
* @returns {Promise<MessageMedia>} media in webp format
|
||||
*/
|
||||
static async formatToWebpSticker(media) {
|
||||
if (media.mimetype.includes('image')) return this.formatImageToWebpSticker(media);
|
||||
else if (media.mimetype.includes('video')) return this.formatVideoToWebpSticker(media);
|
||||
else throw new Error('Invalid media format');
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure ffmpeg path
|
||||
* @param {string} path
|
||||
*/
|
||||
static setFfmpegPath(path) {
|
||||
ffmpeg.setFfmpegPath(path);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Util;
|
||||
Reference in New Issue
Block a user