mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
Compare commits
184 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
c61f447a93 | ||
|
|
49aacec4a7 | ||
|
|
d7a3e1a9a3 | ||
|
|
e14b49c5df | ||
|
|
f34902dfdd | ||
|
|
6e76fece91 | ||
|
|
98458f760e | ||
|
|
48b9ae1e81 | ||
|
|
588dc93c17 | ||
|
|
16fe865a9c | ||
|
|
b07b38bbe8 | ||
|
|
d35f101fac | ||
|
|
72441beb37 | ||
|
|
794c9e16fc | ||
|
|
05f57d2f39 | ||
|
|
130da046f5 | ||
|
|
bb40218c66 | ||
|
|
ad3834e575 | ||
|
|
e6ef5929fc | ||
|
|
bb4ad11bfa | ||
|
|
1ebaf56617 | ||
|
|
60ee2ca522 | ||
|
|
132424ea08 | ||
|
|
5c9e76e23f | ||
|
|
37932d9a69 | ||
|
|
3c500a6474 | ||
|
|
1c60c83e80 | ||
|
|
69d7b3e50b | ||
|
|
0b1f06a932 | ||
|
|
1840826e2b | ||
|
|
6ade08e814 | ||
|
|
9891d85b35 | ||
|
|
67784bc797 | ||
|
|
e385563883 | ||
|
|
d5a26add20 | ||
|
|
4bc67b0f99 | ||
|
|
d44fd5d76a | ||
|
|
a293146ed8 | ||
|
|
3c774d6553 | ||
|
|
dd0a4c6cc3 | ||
|
|
ffe803306e | ||
|
|
74cfc69367 | ||
|
|
2607e6df3a | ||
|
|
5fbd8ddf68 | ||
|
|
6f44fc586b | ||
|
|
7deef27800 | ||
|
|
f947f75725 | ||
|
|
d1dba0f4c0 | ||
|
|
64ed2c125b | ||
|
|
5616613807 | ||
|
|
ef80f966ea | ||
|
|
edc2c7022d | ||
|
|
f2b286a319 | ||
|
|
004312a99f | ||
|
|
2896aeb382 | ||
|
|
065a9212ba | ||
|
|
7b229a39a4 | ||
|
|
4b1768450f | ||
|
|
0cbc24fc6c | ||
|
|
a247b39f81 | ||
|
|
bf70eb1b87 | ||
|
|
1ad9cac682 | ||
|
|
4c05e47027 | ||
|
|
62e264231d | ||
|
|
2f0480c80e | ||
|
|
a098d61b03 | ||
|
|
e717915f94 | ||
|
|
e2351db722 | ||
|
|
b597e4a504 | ||
|
|
b99744afa2 | ||
|
|
cc477f9545 | ||
|
|
8eb461ed32 | ||
|
|
7243240568 | ||
|
|
5b9413de5c | ||
|
|
8ddf4c29be | ||
|
|
caa8598ec1 | ||
|
|
a6cc5e5bf2 | ||
|
|
ba8edc8d40 | ||
|
|
88c56b1371 | ||
|
|
2a3f404244 | ||
|
|
d2889a8f03 | ||
|
|
3c55fbf2ca | ||
|
|
6b1b51eacd | ||
|
|
2dc53e0820 | ||
|
|
9043e61c40 | ||
|
|
bea1ebf480 |
8
.editorconfig
Normal file
8
.editorconfig
Normal file
@@ -0,0 +1,8 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
||||
34
.eslintrc.json
Normal file
34
.eslintrc.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"commonjs": true,
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
4
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
]
|
||||
}
|
||||
}
|
||||
39
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
39
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Is something not working as intended? Report it here.
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Bug description
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
### Reproduction steps
|
||||
Steps to reproduce the behavior:
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
...
|
||||
|
||||
### Expected behavior
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
### Relevant code
|
||||
If applicable, add code snippets to help explain your problem.
|
||||
|
||||
### Environment (please complete the following information):
|
||||
**WhatsApp**
|
||||
- Account type [Standard / Business]:
|
||||
- Device OS [iOS / Android]:
|
||||
- WhatsApp Web version [run `await client.getWWebVersion()`]:
|
||||
|
||||
**Library**
|
||||
- Browser [Chrome / Chromium]:
|
||||
- NodeJS version (`node -v`):
|
||||
- npm or yarn version (`npm -v`):
|
||||
- whatsapp-web.js version:
|
||||
|
||||
### Additional context
|
||||
Add any other context about the problem here.
|
||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
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.
|
||||
24
.github/workflows/lint.yml
vendored
Normal file
24
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
eslint:
|
||||
name: eslint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: install node v12
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12
|
||||
- name: npm install
|
||||
run: npm install
|
||||
- name: eslint
|
||||
uses: icrawl/action-eslint@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
job-name: eslint
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -36,6 +36,10 @@ build/Release
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Lock files
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
|
||||
26
.jsdoc.json
Normal file
26
.jsdoc.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"tags": {
|
||||
"allowUnknownTags": true,
|
||||
"dictionaries": ["jsdoc"]
|
||||
},
|
||||
"source": {
|
||||
"include": ["src", "package.json", "README.md"],
|
||||
"includePattern": ".js$",
|
||||
"excludePattern": "(node_modules/|docs)"
|
||||
},
|
||||
"plugins": [
|
||||
"plugins/markdown"
|
||||
],
|
||||
"templates": {
|
||||
"cleverLinks": false,
|
||||
"monospaceLinks": true,
|
||||
"useLongnameInNav": false,
|
||||
"showInheritedInNav": true
|
||||
},
|
||||
"opts": {
|
||||
"destination": "./docs/",
|
||||
"encoding": "utf8",
|
||||
"recurse": true,
|
||||
"template": "./node_modules/jsdoc-baseline"
|
||||
}
|
||||
}
|
||||
95
README.md
95
README.md
@@ -1,4 +1,5 @@
|
||||
[](https://www.npmjs.com/package/whatsapp-web.js)
|
||||
[](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
|
||||
|
||||
@@ -6,8 +7,96 @@ It uses Puppeteer to run a real instance of Whatsapp Web to avoid getting blocke
|
||||
|
||||
**NOTE:** I can't guarantee you will not be blocked by using this method, although it has worked for me. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.
|
||||
|
||||
This is still very much a work in progress, but you can check out [example.js](./example.js) to see how to read and send messages.
|
||||
|
||||
## Installation
|
||||
|
||||
The module is now available on npm! `npm i whatsapp-web.js`
|
||||
|
||||
Please note that Node v10.18.1+ is required due to Puppeteer.
|
||||
|
||||
## Example usage
|
||||
|
||||
```js
|
||||
const { Client } = require('whatsapp-web.js');
|
||||
const client = new Client();
|
||||
|
||||
client.on('qr', (qr) => {
|
||||
// Generate and scan this code with your phone
|
||||
console.log('QR RECEIVED', qr);
|
||||
});
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log('Client is ready!');
|
||||
});
|
||||
|
||||
client.on('message', msg => {
|
||||
if (msg.body == '!ping') {
|
||||
msg.reply('pong');
|
||||
}
|
||||
});
|
||||
|
||||
client.initialize();
|
||||
```
|
||||
|
||||
Take a look at [example.js](https://github.com/pedroslopez/whatsapp-web.js/blob/master/example.js) for another example with more use cases.
|
||||
|
||||
## Supported features
|
||||
|
||||
| Feature | Status |
|
||||
| ------------- | ------------- |
|
||||
| Send messages | ✅ |
|
||||
| Receive messages | ✅ |
|
||||
| Send media (images/audio/documents) | ✅ |
|
||||
| Send media (video) | ✅ [(requires google chrome)](https://github.com/pedroslopez/whatsapp-web.js/issues/78#issuecomment-592723583) |
|
||||
| Send stickers | _pending_ |
|
||||
| Receive media (images/audio/video/documents) | ✅ |
|
||||
| Send contact cards | _pending_ |
|
||||
| Send location | ✅ |
|
||||
| Receive location | ✅ |
|
||||
| Message replies | ✅ |
|
||||
| Join groups by invite | ✅ |
|
||||
| Get invite for group | ✅ |
|
||||
| Modify group info (subject, description) | ✅ |
|
||||
| Add group participants | ✅ |
|
||||
| Kick group participants | ✅ |
|
||||
| Promote/demote group participants | ✅ |
|
||||
| Mention users | ✅ |
|
||||
| Mute/unmute chats | ✅ |
|
||||
| Get contact info | ✅ |
|
||||
| Get profile pictures | ✅ |
|
||||
| Set user status message | ✅ |
|
||||
|
||||
Something missing? Make an issue and let us know!
|
||||
|
||||
## Links
|
||||
|
||||
* [Reference](https://pedroslopez.me/whatsapp-web.js)
|
||||
* [Guide](https://waguide.pedroslopez.me/) _(work in progress)_
|
||||
* [GitHub](https://github.com/pedroslopez/whatsapp-web.js)
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests are welcome! If you see something you'd like to add, please do. For drastic changes, please open an issue first.
|
||||
|
||||
## 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.
|
||||
|
||||
65
docs/Base.html
Normal file
65
docs/Base.html
Normal file
@@ -0,0 +1,65 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">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>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a WhatsApp data structure</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="Base">new <span class="symbol-name">Base</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
242
docs/BusinessContact.html
Normal file
242
docs/BusinessContact.html
Normal file
@@ -0,0 +1,242 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">BusinessContact</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_BusinessContact.js.html#source-line-9">structures/<wbr>BusinessContact.<wbr>js:9</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Business Contact on WhatsApp</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Properties</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="BusinessContact.html#businessProfile">businessProfile</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#id">id</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#isMe">isMe</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#isMyContact">isMyContact</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#isUser">isUser</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<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#number">number</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#pushname">pushname</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#shortName">shortName</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="BusinessContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="BusinessContact">new <span class="symbol-name">BusinessContact</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
<dt>Extends</dt>
|
||||
<dd><a href="Contact.html">Contact</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="businessProfile"><span class="symbol-name">businessProfile</span></h3>
|
||||
<p>The contact's business profile</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>ID that represents the contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#id">Contact#id</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>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isBusiness">Contact#isBusiness</a></dd>
|
||||
</dl>
|
||||
<h3 id="isEnterprise"><span class="symbol-name">isEnterprise</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the contact is an enterprise contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isEnterprise">Contact#isEnterprise</a></dd>
|
||||
</dl>
|
||||
<h3 id="isGroup"><span class="symbol-name">isGroup</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the contact is a group contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isGroup">Contact#isGroup</a></dd>
|
||||
</dl>
|
||||
<h3 id="isMe"><span class="symbol-name">isMe</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the contact is the current user's contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isMe">Contact#isMe</a></dd>
|
||||
</dl>
|
||||
<h3 id="isMyContact"><span class="symbol-name">isMyContact</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the number is saved in the current phone's contacts</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isMyContact">Contact#isMyContact</a></dd>
|
||||
</dl>
|
||||
<h3 id="isUser"><span class="symbol-name">isUser</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the contact is a user contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isUser">Contact#isUser</a></dd>
|
||||
</dl>
|
||||
<h3 id="isWAContact"><span class="symbol-name">isWAContact</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the number is registered on WhatsApp</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isWAContact">Contact#isWAContact</a></dd>
|
||||
</dl>
|
||||
<h3 id="name"><span class="symbol-name">name</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>The contact's name, as saved by the current user</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#name">Contact#name</a></dd>
|
||||
</dl>
|
||||
<h3 id="number"><span class="symbol-name">number</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Contact's phone number</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#number">Contact#number</a></dd>
|
||||
</dl>
|
||||
<h3 id="pushname"><span class="symbol-name">pushname</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>The name that the contact has configured to be shown publically</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#pushname">Contact#pushname</a></dd>
|
||||
</dl>
|
||||
<h3 id="shortName"><span class="symbol-name">shortName</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>A shortened version of name</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#shortName">Contact#shortName</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Method</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getProfilePicUrl">Contact#getProfilePicUrl</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></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.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
410
docs/Chat.html
Normal file
410
docs/Chat.html
Normal file
@@ -0,0 +1,410 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">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>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Chat on WhatsApp</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Properties</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Chat.html#archived">archived</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#isGroup">isGroup</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Chat.html#isReadOnly">isReadOnly</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#timestamp">timestamp</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Chat.html#unreadCount">unreadCount</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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="Chat.html#archive">archive()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#clearMessages">clearMessages()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#clearState">clearState()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#delete">delete()</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>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#mute">mute(unmuteDate)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#sendMessage">sendMessage(content, options)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Chat.html#sendSeen">sendSeen()</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>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="Chat">new <span class="symbol-name">Chat</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
<dt>Extends</dt>
|
||||
<dd><a href="Base.html">Base</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="archived"><span class="symbol-name">archived</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the Chat is archived</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>ID that represents the chat</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isGroup"><span class="symbol-name">isGroup</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the Chat is a Group Chat</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="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="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Unix timestamp for when the chat was created</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="unreadCount"><span class="symbol-name">unreadCount</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Amount of messages unread</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<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>
|
||||
<p>Archives this chat</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="clearMessages"><span class="symbol-name">clearMessages</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Boolean</span></span></h3>
|
||||
<p>Clears all messages from the chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Boolean</code> <p>result</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="clearState"><span class="symbol-name">clearState</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Stops typing or recording in chat immediately.</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="delete"><span class="symbol-name">delete</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Boolean</span></span></h3>
|
||||
<p>Deletes the chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Boolean</code> <p>result</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>
|
||||
<p>Loads chat messages, sorted from earliest to latest.</p>
|
||||
<section>
|
||||
<h4>Parameters</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>searchOptions</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Options for searching messages. Right now only limit is supported.</p>
|
||||
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>limit</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
||||
<p>Defaults to <code>50</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Array of <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="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="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>
|
||||
<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>content</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>(string, <a href="MessageMedia.html">MessageMedia</a>, or <a href="Location.html">Location</a>)</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>options</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</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="Message.html">Message</a></code> <p>Message that was just sent</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendSeen"><span class="symbol-name">sendSeen</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Boolean</span></span></h3>
|
||||
<p>Set the message as seen</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Boolean</code> <p>result</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendStateRecording"><span class="symbol-name">sendStateRecording</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Simulate recording audio in chat. This will last for 25 seconds.</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendStateTyping"><span class="symbol-name">sendStateTyping</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Simulate typing in chat. This will last for 25 seconds.</p>
|
||||
<dl class="dl-compact">
|
||||
</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>
|
||||
<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>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
1361
docs/Client.html
Normal file
1361
docs/Client.html
Normal file
File diff suppressed because it is too large
Load Diff
715
docs/Client.js.html
Normal file
715
docs/Client.js.html
Normal file
@@ -0,0 +1,715 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » Source: Client.js</title>
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: Client.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const EventEmitter = require('events');
|
||||
const puppeteer = require('puppeteer');
|
||||
const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
|
||||
const jsQR = require('jsqr');
|
||||
|
||||
const Util = require('./util/Util');
|
||||
const InterfaceController = require('./util/InterfaceController');
|
||||
const { WhatsWebURL, UserAgent, 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, Contact, Location, GroupNotification } = require('./structures');
|
||||
/**
|
||||
* Starting point for interacting with the WhatsApp Web API
|
||||
* @extends {EventEmitter}
|
||||
* @fires Client#qr
|
||||
* @fires Client#authenticated
|
||||
* @fires Client#auth_failure
|
||||
* @fires Client#ready
|
||||
* @fires Client#message
|
||||
* @fires Client#message_ack
|
||||
* @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 = {}) {
|
||||
super();
|
||||
|
||||
this.options = Util.mergeDefault(DefaultOptions, options);
|
||||
|
||||
this.pupBrowser = null;
|
||||
this.pupPage = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up events and requirements, kicks off authentication request
|
||||
*/
|
||||
async initialize() {
|
||||
const browser = await puppeteer.launch(this.options.puppeteer);
|
||||
const page = (await browser.pages())[0];
|
||||
page.setUserAgent(UserAgent);
|
||||
|
||||
this.pupBrowser = browser;
|
||||
this.pupPage = page;
|
||||
|
||||
if (this.options.session) {
|
||||
await page.evaluateOnNewDocument(
|
||||
session => {
|
||||
localStorage.clear();
|
||||
localStorage.setItem('WABrowserId', session.WABrowserId);
|
||||
localStorage.setItem('WASecretBundle', session.WASecretBundle);
|
||||
localStorage.setItem('WAToken1', session.WAToken1);
|
||||
localStorage.setItem('WAToken2', session.WAToken2);
|
||||
}, this.options.session);
|
||||
}
|
||||
|
||||
await page.goto(WhatsWebURL, {
|
||||
waitUntil: 'load',
|
||||
timeout: 0,
|
||||
});
|
||||
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"]';
|
||||
|
||||
if (this.options.session) {
|
||||
// Check if session restore was successfull
|
||||
try {
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: this.options.authTimeoutMs });
|
||||
} catch (err) {
|
||||
if (err.name === 'TimeoutError') {
|
||||
/**
|
||||
* Emitted when there has been an error while trying to restore an existing session
|
||||
* @event Client#auth_failure
|
||||
* @param {string} message
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
} else {
|
||||
const getQrCode = async () => {
|
||||
// Check if retry button is present
|
||||
var QR_RETRY_SELECTOR = 'div[data-ref] > span > div';
|
||||
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, { 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
|
||||
* @param {string} qr QR Code
|
||||
*/
|
||||
this.emit(Events.QR_RECEIVED, qr);
|
||||
};
|
||||
getQrCode();
|
||||
this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
|
||||
|
||||
// Wait for code scan
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
this._qrRefreshInterval = undefined;
|
||||
|
||||
}
|
||||
|
||||
await page.evaluate(ExposeStore, moduleRaid.toString());
|
||||
|
||||
// Get session tokens
|
||||
const localStorage = JSON.parse(await page.evaluate(() => {
|
||||
return JSON.stringify(window.localStorage);
|
||||
}));
|
||||
|
||||
const session = {
|
||||
WABrowserId: localStorage.WABrowserId,
|
||||
WASecretBundle: localStorage.WASecretBundle,
|
||||
WAToken1: localStorage.WAToken1,
|
||||
WAToken2: localStorage.WAToken2
|
||||
};
|
||||
|
||||
/**
|
||||
* Emitted when authentication is successful
|
||||
* @event Client#authenticated
|
||||
* @param {object} session Object containing session information. Can be used to restore the session.
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATED, session);
|
||||
|
||||
// Check window.Store Injection
|
||||
await page.waitForFunction('window.Store != undefined');
|
||||
|
||||
//Load util functions (serializers, helper functions)
|
||||
await page.evaluate(LoadUtils);
|
||||
|
||||
// Expose client info
|
||||
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;
|
||||
|
||||
if (msg.type === 'gp2') {
|
||||
const notification = new GroupNotification(this, msg);
|
||||
if (msg.subtype === 'add' || msg.subtype === 'invite') {
|
||||
/**
|
||||
* Emitted when a user joins the chat via invite link or is added by an admin.
|
||||
* @event Client#group_join
|
||||
* @param {GroupNotification} notification GroupNotification with more information about the action
|
||||
*/
|
||||
this.emit(Events.GROUP_JOIN, notification);
|
||||
} else if (msg.subtype === 'remove' || msg.subtype === 'leave') {
|
||||
/**
|
||||
* Emitted when a user leaves the chat or is removed by an admin.
|
||||
* @event Client#group_leave
|
||||
* @param {GroupNotification} notification GroupNotification with more information about the action
|
||||
*/
|
||||
this.emit(Events.GROUP_LEAVE, notification);
|
||||
} else {
|
||||
/**
|
||||
* Emitted when group settings are updated, such as subject, description or picture.
|
||||
* @event Client#group_update
|
||||
* @param {GroupNotification} notification GroupNotification with more information about the action
|
||||
*/
|
||||
this.emit(Events.GROUP_UPDATE, notification);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
||||
/**
|
||||
* Emitted when a new message is created, which may include the current user's own messages.
|
||||
* @event Client#message_create
|
||||
* @param {Message} message The message that was created
|
||||
*/
|
||||
this.emit(Events.MESSAGE_CREATE, message);
|
||||
|
||||
if (msg.id.fromMe) return;
|
||||
|
||||
/**
|
||||
* Emitted when a new message is received.
|
||||
* @event Client#message
|
||||
* @param {Message} message The message that was received
|
||||
*/
|
||||
this.emit(Events.MESSAGE_RECEIVED, message);
|
||||
});
|
||||
|
||||
let last_message;
|
||||
|
||||
await page.exposeFunction('onChangeMessageTypeEvent', (msg) => {
|
||||
|
||||
if (msg.type === 'revoked') {
|
||||
const message = new Message(this, msg);
|
||||
let revoked_msg;
|
||||
if (last_message &amp;&amp; msg.id.id === last_message.id.id) {
|
||||
revoked_msg = new Message(this, last_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted when a message is deleted for everyone in the chat.
|
||||
* @event Client#message_revoke_everyone
|
||||
* @param {Message} message The message that was revoked, in its current state. It will not contain the original message's data.
|
||||
* @param {?Message} revoked_msg 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.
|
||||
*/
|
||||
this.emit(Events.MESSAGE_REVOKED_EVERYONE, message, revoked_msg);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
await page.exposeFunction('onChangeMessageEvent', (msg) => {
|
||||
|
||||
if (msg.type !== 'revoked') {
|
||||
last_message = msg;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
await page.exposeFunction('onRemoveMessageEvent', (msg) => {
|
||||
|
||||
if (!msg.isNewMsg) return;
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
||||
/**
|
||||
* Emitted when a message is deleted by the current user.
|
||||
* @event Client#message_revoke_me
|
||||
* @param {Message} message The message that was revoked
|
||||
*/
|
||||
this.emit(Events.MESSAGE_REVOKED_ME, message);
|
||||
|
||||
});
|
||||
|
||||
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
|
||||
* @param {Message} message The message that was affected
|
||||
* @param {MessageAck} ack The new ACK value
|
||||
*/
|
||||
this.emit(Events.MESSAGE_ACK, message, ack);
|
||||
|
||||
});
|
||||
|
||||
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
|
||||
* @event Client#change_state
|
||||
* @param {WAState} state the new connection state
|
||||
*/
|
||||
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
|
||||
*/
|
||||
this.emit(Events.DISCONNECTED, state);
|
||||
this.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
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 });
|
||||
});
|
||||
|
||||
await page.evaluate(() => {
|
||||
window.Store.Msg.on('add', (msg) => { if(msg.isNewMsg) window.onAddMessageEvent(msg); });
|
||||
window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(msg); });
|
||||
window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(msg); });
|
||||
window.Store.Msg.on('change:ack', (msg, ack) => { window.onMessageAckEvent(msg, ack); });
|
||||
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if(msg.id.fromMe &amp;&amp; !unsent) window.onMessageMediaUploadedEvent(msg); });
|
||||
window.Store.Msg.on('remove', (msg) => { if(msg.isNewMsg) window.onRemoveMessageEvent(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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @returns {Promise&lt;boolean>} result
|
||||
*
|
||||
*/
|
||||
async sendSeen(chatId) {
|
||||
const result = await this.pupPage.evaluate(async (chatId) => {
|
||||
return window.WWebJS.sendSeen(chatId);
|
||||
|
||||
}, chatId);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to a specific chatId
|
||||
* @param {string} chatId
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {object} options
|
||||
* @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,
|
||||
caption: options.caption,
|
||||
quotedMessageId: options.quotedMessageId,
|
||||
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : []
|
||||
};
|
||||
|
||||
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
||||
|
||||
if (content instanceof MessageMedia) {
|
||||
internalOptions.attachment = content;
|
||||
content = '';
|
||||
} else if (options.media instanceof MessageMedia) {
|
||||
internalOptions.attachment = options.media;
|
||||
internalOptions.caption = content;
|
||||
content = '';
|
||||
} else if (content instanceof Location) {
|
||||
internalOptions.location = content;
|
||||
content = '';
|
||||
}
|
||||
|
||||
const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = await window.Store.Chat.find(chatWid);
|
||||
|
||||
if(sendSeen) {
|
||||
window.WWebJS.sendSeen(chatId);
|
||||
}
|
||||
|
||||
const msg = await window.WWebJS.sendMessage(chat, message, options, sendSeen);
|
||||
return msg.serialize();
|
||||
}, chatId, content, internalOptions, sendSeen);
|
||||
|
||||
return new Message(this, newMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all current chat instances
|
||||
* @returns {Promise&lt;Array&lt;Chat>>}
|
||||
*/
|
||||
async getChats() {
|
||||
let chats = await this.pupPage.evaluate(() => {
|
||||
return window.WWebJS.getChats();
|
||||
});
|
||||
|
||||
return chats.map(chat => ChatFactory.create(this, chat));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get chat instance by ID
|
||||
* @param {string} chatId
|
||||
* @returns {Promise&lt;Chat>}
|
||||
*/
|
||||
async getChatById(chatId) {
|
||||
let chat = await this.pupPage.evaluate(chatId => {
|
||||
return window.WWebJS.getChat(chatId);
|
||||
}, chatId);
|
||||
|
||||
return ChatFactory.create(this, chat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all current contact instances
|
||||
* @returns {Promise&lt;Array&lt;Contact>>}
|
||||
*/
|
||||
async getContacts() {
|
||||
let contacts = await this.pupPage.evaluate(() => {
|
||||
return window.WWebJS.getContacts();
|
||||
});
|
||||
|
||||
return contacts.map(contact => ContactFactory.create(this, contact));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get contact instance by ID
|
||||
* @param {string} contactId
|
||||
* @returns {Promise&lt;Contact>}
|
||||
*/
|
||||
async getContactById(contactId) {
|
||||
let contact = await this.pupPage.evaluate(contactId => {
|
||||
return window.WWebJS.getContact(contactId);
|
||||
}, contactId);
|
||||
|
||||
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
|
||||
*/
|
||||
async acceptInvite(inviteCode) {
|
||||
const chatId = await this.pupPage.evaluate(async inviteCode => {
|
||||
return await window.Store.Invite.sendJoinGroupViaInvite(inviteCode);
|
||||
}, inviteCode);
|
||||
|
||||
return chatId._serialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current user's status message
|
||||
* @param {string} status New status message
|
||||
*/
|
||||
async setStatus(status) {
|
||||
await this.pupPage.evaluate(async status => {
|
||||
return await window.Store.Wap.sendSetStatus(status);
|
||||
}, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current connection state for the client
|
||||
* @returns {WAState}
|
||||
*/
|
||||
async getState() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Store.AppState.state;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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}
|
||||
*/
|
||||
async archiveChat(chatId) {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, true);
|
||||
return chat.archive;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes and returns the archive state of the Chat
|
||||
* @returns {boolean}
|
||||
*/
|
||||
async unarchiveChat(chatId) {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, false);
|
||||
return chat.archive;
|
||||
}, 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(){
|
||||
await this.pupPage.evaluate(() => {
|
||||
window.Store.AppState.phoneWatchdog.shiftTimer.forceRunNow();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given ID is registered in whatsapp
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
239
docs/ClientInfo.html
Normal file
239
docs/ClientInfo.html
Normal file
@@ -0,0 +1,239 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">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>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Current connection 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="ClientInfo.html#me">me</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="ClientInfo.html#phone">phone</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="ClientInfo.html#platform">platform</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="ClientInfo.html#pushname">pushname</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Method</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="ClientInfo.html#getBatteryStatus">getBatteryStatus()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="ClientInfo">new <span class="symbol-name">ClientInfo</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
<dt>Extends</dt>
|
||||
<dd><a href="Base.html">Base</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="me"><span class="symbol-name">me</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>Current user ID</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="phone"><span class="symbol-name">phone</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>Information about the phone this client is connected to</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>wa_version</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>WhatsApp Version running on the phone</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>os_version</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>OS Version running on the phone (iOS or Android version)</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>device_manufacturer</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Device manufacturer</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>device_model</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Device model</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>os_build_number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>OS build number</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="platform"><span class="symbol-name">platform</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Platform the phone is running on</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="pushname"><span class="symbol-name">pushname</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Name configured to be shown in push notifications</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>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
211
docs/Contact.html
Normal file
211
docs/Contact.html
Normal file
@@ -0,0 +1,211 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">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>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Contact on WhatsApp</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Properties</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Contact.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#isBusiness">isBusiness</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#isEnterprise">isEnterprise</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#isGroup">isGroup</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Contact.html#isMe">isMe</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#isMyContact">isMyContact</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#isUser">isUser</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#isWAContact">isWAContact</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>
|
||||
<dt><a href="Contact.html#pushname">pushname</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#shortName">shortName</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="Contact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="Contact">new <span class="symbol-name">Contact</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
<dt>Extends</dt>
|
||||
<dd><a href="Base.html">Base</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>ID that represents the 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>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isEnterprise"><span class="symbol-name">isEnterprise</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the contact is an enterprise contact</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isGroup"><span class="symbol-name">isGroup</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the contact is a group contact</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isMe"><span class="symbol-name">isMe</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the contact is the current user's contact</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isMyContact"><span class="symbol-name">isMyContact</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the number is saved in the current phone's contacts</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isUser"><span class="symbol-name">isUser</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the contact is a user contact</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isWAContact"><span class="symbol-name">isWAContact</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the number is registered on WhatsApp</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="name"><span class="symbol-name">name</span><small class="property-type">
|
||||
nullable string</small></h3>
|
||||
<p>The contact's name, as saved by the current user</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="number"><span class="symbol-name">number</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Contact's phone number</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="pushname"><span class="symbol-name">pushname</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>The name that the contact has configured to be shown publically</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="shortName"><span class="symbol-name">shortName</span><small class="property-type">
|
||||
nullable string</small></h3>
|
||||
<p>A shortened version of 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="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing string</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.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
713
docs/GroupChat.html
Normal file
713
docs/GroupChat.html
Normal file
@@ -0,0 +1,713 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">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>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Group Chat on WhatsApp</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Properties</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupChat.html#archived">archived</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#createdAt">createdAt</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#description">description</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupChat.html#isGroup">isGroup</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#isReadOnly">isReadOnly</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#owner">owner</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupChat.html#participants">participants</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#timestamp">timestamp</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#unreadCount">unreadCount</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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="GroupChat.html#addParticipants">addParticipants(participantIds)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#archive">archive()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#clearMessages">clearMessages()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#clearState">clearState()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#delete">delete()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#demoteParticipants">demoteParticipants(participantIds)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#fetchMessages">fetchMessages(searchOptions)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupChat.html#getInviteCode">getInviteCode()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#leave">leave()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#mute">mute(unmuteDate)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#promoteParticipants">promoteParticipants(participantIds)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#removeParticipants">removeParticipants(participantIds)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#revokeInvite">revokeInvite()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#sendMessage">sendMessage(content, options)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupChat.html#sendSeen">sendSeen()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupChat.html#sendStateRecording">sendStateRecording()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<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#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>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="GroupChat">new <span class="symbol-name">GroupChat</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
<dt>Extends</dt>
|
||||
<dd><a href="Chat.html">Chat</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="archived"><span class="symbol-name">archived</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the Chat is archived</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#archived">Chat#archived</a></dd>
|
||||
</dl>
|
||||
<h3 id="createdAt"><span class="symbol-name">createdAt</span><small class="property-type">
|
||||
date</small></h3>
|
||||
<p>Gets the date at which the group was created</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="description"><span class="symbol-name">description</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Gets the group description</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>ID that represents the chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#id">Chat#id</a></dd>
|
||||
</dl>
|
||||
<h3 id="isGroup"><span class="symbol-name">isGroup</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the Chat is a Group Chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#isGroup">Chat#isGroup</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>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#isReadOnly">Chat#isReadOnly</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>
|
||||
<dl class="dl-compact">
|
||||
<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>
|
||||
<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>
|
||||
<p>Gets the group participants</p>
|
||||
<dl class="dl-compact">
|
||||
</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>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#timestamp">Chat#timestamp</a></dd>
|
||||
</dl>
|
||||
<h3 id="unreadCount"><span class="symbol-name">unreadCount</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Amount of messages unread</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#unreadCount">Chat#unreadCount</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="addParticipants"><span class="symbol-name">addParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span></span></h3>
|
||||
<p>Adds a list of participants by ID to the group</p>
|
||||
<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>participantIds</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Array of 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="archive"><span class="symbol-name">archive</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Archives this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#archive">Chat#archive</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="clearMessages"><span class="symbol-name">clearMessages</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Boolean</span></span></h3>
|
||||
<p>Clears all messages from the chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#clearMessages">Chat#clearMessages</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>result</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="clearState"><span class="symbol-name">clearState</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Stops typing or recording in chat immediately.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#clearState">Chat#clearState</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="delete"><span class="symbol-name">delete</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Boolean</span></span></h3>
|
||||
<p>Deletes the chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#delete">Chat#delete</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>result</p>
|
||||
</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>
|
||||
<p>Demotes participants by IDs to regular users</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>participantIds</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Array of 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="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>
|
||||
<p>Loads chat messages, sorted from earliest to latest.</p>
|
||||
<section>
|
||||
<h4>Parameters</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>searchOptions</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Options for searching messages. Right now only limit is supported.</p>
|
||||
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>limit</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
||||
<p>Defaults to <code>50</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#fetchMessages">Chat#fetchMessages</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getInviteCode"><span class="symbol-name">getInviteCode</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Gets the invite code for a specific group</p>
|
||||
<dl class="dl-compact">
|
||||
</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>
|
||||
<p>Makes the bot leave the group</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> </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="promoteParticipants"><span class="symbol-name">promoteParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span></span></h3>
|
||||
<p>Promotes participants by IDs to admins</p>
|
||||
<section>
|
||||
<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>participantIds</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Array of 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="removeParticipants"><span class="symbol-name">removeParticipants</span><span class="signature"><span class="signature-params">(participantIds)</span></span></h3>
|
||||
<p>Removes a list of participants by ID to the 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>participantIds</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Array of 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="revokeInvite"><span class="symbol-name">revokeInvite</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Invalidates the current group invite code and generates a new one</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(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>
|
||||
<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>content</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>options</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#sendMessage">Chat#sendMessage</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>Message that was just sent</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendSeen"><span class="symbol-name">sendSeen</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Boolean</span></span></h3>
|
||||
<p>Set the message as seen</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#sendSeen">Chat#sendSeen</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>result</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendStateRecording"><span class="symbol-name">sendStateRecording</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Simulate recording audio in chat. This will last for 25 seconds.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#sendStateRecording">Chat#sendStateRecording</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendStateTyping"><span class="symbol-name">sendStateTyping</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Simulate typing in chat. This will last for 25 seconds.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<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>
|
||||
<p>Updates the group description</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>description</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="setSubject"><span class="symbol-name">setSubject</span><span class="signature"><span class="signature-params">(subject)</span></span></h3>
|
||||
<p>Updates the group subject</p>
|
||||
<section>
|
||||
<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>subject</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="unarchive"><span class="symbol-name">unarchive</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>un-archives this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<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>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
248
docs/GroupNotification.html
Normal file
248
docs/GroupNotification.html
Normal file
@@ -0,0 +1,248 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">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>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a GroupNotification on WhatsApp</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Properties</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupNotification.html#author">author</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupNotification.html#body">body</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupNotification.html#chatId">chatId</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupNotification.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupNotification.html#recipientIds">recipientIds</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupNotification.html#timestamp">timestamp</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupNotification.html#type">type</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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="GroupNotification.html#getChat">getChat()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupNotification.html#getContact">getContact()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="GroupNotification.html#getRecipients">getRecipients()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="GroupNotification.html#reply">reply(content, options)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="GroupNotification">new <span class="symbol-name">GroupNotification</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
<dt>Extends</dt>
|
||||
<dd><a href="Base.html">Base</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="author"><span class="symbol-name">author</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>ContactId for the user that produced the GroupNotification.</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="body"><span class="symbol-name">body</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Extra content</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="chatId"><span class="symbol-name">chatId</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>ID for the Chat that this groupNotification was sent for.</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>ID that represents the groupNotification</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="recipientIds"><span class="symbol-name">recipientIds</span><small class="property-type">
|
||||
Array of string</small></h3>
|
||||
<p>Contact IDs for the users that were affected by this GroupNotification.</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 groupNotification was created</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="type"><span class="symbol-name">type</span><small class="property-type">
|
||||
<a href="global.html#GroupNotificationTypes">GroupNotificationTypes</a></small></h3>
|
||||
<p>GroupNotification type</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<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 groupNotification was sent in</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="Chat.html">Chat</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<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 this GroupNotification was produced by</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="getRecipients"><span class="symbol-name">getRecipients</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 affected by this GroupNotification.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Array of <a href="Contact.html">Contact</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="reply"><span class="symbol-name">reply</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>Sends a message to the same chat this GroupNotification was produced in.</p>
|
||||
<section>
|
||||
<h4>Parameters</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>content</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>(string, <a href="MessageMedia.html">MessageMedia</a>, or <a href="Location.html">Location</a>)</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>options</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</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="Message.html">Message</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.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
202
docs/InterfaceController.html
Normal file
202
docs/InterfaceController.html
Normal file
@@ -0,0 +1,202 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">InterfaceController</span></h1>
|
||||
<p class="source-link">Source: <a href="util_InterfaceController.js.html#source-line-8">util/<wbr>InterfaceController.<wbr>js:8</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Interface Controller</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Methods</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="InterfaceController.html#closeRightDrawer">closeRightDrawer()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="InterfaceController.html#openChatDrawer">openChatDrawer(chatId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="InterfaceController.html#openChatWindow">openChatWindow(chatId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="InterfaceController.html#openMessageDrawer">openMessageDrawer(msgId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="InterfaceController">new <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="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="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.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
164
docs/Location.html
Normal file
164
docs/Location.html
Normal file
@@ -0,0 +1,164 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">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>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Location 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="Location.html#description">description</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Location.html#latitude">latitude</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Location.html#longitude">longitude</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="Location">new <span class="symbol-name">Location</span><span class="signature"><span class="signature-params">(latitude, longitude, description)</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>latitude</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>longitude</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>description</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="description"><span class="symbol-name">description</span><small class="property-type">
|
||||
nullable string</small></h3>
|
||||
<p>Name for the location</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="latitude"><span class="symbol-name">latitude</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Location latitude</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="longitude"><span class="symbol-name">longitude</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Location longitude</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
402
docs/Message.html
Normal file
402
docs/Message.html
Normal file
@@ -0,0 +1,402 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">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>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Message on WhatsApp</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Properties</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Message.html#ack">ack</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#author">author</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#body">body</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#broadcast">broadcast</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#from">from</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#fromMe">fromMe</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>
|
||||
<dt><a href="Message.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#isForwarded">isForwarded</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#location">location</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#mediaKey">mediaKey</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Message.html#mentionedIds">mentionedIds</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#timestamp">timestamp</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#to">to</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#type">type</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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="Message.html#delete">delete(everyone)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#downloadMedia">downloadMedia()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#getChat">getChat()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Message.html#getContact">getContact()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#getMentions">getMentions()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#getQuotedMessage">getQuotedMessage()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Message.html#reply">reply(content, chatId, options)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="Message">new <span class="symbol-name">Message</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
<dt>Extends</dt>
|
||||
<dd><a href="Base.html">Base</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="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>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="body"><span class="symbol-name">body</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Message content</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="broadcast"><span class="symbol-name">broadcast</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the message was a broadcast</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="from"><span class="symbol-name">from</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>ID for the Chat that this message was sent to, except if the message was sent by the current user.</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="fromMe"><span class="symbol-name">fromMe</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the message was sent by the current user</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="hasMedia"><span class="symbol-name">hasMedia</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the message has media available for download</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="hasQuotedMsg"><span class="symbol-name">hasQuotedMsg</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the message was sent as a reply to another message.</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>ID that represents the message</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isForwarded"><span class="symbol-name">isForwarded</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the message was forwarded</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="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>
|
||||
<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 message was created</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="to"><span class="symbol-name">to</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>ID for who this message is for.</p>
|
||||
<p>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.</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="type"><span class="symbol-name">type</span><small class="property-type">
|
||||
<a href="global.html#MessageTypes">MessageTypes</a></small></h3>
|
||||
<p>Message type</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="delete"><span class="symbol-name">delete</span><span class="signature"><span class="signature-params">(everyone)</span></span></h3>
|
||||
<p>Deletes a message from the 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>everyone</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>If true and the message is sent by the current user, will delete it for everyone in the chat.</p>
|
||||
<p>Value can be null.</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="downloadMedia"><span class="symbol-name">downloadMedia</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="MessageMedia.html">MessageMedia</a></span></span></h3>
|
||||
<p>Downloads and returns the attatched message media</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></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">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <a href="Chat.html">Chat</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<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 this message was sent from</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="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">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Array of <a href="Contact.html">Contact</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getQuotedMessage"><span class="symbol-name">getQuotedMessage</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<p>Returns the quoted message, if any</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<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="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>
|
||||
<section>
|
||||
<h4>Parameters</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>content</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>(string, <a href="MessageMedia.html">MessageMedia</a>, or <a href="Location.html">Location</a>)</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>chatId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>options</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</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="Message.html">Message</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.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
223
docs/MessageMedia.html
Normal file
223
docs/MessageMedia.html
Normal file
@@ -0,0 +1,223 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">MessageMedia</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_MessageMedia.js.html#source-line-14">structures/<wbr>MessageMedia.<wbr>js:14</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Media attached to a message</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="MessageMedia.html#data">data</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="MessageMedia.html#filename">filename</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="MessageMedia.html#mimetype">mimetype</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="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>
|
||||
<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>mimetype</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>MIME type of the attachment</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>data</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Base64-encoded data of the file</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>filename</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Document file name</p>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="data"><span class="symbol-name">data</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Base64 encoded data that represents the file</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="filename"><span class="symbol-name">filename</span><small class="property-type">
|
||||
nullable string</small></h3>
|
||||
<p>Name of the file (for documents)</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="mimetype"><span class="symbol-name">mimetype</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>MIME type of the attachment</p>
|
||||
<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>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
442
docs/PrivateChat.html
Normal file
442
docs/PrivateChat.html
Normal file
@@ -0,0 +1,442 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">PrivateChat</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_PrivateChat.js.html#source-line-9">structures/<wbr>PrivateChat.<wbr>js:9</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Private Chat on WhatsApp</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Properties</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateChat.html#archived">archived</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#isGroup">isGroup</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateChat.html#isReadOnly">isReadOnly</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#name">name</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#timestamp">timestamp</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateChat.html#unreadCount">unreadCount</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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="PrivateChat.html#archive">archive()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#clearMessages">clearMessages()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#clearState">clearState()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#delete">delete()</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>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#mute">mute(unmuteDate)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#sendMessage">sendMessage(content, options)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateChat.html#sendSeen">sendSeen()</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>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="PrivateChat">new <span class="symbol-name">PrivateChat</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
<dt>Extends</dt>
|
||||
<dd><a href="Chat.html">Chat</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="archived"><span class="symbol-name">archived</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the Chat is archived</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#archived">Chat#archived</a></dd>
|
||||
</dl>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>ID that represents the chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#id">Chat#id</a></dd>
|
||||
</dl>
|
||||
<h3 id="isGroup"><span class="symbol-name">isGroup</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the Chat is a Group Chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#isGroup">Chat#isGroup</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>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#isReadOnly">Chat#isReadOnly</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>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#name">Chat#name</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>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#timestamp">Chat#timestamp</a></dd>
|
||||
</dl>
|
||||
<h3 id="unreadCount"><span class="symbol-name">unreadCount</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Amount of messages unread</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#unreadCount">Chat#unreadCount</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Methods</h2>
|
||||
<section>
|
||||
<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>
|
||||
<p>Archives this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#archive">Chat#archive</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="clearMessages"><span class="symbol-name">clearMessages</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Boolean</span></span></h3>
|
||||
<p>Clears all messages from the chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#clearMessages">Chat#clearMessages</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>result</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="clearState"><span class="symbol-name">clearState</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Stops typing or recording in chat immediately.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#clearState">Chat#clearState</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="delete"><span class="symbol-name">delete</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Boolean</span></span></h3>
|
||||
<p>Deletes the chat</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#delete">Chat#delete</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>result</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>
|
||||
<p>Loads chat messages, sorted from earliest to latest.</p>
|
||||
<section>
|
||||
<h4>Parameters</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>searchOptions</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Options for searching messages. Right now only limit is supported.</p>
|
||||
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Optional</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>limit</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
||||
<p>Defaults to <code>50</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#fetchMessages">Chat#fetchMessages</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="mute"><span class="symbol-name">mute</span><span class="signature"><span class="signature-params">(unmuteDate)</span></span></h3>
|
||||
<p>Mutes this chat until a specified date</p>
|
||||
<section>
|
||||
<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="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>
|
||||
<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>content</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>options</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#sendMessage">Chat#sendMessage</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>Message that was just sent</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendSeen"><span class="symbol-name">sendSeen</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Boolean</span></span></h3>
|
||||
<p>Set the message as seen</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#sendSeen">Chat#sendSeen</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p>result</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendStateRecording"><span class="symbol-name">sendStateRecording</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Simulate recording audio in chat. This will last for 25 seconds.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Chat.html#sendStateRecording">Chat#sendStateRecording</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendStateTyping"><span class="symbol-name">sendStateTyping</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Simulate typing in chat. This will last for 25 seconds.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<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="unarchive"><span class="symbol-name">unarchive</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>un-archives this chat</p>
|
||||
<dl class="dl-compact">
|
||||
<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>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
235
docs/PrivateContact.html
Normal file
235
docs/PrivateContact.html
Normal file
@@ -0,0 +1,235 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">PrivateContact</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_PrivateContact.js.html#source-line-9">structures/<wbr>PrivateContact.<wbr>js:9</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Private Contact on WhatsApp</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
<div class="summary-callout">
|
||||
<h2 class="summary-callout-heading">Properties</h2>
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateContact.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#isBusiness">isBusiness</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#isEnterprise">isEnterprise</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#isGroup">isGroup</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateContact.html#isMe">isMe</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#isMyContact">isMyContact</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#isUser">isUser</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#isWAContact">isWAContact</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>
|
||||
<dt><a href="PrivateContact.html#pushname">pushname</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#shortName">shortName</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="PrivateContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="PrivateContact">new <span class="symbol-name">PrivateContact</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
<dt>Extends</dt>
|
||||
<dd><a href="Contact.html">Contact</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Properties</h2>
|
||||
<section>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>ID that represents the contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#id">Contact#id</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>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isBusiness">Contact#isBusiness</a></dd>
|
||||
</dl>
|
||||
<h3 id="isEnterprise"><span class="symbol-name">isEnterprise</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the contact is an enterprise contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isEnterprise">Contact#isEnterprise</a></dd>
|
||||
</dl>
|
||||
<h3 id="isGroup"><span class="symbol-name">isGroup</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the contact is a group contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isGroup">Contact#isGroup</a></dd>
|
||||
</dl>
|
||||
<h3 id="isMe"><span class="symbol-name">isMe</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the contact is the current user's contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isMe">Contact#isMe</a></dd>
|
||||
</dl>
|
||||
<h3 id="isMyContact"><span class="symbol-name">isMyContact</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the number is saved in the current phone's contacts</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isMyContact">Contact#isMyContact</a></dd>
|
||||
</dl>
|
||||
<h3 id="isUser"><span class="symbol-name">isUser</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the contact is a user contact</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isUser">Contact#isUser</a></dd>
|
||||
</dl>
|
||||
<h3 id="isWAContact"><span class="symbol-name">isWAContact</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Indicates if the number is registered on WhatsApp</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#isWAContact">Contact#isWAContact</a></dd>
|
||||
</dl>
|
||||
<h3 id="name"><span class="symbol-name">name</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>The contact's name, as saved by the current user</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#name">Contact#name</a></dd>
|
||||
</dl>
|
||||
<h3 id="number"><span class="symbol-name">number</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>Contact's phone number</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#number">Contact#number</a></dd>
|
||||
</dl>
|
||||
<h3 id="pushname"><span class="symbol-name">pushname</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>The name that the contact has configured to be shown publically</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#pushname">Contact#pushname</a></dd>
|
||||
</dl>
|
||||
<h3 id="shortName"><span class="symbol-name">shortName</span><small class="property-type">
|
||||
unknown</small></h3>
|
||||
<p>A shortened version of name</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#shortName">Contact#shortName</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<h2>Method</h2>
|
||||
<section>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getProfilePicUrl">Contact#getProfilePicUrl</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></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.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
65
docs/Util.html
Normal file
65
docs/Util.html
Normal file
@@ -0,0 +1,65 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||
<h1><small></small><span class="symbol-name">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>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Utility methods</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="Util">new <span class="symbol-name">Util</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
4
docs/css/baseline.css
Normal file
4
docs/css/baseline.css
Normal file
File diff suppressed because one or more lines are too long
1032
docs/global.html
Normal file
1032
docs/global.html
Normal file
File diff suppressed because it is too large
Load Diff
1999
docs/index.html
Normal file
1999
docs/index.html
Normal file
File diff suppressed because it is too large
Load Diff
2
docs/scripts/jquery.min.js
vendored
Normal file
2
docs/scripts/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
17
docs/scripts/jsdoc-toc.js
Normal file
17
docs/scripts/jsdoc-toc.js
Normal file
@@ -0,0 +1,17 @@
|
||||
(function($) {
|
||||
// TODO: make the node ID configurable
|
||||
var treeNode = $('#jsdoc-toc-nav');
|
||||
|
||||
// initialize the tree
|
||||
treeNode.tree({
|
||||
autoEscape: false,
|
||||
closedIcon: '⇢',
|
||||
data: [{"label":"<a href=\"global.html\">Globals</a>","id":"global","children":[]},{"label":"<a href=\"Base.html\">Base</a>","id":"Base","children":[]},{"label":"<a href=\"BusinessContact.html\">BusinessContact</a>","id":"BusinessContact","children":[]},{"label":"<a href=\"Chat.html\">Chat</a>","id":"Chat","children":[]},{"label":"<a href=\"Client.html\">Client</a>","id":"Client","children":[]},{"label":"<a href=\"ClientInfo.html\">ClientInfo</a>","id":"ClientInfo","children":[]},{"label":"<a href=\"Contact.html\">Contact</a>","id":"Contact","children":[]},{"label":"<a href=\"GroupChat.html\">GroupChat</a>","id":"GroupChat","children":[]},{"label":"<a href=\"GroupNotification.html\">GroupNotification</a>","id":"GroupNotification","children":[]},{"label":"<a href=\"InterfaceController.html\">InterfaceController</a>","id":"InterfaceController","children":[]},{"label":"<a href=\"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
|
||||
});
|
||||
|
||||
// add event handlers
|
||||
// TODO
|
||||
})(jQuery);
|
||||
1
docs/scripts/lang-css.js
Normal file
1
docs/scripts/lang-css.js
Normal file
@@ -0,0 +1 @@
|
||||
PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']+)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:<!--|-->)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}\b/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]),PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]),PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]);
|
||||
1
docs/scripts/linenumber.js
Normal file
1
docs/scripts/linenumber.js
Normal file
@@ -0,0 +1 @@
|
||||
!function(){var n,e=0,t=document.getElementsByClassName("prettyprint");t&&t[0]&&(n=(n=(t=t[0].getElementsByTagName("code")[0]).innerHTML.split("\n")).map(function(n){return'<span id="source-line-'+ ++e+'" class="line"></span>'+n}),t.innerHTML=n.join("\n"))}();
|
||||
1
docs/scripts/prettify.js
Normal file
1
docs/scripts/prettify.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/scripts/scrollanchor.js
Normal file
1
docs/scripts/scrollanchor.js
Normal file
@@ -0,0 +1 @@
|
||||
!function(){function o(n){var o,t,e=document.getElementById(n.replace(/^#/,""));e&&(t=e.getBoundingClientRect(),o=t.top+window.pageYOffset,setTimeout(function(){window.scrollTo(0,o-50)},5))}window.addEventListener("load",function(){var n=window.location.hash;n&&"#"!==n&&o(n),window.addEventListener("hashchange",function(){o(window.location.hash)})})}();
|
||||
1
docs/scripts/tree.jquery.js
Normal file
1
docs/scripts/tree.jquery.js
Normal file
File diff suppressed because one or more lines are too long
75
docs/structures_Base.js.html
Normal file
75
docs/structures_Base.js.html
Normal file
@@ -0,0 +1,75 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/Base.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
/**
|
||||
* Represents a WhatsApp data structure
|
||||
*/
|
||||
class Base {
|
||||
constructor(client) {
|
||||
/**
|
||||
* The client that instantiated this
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(this, 'client', { value: client });
|
||||
}
|
||||
|
||||
_clone() {
|
||||
return Object.assign(Object.create(this), this);
|
||||
}
|
||||
|
||||
_patch(data) { return data; }
|
||||
}
|
||||
|
||||
module.exports = Base;</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
74
docs/structures_BusinessContact.js.html
Normal file
74
docs/structures_BusinessContact.js.html
Normal file
@@ -0,0 +1,74 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/BusinessContact.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Contact = require('./Contact');
|
||||
|
||||
/**
|
||||
* Represents a Business Contact on WhatsApp
|
||||
* @extends {Contact}
|
||||
*/
|
||||
class BusinessContact extends Contact {
|
||||
_patch(data) {
|
||||
/**
|
||||
* The contact's business profile
|
||||
*/
|
||||
this.businessProfile = data.businessProfile;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = BusinessContact;</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
245
docs/structures_Chat.js.html
Normal file
245
docs/structures_Chat.js.html
Normal file
@@ -0,0 +1,245 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/Chat.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
const Message = require('./Message');
|
||||
|
||||
/**
|
||||
* Represents a Chat on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class Chat extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* ID that represents the chat
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
/**
|
||||
* Title of the chat
|
||||
* @type {string}
|
||||
*/
|
||||
this.name = data.formattedTitle;
|
||||
|
||||
/**
|
||||
* Indicates if the Chat is a Group Chat
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isGroup = data.isGroup;
|
||||
|
||||
/**
|
||||
* Indicates if the Chat is readonly
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isReadOnly = data.isReadOnly;
|
||||
|
||||
/**
|
||||
* Amount of messages unread
|
||||
* @type {number}
|
||||
*/
|
||||
this.unreadCount = data.unreadCount;
|
||||
|
||||
/**
|
||||
* Unix timestamp for when the chat was created
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.t;
|
||||
|
||||
/**
|
||||
* Indicates if the Chat is archived
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.archived = data.archive;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to this chat
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {object} options
|
||||
* @returns {Promise&lt;Message>} Message that was just sent
|
||||
*/
|
||||
async sendMessage(content, options) {
|
||||
return this.client.sendMessage(this.id._serialized, content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message as seen
|
||||
* @returns {Promise&lt;Boolean>} result
|
||||
*/
|
||||
async sendSeen() {
|
||||
return this.client.sendSeen(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all messages from the chat
|
||||
* @returns {Promise&lt;Boolean>} result
|
||||
*/
|
||||
async clearMessages() {
|
||||
return this.client.pupPage.evaluate(chatId => {
|
||||
return window.WWebJS.sendClearChat(chatId);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the chat
|
||||
* @returns {Promise&lt;Boolean>} result
|
||||
*/
|
||||
async delete() {
|
||||
return this.client.pupPage.evaluate(chatId => {
|
||||
return window.WWebJS.sendDeleteChat(chatId);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Archives this chat
|
||||
*/
|
||||
async archive() {
|
||||
return this.client.archiveChat(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* un-archives this chat
|
||||
*/
|
||||
async unarchive() {
|
||||
return this.client.unarchiveChat(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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads chat messages, sorted from earliest to latest.
|
||||
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
||||
* @param {Number} [searchOptions.limit=50] The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.
|
||||
* @returns {Promise&lt;Array&lt;Message>>}
|
||||
*/
|
||||
async fetchMessages(searchOptions) {
|
||||
if(!searchOptions || !searchOptions.limit) {
|
||||
searchOptions = {limit: 50};
|
||||
}
|
||||
let messages = await this.client.pupPage.evaluate(async (chatId, limit) => {
|
||||
const msgFilter = m => !m.isNotification; // dont include notification messages
|
||||
|
||||
const chat = window.Store.Chat.get(chatId);
|
||||
let msgs = chat.msgs.models.filter(msgFilter);
|
||||
|
||||
while(msgs.length &lt; limit) {
|
||||
const loadedMessages = await chat.loadEarlierMsgs();
|
||||
if(!loadedMessages) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
}
|
||||
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
return msgs.splice(msgs.length - limit).map(m => m.serialize());
|
||||
|
||||
}, this.id._serialized, searchOptions.limit);
|
||||
|
||||
return messages.map(m => new Message(this.client, m));
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate typing in chat. This will last for 25 seconds.
|
||||
*/
|
||||
async sendStateTyping() {
|
||||
return this.client.pupPage.evaluate(chatId => {
|
||||
window.WWebJS.sendChatstate('typing', chatId);
|
||||
return true;
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate recording audio in chat. This will last for 25 seconds.
|
||||
*/
|
||||
async sendStateRecording() {
|
||||
return this.client.pupPage.evaluate(chatId => {
|
||||
window.WWebJS.sendChatstate('recording', chatId);
|
||||
return true;
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops typing or recording in chat immediately.
|
||||
*/
|
||||
async clearState() {
|
||||
return this.client.pupPage.evaluate(chatId => {
|
||||
window.WWebJS.sendChatstate('stop', chatId);
|
||||
return true;
|
||||
}, this.id._serialized);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Chat;
|
||||
</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
117
docs/structures_ClientInfo.js.html
Normal file
117
docs/structures_ClientInfo.js.html
Normal file
@@ -0,0 +1,117 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/ClientInfo.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Current connection information
|
||||
* @extends {Base}
|
||||
*/
|
||||
class ClientInfo extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* Name configured to be shown in push notifications
|
||||
* @type {string}
|
||||
*/
|
||||
this.pushname = data.pushname;
|
||||
|
||||
/**
|
||||
* Current user ID
|
||||
* @type {object}
|
||||
*/
|
||||
this.me = data.me;
|
||||
|
||||
/**
|
||||
* Information about the phone this client is connected to
|
||||
* @type {object}
|
||||
* @property {string} wa_version WhatsApp Version running on the phone
|
||||
* @property {string} os_version OS Version running on the phone (iOS or Android version)
|
||||
* @property {string} device_manufacturer Device manufacturer
|
||||
* @property {string} device_model Device model
|
||||
* @property {string} os_build_number OS build number
|
||||
*/
|
||||
this.phone = data.phone;
|
||||
|
||||
/**
|
||||
* Platform the phone is running on
|
||||
* @type {string}
|
||||
*/
|
||||
this.platform = data.platform;
|
||||
|
||||
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>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
164
docs/structures_Contact.js.html
Normal file
164
docs/structures_Contact.js.html
Normal file
@@ -0,0 +1,164 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/Contact.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Represents a Contact on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class Contact extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* ID that represents the contact
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
/**
|
||||
* Contact's phone number
|
||||
* @type {string}
|
||||
*/
|
||||
this.number = data.userid;
|
||||
|
||||
/**
|
||||
* Indicates if the contact is a business contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isBusiness = data.isBusiness;
|
||||
|
||||
/**
|
||||
* Indicates if the contact is an enterprise contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isEnterprise = data.isEnterprise;
|
||||
|
||||
this.labels = data.labels;
|
||||
|
||||
/**
|
||||
* The contact's name, as saved by the current user
|
||||
* @type {?string}
|
||||
*/
|
||||
this.name = data.name;
|
||||
|
||||
/**
|
||||
* The name that the contact has configured to be shown publically
|
||||
* @type {string}
|
||||
*/
|
||||
this.pushname = data.pushname;
|
||||
|
||||
this.sectionHeader = data.sectionHeader;
|
||||
|
||||
/**
|
||||
* A shortened version of name
|
||||
* @type {?string}
|
||||
*/
|
||||
this.shortName = data.shortName;
|
||||
|
||||
this.statusMute = data.statusMute;
|
||||
this.type = data.type;
|
||||
this.verifiedLevel = data.verifiedLevel;
|
||||
this.verifiedName = data.verifiedName;
|
||||
|
||||
/**
|
||||
* Indicates if the contact is the current user's contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isMe = data.isMe;
|
||||
|
||||
/**
|
||||
* Indicates if the contact is a user contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isUser = data.isUser;
|
||||
|
||||
/**
|
||||
* Indicates if the contact is a group contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isGroup = data.isGroup;
|
||||
|
||||
/**
|
||||
* Indicates if the number is registered on WhatsApp
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isWAContact = data.isWAContact;
|
||||
|
||||
/**
|
||||
* Indicates if the number is saved in the current phone's contacts
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isMyContact = data.isMyContact;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contact's profile picture URL, if privacy settings allow it
|
||||
* @returns {Promise&lt;string>}
|
||||
*/
|
||||
async getProfilePicUrl() {
|
||||
return await this.client.getProfilePicUrl(this.id._serialized);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Contact;</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
203
docs/structures_GroupChat.js.html
Normal file
203
docs/structures_GroupChat.js.html
Normal file
@@ -0,0 +1,203 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/GroupChat.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Chat = require('./Chat');
|
||||
|
||||
/**
|
||||
* Represents a Group Chat on WhatsApp
|
||||
* @extends {Chat}
|
||||
*/
|
||||
class GroupChat extends Chat {
|
||||
_patch(data) {
|
||||
this.groupMetadata = data.groupMetadata;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the group owner
|
||||
*/
|
||||
get owner() {
|
||||
return this.groupMetadata.owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date at which the group was created
|
||||
* @type {date}
|
||||
*/
|
||||
get createdAt() {
|
||||
return new Date(this.groupMetadata.creation * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the group description
|
||||
* @type {string}
|
||||
*/
|
||||
get description() {
|
||||
return this.groupMetadata.desc;
|
||||
}
|
||||
/**
|
||||
* Gets the group participants
|
||||
* @type {array}
|
||||
*/
|
||||
get participants() {
|
||||
return this.groupMetadata.participants;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a list of participants by ID to the group
|
||||
* @param {Array&lt;string>} participantIds
|
||||
*/
|
||||
async addParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.addParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a list of participants by ID to the group
|
||||
* @param {Array&lt;string>} participantIds
|
||||
*/
|
||||
async removeParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.removeParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Promotes participants by IDs to admins
|
||||
* @param {Array&lt;string>} participantIds
|
||||
*/
|
||||
async promoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.promoteParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Demotes participants by IDs to regular users
|
||||
* @param {Array&lt;string>} participantIds
|
||||
*/
|
||||
async demoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.demoteParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the group subject
|
||||
* @param {string} subject
|
||||
*/
|
||||
async setSubject(subject) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, subject) => {
|
||||
return window.Store.Wap.changeSubject(chatId, subject);
|
||||
}, this.id._serialized, subject);
|
||||
|
||||
if(res.status == 200) {
|
||||
this.name = subject;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the group description
|
||||
* @param {string} description
|
||||
*/
|
||||
async setDescription(description) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, description) => {
|
||||
let descId = window.Store.GroupMetadata.get(chatId).descId;
|
||||
return window.Store.Wap.setGroupDescription(chatId, description, window.Store.genId(), descId);
|
||||
}, this.id._serialized, description);
|
||||
|
||||
if (res.status == 200) {
|
||||
this.groupMetadata.desc = description;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the invite code for a specific group
|
||||
*/
|
||||
async getInviteCode() {
|
||||
let res = await this.client.pupPage.evaluate(chatId => {
|
||||
return window.Store.Wap.groupInviteCode(chatId);
|
||||
}, this.id._serialized);
|
||||
|
||||
if (res.status == 200) {
|
||||
return res.code;
|
||||
}
|
||||
|
||||
throw new Error('Not authorized');
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates the current group invite code and generates a new one
|
||||
*/
|
||||
async revokeInvite() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
return window.Store.Wap.revokeGroupInvite(chatId);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the bot leave the group
|
||||
*/
|
||||
async leave() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
return window.Store.Wap.leaveGroup(chatId);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = GroupChat;</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
158
docs/structures_GroupNotification.js.html
Normal file
158
docs/structures_GroupNotification.js.html
Normal file
@@ -0,0 +1,158 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/GroupNotification.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Represents a GroupNotification on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class GroupNotification extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* ID that represents the groupNotification
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
/**
|
||||
* Extra content
|
||||
* @type {string}
|
||||
*/
|
||||
this.body = data.body || '';
|
||||
|
||||
/**
|
||||
* GroupNotification type
|
||||
* @type {GroupNotificationTypes}
|
||||
*/
|
||||
this.type = data.subtype;
|
||||
|
||||
/**
|
||||
* Unix timestamp for when the groupNotification was created
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.t;
|
||||
|
||||
/**
|
||||
* ID for the Chat that this groupNotification was sent for.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.chatId = typeof (data.from) === 'object' ? data.from._serialized : data.from;
|
||||
|
||||
/**
|
||||
* ContactId for the user that produced the GroupNotification.
|
||||
* @type {string}
|
||||
*/
|
||||
this.author = typeof (data.author) === 'object' ? data.author._serialized : data.author;
|
||||
|
||||
/**
|
||||
* Contact IDs for the users that were affected by this GroupNotification.
|
||||
* @type {Array&lt;string>}
|
||||
*/
|
||||
this.recipientIds = [];
|
||||
|
||||
if (data.recipients) {
|
||||
this.recipientIds = data.recipients;
|
||||
}
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Chat this groupNotification was sent in
|
||||
* @returns {Promise&lt;Chat>}
|
||||
*/
|
||||
getChat() {
|
||||
return this.client.getChatById(this.chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Contact this GroupNotification was produced by
|
||||
* @returns {Promise&lt;Contact>}
|
||||
*/
|
||||
getContact() {
|
||||
return this.client.getContactById(this.author);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Contacts affected by this GroupNotification.
|
||||
* @returns {Promise&lt;Array&lt;Contact>>}
|
||||
*/
|
||||
async getRecipients() {
|
||||
return await Promise.all(this.recipientIds.map(async m => await this.client.getContactById(m)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the same chat this GroupNotification was produced in.
|
||||
*
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {object} options
|
||||
* @returns {Promise&lt;Message>}
|
||||
*/
|
||||
async reply(content, options={}) {
|
||||
return this.client.sendMessage(this.chatId, content, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = GroupNotification;
|
||||
</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
86
docs/structures_Location.js.html
Normal file
86
docs/structures_Location.js.html
Normal file
@@ -0,0 +1,86 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/Location.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
/**
|
||||
* Location information
|
||||
*/
|
||||
class Location {
|
||||
/**
|
||||
* @param {number} latitude
|
||||
* @param {number} longitude
|
||||
* @param {?string} description
|
||||
*/
|
||||
constructor(latitude, longitude, description) {
|
||||
/**
|
||||
* Location latitude
|
||||
* @type {number}
|
||||
*/
|
||||
this.latitude = latitude;
|
||||
|
||||
/**
|
||||
* Location longitude
|
||||
* @type {number}
|
||||
*/
|
||||
this.longitude = longitude;
|
||||
|
||||
/**
|
||||
* Name for the location
|
||||
* @type {?string}
|
||||
*/
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Location;</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
302
docs/structures_Message.js.html
Normal file
302
docs/structures_Message.js.html
Normal file
@@ -0,0 +1,302 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » Source: structures/Message.js</title>
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/Message.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
const MessageMedia = require('./MessageMedia');
|
||||
const Location = require('./Location');
|
||||
const { MessageTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents a Message on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class Message extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Message content
|
||||
* @type {string}
|
||||
*/
|
||||
this.body = this.hasMedia ? data.caption || '' : data.body || '';
|
||||
|
||||
/**
|
||||
* Message type
|
||||
* @type {MessageTypes}
|
||||
*/
|
||||
this.type = data.type;
|
||||
|
||||
/**
|
||||
* Unix timestamp for when the message was created
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.t;
|
||||
|
||||
/**
|
||||
* 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' &amp;&amp; data.from !== null) ? data.from._serialized : data.from;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @type {string}
|
||||
*/
|
||||
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' &amp;&amp; data.author !== null) ? data.author._serialized : data.author;
|
||||
|
||||
/**
|
||||
* Indicates if the message was forwarded
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isForwarded = data.isForwarded;
|
||||
|
||||
/**
|
||||
* Indicates if the message was a broadcast
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.broadcast = data.broadcast;
|
||||
|
||||
/**
|
||||
* Indicates if the message was sent by the current user
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.fromMe = data.id.fromMe;
|
||||
|
||||
/**
|
||||
* Indicates if the message was sent as a reply to another message.
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.hasQuotedMsg = data.quotedMsg ? true : false;
|
||||
|
||||
/**
|
||||
* Location information contained in the message, if the message is type "location"
|
||||
* @type {Location}
|
||||
*/
|
||||
this.location = data.type === MessageTypes.LOCATION ? new Location(data.lat, data.lng, data.loc) : undefined;
|
||||
|
||||
/**
|
||||
* Indicates the mentions in the message body.
|
||||
* @type {Array&lt;string>}
|
||||
*/
|
||||
this.mentionedIds = [];
|
||||
|
||||
if (data.mentionedJidList) {
|
||||
this.mentionedIds = data.mentionedJidList;
|
||||
}
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
_getChatId() {
|
||||
return this.fromMe ? this.to : this.from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Chat this message was sent in
|
||||
* @returns {Promise&lt;Chat>}
|
||||
*/
|
||||
getChat() {
|
||||
return this.client.getChatById(this._getChatId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Contact this message was sent from
|
||||
* @returns {Promise&lt;Contact>}
|
||||
*/
|
||||
getContact() {
|
||||
return this.client.getContactById(this.author || this.from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Contacts mentioned in this message
|
||||
* @returns {Promise&lt;Array&lt;Contact>>}
|
||||
*/
|
||||
async getMentions() {
|
||||
return await Promise.all(this.mentionedIds.map(async m => await this.client.getContactById(m)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quoted message, if any
|
||||
* @returns {Promise&lt;Message>}
|
||||
*/
|
||||
async getQuotedMessage() {
|
||||
if (!this.hasQuotedMsg) return undefined;
|
||||
|
||||
const quotedMsg = await this.client.pupPage.evaluate((msgId) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
return msg.quotedMsgObj().serialize();
|
||||
}, this.id._serialized);
|
||||
|
||||
return new Message(this.client, quotedMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {?string} chatId
|
||||
* @param {object} options
|
||||
* @returns {Promise&lt;Message>}
|
||||
*/
|
||||
async reply(content, chatId, options={}) {
|
||||
if (!chatId) {
|
||||
chatId = this._getChatId();
|
||||
}
|
||||
|
||||
options = {
|
||||
...options,
|
||||
quotedMessageId: this.id._serialized
|
||||
};
|
||||
|
||||
return this.client.sendMessage(chatId, content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the attatched message media
|
||||
* @returns {Promise&lt;MessageMedia>}
|
||||
*/
|
||||
async downloadMedia() {
|
||||
if (!this.hasMedia) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const result = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
|
||||
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 buffer = await window.WWebJS.downloadBuffer(msg.clientUrl);
|
||||
const decrypted = await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
|
||||
const data = await window.WWebJS.readBlobAsync(decrypted._blob);
|
||||
|
||||
return {
|
||||
data: data.split(',')[1],
|
||||
mimetype: msg.mimetype,
|
||||
filename: msg.filename
|
||||
};
|
||||
|
||||
}, this.id._serialized);
|
||||
|
||||
if(!result) return undefined;
|
||||
return new MessageMedia(result.mimetype, result.data, result.filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a message from the chat
|
||||
* @param {?boolean} everyone If true and the message is sent by the current user, will delete it for everyone in the chat.
|
||||
*/
|
||||
async delete(everyone) {
|
||||
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()) {
|
||||
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], true);
|
||||
}
|
||||
|
||||
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
||||
}, this.id._serialized, everyone);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Message;
|
||||
</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
101
docs/structures_MessageMedia.js.html
Normal file
101
docs/structures_MessageMedia.js.html
Normal file
@@ -0,0 +1,101 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/MessageMedia.js</h1>
|
||||
</header>
|
||||
<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
|
||||
* @param {string} data Base64-encoded data of the file
|
||||
* @param {?string} filename Document file name
|
||||
*/
|
||||
class MessageMedia {
|
||||
constructor(mimetype, data, filename) {
|
||||
/**
|
||||
* MIME type of the attachment
|
||||
* @type {string}
|
||||
*/
|
||||
this.mimetype = mimetype;
|
||||
|
||||
/**
|
||||
* Base64 encoded data that represents the file
|
||||
* @type {string}
|
||||
*/
|
||||
this.data = data;
|
||||
|
||||
/**
|
||||
* Name of the file (for documents)
|
||||
* @type {?string}
|
||||
*/
|
||||
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>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
66
docs/structures_PrivateChat.js.html
Normal file
66
docs/structures_PrivateChat.js.html
Normal file
@@ -0,0 +1,66 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/PrivateChat.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Chat = require('./Chat');
|
||||
|
||||
/**
|
||||
* Represents a Private Chat on WhatsApp
|
||||
* @extends {Chat}
|
||||
*/
|
||||
class PrivateChat extends Chat {
|
||||
|
||||
}
|
||||
|
||||
module.exports = PrivateChat;</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
66
docs/structures_PrivateContact.js.html
Normal file
66
docs/structures_PrivateContact.js.html
Normal file
@@ -0,0 +1,66 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: structures/PrivateContact.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Contact = require('./Contact');
|
||||
|
||||
/**
|
||||
* Represents a Private Contact on WhatsApp
|
||||
* @extends {Contact}
|
||||
*/
|
||||
class PrivateContact extends Contact {
|
||||
|
||||
}
|
||||
|
||||
module.exports = PrivateContact;</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
189
docs/util_Constants.js.html
Normal file
189
docs/util_Constants.js.html
Normal file
@@ -0,0 +1,189 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: util/Constants.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
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,
|
||||
defaultViewport: null
|
||||
},
|
||||
session: false,
|
||||
qrTimeoutMs: 45000,
|
||||
qrRefreshIntervalMs: 20000,
|
||||
authTimeoutMs: 45000,
|
||||
takeoverOnConflict: false,
|
||||
takeoverTimeoutMs: 0
|
||||
};
|
||||
|
||||
/**
|
||||
* Client status
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
*/
|
||||
exports.Status = {
|
||||
INITIALIZING: 0,
|
||||
AUTHENTICATING: 1,
|
||||
READY: 3
|
||||
};
|
||||
|
||||
/**
|
||||
* Events that can be emitted by the client
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
exports.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'
|
||||
};
|
||||
|
||||
/**
|
||||
* Message types
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
exports.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'
|
||||
};
|
||||
|
||||
/**
|
||||
* Group notification types
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
exports.GroupNotificationTypes = {
|
||||
ADD: 'add',
|
||||
INVITE: 'invite',
|
||||
REMOVE: 'remove',
|
||||
LEAVE: 'leave',
|
||||
SUBJECT: 'subject',
|
||||
DESCRIPTION: 'description',
|
||||
PICTURE: 'picture',
|
||||
ANNOUNCE: 'announce',
|
||||
RESTRICT: 'restrict',
|
||||
};
|
||||
|
||||
/**
|
||||
* Chat types
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
exports.ChatTypes = {
|
||||
SOLO: 'solo',
|
||||
GROUP: 'group',
|
||||
UNKNOWN: 'unknown'
|
||||
};
|
||||
|
||||
/**
|
||||
* WhatsApp state
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
exports.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'
|
||||
};
|
||||
|
||||
/**
|
||||
* Message ACK
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
*/
|
||||
exports.MessageAck = {
|
||||
ACK_ERROR: -1,
|
||||
ACK_PENDING: 0,
|
||||
ACK_SERVER: 1,
|
||||
ACK_DEVICE: 2,
|
||||
ACK_READ: 3,
|
||||
ACK_PLAYED: 4,
|
||||
};
|
||||
</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
109
docs/util_InterfaceController.js.html
Normal file
109
docs/util_InterfaceController.js.html
Normal file
@@ -0,0 +1,109 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: util/InterfaceController.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
/**
|
||||
* Interface Controller
|
||||
*/
|
||||
class InterfaceController {
|
||||
|
||||
constructor(props) {
|
||||
this.pupPage = props.pupPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Chat Window
|
||||
* @param {string} chatId ID of the chat window that will be opened
|
||||
*/
|
||||
async openChatWindow(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.openChatAt(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Chat Drawer
|
||||
* @param {string} chatId ID of the chat drawer that will be opened
|
||||
*/
|
||||
async openChatDrawer(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.chatInfoDrawer(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Message Drawer
|
||||
* @param {string} msgId ID of the message drawer that will be opened
|
||||
*/
|
||||
async openMessageDrawer(msgId) {
|
||||
await this.pupPage.evaluate(async msgId => {
|
||||
let msg = await window.Store.Msg.get(msgId);
|
||||
await window.Store.Cmd.msgInfoDrawer(msg);
|
||||
}, msgId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the Right Drawer
|
||||
*/
|
||||
async closeRightDrawer() {
|
||||
await this.pupPage.evaluate(async () => {
|
||||
await window.Store.Cmd.closeDrawerRight();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = InterfaceController;</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
88
docs/util_Util.js.html
Normal file
88
docs/util_Util.js.html
Normal file
@@ -0,0 +1,88 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.4">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.7.0 » 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">
|
||||
<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>7.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="jsdoc-body-container">
|
||||
<div id="jsdoc-content">
|
||||
<div id="jsdoc-content-container">
|
||||
<div id="jsdoc-banner" role="banner">
|
||||
</div>
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>Source: util/Util.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
||||
|
||||
/**
|
||||
* Utility methods
|
||||
*/
|
||||
class Util {
|
||||
|
||||
constructor() {
|
||||
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets default properties on an object that aren't already specified.
|
||||
* @param {Object} def Default properties
|
||||
* @param {Object} given Object to assign defaults to
|
||||
* @returns {Object}
|
||||
* @private
|
||||
*/
|
||||
static mergeDefault(def, given) {
|
||||
if (!given) return def;
|
||||
for (const key in def) {
|
||||
if (!has(given, key) || given[key] === undefined) {
|
||||
given[key] = def[key];
|
||||
} else if (given[key] === Object(given[key])) {
|
||||
given[key] = Util.mergeDefault(def[key], given[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return given;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Util;</code></pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
||||
</div>
|
||||
</div>
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.4 on June 18, 2020.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/tree.jquery.js"></script>
|
||||
<script src="scripts/prettify.js"></script>
|
||||
<script src="scripts/jsdoc-toc.js"></script>
|
||||
<script src="scripts/linenumber.js"></script>
|
||||
<script src="scripts/scrollanchor.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
180
example.js
180
example.js
@@ -1,6 +1,13 @@
|
||||
const { Client } = require('./index')
|
||||
const fs = require('fs');
|
||||
const { Client, Location } = require('./index');
|
||||
|
||||
const client = new Client({puppeteer: {headless: false}});
|
||||
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 });
|
||||
// You can use an existing session and avoid scanning a QR code by adding a "session" object to the client options.
|
||||
// This object must include WABrowserId, WASecretBundle, WAToken1 and WAToken2.
|
||||
|
||||
@@ -13,12 +20,18 @@ client.on('qr', (qr) => {
|
||||
|
||||
client.on('authenticated', (session) => {
|
||||
console.log('AUTHENTICATED', session);
|
||||
sessionCfg=session;
|
||||
fs.writeFile(SESSION_FILE_PATH, JSON.stringify(session), function (err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
client.on('auth_failure', msg => {
|
||||
// Fired if session restore was unsuccessfull
|
||||
console.error('AUTHENTICATION FAILURE', msg);
|
||||
})
|
||||
});
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log('READY');
|
||||
@@ -35,10 +48,20 @@ client.on('message', async msg => {
|
||||
// Send a new message to the same chat
|
||||
client.sendMessage(msg.from, 'pong');
|
||||
|
||||
} else if (msg.body.startsWith('!sendto ')) {
|
||||
// Direct send a new message to specific id
|
||||
let number = msg.body.split(' ')[1];
|
||||
let messageIndex = msg.body.indexOf(number) + number.length;
|
||||
let message = msg.body.slice(messageIndex, msg.body.length);
|
||||
number = number.includes('@c.us') ? number : `${number}@c.us`;
|
||||
let chat = await msg.getChat();
|
||||
chat.sendSeen();
|
||||
client.sendMessage(number, message);
|
||||
|
||||
} else if (msg.body.startsWith('!subject ')) {
|
||||
// Change the group subject
|
||||
let chat = await msg.getChat();
|
||||
if(chat.isGroup) {
|
||||
if (chat.isGroup) {
|
||||
let newSubject = msg.body.slice(9);
|
||||
chat.setSubject(newSubject);
|
||||
} else {
|
||||
@@ -50,7 +73,7 @@ client.on('message', async msg => {
|
||||
} else if (msg.body.startsWith('!desc ')) {
|
||||
// Change the group description
|
||||
let chat = await msg.getChat();
|
||||
if(chat.isGroup) {
|
||||
if (chat.isGroup) {
|
||||
let newDescription = msg.body.slice(6);
|
||||
chat.setDescription(newDescription);
|
||||
} else {
|
||||
@@ -59,14 +82,22 @@ client.on('message', async msg => {
|
||||
} else if (msg.body == '!leave') {
|
||||
// Leave the group
|
||||
let chat = await msg.getChat();
|
||||
if(chat.isGroup) {
|
||||
if (chat.isGroup) {
|
||||
chat.leave();
|
||||
} else {
|
||||
msg.reply('This command can only be used in a group!');
|
||||
}
|
||||
} else if(msg.body == '!groupinfo') {
|
||||
} else if (msg.body.startsWith('!join ')) {
|
||||
const inviteCode = msg.body.split(' ')[1];
|
||||
try {
|
||||
await client.acceptInvite(inviteCode);
|
||||
msg.reply('Joined the group!');
|
||||
} catch (e) {
|
||||
msg.reply('That invite code seems to be invalid.');
|
||||
}
|
||||
} else if (msg.body == '!groupinfo') {
|
||||
let chat = await msg.getChat();
|
||||
if(chat.isGroup) {
|
||||
if (chat.isGroup) {
|
||||
msg.reply(`
|
||||
*Group Details*
|
||||
Name: ${chat.name}
|
||||
@@ -78,10 +109,19 @@ 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 == '!mediainfo' && msg.hasMedia) {
|
||||
} else if (msg.body == '!info') {
|
||||
let info = client.info;
|
||||
client.sendMessage(msg.from, `
|
||||
*Connection info*
|
||||
User name: ${info.pushname}
|
||||
My number: ${info.me.user}
|
||||
Platform: ${info.platform}
|
||||
WhatsApp version: ${info.phone.wa_version}
|
||||
`);
|
||||
} else if (msg.body == '!mediainfo' && msg.hasMedia) {
|
||||
const attachmentData = await msg.downloadMedia();
|
||||
msg.reply(`
|
||||
*Media info*
|
||||
@@ -89,17 +129,127 @@ client.on('message', async msg => {
|
||||
Filename: ${attachmentData.filename}
|
||||
Data (length): ${attachmentData.data.length}
|
||||
`);
|
||||
} else if (msg.body == '!quoteinfo' && msg.hasQuotedMsg) {
|
||||
const quotedMsg = await msg.getQuotedMessage();
|
||||
|
||||
quotedMsg.reply(`
|
||||
ID: ${quotedMsg.id._serialized}
|
||||
Type: ${quotedMsg.type}
|
||||
Author: ${quotedMsg.author || quotedMsg.from}
|
||||
Timestamp: ${quotedMsg.timestamp}
|
||||
Has Media? ${quotedMsg.hasMedia}
|
||||
`);
|
||||
} 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') {
|
||||
msg.reply(new Location(37.422, -122.084, 'Googleplex\nGoogle Headquarters'));
|
||||
} else if (msg.location) {
|
||||
msg.reply(msg.location);
|
||||
} else if (msg.body.startsWith('!status ')) {
|
||||
const newStatus = msg.body.split(' ')[1];
|
||||
await client.setStatus(newStatus);
|
||||
msg.reply(`Status was updated to *${newStatus}*`);
|
||||
} 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 === '!archive') {
|
||||
const chat = await msg.getChat();
|
||||
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();
|
||||
} else if (msg.body === '!recording') {
|
||||
const chat = await msg.getChat();
|
||||
// simulates recording audio in the chat
|
||||
chat.sendStateRecording();
|
||||
} else if (msg.body === '!clearstate') {
|
||||
const chat = await msg.getChat();
|
||||
// stops typing or recording in the chat
|
||||
chat.clearState();
|
||||
}
|
||||
});
|
||||
|
||||
client.on('message_create', (msg) => {
|
||||
// Fired on all message creations, including your own
|
||||
if(msg.fromMe) {
|
||||
if (msg.fromMe) {
|
||||
// do stuff here
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
client.on('disconnected', () => {
|
||||
console.log('Client was logged out');
|
||||
})
|
||||
client.on('message_revoke_everyone', async (after, before) => {
|
||||
// Fired whenever a message is deleted by anyone (including you)
|
||||
console.log(after); // message after it was deleted.
|
||||
if (before) {
|
||||
console.log(before); // message before it was deleted.
|
||||
}
|
||||
});
|
||||
|
||||
client.on('message_revoke_me', async (msg) => {
|
||||
// Fired whenever a message is only deleted in your own view.
|
||||
console.log(msg.body); // message before it was deleted.
|
||||
});
|
||||
|
||||
client.on('message_ack', (msg, ack) => {
|
||||
/*
|
||||
== ACK VALUES ==
|
||||
ACK_ERROR: -1
|
||||
ACK_PENDING: 0
|
||||
ACK_SERVER: 1
|
||||
ACK_DEVICE: 2
|
||||
ACK_READ: 3
|
||||
ACK_PLAYED: 4
|
||||
*/
|
||||
|
||||
if(ack == 3) {
|
||||
// The message was read
|
||||
}
|
||||
});
|
||||
|
||||
client.on('group_join', (notification) => {
|
||||
// User has joined or been added to the group.
|
||||
console.log('join', notification);
|
||||
notification.reply('User joined.');
|
||||
});
|
||||
|
||||
client.on('group_leave', (notification) => {
|
||||
// User has left or been kicked from the group.
|
||||
console.log('leave', notification);
|
||||
notification.reply('User left.');
|
||||
});
|
||||
|
||||
client.on('group_update', (notification) => {
|
||||
// Group picture, subject or description has been updated.
|
||||
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('disconnected', (reason) => {
|
||||
console.log('Client was logged out', reason);
|
||||
});
|
||||
|
||||
|
||||
669
index.d.ts
vendored
Normal file
669
index.d.ts
vendored
Normal file
@@ -0,0 +1,669 @@
|
||||
|
||||
import { EventEmitter } from 'events'
|
||||
import puppeteer = require('puppeteer')
|
||||
|
||||
declare namespace WAWebJS {
|
||||
|
||||
export class Client extends EventEmitter {
|
||||
constructor(options: ClientOptions)
|
||||
|
||||
/**Accepts an invitation to join a group */
|
||||
acceptInvite(inviteCode: string): Promise<void>
|
||||
|
||||
/**Returns an object with information about the invite code's group */
|
||||
getInviteInfo(inviteCode: string): Promise<object>
|
||||
|
||||
/** Enables and returns the archive state of the Chat */
|
||||
archiveChat(): Promise<boolean>
|
||||
|
||||
/**
|
||||
* Create a new group
|
||||
* @param name group title
|
||||
* @param participants an array of Contacts or contact IDs to add to the group
|
||||
*
|
||||
* @todo improve return type in the official docs
|
||||
*/
|
||||
createGroup(name: string, participants: Contact[] | string[]): Promise<CreateGroupResult>
|
||||
|
||||
/** Closes the client */
|
||||
destroy(): Promise<void>
|
||||
|
||||
/** Logs out the client, closing the current session */
|
||||
logout(): Promise<void>
|
||||
|
||||
/** Get chat instance by ID */
|
||||
getChatById(chatId: string): Promise<Chat>
|
||||
|
||||
/** Get all current chat instances */
|
||||
getChats(): Promise<Chat[]>
|
||||
|
||||
/** Get contact instance by ID */
|
||||
getContactById(contactId: string): Promise<Contact>
|
||||
|
||||
/** Get all current contact instances */
|
||||
getContacts(): Promise<Contact[]>
|
||||
|
||||
/** Returns the contact ID's profile picture URL, if privacy settings allow it */
|
||||
getProfilePicUrl(contactId: string): Promise<string>
|
||||
|
||||
/** Gets the current connection state for the client */
|
||||
getState(): Promise<WAState>
|
||||
|
||||
/**
|
||||
* Returns the version of WhatsApp Web currently being run
|
||||
* @todo fix the return value in the official docs
|
||||
*/
|
||||
getWWebVersion(): Promise<string>
|
||||
|
||||
/** Sets up events and requirements, kicks off authentication request */
|
||||
initialize(): Promise<void>
|
||||
|
||||
/**
|
||||
* Check if a given ID is registered in whatsapp
|
||||
* @todo add contactId param in the official docs
|
||||
*/
|
||||
isRegisteredUser(contactId: string): Promise<boolean>
|
||||
|
||||
/**
|
||||
* Mutes the Chat until a specified date
|
||||
* @param chatId ID of the chat that will be muted
|
||||
* @param unmuteDate Date when the chat will be unmuted
|
||||
*/
|
||||
muteChat(chatId: string, unmuteDate: Date): Promise<void>
|
||||
|
||||
/** Force reset of connection state for the client */
|
||||
resetState(): Promise<void>
|
||||
|
||||
/** Send a message to a specific chatId */
|
||||
sendMessage(chatId: string, content: MessageContent, options: MessageSendOptions): Promise<Message>
|
||||
|
||||
/** Marks the client as online */
|
||||
sendPresenceAvailable(): Promise<void>
|
||||
|
||||
/** Mark as seen for the Chat */
|
||||
sendSeen(chatId: string): Promise<boolean>
|
||||
|
||||
/**
|
||||
* Sets the current user's status message
|
||||
* @param status New status message
|
||||
*/
|
||||
setStatus(status: string): Promise<void>
|
||||
|
||||
/** Changes and returns the archive state of the Chat */
|
||||
unarchiveChat(chatId: string): Promise<boolean>
|
||||
|
||||
/**
|
||||
* Unmutes the Chat
|
||||
* @todo add chatId param in the official docs
|
||||
*/
|
||||
unmuteChat(chatId: string): Promise<void>
|
||||
|
||||
/** Generic event */
|
||||
on(event: string, listener: (...args: any) => void): this
|
||||
|
||||
/** Emitted when there has been an error while trying to restore an existing session */
|
||||
on(event: 'auth_failure', listener: (message: string) => void): this
|
||||
|
||||
/** Emitted when authentication is successful */
|
||||
on(event: 'authenticated', listener: (
|
||||
/** Object containing session information. Can be used to restore the session */
|
||||
session: ClientSession
|
||||
) => void): this
|
||||
|
||||
/** Emitted when the battery percentage for the attached device changes */
|
||||
on(event: 'change_battery', listener: (batteryInfo: BatteryInfo) => void): this
|
||||
|
||||
/** Emitted when the connection state changes */
|
||||
on(event: 'change_state', listener: (
|
||||
/** the new connection state */
|
||||
state: WAState
|
||||
) => void): this
|
||||
|
||||
/** Emitted when the client has been disconnected */
|
||||
on(event: 'disconnected', listener: (
|
||||
/** state that caused the disconnect */
|
||||
reason: WAState
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a user joins the chat via invite link or is added by an admin */
|
||||
on(event: 'group_join', listener: (
|
||||
/** GroupNotification with more information about the action */
|
||||
notification: GroupNotification
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a user leaves the chat or is removed by an admin */
|
||||
on(event: 'group_leave', listener: (
|
||||
/** GroupNotification with more information about the action */
|
||||
notification: GroupNotification
|
||||
) => void): this
|
||||
|
||||
/** Emitted when group settings are updated, such as subject, description or picture */
|
||||
on(event: 'group_update', listener: (
|
||||
/** GroupNotification with more information about the action */
|
||||
notification: GroupNotification
|
||||
) => void): this
|
||||
|
||||
/** Emitted when media has been uploaded for a message sent by the client */
|
||||
on(event: 'media_uploaded', listener: (
|
||||
/** The message with media that was uploaded */
|
||||
message: Message
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a new message is received */
|
||||
on(event: 'message', listener: (
|
||||
/** The message that was received */
|
||||
message: Message
|
||||
) => void): this
|
||||
|
||||
/** Emitted when an ack event occurrs on message type */
|
||||
on(event: 'message_ack', listener: (
|
||||
/** The message that was affected */
|
||||
message: Message,
|
||||
/** The new ACK value */
|
||||
ack: MessageAck
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a new message is created, which may include the current user's own messages */
|
||||
on(event: 'message_create', listener: (
|
||||
/** The message that was created */
|
||||
message: Message
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a message is deleted for everyone in the chat */
|
||||
on(event: 'message_revoke_everyone', listener: (
|
||||
/** The message that was revoked, in its current state. It will not contain the original message's data */
|
||||
message: Message,
|
||||
/**The message that was revoked, before it was revoked.
|
||||
* It will contain the message's original data.
|
||||
* Note that due to the way this data is captured,
|
||||
* it may be possible that this param will be undefined. */
|
||||
revoked_msg?: Message | null
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a message is deleted by the current user */
|
||||
on(event: 'message_revoke_me', listener: (
|
||||
/** The message that was revoked */
|
||||
message: Message
|
||||
) => void): this
|
||||
|
||||
/** Emitted when the QR code is received */
|
||||
on(event: 'qr', listener: (
|
||||
/** qr code string
|
||||
* @example ```1@9Q8tWf6bnezr8uVGwVCluyRuBOJ3tIglimzI5dHB0vQW2m4DQ0GMlCGf,f1/vGcW4Z3vBa1eDNl3tOjWqLL5DpYTI84DMVkYnQE8=,ZL7YnK2qdPN8vKo2ESxhOQ==``` */
|
||||
qr: string
|
||||
) => void): this
|
||||
|
||||
/** Emitted when the client has initialized and is ready to receive messages */
|
||||
on(event: 'ready', listener: () => void): this
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for initializing the whatsapp client
|
||||
* @todo add these in the official docs
|
||||
*/
|
||||
export interface ClientOptions {
|
||||
puppeteer?: puppeteer.LaunchOptions
|
||||
/** Whatsapp session to restore. If not set, will start a new session */
|
||||
session?: ClientSession,
|
||||
/** @default 45000 */
|
||||
qrTimeoutMs?: number,
|
||||
/** @default 20000 */
|
||||
qrRefreshIntervalMs?: number,
|
||||
/** @default 45000 */
|
||||
authTimeoutMs?: number,
|
||||
/** @default false */
|
||||
takeoverOnConflict?: boolean,
|
||||
/** @default 0 */
|
||||
takeoverTimeoutMs?: number,
|
||||
}
|
||||
|
||||
/** 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>,
|
||||
|
||||
}
|
||||
|
||||
/** Chat types */
|
||||
export enum ChatTypes {
|
||||
SOLO = 'solo',
|
||||
GROUP = 'group',
|
||||
UNKNOWN = 'unknown',
|
||||
}
|
||||
|
||||
/** Events that can be emitted by the client */
|
||||
export enum Events {
|
||||
AUTHENTICATED = 'authenticated',
|
||||
AUTHENTICATION_FAILURE = 'auth_failure',
|
||||
READY = 'ready',
|
||||
MESSAGE_RECEIVED = 'message',
|
||||
MESSAGE_CREATE = 'message_create',
|
||||
MESSAGE_REVOKED_EVERYONE = 'message_revoke_everyone',
|
||||
MESSAGE_REVOKED_ME = 'message_revoke_me',
|
||||
MESSAGE_ACK = 'message_ack',
|
||||
MEDIA_UPLOADED = 'media_uploaded',
|
||||
GROUP_JOIN = 'group_join',
|
||||
GROUP_LEAVE = 'group_leave',
|
||||
GROUP_UPDATE = 'group_update',
|
||||
QR_RECEIVED = 'qr',
|
||||
DISCONNECTED = 'disconnected',
|
||||
STATE_CHANGED = 'change_state',
|
||||
BATTERY_CHANGED = 'change_battery',
|
||||
}
|
||||
|
||||
/** Group notification types */
|
||||
export enum GroupNotificationTypes {
|
||||
ADD = 'add',
|
||||
INVITE = 'invite',
|
||||
REMOVE = 'remove',
|
||||
LEAVE = 'leave',
|
||||
SUBJECT = 'subject',
|
||||
DESCRIPTION = 'description',
|
||||
PICTURE = 'picture',
|
||||
ANNOUNCE = 'announce',
|
||||
RESTRICT = 'restrict',
|
||||
}
|
||||
|
||||
/** Message ACK */
|
||||
export enum MessageAck {
|
||||
ACK_ERROR = -1,
|
||||
ACK_PENDING = 0,
|
||||
ACK_SERVER = 1,
|
||||
ACK_DEVICE = 2,
|
||||
ACK_READ = 3,
|
||||
ACK_PLAYED = 4,
|
||||
}
|
||||
|
||||
/** Message types */
|
||||
export enum MessageTypes {
|
||||
TEXT = 'chat',
|
||||
AUDIO = 'audio',
|
||||
VOICE = 'ptt',
|
||||
IMAGE = 'image',
|
||||
VIDEO = 'video',
|
||||
DOCUMENT = 'document',
|
||||
STICKER = 'sticker',
|
||||
LOCATION = 'location',
|
||||
CONTACT_CARD = 'vcard',
|
||||
CONTACT_CARD_MULTI = 'multi_vcard',
|
||||
REVOKED = 'revoked',
|
||||
UNKNOWN = 'unknown',
|
||||
}
|
||||
|
||||
/** Client status */
|
||||
export enum Status {
|
||||
INITIALIZING = 0,
|
||||
AUTHENTICATING = 1,
|
||||
READY = 3,
|
||||
}
|
||||
|
||||
/** WhatsApp state */
|
||||
export enum WAState {
|
||||
CONFLICT = 'CONFLICT',
|
||||
CONNECTED = 'CONNECTED',
|
||||
DEPRECATED_VERSION = 'DEPRECATED_VERSION',
|
||||
OPENING = 'OPENING',
|
||||
PAIRING = 'PAIRING',
|
||||
PROXYBLOCK = 'PROXYBLOCK',
|
||||
SMB_TOS_BLOCK = 'SMB_TOS_BLOCK',
|
||||
TIMEOUT = 'TIMEOUT',
|
||||
TOS_BLOCK = 'TOS_BLOCK',
|
||||
UNLAUNCHED = 'UNLAUNCHED',
|
||||
UNPAIRED = 'UNPAIRED',
|
||||
UNPAIRED_IDLE = 'UNPAIRED_IDLE',
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Message on WhatsApp
|
||||
*
|
||||
* @example
|
||||
* {
|
||||
* mediaKey: undefined,
|
||||
* id: {
|
||||
* fromMe: false,
|
||||
* remote: `554199999999@c.us`,
|
||||
* id: '1234567890ABCDEFGHIJ',
|
||||
* _serialized: `false_554199999999@c.us_1234567890ABCDEFGHIJ`
|
||||
* },
|
||||
* ack: -1,
|
||||
* hasMedia: false,
|
||||
* body: 'Hello!',
|
||||
* type: 'chat',
|
||||
* timestamp: 1591482682,
|
||||
* from: `554199999999@c.us`,
|
||||
* to: `554188888888@c.us`,
|
||||
* author: undefined,
|
||||
* isForwarded: false,
|
||||
* broadcast: false,
|
||||
* fromMe: false,
|
||||
* hasQuotedMsg: false,
|
||||
* location: undefined,
|
||||
* mentionedIds: []
|
||||
* }
|
||||
*/
|
||||
export interface Message {
|
||||
/** ACK status for the message */
|
||||
ack: MessageAck,
|
||||
/** If the message was sent to a group, this field will contain the user that sent the message. */
|
||||
author?: string,
|
||||
/** Message content */
|
||||
body: string,
|
||||
/** Indicates if the message was a broadcast */
|
||||
broadcast: boolean,
|
||||
/** ID for the Chat that this message was sent to, except if the message was sent by the current user */
|
||||
from: string,
|
||||
/** Indicates if the message was sent by the current user */
|
||||
fromMe: boolean,
|
||||
/** Indicates if the message has media available for download */
|
||||
hasMedia: boolean,
|
||||
/** Indicates if the message was sent as a reply to another message */
|
||||
hasQuotedMsg: boolean,
|
||||
/** ID that represents the message */
|
||||
id: MessageId,
|
||||
/** Indicates if the message was forwarded */
|
||||
isForwarded: boolean,
|
||||
/** Location information contained in the message, if the message is type "location" */
|
||||
location: Location,
|
||||
/** MediaKey that represents the sticker 'ID' */
|
||||
mediaKey?: string,
|
||||
/** Indicates the mentions in the message body. */
|
||||
mentionedIds: [],
|
||||
/** Unix timestamp for when the message was created */
|
||||
timestamp: number,
|
||||
/**
|
||||
* ID for who this message is for.
|
||||
* If the message is sent by the current user, it will be the Chat to which the message is being sent.
|
||||
* If the message is sent by another user, it will be the ID for the current user.
|
||||
*/
|
||||
to: string,
|
||||
/** Message type */
|
||||
type: 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>,
|
||||
}
|
||||
|
||||
/** ID that represents a message */
|
||||
export interface MessageId {
|
||||
fromMe: boolean,
|
||||
remote: string,
|
||||
id: string,
|
||||
_serialized: string,
|
||||
}
|
||||
|
||||
export interface Location {
|
||||
description?: string | null,
|
||||
latitude: string,
|
||||
longitude: string,
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for sending a message
|
||||
* @todo add more specific type for the object */
|
||||
export type MessageSendOptions = object
|
||||
|
||||
export interface MessageMedia {
|
||||
data: string,
|
||||
mimetype: string,
|
||||
filename?: string | null,
|
||||
|
||||
fromFilePath: (filePath: string) => MessageMedia,
|
||||
}
|
||||
|
||||
export type MessageContent = string | MessageMedia | Location
|
||||
|
||||
/**
|
||||
* Represents a Contact on WhatsApp
|
||||
*
|
||||
* @example
|
||||
* {
|
||||
* id: {
|
||||
* server: 'c.us',
|
||||
* user: '554199999999',
|
||||
* _serialized: `554199999999@c.us`
|
||||
* },
|
||||
* number: '554199999999',
|
||||
* isBusiness: false,
|
||||
* isEnterprise: false,
|
||||
* labels: [],
|
||||
* name: undefined,
|
||||
* pushname: 'John',
|
||||
* sectionHeader: undefined,
|
||||
* shortName: undefined,
|
||||
* statusMute: false,
|
||||
* type: 'in',
|
||||
* verifiedLevel: undefined,
|
||||
* verifiedName: undefined,
|
||||
* isMe: false,
|
||||
* isUser: true,
|
||||
* isGroup: false,
|
||||
* isWAContact: true,
|
||||
* isMyContact: false
|
||||
* }
|
||||
*/
|
||||
export interface Contact {
|
||||
/** Contact's phone number */
|
||||
number: string,
|
||||
/** Indicates if the contact is a business contact */
|
||||
isBusiness: boolean,
|
||||
/** ID that represents the contact */
|
||||
id: ContactId,
|
||||
/** Indicates if the contact is an enterprise contact */
|
||||
isEnterprise: boolean,
|
||||
/** Indicates if the contact is a group contact */
|
||||
isGroup: boolean,
|
||||
/** Indicates if the contact is the current user's contact */
|
||||
isMe: boolean,
|
||||
/** Indicates if the number is saved in the current phone's contacts */
|
||||
isMyContact: boolean
|
||||
/** Indicates if the contact is a user contact */
|
||||
isUser: boolean,
|
||||
/** Indicates if the number is registered on WhatsApp */
|
||||
isWAContact: boolean,
|
||||
/** @todo verify labels type. didn't have any documentation */
|
||||
labels?: string[],
|
||||
/** The contact's name, as saved by the current user */
|
||||
name?: string,
|
||||
/** The name that the contact has configured to be shown publically */
|
||||
pushname: string,
|
||||
/** @todo missing documentation */
|
||||
sectionHeader: string,
|
||||
/** A shortened version of name */
|
||||
shortName?: string,
|
||||
/** Indicates if the status from the contact is muted */
|
||||
statusMute: boolean,
|
||||
/** @todo missing documentation */
|
||||
type: string,
|
||||
/** @todo missing documentation */
|
||||
verifiedLevel?: undefined,
|
||||
/** @todo missing documentation */
|
||||
verifiedName?: undefined,
|
||||
|
||||
/** Returns the contact's profile picture URL, if privacy settings allow it */
|
||||
getProfilePicUrl: () => Promise<string>,
|
||||
}
|
||||
|
||||
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,
|
||||
/** Title of the chat */
|
||||
name: string,
|
||||
/** Unix timestamp for when the chat was created */
|
||||
timestamp: number,
|
||||
/** Amount of messages unread */
|
||||
unreadCount: number,
|
||||
|
||||
/** Archives this chat */
|
||||
archive: () => Promise<void>,
|
||||
/** 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>,
|
||||
}
|
||||
|
||||
export interface MessageSearchOptions {
|
||||
/**
|
||||
* The amount of messages to return.
|
||||
* Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation.
|
||||
* Set this to Infinity to load all messages.
|
||||
* @default 50
|
||||
*/
|
||||
limit?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Id that represents the chat
|
||||
*
|
||||
* @example
|
||||
* id: {
|
||||
* server: 'c.us',
|
||||
* user: '554199999999',
|
||||
* _serialized: `554199999999@c.us`
|
||||
* },
|
||||
*/
|
||||
export interface ChatId {
|
||||
/**
|
||||
* Whatsapp server domain
|
||||
* @example `c.us`
|
||||
*/
|
||||
server: string,
|
||||
/**
|
||||
* User whatsapp number
|
||||
* @example `554199999999`
|
||||
*/
|
||||
user: string,
|
||||
/**
|
||||
* Serialized id
|
||||
* @example `554199999999@c.us`
|
||||
*/
|
||||
_serialized: string,
|
||||
}
|
||||
|
||||
export interface PrivateChat extends Chat {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export = WAWebJS
|
||||
8
index.js
8
index.js
@@ -9,5 +9,11 @@ module.exports = {
|
||||
Chat: require('./src/structures/Chat'),
|
||||
PrivateChat: require('./src/structures/PrivateChat'),
|
||||
GroupChat: require('./src/structures/GroupChat'),
|
||||
Message: require('./src/structures/Message')
|
||||
Message: require('./src/structures/Message'),
|
||||
MessageMedia: require('./src/structures/MessageMedia'),
|
||||
Contact: require('./src/structures/Contact'),
|
||||
PrivateContact: require('./src/structures/PrivateContact'),
|
||||
BusinessContact: require('./src/structures/BusinessContact'),
|
||||
ClientInfo: require('./src/structures/ClientInfo'),
|
||||
Location: require('./src/structures/Location')
|
||||
};
|
||||
321
package-lock.json
generated
321
package-lock.json
generated
@@ -1,321 +0,0 @@
|
||||
{
|
||||
"name": "whatsapp-web.js",
|
||||
"version": "0.3.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"agent-base": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz",
|
||||
"integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==",
|
||||
"requires": {
|
||||
"es6-promisify": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"async-limiter": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
|
||||
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"buffer-from": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
},
|
||||
"concat-stream": {
|
||||
"version": "1.6.2",
|
||||
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
|
||||
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
|
||||
"requires": {
|
||||
"buffer-from": "^1.0.0",
|
||||
"inherits": "^2.0.3",
|
||||
"readable-stream": "^2.2.2",
|
||||
"typedarray": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"es6-promise": {
|
||||
"version": "4.2.8",
|
||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
|
||||
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
|
||||
},
|
||||
"es6-promisify": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
|
||||
"integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=",
|
||||
"requires": {
|
||||
"es6-promise": "^4.0.3"
|
||||
}
|
||||
},
|
||||
"extract-zip": {
|
||||
"version": "1.6.7",
|
||||
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz",
|
||||
"integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=",
|
||||
"requires": {
|
||||
"concat-stream": "1.6.2",
|
||||
"debug": "2.6.9",
|
||||
"mkdirp": "0.5.1",
|
||||
"yauzl": "2.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
}
|
||||
}
|
||||
},
|
||||
"fd-slicer": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz",
|
||||
"integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=",
|
||||
"requires": {
|
||||
"pend": "~1.2.0"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.4",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
|
||||
"integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==",
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"https-proxy-agent": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz",
|
||||
"integrity": "sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg==",
|
||||
"requires": {
|
||||
"agent-base": "^4.3.0",
|
||||
"debug": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "3.2.6",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
|
||||
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"requires": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
},
|
||||
"isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
||||
},
|
||||
"mime": {
|
||||
"version": "2.4.4",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz",
|
||||
"integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA=="
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
},
|
||||
"moduleraid": {
|
||||
"version": "git+https://github.com/pixeldesu/moduleRaid.git#113b90ec709f5d4601db8d5e96b1155aa772ae97",
|
||||
"from": "git+https://github.com/pixeldesu/moduleRaid.git"
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
},
|
||||
"pend": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
|
||||
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA="
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
|
||||
},
|
||||
"progress": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
|
||||
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA=="
|
||||
},
|
||||
"proxy-from-env": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz",
|
||||
"integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4="
|
||||
},
|
||||
"puppeteer": {
|
||||
"version": "1.20.0",
|
||||
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.20.0.tgz",
|
||||
"integrity": "sha512-bt48RDBy2eIwZPrkgbcwHtb51mj2nKvHOPMaSH2IsWiv7lOG9k9zhaRzpDZafrk05ajMc3cu+lSQYYOfH2DkVQ==",
|
||||
"requires": {
|
||||
"debug": "^4.1.0",
|
||||
"extract-zip": "^1.6.6",
|
||||
"https-proxy-agent": "^2.2.1",
|
||||
"mime": "^2.0.3",
|
||||
"progress": "^2.0.1",
|
||||
"proxy-from-env": "^1.0.0",
|
||||
"rimraf": "^2.6.1",
|
||||
"ws": "^6.1.0"
|
||||
}
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"rimraf": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||
"requires": {
|
||||
"glob": "^7.1.3"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"requires": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
},
|
||||
"typedarray": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
||||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"ws": {
|
||||
"version": "6.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz",
|
||||
"integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==",
|
||||
"requires": {
|
||||
"async-limiter": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"yauzl": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz",
|
||||
"integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=",
|
||||
"requires": {
|
||||
"fd-slicer": "~1.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
package.json
17
package.json
@@ -1,10 +1,12 @@
|
||||
{
|
||||
"name": "whatsapp-web.js",
|
||||
"version": "0.3.0",
|
||||
"version": "1.7.0",
|
||||
"description": "Library for interacting with the WhatsApp Web API ",
|
||||
"main": "./index.js",
|
||||
"typings": "./index.d.ts",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -25,7 +27,14 @@
|
||||
},
|
||||
"homepage": "https://github.com/pedroslopez/whatsapp-web.js#readme",
|
||||
"dependencies": {
|
||||
"moduleraid": "git+https://github.com/pixeldesu/moduleRaid.git",
|
||||
"puppeteer": "^1.20.0"
|
||||
"@pedroslopez/moduleraid": "^4.1.0",
|
||||
"jsqr": "^1.3.1",
|
||||
"mime": "^2.4.5",
|
||||
"puppeteer": "^3.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.8.0",
|
||||
"jsdoc": "^3.6.4",
|
||||
"jsdoc-baseline": "^0.1.5"
|
||||
}
|
||||
}
|
||||
|
||||
567
src/Client.js
567
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 InterfaceController = require('./util/InterfaceController');
|
||||
const { WhatsWebURL, UserAgent, DefaultOptions, Events, WAState } = require('./util/Constants');
|
||||
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
||||
const ChatFactory = require('./factories/ChatFactory');
|
||||
const Chat = require('./structures/Chat');
|
||||
const Message = require('./structures/Message');
|
||||
|
||||
const ContactFactory = require('./factories/ContactFactory');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification } = require('./structures');
|
||||
/**
|
||||
* Starting point for interacting with the WhatsApp Web API
|
||||
* @extends {EventEmitter}
|
||||
* @fires Client#qr
|
||||
* @fires Client#authenticated
|
||||
* @fires Client#auth_failure
|
||||
* @fires Client#ready
|
||||
* @fires Client#message
|
||||
* @fires Client#message_ack
|
||||
* @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 = {}) {
|
||||
@@ -30,33 +47,48 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
async initialize() {
|
||||
const browser = await puppeteer.launch(this.options.puppeteer);
|
||||
const page = await browser.newPage();
|
||||
const page = (await browser.pages())[0];
|
||||
page.setUserAgent(UserAgent);
|
||||
|
||||
this.pupBrowser = browser;
|
||||
this.pupPage = page;
|
||||
|
||||
if (this.options.session) {
|
||||
await page.evaluateOnNewDocument(
|
||||
session => {
|
||||
localStorage.clear();
|
||||
localStorage.setItem("WABrowserId", session.WABrowserId);
|
||||
localStorage.setItem("WASecretBundle", session.WASecretBundle);
|
||||
localStorage.setItem("WAToken1", session.WAToken1);
|
||||
localStorage.setItem("WAToken2", session.WAToken2);
|
||||
localStorage.setItem('WABrowserId', session.WABrowserId);
|
||||
localStorage.setItem('WASecretBundle', session.WASecretBundle);
|
||||
localStorage.setItem('WAToken1', session.WAToken1);
|
||||
localStorage.setItem('WAToken2', session.WAToken2);
|
||||
}, this.options.session);
|
||||
}
|
||||
|
||||
await page.goto(WhatsWebURL);
|
||||
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '._1wSzK';
|
||||
await page.goto(WhatsWebURL, {
|
||||
waitUntil: 'load',
|
||||
timeout: 0,
|
||||
});
|
||||
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"]';
|
||||
|
||||
if (this.options.session) {
|
||||
// Check if session restore was successfull
|
||||
try {
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 5000 });
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: this.options.authTimeoutMs });
|
||||
} catch (err) {
|
||||
if (err.name === 'TimeoutError') {
|
||||
/**
|
||||
* Emitted when there has been an error while trying to restore an existing session
|
||||
* @event Client#auth_failure
|
||||
* @param {string} message
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -64,17 +96,35 @@ class Client extends EventEmitter {
|
||||
}
|
||||
|
||||
} else {
|
||||
// Wait for QR Code
|
||||
const QR_CONTAINER_SELECTOR = '._2d3Jz';
|
||||
const QR_VALUE_SELECTOR = '._1pw2F';
|
||||
const getQrCode = async () => {
|
||||
// Check if retry button is present
|
||||
var QR_RETRY_SELECTOR = 'div[data-ref] > span > div';
|
||||
var qrRetry = await page.$(QR_RETRY_SELECTOR);
|
||||
if (qrRetry) {
|
||||
await qrRetry.click();
|
||||
}
|
||||
|
||||
await page.waitForSelector(QR_CONTAINER_SELECTOR);
|
||||
// Wait for QR Code
|
||||
|
||||
const qr = await page.$eval(QR_VALUE_SELECTOR, node => node.getAttribute('data-ref'));
|
||||
this.emit(Events.QR_RECEIVED, qr);
|
||||
const QR_CANVAS_SELECTOR = 'canvas';
|
||||
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
|
||||
* @param {string} qr QR Code
|
||||
*/
|
||||
this.emit(Events.QR_RECEIVED, qr);
|
||||
};
|
||||
getQrCode();
|
||||
this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
|
||||
|
||||
// Wait for code scan
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
this._qrRefreshInterval = undefined;
|
||||
|
||||
}
|
||||
|
||||
await page.evaluate(ExposeStore, moduleRaid.toString());
|
||||
@@ -89,67 +139,311 @@ class Client extends EventEmitter {
|
||||
WASecretBundle: localStorage.WASecretBundle,
|
||||
WAToken1: localStorage.WAToken1,
|
||||
WAToken2: localStorage.WAToken2
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Emitted when authentication is successful
|
||||
* @event Client#authenticated
|
||||
* @param {object} session Object containing session information. Can be used to restore the session.
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATED, session);
|
||||
|
||||
// Check Store Injection
|
||||
// Check window.Store Injection
|
||||
await page.waitForFunction('window.Store != undefined');
|
||||
|
||||
//Load util functions (serializers, helper functions)
|
||||
await page.evaluate(LoadUtils);
|
||||
|
||||
// Expose client info
|
||||
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;
|
||||
|
||||
if (msg.type === 'gp2') {
|
||||
const notification = new GroupNotification(this, msg);
|
||||
if (msg.subtype === 'add' || msg.subtype === 'invite') {
|
||||
/**
|
||||
* Emitted when a user joins the chat via invite link or is added by an admin.
|
||||
* @event Client#group_join
|
||||
* @param {GroupNotification} notification GroupNotification with more information about the action
|
||||
*/
|
||||
this.emit(Events.GROUP_JOIN, notification);
|
||||
} else if (msg.subtype === 'remove' || msg.subtype === 'leave') {
|
||||
/**
|
||||
* Emitted when a user leaves the chat or is removed by an admin.
|
||||
* @event Client#group_leave
|
||||
* @param {GroupNotification} notification GroupNotification with more information about the action
|
||||
*/
|
||||
this.emit(Events.GROUP_LEAVE, notification);
|
||||
} else {
|
||||
/**
|
||||
* Emitted when group settings are updated, such as subject, description or picture.
|
||||
* @event Client#group_update
|
||||
* @param {GroupNotification} notification GroupNotification with more information about the action
|
||||
*/
|
||||
this.emit(Events.GROUP_UPDATE, notification);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
||||
/**
|
||||
* Emitted when a new message is created, which may include the current user's own messages.
|
||||
* @event Client#message_create
|
||||
* @param {Message} message The message that was created
|
||||
*/
|
||||
this.emit(Events.MESSAGE_CREATE, message);
|
||||
|
||||
if (msg.id.fromMe) return;
|
||||
|
||||
/**
|
||||
* Emitted when a new message is received.
|
||||
* @event Client#message
|
||||
* @param {Message} message The message that was received
|
||||
*/
|
||||
this.emit(Events.MESSAGE_RECEIVED, message);
|
||||
});
|
||||
|
||||
await page.exposeFunction('onAppStateChangedEvent', (AppState, state) => {
|
||||
const ACCEPTED_STATES = [WAState.CONNECTED, WAState.OPENING, WAState.PAIRING];
|
||||
let last_message;
|
||||
|
||||
await page.exposeFunction('onChangeMessageTypeEvent', (msg) => {
|
||||
|
||||
if (msg.type === 'revoked') {
|
||||
const message = new Message(this, msg);
|
||||
let revoked_msg;
|
||||
if (last_message && msg.id.id === last_message.id.id) {
|
||||
revoked_msg = new Message(this, last_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted when a message is deleted for everyone in the chat.
|
||||
* @event Client#message_revoke_everyone
|
||||
* @param {Message} message The message that was revoked, in its current state. It will not contain the original message's data.
|
||||
* @param {?Message} revoked_msg 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.
|
||||
*/
|
||||
this.emit(Events.MESSAGE_REVOKED_EVERYONE, message, revoked_msg);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
await page.exposeFunction('onChangeMessageEvent', (msg) => {
|
||||
|
||||
if (msg.type !== 'revoked') {
|
||||
last_message = msg;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
await page.exposeFunction('onRemoveMessageEvent', (msg) => {
|
||||
|
||||
if (!msg.isNewMsg) return;
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
||||
/**
|
||||
* Emitted when a message is deleted by the current user.
|
||||
* @event Client#message_revoke_me
|
||||
* @param {Message} message The message that was revoked
|
||||
*/
|
||||
this.emit(Events.MESSAGE_REVOKED_ME, message);
|
||||
|
||||
});
|
||||
|
||||
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
|
||||
* @param {Message} message The message that was affected
|
||||
* @param {MessageAck} ack The new ACK value
|
||||
*/
|
||||
this.emit(Events.MESSAGE_ACK, message, ack);
|
||||
|
||||
});
|
||||
|
||||
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
|
||||
* @event Client#change_state
|
||||
* @param {WAState} state the new connection state
|
||||
*/
|
||||
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)) {
|
||||
this.emit(Events.DISCONNECTED);
|
||||
/**
|
||||
* Emitted when the client has been disconnected
|
||||
* @event Client#disconnected
|
||||
* @param {WAState} reason state that caused the disconnect
|
||||
*/
|
||||
this.emit(Events.DISCONNECTED, state);
|
||||
this.destroy();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
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 });
|
||||
});
|
||||
|
||||
await page.evaluate(() => {
|
||||
Store.Msg.on('add', onAddMessageEvent);
|
||||
Store.AppState.on('change:state', onAppStateChangedEvent);
|
||||
}).catch(err => console.log(err.message));
|
||||
|
||||
this.pupBrowser = browser;
|
||||
this.pupPage = page;
|
||||
window.Store.Msg.on('add', (msg) => { if(msg.isNewMsg) window.onAddMessageEvent(msg); });
|
||||
window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(msg); });
|
||||
window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(msg); });
|
||||
window.Store.Msg.on('change:ack', (msg, ack) => { window.onMessageAckEvent(msg, ack); });
|
||||
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if(msg.id.fromMe && !unsent) window.onMessageMediaUploadedEvent(msg); });
|
||||
window.Store.Msg.on('remove', (msg) => { if(msg.isNewMsg) window.onRemoveMessageEvent(msg); });
|
||||
window.Store.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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @returns {Promise<boolean>} result
|
||||
*
|
||||
*/
|
||||
async sendSeen(chatId) {
|
||||
const result = await this.pupPage.evaluate(async (chatId) => {
|
||||
return window.WWebJS.sendSeen(chatId);
|
||||
|
||||
}, chatId);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to a specific chatId
|
||||
* @param {string} chatId
|
||||
* @param {string} message
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {object} options
|
||||
* @returns {Promise<Message>} Message that was just sent
|
||||
*/
|
||||
async sendMessage(chatId, message) {
|
||||
await this.pupPage.evaluate((chatId, message) => {
|
||||
Store.SendMessage(Store.Chat.get(chatId), message);
|
||||
}, chatId, message)
|
||||
async sendMessage(chatId, content, options = {}) {
|
||||
let internalOptions = {
|
||||
linkPreview: options.linkPreview === false ? undefined : true,
|
||||
sendAudioAsVoice: options.sendAudioAsVoice,
|
||||
caption: options.caption,
|
||||
quotedMessageId: options.quotedMessageId,
|
||||
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : []
|
||||
};
|
||||
|
||||
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
||||
|
||||
if (content instanceof MessageMedia) {
|
||||
internalOptions.attachment = content;
|
||||
content = '';
|
||||
} else if (options.media instanceof MessageMedia) {
|
||||
internalOptions.attachment = options.media;
|
||||
internalOptions.caption = content;
|
||||
content = '';
|
||||
} else if (content instanceof Location) {
|
||||
internalOptions.location = content;
|
||||
content = '';
|
||||
}
|
||||
|
||||
const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = await window.Store.Chat.find(chatWid);
|
||||
|
||||
if(sendSeen) {
|
||||
window.WWebJS.sendSeen(chatId);
|
||||
}
|
||||
|
||||
const msg = await window.WWebJS.sendMessage(chat, message, options, sendSeen);
|
||||
return msg.serialize();
|
||||
}, chatId, content, internalOptions, sendSeen);
|
||||
|
||||
return new Message(this, newMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all current chat instances
|
||||
* @returns {Promise<Array<Chat>>}
|
||||
*/
|
||||
async getChats() {
|
||||
let chats = await this.pupPage.evaluate(() => {
|
||||
return WWebJS.getChats();
|
||||
return window.WWebJS.getChats();
|
||||
});
|
||||
|
||||
return chats.map(chat => ChatFactory.create(this, chat));
|
||||
@@ -158,15 +452,210 @@ class Client extends EventEmitter {
|
||||
/**
|
||||
* Get chat instance by ID
|
||||
* @param {string} chatId
|
||||
* @returns {Promise<Chat>}
|
||||
*/
|
||||
async getChatById(chatId) {
|
||||
let chat = await this.pupPage.evaluate(chatId => {
|
||||
return WWebJS.getChat(chatId);
|
||||
return window.WWebJS.getChat(chatId);
|
||||
}, chatId);
|
||||
|
||||
return ChatFactory.create(this, chat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all current contact instances
|
||||
* @returns {Promise<Array<Contact>>}
|
||||
*/
|
||||
async getContacts() {
|
||||
let contacts = await this.pupPage.evaluate(() => {
|
||||
return window.WWebJS.getContacts();
|
||||
});
|
||||
|
||||
return contacts.map(contact => ContactFactory.create(this, contact));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get contact instance by ID
|
||||
* @param {string} contactId
|
||||
* @returns {Promise<Contact>}
|
||||
*/
|
||||
async getContactById(contactId) {
|
||||
let contact = await this.pupPage.evaluate(contactId => {
|
||||
return window.WWebJS.getContact(contactId);
|
||||
}, contactId);
|
||||
|
||||
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
|
||||
*/
|
||||
async acceptInvite(inviteCode) {
|
||||
const chatId = await this.pupPage.evaluate(async inviteCode => {
|
||||
return await window.Store.Invite.sendJoinGroupViaInvite(inviteCode);
|
||||
}, inviteCode);
|
||||
|
||||
return chatId._serialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current user's status message
|
||||
* @param {string} status New status message
|
||||
*/
|
||||
async setStatus(status) {
|
||||
await this.pupPage.evaluate(async status => {
|
||||
return await window.Store.Wap.sendSetStatus(status);
|
||||
}, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current connection state for the client
|
||||
* @returns {WAState}
|
||||
*/
|
||||
async getState() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Store.AppState.state;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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}
|
||||
*/
|
||||
async archiveChat(chatId) {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, true);
|
||||
return chat.archive;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes and returns the archive state of the Chat
|
||||
* @returns {boolean}
|
||||
*/
|
||||
async unarchiveChat(chatId) {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, false);
|
||||
return chat.archive;
|
||||
}, 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(){
|
||||
await this.pupPage.evaluate(() => {
|
||||
window.Store.AppState.phoneWatchdog.shiftTimer.forceRunNow();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given ID is registered in whatsapp
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
|
||||
16
src/factories/ContactFactory.js
Normal file
16
src/factories/ContactFactory.js
Normal file
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const PrivateContact = require('../structures/PrivateContact');
|
||||
const BusinessContact = require('../structures/BusinessContact');
|
||||
|
||||
class ContactFactory {
|
||||
static create(client, data) {
|
||||
if(data.isBusiness) {
|
||||
return new BusinessContact(client, data);
|
||||
}
|
||||
|
||||
return new PrivateContact(client, data);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ContactFactory;
|
||||
@@ -14,7 +14,7 @@ class Base {
|
||||
|
||||
_clone() {
|
||||
return Object.assign(Object.create(this), this);
|
||||
}
|
||||
}
|
||||
|
||||
_patch(data) { return data; }
|
||||
}
|
||||
|
||||
21
src/structures/BusinessContact.js
Normal file
21
src/structures/BusinessContact.js
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
const Contact = require('./Contact');
|
||||
|
||||
/**
|
||||
* Represents a Business Contact on WhatsApp
|
||||
* @extends {Contact}
|
||||
*/
|
||||
class BusinessContact extends Contact {
|
||||
_patch(data) {
|
||||
/**
|
||||
* The contact's business profile
|
||||
*/
|
||||
this.businessProfile = data.businessProfile;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = BusinessContact;
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
const Message = require('./Message');
|
||||
|
||||
/**
|
||||
* Represents a Chat on WhatsApp
|
||||
@@ -10,24 +11,181 @@ class Chat extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* ID that represents the chat
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
/**
|
||||
* Title of the chat
|
||||
* @type {string}
|
||||
*/
|
||||
this.name = data.formattedTitle;
|
||||
|
||||
/**
|
||||
* Indicates if the Chat is a Group Chat
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isGroup = data.isGroup;
|
||||
|
||||
/**
|
||||
* Indicates if the Chat is readonly
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isReadOnly = data.isReadOnly;
|
||||
|
||||
/**
|
||||
* Amount of messages unread
|
||||
* @type {number}
|
||||
*/
|
||||
this.unreadCount = data.unreadCount;
|
||||
|
||||
/**
|
||||
* Unix timestamp for when the chat was created
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.t;
|
||||
|
||||
/**
|
||||
* Indicates if the Chat is archived
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.archived = data.archive;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
sendMessage(message) {
|
||||
return this.client.sendMessage(this.id._serialized, message);
|
||||
/**
|
||||
* Send a message to this chat
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {object} options
|
||||
* @returns {Promise<Message>} Message that was just sent
|
||||
*/
|
||||
async sendMessage(content, options) {
|
||||
return this.client.sendMessage(this.id._serialized, content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message as seen
|
||||
* @returns {Promise<Boolean>} result
|
||||
*/
|
||||
async sendSeen() {
|
||||
return this.client.sendSeen(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all messages from the chat
|
||||
* @returns {Promise<Boolean>} result
|
||||
*/
|
||||
async clearMessages() {
|
||||
return this.client.pupPage.evaluate(chatId => {
|
||||
return window.WWebJS.sendClearChat(chatId);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the chat
|
||||
* @returns {Promise<Boolean>} result
|
||||
*/
|
||||
async delete() {
|
||||
return this.client.pupPage.evaluate(chatId => {
|
||||
return window.WWebJS.sendDeleteChat(chatId);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Archives this chat
|
||||
*/
|
||||
async archive() {
|
||||
return this.client.archiveChat(this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* un-archives this chat
|
||||
*/
|
||||
async unarchive() {
|
||||
return this.client.unarchiveChat(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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads chat messages, sorted from earliest to latest.
|
||||
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
||||
* @param {Number} [searchOptions.limit=50] The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.
|
||||
* @returns {Promise<Array<Message>>}
|
||||
*/
|
||||
async fetchMessages(searchOptions) {
|
||||
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) {
|
||||
const loadedMessages = await chat.loadEarlierMsgs();
|
||||
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());
|
||||
|
||||
}, this.id._serialized, searchOptions.limit);
|
||||
|
||||
return messages.map(m => new Message(this.client, m));
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate typing in chat. This will last for 25 seconds.
|
||||
*/
|
||||
async sendStateTyping() {
|
||||
return this.client.pupPage.evaluate(chatId => {
|
||||
window.WWebJS.sendChatstate('typing', chatId);
|
||||
return true;
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate recording audio in chat. This will last for 25 seconds.
|
||||
*/
|
||||
async sendStateRecording() {
|
||||
return this.client.pupPage.evaluate(chatId => {
|
||||
window.WWebJS.sendChatstate('recording', chatId);
|
||||
return true;
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops typing or recording in chat immediately.
|
||||
*/
|
||||
async clearState() {
|
||||
return this.client.pupPage.evaluate(chatId => {
|
||||
window.WWebJS.sendChatstate('stop', chatId);
|
||||
return true;
|
||||
}, this.id._serialized);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Chat;
|
||||
module.exports = Chat;
|
||||
|
||||
64
src/structures/ClientInfo.js
Normal file
64
src/structures/ClientInfo.js
Normal file
@@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Current connection information
|
||||
* @extends {Base}
|
||||
*/
|
||||
class ClientInfo extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* Name configured to be shown in push notifications
|
||||
* @type {string}
|
||||
*/
|
||||
this.pushname = data.pushname;
|
||||
|
||||
/**
|
||||
* Current user ID
|
||||
* @type {object}
|
||||
*/
|
||||
this.me = data.me;
|
||||
|
||||
/**
|
||||
* Information about the phone this client is connected to
|
||||
* @type {object}
|
||||
* @property {string} wa_version WhatsApp Version running on the phone
|
||||
* @property {string} os_version OS Version running on the phone (iOS or Android version)
|
||||
* @property {string} device_manufacturer Device manufacturer
|
||||
* @property {string} device_model Device model
|
||||
* @property {string} os_build_number OS build number
|
||||
*/
|
||||
this.phone = data.phone;
|
||||
|
||||
/**
|
||||
* Platform the phone is running on
|
||||
* @type {string}
|
||||
*/
|
||||
this.platform = data.platform;
|
||||
|
||||
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;
|
||||
111
src/structures/Contact.js
Normal file
111
src/structures/Contact.js
Normal file
@@ -0,0 +1,111 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Represents a Contact on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class Contact extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* ID that represents the contact
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
/**
|
||||
* Contact's phone number
|
||||
* @type {string}
|
||||
*/
|
||||
this.number = data.userid;
|
||||
|
||||
/**
|
||||
* Indicates if the contact is a business contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isBusiness = data.isBusiness;
|
||||
|
||||
/**
|
||||
* Indicates if the contact is an enterprise contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isEnterprise = data.isEnterprise;
|
||||
|
||||
this.labels = data.labels;
|
||||
|
||||
/**
|
||||
* The contact's name, as saved by the current user
|
||||
* @type {?string}
|
||||
*/
|
||||
this.name = data.name;
|
||||
|
||||
/**
|
||||
* The name that the contact has configured to be shown publically
|
||||
* @type {string}
|
||||
*/
|
||||
this.pushname = data.pushname;
|
||||
|
||||
this.sectionHeader = data.sectionHeader;
|
||||
|
||||
/**
|
||||
* A shortened version of name
|
||||
* @type {?string}
|
||||
*/
|
||||
this.shortName = data.shortName;
|
||||
|
||||
this.statusMute = data.statusMute;
|
||||
this.type = data.type;
|
||||
this.verifiedLevel = data.verifiedLevel;
|
||||
this.verifiedName = data.verifiedName;
|
||||
|
||||
/**
|
||||
* Indicates if the contact is the current user's contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isMe = data.isMe;
|
||||
|
||||
/**
|
||||
* Indicates if the contact is a user contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isUser = data.isUser;
|
||||
|
||||
/**
|
||||
* Indicates if the contact is a group contact
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isGroup = data.isGroup;
|
||||
|
||||
/**
|
||||
* Indicates if the number is registered on WhatsApp
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isWAContact = data.isWAContact;
|
||||
|
||||
/**
|
||||
* Indicates if the number is saved in the current phone's contacts
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isMyContact = data.isMyContact;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contact's profile picture URL, if privacy settings allow it
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getProfilePicUrl() {
|
||||
return await this.client.getProfilePicUrl(this.id._serialized);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Contact;
|
||||
@@ -22,6 +22,7 @@ class GroupChat extends Chat {
|
||||
|
||||
/**
|
||||
* Gets the date at which the group was created
|
||||
* @type {date}
|
||||
*/
|
||||
get createdAt() {
|
||||
return new Date(this.groupMetadata.creation * 1000);
|
||||
@@ -29,12 +30,14 @@ class GroupChat extends Chat {
|
||||
|
||||
/**
|
||||
* Gets the group description
|
||||
* @type {string}
|
||||
*/
|
||||
get description() {
|
||||
return this.groupMetadata.desc;
|
||||
}
|
||||
/**
|
||||
* Gets the group participants
|
||||
* @type {array}
|
||||
*/
|
||||
get participants() {
|
||||
return this.groupMetadata.participants;
|
||||
@@ -42,41 +45,41 @@ class GroupChat extends Chat {
|
||||
|
||||
/**
|
||||
* Adds a list of participants by ID to the group
|
||||
* @param {Array[string]} participantIds
|
||||
* @param {Array<string>} participantIds
|
||||
*/
|
||||
async addParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return Store.Wap.addParticipants(chatId, participantIds);
|
||||
return window.Store.Wap.addParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a list of participants by ID to the group
|
||||
* @param {Array[string]} participantIds
|
||||
* @param {Array<string>} participantIds
|
||||
*/
|
||||
async removeParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return Store.Wap.removeParticipants(chatId, participantIds);
|
||||
return window.Store.Wap.removeParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Promotes participants by IDs to admins
|
||||
* @param {Array[string]} participantIds
|
||||
* @param {Array<string>} participantIds
|
||||
*/
|
||||
async promoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return Store.Wap.promoteParticipants(chatId, participantIds);
|
||||
return window.Store.Wap.promoteParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Demotes participants by IDs to regular users
|
||||
* @param {Array[string]} participantIds
|
||||
* @param {Array<string>} participantIds
|
||||
*/
|
||||
async demoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return Store.Wap.demoteParticipants(chatId, participantIds);
|
||||
return window.Store.Wap.demoteParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
@@ -86,7 +89,7 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async setSubject(subject) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, subject) => {
|
||||
return Store.Wap.changeSubject(chatId, subject);
|
||||
return window.Store.Wap.changeSubject(chatId, subject);
|
||||
}, this.id._serialized, subject);
|
||||
|
||||
if(res.status == 200) {
|
||||
@@ -100,8 +103,8 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async setDescription(description) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, description) => {
|
||||
let descId = Store.GroupMetadata.get(chatId).descId;
|
||||
return Store.Wap.setGroupDescription(chatId, description, Store.genId(), descId);
|
||||
let descId = window.Store.GroupMetadata.get(chatId).descId;
|
||||
return window.Store.Wap.setGroupDescription(chatId, description, window.Store.genId(), descId);
|
||||
}, this.id._serialized, description);
|
||||
|
||||
if (res.status == 200) {
|
||||
@@ -114,14 +117,14 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async getInviteCode() {
|
||||
let res = await this.client.pupPage.evaluate(chatId => {
|
||||
return Store.Wap.groupInviteCode(chatId);
|
||||
return window.Store.Wap.groupInviteCode(chatId);
|
||||
}, this.id._serialized);
|
||||
|
||||
if (res.status == 200) {
|
||||
return res.code;
|
||||
}
|
||||
|
||||
throw new Error('Not authorized')
|
||||
throw new Error('Not authorized');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,28 +132,8 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async revokeInvite() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
return Store.Wap.revokeGroupInvite(chatId);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object with information about the invite code's group
|
||||
* @param {string} inviteCode
|
||||
*/
|
||||
static async getInviteInfo(inviteCode) {
|
||||
return await this.client.pupPage.evaluate(inviteCode => {
|
||||
return 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 Store.Wap.acceptGroupInvite(inviteCode);
|
||||
}, inviteCode);
|
||||
return window.Store.Wap.revokeGroupInvite(chatId);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +141,7 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async leave() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
return Store.Wap.leaveGroup(chatId);
|
||||
return window.Store.Wap.leaveGroup(chatId);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
|
||||
104
src/structures/GroupNotification.js
Normal file
104
src/structures/GroupNotification.js
Normal file
@@ -0,0 +1,104 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Represents a GroupNotification on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class GroupNotification extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* ID that represents the groupNotification
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.id;
|
||||
|
||||
/**
|
||||
* Extra content
|
||||
* @type {string}
|
||||
*/
|
||||
this.body = data.body || '';
|
||||
|
||||
/**
|
||||
* GroupNotification type
|
||||
* @type {GroupNotificationTypes}
|
||||
*/
|
||||
this.type = data.subtype;
|
||||
|
||||
/**
|
||||
* Unix timestamp for when the groupNotification was created
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.t;
|
||||
|
||||
/**
|
||||
* ID for the Chat that this groupNotification was sent for.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.chatId = typeof (data.from) === 'object' ? data.from._serialized : data.from;
|
||||
|
||||
/**
|
||||
* ContactId for the user that produced the GroupNotification.
|
||||
* @type {string}
|
||||
*/
|
||||
this.author = typeof (data.author) === 'object' ? data.author._serialized : data.author;
|
||||
|
||||
/**
|
||||
* Contact IDs for the users that were affected by this GroupNotification.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
this.recipientIds = [];
|
||||
|
||||
if (data.recipients) {
|
||||
this.recipientIds = data.recipients;
|
||||
}
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Chat this groupNotification was sent in
|
||||
* @returns {Promise<Chat>}
|
||||
*/
|
||||
getChat() {
|
||||
return this.client.getChatById(this.chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Contact this GroupNotification was produced by
|
||||
* @returns {Promise<Contact>}
|
||||
*/
|
||||
getContact() {
|
||||
return this.client.getContactById(this.author);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Contacts affected by this GroupNotification.
|
||||
* @returns {Promise<Array<Contact>>}
|
||||
*/
|
||||
async getRecipients() {
|
||||
return await Promise.all(this.recipientIds.map(async m => await this.client.getContactById(m)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the same chat this GroupNotification was produced in.
|
||||
*
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {object} options
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async reply(content, options={}) {
|
||||
return this.client.sendMessage(this.chatId, content, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = GroupNotification;
|
||||
33
src/structures/Location.js
Normal file
33
src/structures/Location.js
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Location information
|
||||
*/
|
||||
class Location {
|
||||
/**
|
||||
* @param {number} latitude
|
||||
* @param {number} longitude
|
||||
* @param {?string} description
|
||||
*/
|
||||
constructor(latitude, longitude, description) {
|
||||
/**
|
||||
* Location latitude
|
||||
* @type {number}
|
||||
*/
|
||||
this.latitude = latitude;
|
||||
|
||||
/**
|
||||
* Location longitude
|
||||
* @type {number}
|
||||
*/
|
||||
this.longitude = longitude;
|
||||
|
||||
/**
|
||||
* Name for the location
|
||||
* @type {?string}
|
||||
*/
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Location;
|
||||
@@ -1,6 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
const MessageMedia = require('./MessageMedia');
|
||||
const Location = require('./Location');
|
||||
const { MessageTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents a Message on WhatsApp
|
||||
@@ -14,73 +17,232 @@ class Message extends Base {
|
||||
}
|
||||
|
||||
_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;
|
||||
|
||||
/**
|
||||
* Message content
|
||||
* @type {string}
|
||||
*/
|
||||
this.body = this.hasMedia ? data.caption || '' : data.body || '';
|
||||
|
||||
/**
|
||||
* Message type
|
||||
* @type {MessageTypes}
|
||||
*/
|
||||
this.type = data.type;
|
||||
|
||||
/**
|
||||
* Unix timestamp for when the message was created
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.t;
|
||||
this.from = data.from;
|
||||
this.to = data.to;
|
||||
this.author = data.author;
|
||||
|
||||
/**
|
||||
* 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 !== null) ? data.from._serialized : data.from;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @type {string}
|
||||
*/
|
||||
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 !== null) ? data.author._serialized : data.author;
|
||||
|
||||
/**
|
||||
* Indicates if the message was forwarded
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isForwarded = data.isForwarded;
|
||||
|
||||
/**
|
||||
* Indicates if the message was a broadcast
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.broadcast = data.broadcast;
|
||||
|
||||
/**
|
||||
* Indicates if the message was sent by the current user
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.fromMe = data.id.fromMe;
|
||||
|
||||
/**
|
||||
* Indicates if the message was sent as a reply to another message.
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.hasQuotedMsg = data.quotedMsg ? true : false;
|
||||
|
||||
/**
|
||||
* Location information contained in the message, if the message is type "location"
|
||||
* @type {Location}
|
||||
*/
|
||||
this.location = data.type === MessageTypes.LOCATION ? new Location(data.lat, data.lng, data.loc) : undefined;
|
||||
|
||||
/**
|
||||
* Indicates the mentions in the message body.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
this.mentionedIds = [];
|
||||
|
||||
if (data.mentionedJidList) {
|
||||
this.mentionedIds = data.mentionedJidList;
|
||||
}
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
_getChatId() {
|
||||
return this.fromMe ? this.to : this.from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Chat this message was sent in
|
||||
* @returns {Promise<Chat>}
|
||||
*/
|
||||
getChat() {
|
||||
return this.client.getChatById(this.from);
|
||||
return this.client.getChatById(this._getChatId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message as a reply. 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.
|
||||
* @param {string} message
|
||||
* @param {?string} chatId
|
||||
* Returns the Contact this message was sent from
|
||||
* @returns {Promise<Contact>}
|
||||
*/
|
||||
async reply(message, chatId) {
|
||||
if (!chatId) {
|
||||
chatId = this.from;
|
||||
}
|
||||
|
||||
return await this.client.pupPage.evaluate((chatId, quotedMessageId, message) => {
|
||||
let quotedMessage = Store.Msg.get(quotedMessageId);
|
||||
if(quotedMessage.canReply()) {
|
||||
const chat = Store.Chat.get(chatId);
|
||||
chat.composeQuotedMsg = quotedMessage;
|
||||
window.Store.SendMessage(chat, message, {quotedMsg: quotedMessage});
|
||||
chat.composeQuotedMsg = null;
|
||||
} else {
|
||||
throw new Error('This message cannot be replied to.');
|
||||
}
|
||||
|
||||
}, chatId, this.id._serialized, message);
|
||||
getContact() {
|
||||
return this.client.getContactById(this.author || this.from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Contacts mentioned in this message
|
||||
* @returns {Promise<Array<Contact>>}
|
||||
*/
|
||||
async getMentions() {
|
||||
return await Promise.all(this.mentionedIds.map(async m => await this.client.getContactById(m)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quoted message, if any
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async getQuotedMessage() {
|
||||
if (!this.hasQuotedMsg) return undefined;
|
||||
|
||||
const quotedMsg = await this.client.pupPage.evaluate((msgId) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
return msg.quotedMsgObj().serialize();
|
||||
}, this.id._serialized);
|
||||
|
||||
return new Message(this.client, quotedMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {?string} chatId
|
||||
* @param {object} options
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async reply(content, chatId, options={}) {
|
||||
if (!chatId) {
|
||||
chatId = this._getChatId();
|
||||
}
|
||||
|
||||
options = {
|
||||
...options,
|
||||
quotedMessageId: this.id._serialized
|
||||
};
|
||||
|
||||
return this.client.sendMessage(chatId, content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the attatched message media
|
||||
* @returns {Promise<MessageMedia>}
|
||||
*/
|
||||
async downloadMedia() {
|
||||
if (!this.hasMedia) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = Store.Msg.get(msgId);
|
||||
const buffer = await WWebJS.downloadBuffer(msg.clientUrl);
|
||||
const decrypted = await Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
|
||||
const data = await WWebJS.readBlobAsync(decrypted._blob);
|
||||
const result = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
|
||||
return {
|
||||
data,
|
||||
mimetype: msg.mimetype,
|
||||
filename: msg.filename
|
||||
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 buffer = await window.WWebJS.downloadBuffer(msg.clientUrl);
|
||||
const decrypted = await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
|
||||
const data = await window.WWebJS.readBlobAsync(decrypted._blob);
|
||||
|
||||
return {
|
||||
data: data.split(',')[1],
|
||||
mimetype: msg.mimetype,
|
||||
filename: msg.filename
|
||||
};
|
||||
|
||||
}, this.id._serialized);
|
||||
|
||||
if(!result) return undefined;
|
||||
return new MessageMedia(result.mimetype, result.data, result.filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a message from the chat
|
||||
* @param {?boolean} everyone If true and the message is sent by the current user, will delete it for everyone in the chat.
|
||||
*/
|
||||
async delete(everyone) {
|
||||
await this.client.pupPage.evaluate((msgId, everyone) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Message;
|
||||
module.exports = Message;
|
||||
|
||||
48
src/structures/MessageMedia.js
Normal file
48
src/structures/MessageMedia.js
Normal file
@@ -0,0 +1,48 @@
|
||||
'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
|
||||
* @param {string} data Base64-encoded data of the file
|
||||
* @param {?string} filename Document file name
|
||||
*/
|
||||
class MessageMedia {
|
||||
constructor(mimetype, data, filename) {
|
||||
/**
|
||||
* MIME type of the attachment
|
||||
* @type {string}
|
||||
*/
|
||||
this.mimetype = mimetype;
|
||||
|
||||
/**
|
||||
* Base64 encoded data that represents the file
|
||||
* @type {string}
|
||||
*/
|
||||
this.data = data;
|
||||
|
||||
/**
|
||||
* Name of the file (for documents)
|
||||
* @type {?string}
|
||||
*/
|
||||
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;
|
||||
13
src/structures/PrivateContact.js
Normal file
13
src/structures/PrivateContact.js
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const Contact = require('./Contact');
|
||||
|
||||
/**
|
||||
* Represents a Private Contact on WhatsApp
|
||||
* @extends {Contact}
|
||||
*/
|
||||
class PrivateContact extends Contact {
|
||||
|
||||
}
|
||||
|
||||
module.exports = PrivateContact;
|
||||
14
src/structures/index.js
Normal file
14
src/structures/index.js
Normal file
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
Base: require('./Base'),
|
||||
BusinessContact: require('./BusinessContact'),
|
||||
Chat: require('./Chat'),
|
||||
ClientInfo: require('./ClientInfo'),
|
||||
Contact: require('./Contact'),
|
||||
GroupChat: require('./GroupChat'),
|
||||
Location: require('./Location'),
|
||||
Message: require('./Message'),
|
||||
MessageMedia: require('./MessageMedia'),
|
||||
PrivateChat: require('./PrivateChat'),
|
||||
PrivateContact: require('./PrivateContact'),
|
||||
GroupNotification: require('./GroupNotification')
|
||||
};
|
||||
@@ -1,32 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
exports.WhatsWebURL = 'https://web.whatsapp.com/'
|
||||
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
|
||||
};
|
||||
|
||||
/**
|
||||
* Client status
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
*/
|
||||
exports.Status = {
|
||||
INITIALIZING: 0,
|
||||
AUTHENTICATING: 1,
|
||||
READY: 3
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Events that can be emitted by the client
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
exports.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'
|
||||
}
|
||||
DISCONNECTED: 'disconnected',
|
||||
STATE_CHANGED: 'change_state',
|
||||
BATTERY_CHANGED: 'change_battery'
|
||||
};
|
||||
|
||||
/**
|
||||
* Message types
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
exports.MessageTypes = {
|
||||
TEXT: 'chat',
|
||||
AUDIO: 'audio',
|
||||
@@ -34,26 +64,72 @@ exports.MessageTypes = {
|
||||
IMAGE: 'image',
|
||||
VIDEO: 'video',
|
||||
DOCUMENT: 'document',
|
||||
STICKER: 'sticker'
|
||||
}
|
||||
STICKER: 'sticker',
|
||||
LOCATION: 'location',
|
||||
CONTACT_CARD: 'vcard',
|
||||
CONTACT_CARD_MULTI: 'multi_vcard',
|
||||
REVOKED: 'revoked',
|
||||
UNKNOWN: 'unknown'
|
||||
};
|
||||
|
||||
/**
|
||||
* Group notification types
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
exports.GroupNotificationTypes = {
|
||||
ADD: 'add',
|
||||
INVITE: 'invite',
|
||||
REMOVE: 'remove',
|
||||
LEAVE: 'leave',
|
||||
SUBJECT: 'subject',
|
||||
DESCRIPTION: 'description',
|
||||
PICTURE: 'picture',
|
||||
ANNOUNCE: 'announce',
|
||||
RESTRICT: 'restrict',
|
||||
};
|
||||
|
||||
/**
|
||||
* Chat types
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
exports.ChatTypes = {
|
||||
SOLO: 'solo',
|
||||
GROUP: 'group',
|
||||
UNKNOWN: 'unknown'
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* WhatsApp state
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
exports.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"
|
||||
}
|
||||
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'
|
||||
};
|
||||
|
||||
/**
|
||||
* Message ACK
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
*/
|
||||
exports.MessageAck = {
|
||||
ACK_ERROR: -1,
|
||||
ACK_PENDING: 0,
|
||||
ACK_SERVER: 1,
|
||||
ACK_DEVICE: 2,
|
||||
ACK_READ: 3,
|
||||
ACK_PLAYED: 4,
|
||||
};
|
||||
|
||||
@@ -1,20 +1,164 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Exposes the internal Store to the WhatsApp Web client
|
||||
*/
|
||||
// Exposes the internal Store to the WhatsApp Web client
|
||||
exports.ExposeStore = (moduleRaidStr) => {
|
||||
eval("var moduleRaid = " + moduleRaidStr);
|
||||
eval('var moduleRaid = ' + moduleRaidStr);
|
||||
// eslint-disable-next-line no-undef
|
||||
window.mR = moduleRaid();
|
||||
window.Store = window.mR.findModule("Chat")[1].default;
|
||||
window.Store.AppState = window.mR.findModule("STREAM")[0].default;
|
||||
window.Store.CryptoLib = window.mR.findModule("decryptE2EMedia")[0];
|
||||
window.Store = window.mR.findModule('Chat')[1].default;
|
||||
window.Store.AppState = window.mR.findModule('STREAM')[0].default;
|
||||
window.Store.Conn = window.mR.findModule('Conn')[0].default;
|
||||
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
|
||||
window.Store.Wap = window.mR.findModule('Wap')[0].default;
|
||||
window.Store.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.SendMessage = window.mR.findModule("sendTextMsgToChat")[0].sendTextMsgToChat;
|
||||
}
|
||||
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.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.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];
|
||||
};
|
||||
|
||||
exports.LoadUtils = () => {
|
||||
window.WWebJS = {};
|
||||
window.WWebJS.getNumberId = async (id) => {
|
||||
|
||||
let result = await window.Store.Wap.queryExist(id);
|
||||
if (result.jid === undefined)
|
||||
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) {
|
||||
await window.Store.SendSeen.sendSeen(chat, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
};
|
||||
window.WWebJS.sendMessage = async (chat, content, options = {}) => {
|
||||
let attOptions = {};
|
||||
if (options.attachment) {
|
||||
attOptions = await window.WWebJS.processMediaData(options.attachment, options.sendAudioAsVoice);
|
||||
content = attOptions.preview;
|
||||
delete options.attachment;
|
||||
}
|
||||
|
||||
let quotedMsgOptions = {};
|
||||
if (options.quotedMessageId) {
|
||||
let quotedMessage = window.Store.Msg.get(options.quotedMessageId);
|
||||
if (quotedMessage.canReply()) {
|
||||
quotedMsgOptions = quotedMessage.msgContextInfo(chat);
|
||||
}
|
||||
delete options.quotedMessageId;
|
||||
}
|
||||
|
||||
if (options.mentionedJidList) {
|
||||
options.mentionedJidList = options.mentionedJidList.map(cId => window.Store.Contact.get(cId).id);
|
||||
}
|
||||
|
||||
let locationOptions = {};
|
||||
if (options.location) {
|
||||
locationOptions = {
|
||||
type: 'location',
|
||||
loc: options.location.description,
|
||||
lat: options.location.latitude,
|
||||
lng: options.location.longitude
|
||||
};
|
||||
delete options.location;
|
||||
}
|
||||
|
||||
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,
|
||||
id: window.Store.genId(),
|
||||
});
|
||||
|
||||
const message = {
|
||||
...options,
|
||||
id: newMsgId,
|
||||
ack: 0,
|
||||
body: content,
|
||||
from: window.Store.Conn.me,
|
||||
to: chat.id,
|
||||
local: true,
|
||||
self: 'out',
|
||||
t: parseInt(new Date().getTime() / 1000),
|
||||
isNewMsg: true,
|
||||
type: 'chat',
|
||||
...locationOptions,
|
||||
...attOptions,
|
||||
...quotedMsgOptions
|
||||
};
|
||||
|
||||
await window.Store.SendMessage.addAndSendMsgToChat(chat, message);
|
||||
return window.Store.Msg.get(newMsgId._serialized);
|
||||
};
|
||||
|
||||
window.WWebJS.processMediaData = async (mediaInfo, forceVoice) => {
|
||||
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
|
||||
const mData = await window.Store.OpaqueData.default.createFromData(file, file.type);
|
||||
const mediaPrep = window.Store.MediaPrep.prepRawMedia(mData, {});
|
||||
const mediaData = await mediaPrep.waitForPrep();
|
||||
const mediaObject = window.Store.MediaObject.getOrCreateMediaObject(mediaData.filehash);
|
||||
|
||||
const mediaType = window.Store.MediaTypes.msgToMediaType({
|
||||
type: mediaData.type,
|
||||
isGif: mediaData.isGif
|
||||
});
|
||||
|
||||
if(forceVoice && mediaData.type === 'audio') {
|
||||
mediaData.type = 'ptt';
|
||||
}
|
||||
|
||||
if (!(mediaData.mediaBlob instanceof window.Store.OpaqueData.default)) {
|
||||
mediaData.mediaBlob = await window.Store.OpaqueData.default.createFromData(mediaData.mediaBlob, mediaData.mediaBlob.type);
|
||||
}
|
||||
|
||||
mediaData.renderableUrl = mediaData.mediaBlob.url();
|
||||
mediaObject.consolidate(mediaData.toJSON());
|
||||
mediaData.mediaBlob.autorelease();
|
||||
|
||||
const uploadedMedia = await window.Store.MediaUpload.uploadMedia({ mimetype: mediaData.mimetype, mediaObject, mediaType });
|
||||
if (!uploadedMedia) {
|
||||
throw new Error('upload failed: media entry was not created');
|
||||
}
|
||||
|
||||
mediaData.set({
|
||||
clientUrl: uploadedMedia.mmsUrl,
|
||||
directPath: uploadedMedia.directPath,
|
||||
mediaKey: uploadedMedia.mediaKey,
|
||||
mediaKeyTimestamp: uploadedMedia.mediaKeyTimestamp,
|
||||
filehash: mediaObject.filehash,
|
||||
uploadhash: uploadedMedia.uploadHash,
|
||||
size: mediaObject.size,
|
||||
streamingSidecar: uploadedMedia.sidecar,
|
||||
firstFrameSidecar: uploadedMedia.firstFrameSidecar
|
||||
});
|
||||
|
||||
return mediaData;
|
||||
};
|
||||
|
||||
window.WWebJS.getChatModel = chat => {
|
||||
let res = chat.serialize();
|
||||
@@ -26,22 +170,66 @@ exports.LoadUtils = () => {
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
window.WWebJS.getChat = chatId => {
|
||||
const chat = Store.Chat.get(chatId);
|
||||
return WWebJS.getChatModel(chat);
|
||||
}
|
||||
const chat = window.Store.Chat.get(chatId);
|
||||
return window.WWebJS.getChatModel(chat);
|
||||
};
|
||||
|
||||
window.WWebJS.getChats = () => {
|
||||
const chats = Store.Chat.models;
|
||||
return chats.map(chat => WWebJS.getChatModel(chat));
|
||||
}
|
||||
const chats = window.Store.Chat.models;
|
||||
return chats.map(chat => window.WWebJS.getChatModel(chat));
|
||||
};
|
||||
|
||||
window.WWebJS.getContactModel = contact => {
|
||||
let res = contact.serialize();
|
||||
res.isBusiness = contact.isBusiness;
|
||||
|
||||
if (contact.businessProfile) {
|
||||
res.businessProfile = contact.businessProfile.serialize();
|
||||
}
|
||||
|
||||
res.isMe = contact.isMe;
|
||||
res.isUser = contact.isUser;
|
||||
res.isGroup = contact.isGroup;
|
||||
res.isWAContact = contact.isWAContact;
|
||||
res.isMyContact = contact.isMyContact;
|
||||
res.userid = contact.userid;
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
window.WWebJS.getContact = contactId => {
|
||||
const contact = window.Store.Contact.get(contactId);
|
||||
return window.WWebJS.getContactModel(contact);
|
||||
};
|
||||
|
||||
window.WWebJS.getContacts = () => {
|
||||
const contacts = window.Store.Contact.models;
|
||||
return contacts.map(contact => window.WWebJS.getContactModel(contact));
|
||||
};
|
||||
|
||||
window.WWebJS.mediaInfoToFile = ({ data, mimetype, filename }) => {
|
||||
const binaryData = atob(data);
|
||||
|
||||
const buffer = new ArrayBuffer(binaryData.length);
|
||||
const view = new Uint8Array(buffer);
|
||||
for (let i = 0; i < binaryData.length; i++) {
|
||||
view[i] = binaryData.charCodeAt(i);
|
||||
}
|
||||
|
||||
const blob = new Blob([buffer], { type: mimetype });
|
||||
return new File([blob], filename, {
|
||||
type: mimetype,
|
||||
lastModified: Date.now()
|
||||
});
|
||||
};
|
||||
|
||||
window.WWebJS.downloadBuffer = (url) => {
|
||||
return new Promise(function(resolve, reject) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", url);
|
||||
xhr.open('GET', url);
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.onload = function () {
|
||||
if (xhr.status == 200) {
|
||||
@@ -61,27 +249,64 @@ exports.LoadUtils = () => {
|
||||
};
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
window.WWebJS.readBlobAsync = (blob) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let reader = new FileReader();
|
||||
|
||||
reader.onload = () => {
|
||||
resolve(reader.result);
|
||||
};
|
||||
|
||||
reader.onerror = reject;
|
||||
|
||||
reader.readAsDataURL(blob);
|
||||
})
|
||||
}
|
||||
}
|
||||
let reader = new FileReader();
|
||||
|
||||
reader.onload = () => {
|
||||
resolve(reader.result);
|
||||
};
|
||||
|
||||
reader.onerror = reject;
|
||||
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
};
|
||||
|
||||
window.WWebJS.sendClearChat = async (chatId) => {
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
if (chat !== undefined) {
|
||||
await window.Store.SendClear.sendClear(chat, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
window.WWebJS.sendDeleteChat = async (chatId) => {
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
if (chat !== undefined) {
|
||||
await window.Store.SendDelete.sendDelete(chat);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
window.WWebJS.sendChatstate = async (state, chatId) => {
|
||||
switch(state) {
|
||||
case 'typing':
|
||||
await window.Store.Wap.sendChatstateComposing(chatId);
|
||||
break;
|
||||
case 'recording':
|
||||
await window.Store.Wap.sendChatstateRecording(chatId);
|
||||
break;
|
||||
case 'stop':
|
||||
await window.Store.Wap.sendChatstatePaused(chatId);
|
||||
break;
|
||||
default:
|
||||
throw 'Invalid chatstate';
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
exports.MarkAllRead = () => {
|
||||
let Chats = Store.Chat.models;
|
||||
let Chats = window.Store.Chat.models;
|
||||
|
||||
for (chatIndex in Chats) {
|
||||
for (let chatIndex in Chats) {
|
||||
if (isNaN(chatIndex)) {
|
||||
continue;
|
||||
}
|
||||
@@ -90,7 +315,7 @@ exports.MarkAllRead = () => {
|
||||
|
||||
if (chat.unreadCount > 0) {
|
||||
chat.markSeen();
|
||||
Store.Wap.sendConversationSeen(chat.id, chat.getLastMsgKeyForAction(), chat.unreadCount - chat.pendingSeenCount);
|
||||
window.Store.Wap.sendConversationSeen(chat.id, chat.getLastMsgKeyForAction(), chat.unreadCount - chat.pendingSeenCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
56
src/util/InterfaceController.js
Normal file
56
src/util/InterfaceController.js
Normal file
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Interface Controller
|
||||
*/
|
||||
class InterfaceController {
|
||||
|
||||
constructor(props) {
|
||||
this.pupPage = props.pupPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Chat Window
|
||||
* @param {string} chatId ID of the chat window that will be opened
|
||||
*/
|
||||
async openChatWindow(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.openChatAt(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Chat Drawer
|
||||
* @param {string} chatId ID of the chat drawer that will be opened
|
||||
*/
|
||||
async openChatDrawer(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.chatInfoDrawer(chat);
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Message Drawer
|
||||
* @param {string} msgId ID of the message drawer that will be opened
|
||||
*/
|
||||
async openMessageDrawer(msgId) {
|
||||
await this.pupPage.evaluate(async msgId => {
|
||||
let msg = await window.Store.Msg.get(msgId);
|
||||
await window.Store.Cmd.msgInfoDrawer(msg);
|
||||
}, msgId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the Right Drawer
|
||||
*/
|
||||
async closeRightDrawer() {
|
||||
await this.pupPage.evaluate(async () => {
|
||||
await window.Store.Cmd.closeDrawerRight();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = InterfaceController;
|
||||
@@ -7,29 +7,29 @@ const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
||||
*/
|
||||
class Util {
|
||||
|
||||
constructor() {
|
||||
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets default properties on an object that aren't already specified.
|
||||
* @param {Object} def Default properties
|
||||
* @param {Object} given Object to assign defaults to
|
||||
* @returns {Object}
|
||||
* @private
|
||||
*/
|
||||
static mergeDefault(def, given) {
|
||||
if (!given) return def;
|
||||
for (const key in def) {
|
||||
if (!has(given, key) || given[key] === undefined) {
|
||||
given[key] = def[key];
|
||||
} else if (given[key] === Object(given[key])) {
|
||||
given[key] = Util.mergeDefault(def[key], given[key]);
|
||||
}
|
||||
constructor() {
|
||||
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
|
||||
}
|
||||
|
||||
return given;
|
||||
}
|
||||
/**
|
||||
* Sets default properties on an object that aren't already specified.
|
||||
* @param {Object} def Default properties
|
||||
* @param {Object} given Object to assign defaults to
|
||||
* @returns {Object}
|
||||
* @private
|
||||
*/
|
||||
static mergeDefault(def, given) {
|
||||
if (!given) return def;
|
||||
for (const key in def) {
|
||||
if (!has(given, key) || given[key] === undefined) {
|
||||
given[key] = def[key];
|
||||
} else if (given[key] === Object(given[key])) {
|
||||
given[key] = Util.mergeDefault(def[key], given[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return given;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Util;
|
||||
Reference in New Issue
Block a user