mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
Compare commits
5 Commits
WaWJS2
...
message-by
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
308ab9826c | ||
|
|
6cf9c2a0f3 | ||
|
|
60761399ca | ||
|
|
7a8e922696 | ||
|
|
841719ff4c |
@@ -1,3 +1,2 @@
|
|||||||
WWEBJS_TEST_REMOTE_ID=XXXXXXXXXX@c.us
|
WWEBJS_TEST_SESSION_PATH=test_session.json
|
||||||
WWEBJS_TEST_CLIENT_ID=authenticated
|
WWEBJS_TEST_REMOTE_ID=XXXXXXXXXX@c.us
|
||||||
WWEBJS_TEST_MD=1
|
|
||||||
3
.github/FUNDING.yml
vendored
3
.github/FUNDING.yml
vendored
@@ -1,3 +0,0 @@
|
|||||||
github: [pedroslopez, PurpShell]
|
|
||||||
ko_fi: pedroslopez
|
|
||||||
custom: ["paypal.me/psla", "buymeacoff.ee/pedroslopez"]
|
|
||||||
41
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
41
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Is something not working as intended? Report it here.
|
||||||
|
title: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Bug description
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
### Reproduction steps
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
...
|
||||||
|
|
||||||
|
### Expected behavior
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
### Relevant code
|
||||||
|
If applicable, add code snippets to help explain your problem.
|
||||||
|
|
||||||
|
### Environment (please complete the following information):
|
||||||
|
**WhatsApp**
|
||||||
|
- Account type [Standard / Business]:
|
||||||
|
- Device OS [iOS / Android]:
|
||||||
|
- WhatsApp Web version [run `await client.getWWebVersion()`]:
|
||||||
|
|
||||||
|
**Library**
|
||||||
|
- Browser [Chrome / Chromium]:
|
||||||
|
- NodeJS version (`node -v`):
|
||||||
|
- npm or yarn version (`npm -v`):
|
||||||
|
- whatsapp-web.js version:
|
||||||
|
|
||||||
|
**Other**
|
||||||
|
- Operating system (the one running node) [Linux / MacOS / Windows]:
|
||||||
|
- Operating system version (ex. Windows 10):
|
||||||
|
### Additional context
|
||||||
|
Add any other context about the problem here.
|
||||||
105
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
105
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -1,105 +0,0 @@
|
|||||||
name: '🐛 Bug report'
|
|
||||||
description: Create a report to help us improve
|
|
||||||
labels: bug
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Thank you for reporting an issue :pray:.
|
|
||||||
|
|
||||||
This issue tracker is for reporting bugs found in [`whatsapp-web.js`](https://github.com/pedroslopez/whatsapp-web.js).
|
|
||||||
|
|
||||||
If you have a question about how to achieve something and are struggling, please post a question in our [Discord server](https://discord.gg/wyKybbF) instead.
|
|
||||||
|
|
||||||
Before submitting a new bug/issue, please check the links below to see if there is a solution or question posted there already:
|
|
||||||
- `whatsapp-web.js` [Issues tab](https://github.com/pedroslopez/whatsapp-web.js/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
|
|
||||||
- `whatsapp-web.js` [closed Issues tab](https://github.com/pedroslopez/whatsapp-web.js/issues?q=is%3Aissue+sort%3Aupdated-desc+is%3Aclosed)
|
|
||||||
|
|
||||||
The more information you fill in, the better the community can help you.
|
|
||||||
- type: checkboxes
|
|
||||||
attributes:
|
|
||||||
label: Is there an existing issue for this?
|
|
||||||
description: Please search to see if an issue already exists for the bug you encountered.
|
|
||||||
options:
|
|
||||||
- label: I have searched the existing issues
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: description
|
|
||||||
attributes:
|
|
||||||
label: Describe the bug
|
|
||||||
description: Provide a clear and concise description of the challenge you are running into.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: expected
|
|
||||||
attributes:
|
|
||||||
label: Expected behavior
|
|
||||||
description: Provide a clear and concise description of what you expected to happen.
|
|
||||||
placeholder: |
|
|
||||||
As a user, I expected ___ behavior but I am seeing ___
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: steps
|
|
||||||
attributes:
|
|
||||||
label: Steps to Reproduce the Bug or Issue
|
|
||||||
description: Describe the steps we have to take to reproduce the behavior.
|
|
||||||
placeholder: |
|
|
||||||
1. Do X
|
|
||||||
2. Do Y
|
|
||||||
3. Do Z
|
|
||||||
4. See error
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: relevant_code
|
|
||||||
attributes:
|
|
||||||
label: Relevant Code
|
|
||||||
description: If applicable, add code snippets to help explain your problem.
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
- type: dropdown
|
|
||||||
id: browser_type
|
|
||||||
attributes:
|
|
||||||
label: Browser Type
|
|
||||||
description: What web browser are you using?
|
|
||||||
options:
|
|
||||||
- Chromium
|
|
||||||
- Google Chrome
|
|
||||||
- Other (please write in Additional Context)
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: dropdown
|
|
||||||
id: whatsapp_type
|
|
||||||
attributes:
|
|
||||||
label: WhatsApp Account Type
|
|
||||||
options:
|
|
||||||
- Standard
|
|
||||||
- WhatsApp Business
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: dropdown
|
|
||||||
id: multidevice
|
|
||||||
attributes:
|
|
||||||
label: Does your WhatsApp account have multidevice enabled?
|
|
||||||
options:
|
|
||||||
- Yes, I am using Multi Device
|
|
||||||
- No, I am not using Multi Device
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Environment
|
|
||||||
description: |
|
|
||||||
- OS: [e.g. Mac, Windows, Linux, Docker + Ubuntu 18, etc]
|
|
||||||
- Phone OS: [e.g. Android, iOS]
|
|
||||||
- whatsapp-web.js version [e.g. 1.2.3]
|
|
||||||
- WhatsApp Web version [run `await client.getWWebVersion()`]:
|
|
||||||
- Node.js Version [e.g. 1.2.3]
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: additional
|
|
||||||
attributes:
|
|
||||||
label: Additional context
|
|
||||||
description: Add any other context about the problem 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.
|
||||||
42
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
42
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@@ -1,42 +0,0 @@
|
|||||||
name: 🚀 Feature request
|
|
||||||
description: Suggest an idea for this project
|
|
||||||
labels: enhancement
|
|
||||||
|
|
||||||
body:
|
|
||||||
- type: checkboxes
|
|
||||||
attributes:
|
|
||||||
label: Is there an existing issue for this?
|
|
||||||
description: Please search to see if an issue related to this feature request already exists.
|
|
||||||
options:
|
|
||||||
- label: I have searched the existing issues
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Is your feature request related to a problem? Please describe.
|
|
||||||
description: A concise description of the problem you are facing or the motivetion behind this feature request.
|
|
||||||
placeholder: I faced a problem due to ...
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Describe the solution you'd like.
|
|
||||||
description: A concise description of the solution for the issue.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Describe an alternate solution.
|
|
||||||
description: Is there any other approach to solve the problem?
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Additional context
|
|
||||||
description: |
|
|
||||||
Links? Screenshots? References? Anything that will give us more context about what you would like to see!
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
41
.github/pull_request_template.md
vendored
41
.github/pull_request_template.md
vendored
@@ -1,41 +0,0 @@
|
|||||||
# PR Details
|
|
||||||
|
|
||||||
<!--- Provide a general summary of your changes in the Title above -->
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
<!--- Describe your changes in detail -->
|
|
||||||
|
|
||||||
## Related Issue
|
|
||||||
|
|
||||||
<!--- Optional --->
|
|
||||||
<!--- If there is an issue link it here: -->
|
|
||||||
|
|
||||||
## Motivation and Context
|
|
||||||
|
|
||||||
<!--- Optional --->
|
|
||||||
<!--- Why is this change required? What problem does it solve? -->
|
|
||||||
|
|
||||||
## How Has This Been Tested
|
|
||||||
|
|
||||||
<!--- Please describe in detail how you tested your changes. -->
|
|
||||||
<!--- Include details of your testing environment, and the tests you ran to -->
|
|
||||||
|
|
||||||
## Types of changes
|
|
||||||
|
|
||||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
|
||||||
|
|
||||||
- [ ] Dependency change
|
|
||||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
|
||||||
- [ ] New feature (non-breaking change which adds functionality)
|
|
||||||
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
|
||||||
|
|
||||||
## Checklist
|
|
||||||
|
|
||||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
|
||||||
|
|
||||||
- [ ] My code follows the code style of this project.
|
|
||||||
- [ ] I have updated the documentation accordingly (index.d.ts).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
32
.github/workflows/release.yml
vendored
32
.github/workflows/release.yml
vendored
@@ -1,32 +0,0 @@
|
|||||||
name: release
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
release_type:
|
|
||||||
description: "`alpha`, `alpha-minor`, `alpha-major` release?"
|
|
||||||
required: true
|
|
||||||
default: "alpha"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: ${{ github.repository == 'pedroslopez/whatsapp-web.js' }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
|
|
||||||
- run: git config --global user.email "hello@wwebjs.dev"
|
|
||||||
- run: git config --global user.name "WWebJS Bot"
|
|
||||||
- name: Bump version and publish to NPM
|
|
||||||
id: publish
|
|
||||||
run: ./tools/publish ${{ github.event.inputs.release_type }}
|
|
||||||
env:
|
|
||||||
NPM_TOKEN: ${{ secrets.RELEASE_NPM_TOKEN }}
|
|
||||||
- name: Create GitHub Release
|
|
||||||
id: create_release
|
|
||||||
uses: ncipollo/release-action@v1
|
|
||||||
with:
|
|
||||||
prerelease: ${{ steps.publish.outputs.PRERELEASE }}
|
|
||||||
generateReleaseNotes: true
|
|
||||||
tag: v${{ steps.publish.outputs.NEW_VERSION }}
|
|
||||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -64,10 +64,8 @@ typings/
|
|||||||
# next.js build output
|
# next.js build output
|
||||||
.next
|
.next
|
||||||
|
|
||||||
# macOS
|
# macOS Thumbnails
|
||||||
._*
|
._*
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# Test sessions
|
# Test sessions
|
||||||
*session.json
|
*session.json
|
||||||
.wwebjs_auth/
|
|
||||||
@@ -12,8 +12,6 @@ yarn-debug.log*
|
|||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
*session.json
|
*session.json
|
||||||
.wwebjs_auth/
|
|
||||||
|
|
||||||
.env
|
.env
|
||||||
tools/
|
tools/
|
||||||
tests/
|
tests/
|
||||||
|
|||||||
@@ -1,133 +0,0 @@
|
|||||||
|
|
||||||
# Contributor Covenant Code of Conduct
|
|
||||||
|
|
||||||
## Our Pledge
|
|
||||||
|
|
||||||
We as members, contributors, and leaders pledge to make participation in our
|
|
||||||
community a harassment-free experience for everyone, regardless of age, body
|
|
||||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
||||||
identity and expression, level of experience, education, socio-economic status,
|
|
||||||
nationality, personal appearance, race, religion, or sexual identity
|
|
||||||
and orientation.
|
|
||||||
|
|
||||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
||||||
diverse, inclusive, and healthy community.
|
|
||||||
|
|
||||||
## Our Standards
|
|
||||||
|
|
||||||
Examples of behavior that contributes to a positive environment for our
|
|
||||||
community include:
|
|
||||||
|
|
||||||
* Demonstrating empathy and kindness toward other people
|
|
||||||
* Being respectful of differing opinions, viewpoints, and experiences
|
|
||||||
* Giving and gracefully accepting constructive feedback
|
|
||||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
||||||
and learning from the experience
|
|
||||||
* Focusing on what is best not just for us as individuals, but for the
|
|
||||||
overall community
|
|
||||||
|
|
||||||
Examples of unacceptable behavior include:
|
|
||||||
|
|
||||||
* The use of sexualized language or imagery, and sexual attention or
|
|
||||||
advances of any kind
|
|
||||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
||||||
* Public or private harassment
|
|
||||||
* Publishing others' private information, such as a physical or email
|
|
||||||
address, without their explicit permission
|
|
||||||
* Other conduct which could reasonably be considered inappropriate in a
|
|
||||||
professional setting
|
|
||||||
|
|
||||||
## Enforcement Responsibilities
|
|
||||||
|
|
||||||
Community leaders are responsible for clarifying and enforcing our standards of
|
|
||||||
acceptable behavior and will take appropriate and fair corrective action in
|
|
||||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
||||||
or harmful.
|
|
||||||
|
|
||||||
Community leaders have the right and responsibility to remove, edit, or reject
|
|
||||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
||||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
||||||
decisions when appropriate.
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
This Code of Conduct applies within all community spaces, and also applies when
|
|
||||||
an individual is officially representing the community in public spaces.
|
|
||||||
Examples of representing our community include using an official e-mail address,
|
|
||||||
posting via an official social media account, or acting as an appointed
|
|
||||||
representative at an online or offline event.
|
|
||||||
|
|
||||||
## Enforcement
|
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
||||||
reported to the community leaders responsible for enforcement at
|
|
||||||
[pedroslopez@me.com](mailto:pedroslopez@me.com).
|
|
||||||
All complaints will be reviewed and investigated promptly and fairly.
|
|
||||||
|
|
||||||
All community leaders are obligated to respect the privacy and security of the
|
|
||||||
reporter of any incident.
|
|
||||||
|
|
||||||
## Enforcement Guidelines
|
|
||||||
|
|
||||||
Community leaders will follow these Community Impact Guidelines in determining
|
|
||||||
the consequences for any action they deem in violation of this Code of Conduct:
|
|
||||||
|
|
||||||
### 1. Correction
|
|
||||||
|
|
||||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
||||||
unprofessional or unwelcome in the community.
|
|
||||||
|
|
||||||
**Consequence**: A private, written warning from community leaders, providing
|
|
||||||
clarity around the nature of the violation and an explanation of why the
|
|
||||||
behavior was inappropriate. A public apology may be requested.
|
|
||||||
|
|
||||||
### 2. Warning
|
|
||||||
|
|
||||||
**Community Impact**: A violation through a single incident or series
|
|
||||||
of actions.
|
|
||||||
|
|
||||||
**Consequence**: A warning with consequences for continued behavior. No
|
|
||||||
interaction with the people involved, including unsolicited interaction with
|
|
||||||
those enforcing the Code of Conduct, for a specified period of time. This
|
|
||||||
includes avoiding interactions in community spaces as well as external channels
|
|
||||||
like social media. Violating these terms may lead to a temporary or
|
|
||||||
permanent ban.
|
|
||||||
|
|
||||||
### 3. Temporary Ban
|
|
||||||
|
|
||||||
**Community Impact**: A serious violation of community standards, including
|
|
||||||
sustained inappropriate behavior.
|
|
||||||
|
|
||||||
**Consequence**: A temporary ban from any sort of interaction or public
|
|
||||||
communication with the community for a specified period of time. No public or
|
|
||||||
private interaction with the people involved, including unsolicited interaction
|
|
||||||
with those enforcing the Code of Conduct, is allowed during this period.
|
|
||||||
Violating these terms may lead to a permanent ban.
|
|
||||||
|
|
||||||
### 4. Permanent Ban
|
|
||||||
|
|
||||||
**Community Impact**: Demonstrating a pattern of violation of community
|
|
||||||
standards, including sustained inappropriate behavior, harassment of an
|
|
||||||
individual, or aggression toward or disparagement of classes of individuals.
|
|
||||||
|
|
||||||
**Consequence**: A permanent ban from any sort of public interaction within
|
|
||||||
the community.
|
|
||||||
|
|
||||||
## Attribution
|
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
||||||
version 2.0, available at
|
|
||||||
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
|
|
||||||
|
|
||||||
Community Impact Guidelines were inspired by
|
|
||||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
||||||
|
|
||||||
For answers to common questions about this code of conduct, see the FAQ at
|
|
||||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
|
|
||||||
at [https://www.contributor-covenant.org/translations][translations].
|
|
||||||
|
|
||||||
[homepage]: https://www.contributor-covenant.org
|
|
||||||
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
|
|
||||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
||||||
[FAQ]: https://www.contributor-covenant.org/faq
|
|
||||||
[translations]: https://www.contributor-covenant.org/translations
|
|
||||||
62
README.md
62
README.md
@@ -1,4 +1,4 @@
|
|||||||
[](https://www.npmjs.com/package/whatsapp-web.js) [](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765)  [](https://discord.gg/H7DqQs4)
|
[](https://www.npmjs.com/package/whatsapp-web.js) [](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765)  [](https://discord.gg/H7DqQs4)
|
||||||
|
|
||||||
# whatsapp-web.js
|
# whatsapp-web.js
|
||||||
A WhatsApp API client that connects through the WhatsApp Web browser app
|
A WhatsApp API client that connects through the WhatsApp Web browser app
|
||||||
@@ -7,13 +7,6 @@ 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.
|
**NOTE:** I can't guarantee you will not be blocked by using this method, although it has worked for me. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.
|
||||||
|
|
||||||
## Quick Links
|
|
||||||
|
|
||||||
* [Guide / Getting Started](https://wwebjs.dev/guide) _(work in progress)_
|
|
||||||
* [Reference documentation](https://docs.wwebjs.dev/)
|
|
||||||
* [GitHub](https://github.com/pedroslopez/whatsapp-web.js)
|
|
||||||
* [npm](https://npmjs.org/package/whatsapp-web.js)
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
The module is now available on npm! `npm i whatsapp-web.js`
|
The module is now available on npm! `npm i whatsapp-web.js`
|
||||||
@@ -47,24 +40,51 @@ 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.
|
Take a look at [example.js](https://github.com/pedroslopez/whatsapp-web.js/blob/master/example.js) for another example with more use cases.
|
||||||
|
|
||||||
For more information on saving and restoring sessions, check out the available [Authentication Strategies](https://wwebjs.dev/guide/authentication.html).
|
## Remote Access
|
||||||
|
|
||||||
|
You could also connect to any previously existing browser instance:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const client = new Client({
|
||||||
|
puppeteer: {
|
||||||
|
browserWSEndpoint: `ws://localhost:3000`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
|
||||||
|
1) Installing a browser using browserless:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run \
|
||||||
|
--rm \
|
||||||
|
-p 3000:3000 \
|
||||||
|
-e "MAX_CONCURRENT_SESSIONS=1" \
|
||||||
|
browserless/chrome:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Reference: https://docs.browserless.io/docs/docker-quickstart.html
|
||||||
|
|
||||||
|
### Remote Debugging
|
||||||
|
|
||||||
|
2) Running a browser with websocket remote debugging enabled:
|
||||||
|
> chrome.exe --remote-debugging-port=9222
|
||||||
|
|
||||||
|
After that check the following webpage and check http://127.0.0.1:9220/json and get the **webSocketDebuggerUrl**
|
||||||
|
|
||||||
## Supported features
|
## Supported features
|
||||||
|
|
||||||
| Feature | Status |
|
| Feature | Status |
|
||||||
| ------------- | ------------- |
|
| ------------- | ------------- |
|
||||||
| Multi Device | ✅ |
|
|
||||||
| Send messages | ✅ |
|
| Send messages | ✅ |
|
||||||
| Receive messages | ✅ |
|
| Receive messages | ✅ |
|
||||||
| Send media (images/audio/documents) | ✅ |
|
| Send media (images/audio/documents) | ✅ |
|
||||||
| Send media (video) | ✅ [(requires google chrome)](https://wwebjs.dev/guide/handling-attachments.html#caveat-for-sending-videos-and-gifs) |
|
| Send media (video) | ✅ [(requires google chrome)](https://guide.wwebjs.dev/features/handling-attachments#caveat-for-sending-videos-and-gifs) |
|
||||||
| Send stickers | ✅ |
|
| Send stickers | ✅ |
|
||||||
| Receive media (images/audio/video/documents) | ✅ |
|
| Receive media (images/audio/video/documents) | ✅ |
|
||||||
| Send contact cards | ✅ |
|
| Send contact cards | ✅ |
|
||||||
| Send location | ✅ |
|
| Send location | ✅ |
|
||||||
| Send buttons | ✅ |
|
|
||||||
| Send lists | ✅ (business accounts not supported) |
|
|
||||||
| Receive location | ✅ |
|
| Receive location | ✅ |
|
||||||
| Message replies | ✅ |
|
| Message replies | ✅ |
|
||||||
| Join groups by invite | ✅ |
|
| Join groups by invite | ✅ |
|
||||||
@@ -80,21 +100,25 @@ For more information on saving and restoring sessions, check out the available [
|
|||||||
| Get contact info | ✅ |
|
| Get contact info | ✅ |
|
||||||
| Get profile pictures | ✅ |
|
| Get profile pictures | ✅ |
|
||||||
| Set user status message | ✅ |
|
| Set user status message | ✅ |
|
||||||
| React to messages | ✅ |
|
|
||||||
|
|
||||||
Something missing? Make an issue and let us know!
|
Something missing? Make an issue and let us know!
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
* [Reference](https://docs.wwebjs.dev/)
|
||||||
|
* [Guide](https://guide.wwebjs.dev/) _(work in progress)_
|
||||||
|
* [GitHub](https://github.com/pedroslopez/whatsapp-web.js)
|
||||||
|
* [npm](https://npmjs.org/package/whatsapp-web.js)
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Pull requests are welcome! If you see something you'd like to add, please do. For drastic changes, please open an issue first.
|
Pull requests are welcome! If you see something you'd like to add, please do. For drastic changes, please open an issue first.
|
||||||
|
|
||||||
## Supporting the project
|
## Donating
|
||||||
|
|
||||||
You can support the maintainer of this project through the links below
|
You can support the maintainer of this project through the link below
|
||||||
|
|
||||||
- [Support via GitHub Sponsors](https://github.com/sponsors/pedroslopez)
|
[](https://www.paypal.me/psla/)
|
||||||
- [Support via PayPal](https://www.paypal.me/psla/)
|
|
||||||
- [Sign up for DigitalOcean](https://m.do.co/c/73f906a36ed4) and get $200 in credit when you sign up (Referral)
|
|
||||||
|
|
||||||
## Disclaimer
|
## Disclaimer
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Base</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: BaseAuthStrategy</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>19.<wbr>4</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">BaseAuthStrategy</span></h1>
|
|
||||||
<p class="source-link">Source: <a href="authStrategies_BaseAuthStrategy.js.html#source-line-6">authStrategies/<wbr>BaseAuthStrategy.<wbr>js:6</a></p>
|
|
||||||
<div class="symbol-classdesc">
|
|
||||||
<p>Base class which all authentication strategies extend</p>
|
|
||||||
</div>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</header>
|
|
||||||
<section id="summary">
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2 id="BaseAuthStrategy">new <span class="symbol-name">BaseAuthStrategy</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.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: BusinessContact</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -104,29 +104,20 @@
|
|||||||
<dt><a href="BusinessContact.html#getAbout">getAbout()</a></dt>
|
<dt><a href="BusinessContact.html#getAbout">getAbout()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="summary-column">
|
||||||
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="BusinessContact.html#getChat">getChat()</a></dt>
|
<dt><a href="BusinessContact.html#getChat">getChat()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="BusinessContact.html#getCommonGroups">getCommonGroups()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="BusinessContact.html#getCountryCode">getCountryCode()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="BusinessContact.html#getFormattedNumber">getFormattedNumber()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="BusinessContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
<dt><a href="BusinessContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="summary-column">
|
||||||
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="BusinessContact.html#unblock">unblock()</a></dt>
|
<dt><a href="BusinessContact.html#unblock">unblock()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -272,33 +263,6 @@
|
|||||||
<dd></dd>
|
<dd></dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="getCommonGroups"><span class="symbol-name">getCommonGroups</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of WAWebJS.ChatId</span></span></h3>
|
|
||||||
<p>Gets the Contact's common groups with you. Returns empty array if you don't have any common group.</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Inherited from</dt>
|
|
||||||
<dd><a href="Contact.html#getCommonGroups">Contact#getCommonGroups</a></dd>
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd></dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getCountryCode"><span class="symbol-name">getCountryCode</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
|
||||||
<p>Returns the contact's countrycode, (1541859685@c.us) => (1)</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Inherited from</dt>
|
|
||||||
<dd><a href="Contact.html#getCountryCode">Contact#getCountryCode</a></dd>
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd></dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getFormattedNumber"><span class="symbol-name">getFormattedNumber</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
|
||||||
<p>Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901)</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Inherited from</dt>
|
|
||||||
<dd><a href="Contact.html#getFormattedNumber">Contact#getFormattedNumber</a></dd>
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd></dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
<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>
|
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
@@ -326,7 +290,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -1,249 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Buttons</title>
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
|
||||||
<link href="css/baseline.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body onload="prettyPrint()">
|
|
||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
|
||||||
<div id="jsdoc-navbar-container">
|
|
||||||
<div id="jsdoc-navbar-content">
|
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<div id="jsdoc-body-container">
|
|
||||||
<div id="jsdoc-content">
|
|
||||||
<div id="jsdoc-content-container">
|
|
||||||
<div id="jsdoc-main" role="main">
|
|
||||||
<header class="page-header">
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
|
||||||
<h1><small></small><span class="symbol-name">Buttons</span></h1>
|
|
||||||
<p class="source-link">Source: <a href="structures_Buttons.js.html#source-line-23">structures/<wbr>Buttons.<wbr>js:23</a></p>
|
|
||||||
<div class="symbol-classdesc">
|
|
||||||
<p>Message type buttons</p>
|
|
||||||
</div>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</header>
|
|
||||||
<section id="summary">
|
|
||||||
<div class="summary-callout">
|
|
||||||
<h2 class="summary-callout-heading">Properties</h2>
|
|
||||||
<div class="summary-content">
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="Buttons.html#body">body</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Buttons.html#buttons">buttons</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="Buttons.html#footer">footer</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Buttons.html#title">title</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="summary-callout">
|
|
||||||
<h2 class="summary-callout-heading">Method</h2>
|
|
||||||
<div class="summary-content">
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="Buttons.html#_format">_format(buttons)</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2 id="Buttons">new <span class="symbol-name">Buttons</span><span class="signature"><span class="signature-params">(body, buttons, title, footer)</span></span></h2>
|
|
||||||
<section>
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>body</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>buttons</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>See <a href="global.html#ButtonSpec"><code>ButtonSpec</code></a></p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>title</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Value can be null.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>footer</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Value can be null.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2>Properties</h2>
|
|
||||||
<section>
|
|
||||||
<h3 id="body"><span class="symbol-name">body</span><small class="property-type">
|
|
||||||
(string or <a href="MessageMedia.html">MessageMedia</a>)</small></h3>
|
|
||||||
<p>Message body</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="buttons"><span class="symbol-name">buttons</span><small class="property-type">
|
|
||||||
Array of <a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></small></h3>
|
|
||||||
<p>buttons of message</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="footer"><span class="symbol-name">footer</span><small class="property-type">
|
|
||||||
string</small></h3>
|
|
||||||
<p>footer of message</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="title"><span class="symbol-name">title</span><small class="property-type">
|
|
||||||
string</small></h3>
|
|
||||||
<p>title of message</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</section>
|
|
||||||
<h2>Method</h2>
|
|
||||||
<section>
|
|
||||||
<h3 id="_format"><span class="symbol-name">_format</span><span class="signature"><span class="signature-params">(buttons)</span> → <span class="signature-returns"> Array of <a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></span></span></h3>
|
|
||||||
<p>Creates button array from simple array</p>
|
|
||||||
<section>
|
|
||||||
<h4>
|
|
||||||
Example
|
|
||||||
</h4>
|
|
||||||
<div>
|
|
||||||
<pre class="prettyprint"><code>Input: [{id:'customId',body:'button1'},{body:'button2'},{body:'button3'},{body:'button4'}]
|
|
||||||
Returns: [{ buttonId:'customId',buttonText:{'displayText':'button1'},type: 1 },{buttonId:'n3XKsL',buttonText:{'displayText':'button2'},type:1},{buttonId:'NDJk0a',buttonText:{'displayText':'button3'},type:1}]</code></pre>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h4>Parameter</h4>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>buttons</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Array of <a href="global.html#ButtonSpec">ButtonSpec</a></p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Array of <a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
|
||||||
<div id="jsdoc-footer-container">
|
|
||||||
<p>
|
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Call</title>
|
<title>whatsapp-web.js 1.14.1 » Class: Call</title>
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -78,22 +78,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</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="Call.html#reject">reject()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<h2 id="Call">new <span class="symbol-name">Call</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
<h2 id="Call">new <span class="symbol-name">Call</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||||
@@ -151,14 +135,6 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
</section>
|
</section>
|
||||||
<h2>Method</h2>
|
|
||||||
<section>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="reject"><span class="symbol-name">reject</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
|
||||||
<p>Reject the call</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</section>
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -168,7 +144,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Chat</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -176,7 +176,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="isMuted"><span class="symbol-name">isMuted</span><small class="property-type">
|
<h3 id="isMuted"><span class="symbol-name">isMuted</span><small class="property-type">
|
||||||
boolean</small></h3>
|
number</small></h3>
|
||||||
<p>Indicates if the chat is muted or not</p>
|
<p>Indicates if the chat is muted or not</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
@@ -224,8 +224,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing Boolean</code>
|
<p><code>Promise containing Boolean</code> <p>result</p>
|
||||||
<p>result</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -240,8 +239,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing Boolean</code>
|
<p><code>Promise containing Boolean</code> <p>result</p>
|
||||||
<p>result</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -271,7 +269,7 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>Options for searching messages. Right now only limit and fromMe is supported.</p>
|
<p>Options for searching messages. Right now only limit is supported.</p>
|
||||||
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -294,21 +292,8 @@
|
|||||||
<p>Yes</p>
|
<p>Yes</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
<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>
|
||||||
</td>
|
<p>Defaults to <code>50</code>.</p>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>fromMe</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Boolean</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Yes</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.</p>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -349,7 +334,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<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>
|
<h3 id="mute"><span class="symbol-name">mute</span><span class="signature"><span class="signature-params">(unmuteDate)</span></span></h3>
|
||||||
<p>Mutes this chat forever, unless a date is specified</p>
|
<p>Mutes this chat until a specified date</p>
|
||||||
<section>
|
<section>
|
||||||
<h4>Parameter</h4>
|
<h4>Parameter</h4>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
@@ -373,8 +358,7 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>Date at which the Chat will be unmuted, leave as is to mute forever</p>
|
<p>Date at which the Chat will be unmuted</p>
|
||||||
<p>Value can be null.</p>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -388,8 +372,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing boolean</code>
|
<p><code>Promise containing boolean</code> <p>New pin state. Could be false if the max number of pinned chats was reached.</p>
|
||||||
<p>New pin state. Could be false if the max number of pinned chats was reached.</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -440,8 +423,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing <a href="Message.html">Message</a></code>
|
<p><code>Promise containing <a href="Message.html">Message</a></code> <p>Message that was just sent</p>
|
||||||
<p>Message that was just sent</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -451,8 +433,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing Boolean</code>
|
<p><code>Promise containing Boolean</code> <p>result</p>
|
||||||
<p>result</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -482,8 +463,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing boolean</code>
|
<p><code>Promise containing boolean</code> <p>New pin state</p>
|
||||||
<p>New pin state</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -497,7 +477,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
578
docs/Client.html
578
docs/Client.html
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Client</title>
|
<title>whatsapp-web.js 1.14.1 » Class: Client</title>
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||||
<h1><small></small><span class="symbol-name">Client</span></h1>
|
<h1><small></small><span class="symbol-name">Client</span></h1>
|
||||||
<p class="source-link">Source: <a href="Client.js.html#source-line-49">Client.<wbr>js:49</a></p>
|
<p class="source-link">Source: <a href="Client.js.html#source-line-52">Client.<wbr>js:52</a></p>
|
||||||
<div class="symbol-classdesc">
|
<div class="symbol-classdesc">
|
||||||
<p>Starting point for interacting with the WhatsApp Web API</p>
|
<p>Starting point for interacting with the WhatsApp Web API</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
<div class="summary-content">
|
<div class="summary-content">
|
||||||
<div class="summary-column">
|
<div class="summary-column">
|
||||||
<dl class="dl-summary-callout">
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="Client.html#acceptGroupV4Invite">acceptGroupV4Invite(inviteInfo)</a></dt>
|
<dt><a href="Client.html#acceptGroupV4Invite">acceptGroupV4Invite(inviteV4)</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Client.html#acceptInvite">acceptInvite(inviteCode)</a></dt>
|
<dt><a href="Client.html#acceptInvite">acceptInvite(inviteCode)</a></dt>
|
||||||
@@ -70,9 +70,6 @@
|
|||||||
<dt><a href="Client.html#destroy">destroy()</a></dt>
|
<dt><a href="Client.html#destroy">destroy()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Client.html#getBlockedContacts">getBlockedContacts()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Client.html#getChatById">getChatById(chatId)</a></dt>
|
<dt><a href="Client.html#getChatById">getChatById(chatId)</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -85,28 +82,19 @@
|
|||||||
<dt><a href="Client.html#getChatsByLabelId">getChatsByLabelId(labelId)</a></dt>
|
<dt><a href="Client.html#getChatsByLabelId">getChatsByLabelId(labelId)</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Client.html#getCommonGroups">getCommonGroups(contactId)</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Client.html#getContactById">getContactById(contactId)</a></dt>
|
<dt><a href="Client.html#getContactById">getContactById(contactId)</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Client.html#getContacts">getContacts()</a></dt>
|
<dt><a href="Client.html#getContacts">getContacts()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
|
<dt><a href="Client.html#getInviteInfo">getInviteInfo(inviteCode)</a></dt>
|
||||||
|
<dd>
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="summary-column">
|
<div class="summary-column">
|
||||||
<dl class="dl-summary-callout">
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="Client.html#getCountryCode">getCountryCode(number)</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Client.html#getFormattedNumber">getFormattedNumber(number)</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Client.html#getInviteInfo">getInviteInfo(inviteCode)</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Client.html#getLabelById">getLabelById(labelId)</a></dt>
|
<dt><a href="Client.html#getLabelById">getLabelById(labelId)</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -137,16 +125,16 @@
|
|||||||
<dt><a href="Client.html#markChatUnread">markChatUnread(chatId)</a></dt>
|
<dt><a href="Client.html#markChatUnread">markChatUnread(chatId)</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="Client.html#muteChat">muteChat(chatId, unmuteDate)</a></dt>
|
<dt><a href="Client.html#muteChat">muteChat(chatId, unmuteDate)</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Client.html#pinChat">pinChat()</a></dt>
|
<dt><a href="Client.html#pinChat">pinChat()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="summary-column">
|
||||||
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="Client.html#resetState">resetState()</a></dt>
|
<dt><a href="Client.html#resetState">resetState()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -159,9 +147,6 @@
|
|||||||
<dt><a href="Client.html#sendPresenceAvailable">sendPresenceAvailable()</a></dt>
|
<dt><a href="Client.html#sendPresenceAvailable">sendPresenceAvailable()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Client.html#sendPresenceUnavailable">sendPresenceUnavailable()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Client.html#sendSeen">sendSeen(chatId)</a></dt>
|
<dt><a href="Client.html#sendSeen">sendSeen(chatId)</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -236,9 +221,6 @@
|
|||||||
<dt><a href="Client.html#event:message_create">message_create</a></dt>
|
<dt><a href="Client.html#event:message_create">message_create</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Client.html#event:message_reaction">message_reaction</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Client.html#event:message_revoke_everyone">message_revoke_everyone</a></dt>
|
<dt><a href="Client.html#event:message_revoke_everyone">message_revoke_everyone</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -293,20 +275,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>authStrategy</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p>authTimeoutMs</p>
|
<p>authTimeoutMs</p>
|
||||||
@@ -337,7 +305,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p>qrMaxRetries</p>
|
<p>qrRefreshIntervalMs</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
@@ -346,7 +314,21 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>How many times should the qrcode be refreshed before giving up</p>
|
<p>Refresh interval for qr code (how much time to wait before checking if the qr code has changed)</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>qrTimeoutMs</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>Timeout for qr code selector in puppeteer</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -360,7 +342,7 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>@deprecated This option should be set directly on the LegacySessionAuth.</p>
|
<p>Restart client with a new session (i.e. use null 'session' var) if authentication fails</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -374,7 +356,59 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>@deprecated Only here for backwards-compatibility. You should move to using LocalAuth, or set the authStrategy to LegacySessionAuth explicitly.</p>
|
<p>Whatsapp session to restore. If not set, will start a new session</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>session.WABrowserId</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>session.WASecretBundle</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>session.WAToken1</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>session.WAToken2</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -473,6 +507,7 @@
|
|||||||
<dd><a href="Client.html#event:group_update">Client#event:group_update</a></dd>
|
<dd><a href="Client.html#event:group_update">Client#event:group_update</a></dd>
|
||||||
<dd><a href="Client.html#event:disconnected">Client#event:disconnected</a></dd>
|
<dd><a href="Client.html#event:disconnected">Client#event:disconnected</a></dd>
|
||||||
<dd><a href="Client.html#event:change_state">Client#event:change_state</a></dd>
|
<dd><a href="Client.html#event:change_state">Client#event:change_state</a></dd>
|
||||||
|
<dd><a href="Client.html#event:change_battery">Client#event:change_battery</a></dd>
|
||||||
</dl>
|
</dl>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
@@ -487,7 +522,7 @@
|
|||||||
<h2>Methods</h2>
|
<h2>Methods</h2>
|
||||||
<section>
|
<section>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="acceptGroupV4Invite"><span class="symbol-name">acceptGroupV4Invite</span><span class="signature"><span class="signature-params">(inviteInfo)</span> → <span class="signature-returns"> Promise containing Object</span></span></h3>
|
<h3 id="acceptGroupV4Invite"><span class="symbol-name">acceptGroupV4Invite</span><span class="signature"><span class="signature-params">(inviteV4)</span> → <span class="signature-returns"> Promise containing Object</span></span></h3>
|
||||||
<p>Accepts a private invitation to join a group</p>
|
<p>Accepts a private invitation to join a group</p>
|
||||||
<section>
|
<section>
|
||||||
<h4>Parameter</h4>
|
<h4>Parameter</h4>
|
||||||
@@ -503,7 +538,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p>inviteInfo</p>
|
<p>inviteV4</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>object</p>
|
<p>object</p>
|
||||||
@@ -559,8 +594,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing string</code>
|
<p><code>Promise containing string</code> <p>Id of the joined Chat</p>
|
||||||
<p>Id of the joined Chat</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -622,18 +656,15 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Object</code>
|
<p><code>Object</code> <p>createRes</p>
|
||||||
<p>createRes</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>string</code>
|
<p><code>string</code> <p>createRes.gid - ID for the group that was just created</p>
|
||||||
<p>createRes.gid - ID for the group that was just created</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Object with string properties</code>
|
<p><code>Object with string properties</code> <p>createRes.missingParticipants - participants that were not added to the group. Keys represent the ID for participant that was not added and its value is a status code that represents the reason why participant could not be added. This is usually 403 if the user's privacy settings don't allow you to add them to groups.</p>
|
||||||
<p>createRes.missingParticipants - participants that were not added to the group. Keys represent the ID for participant that was not added and its value is a status code that represents the reason why participant could not be added. This is usually 403 if the user's privacy settings don't allow you to add them to groups.</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -643,15 +674,6 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="getBlockedContacts"><span class="symbol-name">getBlockedContacts</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of <a href="Contact.html">Contact</a></span></span></h3>
|
|
||||||
<p>Gets all blocked contacts by host account</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Promise containing Array of <a href="Contact.html">Contact</a></code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getChatById"><span class="symbol-name">getChatById</span><span class="signature"><span class="signature-params">(chatId)</span> → <span class="signature-returns"> Promise containing <a href="Chat.html">Chat</a></span></span></h3>
|
<h3 id="getChatById"><span class="symbol-name">getChatById</span><span class="signature"><span class="signature-params">(chatId)</span> → <span class="signature-returns"> Promise containing <a href="Chat.html">Chat</a></span></span></h3>
|
||||||
<p>Get chat instance by ID</p>
|
<p>Get chat instance by ID</p>
|
||||||
<section>
|
<section>
|
||||||
@@ -772,44 +794,6 @@
|
|||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="getCommonGroups"><span class="symbol-name">getCommonGroups</span><span class="signature"><span class="signature-params">(contactId)</span> → <span class="signature-returns"> Promise containing Array of WAWebJS.ChatId</span></span></h3>
|
|
||||||
<p>Gets the Contact's common groups with you. Returns empty array if you don't have any common 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>contactId</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>string</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>the whatsapp user's ID (_serialized format)</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Promise containing Array of WAWebJS.ChatId</code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getContactById"><span class="symbol-name">getContactById</span><span class="signature"><span class="signature-params">(contactId)</span> → <span class="signature-returns"> Promise containing <a href="Contact.html">Contact</a></span></span></h3>
|
<h3 id="getContactById"><span class="symbol-name">getContactById</span><span class="signature"><span class="signature-params">(contactId)</span> → <span class="signature-returns"> Promise containing <a href="Contact.html">Contact</a></span></span></h3>
|
||||||
<p>Get contact instance by ID</p>
|
<p>Get contact instance by ID</p>
|
||||||
<section>
|
<section>
|
||||||
@@ -856,82 +840,6 @@
|
|||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="getCountryCode"><span class="symbol-name">getCountryCode</span><span class="signature"><span class="signature-params">(number)</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
|
||||||
<p>Get the country code of a WhatsApp ID.</p>
|
|
||||||
<section>
|
|
||||||
<h4>Parameter</h4>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>number</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>string</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Number or ID</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Promise containing string</code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getFormattedNumber"><span class="symbol-name">getFormattedNumber</span><span class="signature"><span class="signature-params">(number)</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
|
||||||
<p>Get the formatted number of a WhatsApp ID.</p>
|
|
||||||
<section>
|
|
||||||
<h4>Parameter</h4>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>number</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>string</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Number or ID</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Promise containing string</code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getInviteInfo"><span class="symbol-name">getInviteInfo</span><span class="signature"><span class="signature-params">(inviteCode)</span> → <span class="signature-returns"> Promise containing object</span></span></h3>
|
<h3 id="getInviteInfo"><span class="symbol-name">getInviteInfo</span><span class="signature"><span class="signature-params">(inviteCode)</span> → <span class="signature-returns"> Promise containing object</span></span></h3>
|
||||||
<p>Returns an object with information about the invite code's group</p>
|
<p>Returns an object with information about the invite code's group</p>
|
||||||
<section>
|
<section>
|
||||||
@@ -965,8 +873,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing object</code>
|
<p><code>Promise containing object</code> <p>Invite information</p>
|
||||||
<p>Invite information</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -1195,7 +1102,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="muteChat"><span class="symbol-name">muteChat</span><span class="signature"><span class="signature-params">(chatId, unmuteDate)</span></span></h3>
|
<h3 id="muteChat"><span class="symbol-name">muteChat</span><span class="signature"><span class="signature-params">(chatId, unmuteDate)</span></span></h3>
|
||||||
<p>Mutes this chat forever, unless a date is specified</p>
|
<p>Mutes the Chat until a specified date</p>
|
||||||
<section>
|
<section>
|
||||||
<h4>Parameters</h4>
|
<h4>Parameters</h4>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
@@ -1233,8 +1140,7 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>Date when the chat will be unmuted, leave as is to mute forever</p>
|
<p>Date when the chat will be unmuted</p>
|
||||||
<p>Value can be null.</p>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -1248,8 +1154,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing boolean</code>
|
<p><code>Promise containing boolean</code> <p>New pin state. Could be false if the max number of pinned chats was reached.</p>
|
||||||
<p>New pin state. Could be false if the max number of pinned chats was reached.</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -1393,7 +1298,7 @@
|
|||||||
<p>content</p>
|
<p>content</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>(string, <a href="MessageMedia.html">MessageMedia</a>, <a href="Location.html">Location</a>, <a href="Contact.html">Contact</a>, Array of <a href="Contact.html">Contact</a>, <a href="Buttons.html">Buttons</a>, or <a href="List.html">List</a>)</p>
|
<p>(string, <a href="MessageMedia.html">MessageMedia</a>, <a href="Location.html">Location</a>, <a href="Contact.html">Contact</a>, or Array of <a href="Contact.html">Contact</a>)</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
@@ -1421,8 +1326,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing <a href="Message.html">Message</a></code>
|
<p><code>Promise containing <a href="Message.html">Message</a></code> <p>Message that was just sent</p>
|
||||||
<p>Message that was just sent</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -1432,11 +1336,6 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="sendPresenceUnavailable"><span class="symbol-name">sendPresenceUnavailable</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
|
||||||
<p>Marks the client as unavailable</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</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">(chatId)</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
<h3 id="sendSeen"><span class="symbol-name">sendSeen</span><span class="signature"><span class="signature-params">(chatId)</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||||
<p>Mark as seen for the Chat</p>
|
<p>Mark as seen for the Chat</p>
|
||||||
<section>
|
<section>
|
||||||
@@ -1470,13 +1369,12 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing boolean</code>
|
<p><code>Promise containing boolean</code> <p>result</p>
|
||||||
<p>result</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="setDisplayName"><span class="symbol-name">setDisplayName</span><span class="signature"><span class="signature-params">(displayName)</span> → <span class="signature-returns"> Promise containing Boolean</span></span></h3>
|
<h3 id="setDisplayName"><span class="symbol-name">setDisplayName</span><span class="signature"><span class="signature-params">(displayName)</span></span></h3>
|
||||||
<p>Sets the current user's display name.
|
<p>Sets the current user's display name.
|
||||||
This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.</p>
|
This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.</p>
|
||||||
<section>
|
<section>
|
||||||
@@ -1509,10 +1407,6 @@
|
|||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Promise containing Boolean</code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="setStatus"><span class="symbol-name">setStatus</span><span class="signature"><span class="signature-params">(status)</span></span></h3>
|
<h3 id="setStatus"><span class="symbol-name">setStatus</span><span class="signature"><span class="signature-params">(status)</span></span></h3>
|
||||||
@@ -1597,8 +1491,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing boolean</code>
|
<p><code>Promise containing boolean</code> <p>New pin state</p>
|
||||||
<p>New pin state</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -1639,10 +1532,104 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<h3 id="event:authenticated"><span class="symbol-name">authenticated</span></h3>
|
<h3 id="event:authenticated"><span class="symbol-name">authenticated</span></h3>
|
||||||
<p>Emitted when authentication is successful</p>
|
<p>Emitted when authentication is successful</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>session</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>object</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>Object containing session information. Can be used to restore the session.</p>
|
||||||
|
<p>Values in <code>session</code> have the following properties:</p>
|
||||||
|
<table class="jsdoc-details-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Optional</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>WABrowserId</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>string</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>WASecretBundle</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>string</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>WAToken1</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>string</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>WAToken2</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>string</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p> </p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="event:change_battery"><span class="symbol-name">change_battery</span></h3>
|
<h3 id="event:change_battery"><span class="symbol-name">change_battery</span></h3>
|
||||||
<p>Emitted when the battery percentage for the attached device changes. Will not be sent if using multi-device.</p>
|
<p>Emitted when the battery percentage for the attached device changes</p>
|
||||||
<section>
|
<section>
|
||||||
<h4>Parameters</h4>
|
<h4>Parameters</h4>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
@@ -1713,8 +1700,6 @@
|
|||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Deprecated</dt>
|
|
||||||
<dd></dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="event:change_state"><span class="symbol-name">change_state</span></h3>
|
<h3 id="event:change_state"><span class="symbol-name">change_state</span></h3>
|
||||||
<p>Emitted when the connection state changes</p>
|
<p>Emitted when the connection state changes</p>
|
||||||
@@ -2184,179 +2169,6 @@
|
|||||||
</section>
|
</section>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="event:message_reaction"><span class="symbol-name">message_reaction</span></h3>
|
|
||||||
<p>Emitted when a reaction is sent, received, updated or removed</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>reaction</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>object</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Values in <code>reaction</code> have the following properties:</p>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>id</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>object</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Reaction id</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>orphan</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>number</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Orphan</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>orphanReason</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>string</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Orphan reason</p>
|
|
||||||
<p>Value can be null.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>timestamp</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>number</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Timestamp</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>reaction</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>string</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Reaction</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>read</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>boolean</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Read</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>msgId</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>object</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Parent message id</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>senderId</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>string</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Sender id</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>ack</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>number</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Ack</p>
|
|
||||||
<p>Value can be null.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="event:message_revoke_everyone"><span class="symbol-name">message_revoke_everyone</span></h3>
|
<h3 id="event:message_revoke_everyone"><span class="symbol-name">message_revoke_everyone</span></h3>
|
||||||
<p>Emitted when a message is deleted for everyone in the chat.</p>
|
<p>Emitted when a message is deleted for everyone in the chat.</p>
|
||||||
<section>
|
<section>
|
||||||
@@ -2440,7 +2252,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="event:qr"><span class="symbol-name">qr</span></h3>
|
<h3 id="event:qr"><span class="symbol-name">qr</span></h3>
|
||||||
<p>Emitted when a QR code is received</p>
|
<p>Emitted when the QR code is received</p>
|
||||||
<section>
|
<section>
|
||||||
<h4>Parameter</h4>
|
<h4>Parameter</h4>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
@@ -2486,7 +2298,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: Client.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const puppeteer = require('puppeteer');
|
const puppeteer = require('puppeteer');
|
||||||
const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
|
const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
|
||||||
|
const jsQR = require('jsqr');
|
||||||
|
|
||||||
const Util = require('./util/Util');
|
const Util = require('./util/Util');
|
||||||
const InterfaceController = require('./util/InterfaceController');
|
const InterfaceController = require('./util/InterfaceController');
|
||||||
@@ -41,20 +42,21 @@ const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./ut
|
|||||||
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
||||||
const ChatFactory = require('./factories/ChatFactory');
|
const ChatFactory = require('./factories/ChatFactory');
|
||||||
const ContactFactory = require('./factories/ContactFactory');
|
const ContactFactory = require('./factories/ContactFactory');
|
||||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List, Reaction } = require('./structures');
|
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label, Call } = require('./structures');
|
||||||
const LegacySessionAuth = require('./authStrategies/LegacySessionAuth');
|
|
||||||
const NoAuth = require('./authStrategies/NoAuth');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starting point for interacting with the WhatsApp Web API
|
* Starting point for interacting with the WhatsApp Web API
|
||||||
* @extends {EventEmitter}
|
* @extends {EventEmitter}
|
||||||
* @param {object} options - Client options
|
* @param {object} options - Client options
|
||||||
* @param {AuthStrategy} options.authStrategy - Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used.
|
|
||||||
* @param {number} options.authTimeoutMs - Timeout for authentication selector in puppeteer
|
* @param {number} options.authTimeoutMs - Timeout for authentication selector in puppeteer
|
||||||
* @param {object} options.puppeteer - Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/
|
* @param {object} options.puppeteer - Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/
|
||||||
* @param {number} options.qrMaxRetries - How many times should the qrcode be refreshed before giving up
|
* @param {number} options.qrRefreshIntervalMs - Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
|
||||||
* @param {string} options.restartOnAuthFail - @deprecated This option should be set directly on the LegacySessionAuth.
|
* @param {number} options.qrTimeoutMs - Timeout for qr code selector in puppeteer
|
||||||
* @param {object} options.session - @deprecated Only here for backwards-compatibility. You should move to using LocalAuth, or set the authStrategy to LegacySessionAuth explicitly.
|
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||||
|
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
|
||||||
|
* @param {string} options.session.WABrowserId
|
||||||
|
* @param {string} options.session.WASecretBundle
|
||||||
|
* @param {string} options.session.WAToken1
|
||||||
|
* @param {string} options.session.WAToken2
|
||||||
* @param {number} options.takeoverOnConflict - If another whatsapp web session is detected (another browser), take over the session in the current browser
|
* @param {number} options.takeoverOnConflict - If another whatsapp web session is detected (another browser), take over the session in the current browser
|
||||||
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
|
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
|
||||||
* @param {string} options.userAgent - User agent to use in puppeteer
|
* @param {string} options.userAgent - User agent to use in puppeteer
|
||||||
@@ -76,33 +78,13 @@ const NoAuth = require('./authStrategies/NoAuth');
|
|||||||
* @fires Client#group_update
|
* @fires Client#group_update
|
||||||
* @fires Client#disconnected
|
* @fires Client#disconnected
|
||||||
* @fires Client#change_state
|
* @fires Client#change_state
|
||||||
|
* @fires Client#change_battery
|
||||||
*/
|
*/
|
||||||
class Client extends EventEmitter {
|
class Client extends EventEmitter {
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.options = Util.mergeDefault(DefaultOptions, options);
|
this.options = Util.mergeDefault(DefaultOptions, options);
|
||||||
|
|
||||||
if(!this.options.authStrategy) {
|
|
||||||
if(Object.prototype.hasOwnProperty.call(this.options, 'session')) {
|
|
||||||
process.emitWarning(
|
|
||||||
'options.session is deprecated and will be removed in a future release due to incompatibility with multi-device. ' +
|
|
||||||
'Use the LocalAuth authStrategy, don\'t pass in a session as an option, or suppress this warning by using the LegacySessionAuth strategy explicitly (see https://wwebjs.dev/guide/authentication.html#legacysessionauth-strategy).',
|
|
||||||
'DeprecationWarning'
|
|
||||||
);
|
|
||||||
|
|
||||||
this.authStrategy = new LegacySessionAuth({
|
|
||||||
session: this.options.session,
|
|
||||||
restartOnAuthFail: this.options.restartOnAuthFail
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.authStrategy = new NoAuth();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.authStrategy = this.options.authStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.authStrategy.setup(this);
|
|
||||||
|
|
||||||
this.pupBrowser = null;
|
this.pupBrowser = null;
|
||||||
this.pupPage = null;
|
this.pupPage = null;
|
||||||
@@ -115,206 +97,126 @@ class Client extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
async initialize() {
|
async initialize() {
|
||||||
let [browser, page] = [null, null];
|
let [browser, page] = [null, null];
|
||||||
|
|
||||||
await this.authStrategy.beforeBrowserInitialized();
|
if(this.options.puppeteer &amp;&amp; this.options.puppeteer.browserWSEndpoint) {
|
||||||
|
browser = await puppeteer.connect(this.options.puppeteer);
|
||||||
const puppeteerOpts = this.options.puppeteer;
|
|
||||||
if (puppeteerOpts &amp;&amp; puppeteerOpts.browserWSEndpoint) {
|
|
||||||
browser = await puppeteer.connect(puppeteerOpts);
|
|
||||||
page = await browser.newPage();
|
page = await browser.newPage();
|
||||||
} else {
|
} else {
|
||||||
const browserArgs = [...(puppeteerOpts.args || [])];
|
browser = await puppeteer.launch(this.options.puppeteer);
|
||||||
if(!browserArgs.find(arg => arg.includes('--user-agent'))) {
|
|
||||||
browserArgs.push(`--user-agent=${this.options.userAgent}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
browser = await puppeteer.launch({...puppeteerOpts, args: browserArgs});
|
|
||||||
page = (await browser.pages())[0];
|
page = (await browser.pages())[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
await page.setUserAgent(this.options.userAgent);
|
page.setUserAgent(this.options.userAgent);
|
||||||
if (this.options.bypassCSP) await page.setBypassCSP(true);
|
|
||||||
|
|
||||||
this.pupBrowser = browser;
|
this.pupBrowser = browser;
|
||||||
this.pupPage = page;
|
this.pupPage = page;
|
||||||
|
|
||||||
await this.authStrategy.afterBrowserInitialized();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.options.bypassCSP) {
|
||||||
|
await page.setBypassCSP(true);
|
||||||
|
}
|
||||||
|
|
||||||
await page.goto(WhatsWebURL, {
|
await page.goto(WhatsWebURL, {
|
||||||
waitUntil: 'load',
|
waitUntil: 'load',
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
referer: 'https://whatsapp.com/'
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.evaluate(`function getElementByXpath(path) {
|
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||||
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
|
||||||
}`);
|
|
||||||
|
|
||||||
let lastPercent = null,
|
if (this.options.session) {
|
||||||
lastPercentMessage = null;
|
// Check if session restore was successfull
|
||||||
|
try {
|
||||||
await page.exposeFunction('loadingScreen', async (percent, message) => {
|
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: this.options.authTimeoutMs });
|
||||||
if (lastPercent !== percent || lastPercentMessage !== message) {
|
} catch (err) {
|
||||||
this.emit(Events.LOADING_SCREEN, percent, message);
|
if (err.name === 'TimeoutError') {
|
||||||
lastPercent = percent;
|
/**
|
||||||
lastPercentMessage = message;
|
* Emitted when there has been an error while trying to restore an existing session
|
||||||
}
|
* @event Client#auth_failure
|
||||||
});
|
* @param {string} message
|
||||||
|
*/
|
||||||
await page.evaluate(
|
this.emit(Events.AUTHENTICATION_FAILURE, 'Unable to log in. Are the session details valid?');
|
||||||
async function (selectors) {
|
browser.close();
|
||||||
var observer = new MutationObserver(function () {
|
if (this.options.restartOnAuthFail) {
|
||||||
let progressBar = window.getElementByXpath(
|
// session restore failed so try again but without session to force new authentication
|
||||||
selectors.PROGRESS
|
this.options.session = null;
|
||||||
);
|
this.initialize();
|
||||||
let progressMessage = window.getElementByXpath(
|
|
||||||
selectors.PROGRESS_MESSAGE
|
|
||||||
);
|
|
||||||
|
|
||||||
if (progressBar) {
|
|
||||||
window.loadingScreen(
|
|
||||||
progressBar.value,
|
|
||||||
progressMessage.innerText
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
return;
|
||||||
|
|
||||||
observer.observe(document, {
|
|
||||||
attributes: true,
|
|
||||||
childList: true,
|
|
||||||
characterData: true,
|
|
||||||
subtree: true,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
{
|
|
||||||
PROGRESS: '//*[@id=\'app\']/div/div/div[2]/progress',
|
|
||||||
PROGRESS_MESSAGE: '//*[@id=\'app\']/div/div/div[3]',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const INTRO_IMG_SELECTOR = '[data-testid="intro-md-beta-logo-dark"], [data-testid="intro-md-beta-logo-light"], [data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
|
||||||
const INTRO_QRCODE_SELECTOR = 'div[data-ref] canvas';
|
|
||||||
|
|
||||||
// Checks which selector appears first
|
|
||||||
const needAuthentication = await Promise.race([
|
|
||||||
new Promise(resolve => {
|
|
||||||
page.waitForSelector(INTRO_IMG_SELECTOR, { timeout: this.options.authTimeoutMs })
|
|
||||||
.then(() => resolve(false))
|
|
||||||
.catch((err) => resolve(err));
|
|
||||||
}),
|
|
||||||
new Promise(resolve => {
|
|
||||||
page.waitForSelector(INTRO_QRCODE_SELECTOR, { timeout: this.options.authTimeoutMs })
|
|
||||||
.then(() => resolve(true))
|
|
||||||
.catch((err) => resolve(err));
|
|
||||||
})
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Checks if an error occurred on the first found selector. The second will be discarded and ignored by .race;
|
|
||||||
if (needAuthentication instanceof Error) throw needAuthentication;
|
|
||||||
|
|
||||||
// Scan-qrcode selector was found. Needs authentication
|
|
||||||
if (needAuthentication) {
|
|
||||||
const { failed, failureEventPayload, restart } = await this.authStrategy.onAuthenticationNeeded();
|
|
||||||
if(failed) {
|
|
||||||
/**
|
|
||||||
* 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, failureEventPayload);
|
|
||||||
await this.destroy();
|
|
||||||
if (restart) {
|
|
||||||
// session restore failed so try again but without session to force new authentication
|
|
||||||
return this.initialize();
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QR_CONTAINER = 'div[data-ref]';
|
} else {
|
||||||
const QR_RETRY_BUTTON = 'div[data-ref] > span > button';
|
const getQrCode = async () => {
|
||||||
let qrRetries = 0;
|
// Check if retry button is present
|
||||||
await page.exposeFunction('qrChanged', async (qr) => {
|
var QR_RETRY_SELECTOR = 'div[data-ref] > span > button';
|
||||||
|
var qrRetry = await page.$(QR_RETRY_SELECTOR);
|
||||||
|
if (qrRetry) {
|
||||||
|
await qrRetry.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for QR Code
|
||||||
|
const QR_CANVAS_SELECTOR = 'canvas';
|
||||||
|
await page.waitForSelector(QR_CANVAS_SELECTOR, { 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 a QR code is received
|
* Emitted when the QR code is received
|
||||||
* @event Client#qr
|
* @event Client#qr
|
||||||
* @param {string} qr QR Code
|
* @param {string} qr QR Code
|
||||||
*/
|
*/
|
||||||
this.emit(Events.QR_RECEIVED, qr);
|
this.emit(Events.QR_RECEIVED, qr);
|
||||||
if (this.options.qrMaxRetries > 0) {
|
};
|
||||||
qrRetries++;
|
getQrCode();
|
||||||
if (qrRetries > this.options.qrMaxRetries) {
|
this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
|
||||||
this.emit(Events.DISCONNECTED, 'Max qrcode retries reached');
|
|
||||||
await this.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
await page.evaluate(function (selectors) {
|
|
||||||
const qr_container = document.querySelector(selectors.QR_CONTAINER);
|
|
||||||
window.qrChanged(qr_container.dataset.ref);
|
|
||||||
|
|
||||||
const obs = new MutationObserver((muts) => {
|
|
||||||
muts.forEach(mut => {
|
|
||||||
// Listens to qr token change
|
|
||||||
if (mut.type === 'attributes' &amp;&amp; mut.attributeName === 'data-ref') {
|
|
||||||
window.qrChanged(mut.target.dataset.ref);
|
|
||||||
} else
|
|
||||||
// Listens to retry button, when found, click it
|
|
||||||
if (mut.type === 'childList') {
|
|
||||||
const retry_button = document.querySelector(selectors.QR_RETRY_BUTTON);
|
|
||||||
if (retry_button) retry_button.click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
obs.observe(qr_container.parentElement, {
|
|
||||||
subtree: true,
|
|
||||||
childList: true,
|
|
||||||
attributes: true,
|
|
||||||
attributeFilter: ['data-ref'],
|
|
||||||
});
|
|
||||||
}, {
|
|
||||||
QR_CONTAINER,
|
|
||||||
QR_RETRY_BUTTON
|
|
||||||
});
|
|
||||||
|
|
||||||
// Wait for code scan
|
// Wait for code scan
|
||||||
try {
|
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||||
await page.waitForSelector(INTRO_IMG_SELECTOR, { timeout: 0 });
|
clearInterval(this._qrRefreshInterval);
|
||||||
} catch(error) {
|
this._qrRefreshInterval = undefined;
|
||||||
if (
|
|
||||||
error.name === 'ProtocolError' &amp;&amp;
|
|
||||||
error.message &amp;&amp;
|
|
||||||
error.message.match(/Target closed/)
|
|
||||||
) {
|
|
||||||
// something has called .destroy() while waiting
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await page.evaluate(ExposeStore, moduleRaid.toString());
|
await page.evaluate(ExposeStore, moduleRaid.toString());
|
||||||
const authEventPayload = await this.authStrategy.getAuthEventPayload();
|
|
||||||
|
// 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
|
* Emitted when authentication is successful
|
||||||
* @event Client#authenticated
|
* @event Client#authenticated
|
||||||
|
* @param {object} session Object containing session information. Can be used to restore the session.
|
||||||
|
* @param {string} session.WABrowserId
|
||||||
|
* @param {string} session.WASecretBundle
|
||||||
|
* @param {string} session.WAToken1
|
||||||
|
* @param {string} session.WAToken2
|
||||||
*/
|
*/
|
||||||
this.emit(Events.AUTHENTICATED, authEventPayload);
|
this.emit(Events.AUTHENTICATED, session);
|
||||||
|
|
||||||
// Check window.Store Injection
|
// Check window.Store Injection
|
||||||
await page.waitForFunction('window.Store != undefined');
|
await page.waitForFunction('window.Store != undefined');
|
||||||
|
|
||||||
await page.evaluate(async () => {
|
|
||||||
// safely unregister service workers
|
|
||||||
const registrations = await navigator.serviceWorker.getRegistrations();
|
|
||||||
for (let registration of registrations) {
|
|
||||||
registration.unregister();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//Load util functions (serializers, helper functions)
|
//Load util functions (serializers, helper functions)
|
||||||
await page.evaluate(LoadUtils);
|
await page.evaluate(LoadUtils);
|
||||||
|
|
||||||
@@ -324,7 +226,7 @@ class Client extends EventEmitter {
|
|||||||
* @type {ClientInfo}
|
* @type {ClientInfo}
|
||||||
*/
|
*/
|
||||||
this.info = new ClientInfo(this, await page.evaluate(() => {
|
this.info = new ClientInfo(this, await page.evaluate(() => {
|
||||||
return { ...window.Store.Conn.serialize(), wid: window.Store.User.getMeUser() };
|
return window.Store.Conn.serialize();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Add InterfaceController
|
// Add InterfaceController
|
||||||
@@ -332,6 +234,8 @@ class Client extends EventEmitter {
|
|||||||
|
|
||||||
// Register events
|
// Register events
|
||||||
await page.exposeFunction('onAddMessageEvent', msg => {
|
await page.exposeFunction('onAddMessageEvent', msg => {
|
||||||
|
if (!msg.isNewMsg) return;
|
||||||
|
|
||||||
if (msg.type === 'gp2') {
|
if (msg.type === 'gp2') {
|
||||||
const notification = new GroupNotification(this, msg);
|
const notification = new GroupNotification(this, msg);
|
||||||
if (msg.subtype === 'add' || msg.subtype === 'invite') {
|
if (msg.subtype === 'add' || msg.subtype === 'invite') {
|
||||||
@@ -450,7 +354,7 @@ class Client extends EventEmitter {
|
|||||||
this.emit(Events.MEDIA_UPLOADED, message);
|
this.emit(Events.MEDIA_UPLOADED, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.exposeFunction('onAppStateChangedEvent', async (state) => {
|
await page.exposeFunction('onAppStateChangedEvent', (state) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when the connection state changes
|
* Emitted when the connection state changes
|
||||||
@@ -477,7 +381,6 @@ class Client extends EventEmitter {
|
|||||||
* @event Client#disconnected
|
* @event Client#disconnected
|
||||||
* @param {WAState|"NAVIGATION"} reason reason that caused the disconnect
|
* @param {WAState|"NAVIGATION"} reason reason that caused the disconnect
|
||||||
*/
|
*/
|
||||||
await this.authStrategy.disconnect();
|
|
||||||
this.emit(Events.DISCONNECTED, state);
|
this.emit(Events.DISCONNECTED, state);
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
@@ -489,12 +392,11 @@ class Client extends EventEmitter {
|
|||||||
if (battery === undefined) return;
|
if (battery === undefined) return;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when the battery percentage for the attached device changes. Will not be sent if using multi-device.
|
* Emitted when the battery percentage for the attached device changes
|
||||||
* @event Client#change_battery
|
* @event Client#change_battery
|
||||||
* @param {object} batteryInfo
|
* @param {object} batteryInfo
|
||||||
* @param {number} batteryInfo.battery - The current battery percentage
|
* @param {number} batteryInfo.battery - The current battery percentage
|
||||||
* @param {boolean} batteryInfo.plugged - Indicates if the phone is plugged in (true) or not (false)
|
* @param {boolean} batteryInfo.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
|
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
|
||||||
});
|
});
|
||||||
@@ -513,66 +415,20 @@ class Client extends EventEmitter {
|
|||||||
* @param {boolean} call.webClientShouldHandle - If Waweb should handle
|
* @param {boolean} call.webClientShouldHandle - If Waweb should handle
|
||||||
* @param {object} call.participants - Participants
|
* @param {object} call.participants - Participants
|
||||||
*/
|
*/
|
||||||
const cll = new Call(this, call);
|
const cll = new Call(this,call);
|
||||||
this.emit(Events.INCOMING_CALL, cll);
|
this.emit(Events.INCOMING_CALL, cll);
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.exposeFunction('onReaction', (reactions) => {
|
|
||||||
for (const reaction of reactions) {
|
|
||||||
/**
|
|
||||||
* Emitted when a reaction is sent, received, updated or removed
|
|
||||||
* @event Client#message_reaction
|
|
||||||
* @param {object} reaction
|
|
||||||
* @param {object} reaction.id - Reaction id
|
|
||||||
* @param {number} reaction.orphan - Orphan
|
|
||||||
* @param {?string} reaction.orphanReason - Orphan reason
|
|
||||||
* @param {number} reaction.timestamp - Timestamp
|
|
||||||
* @param {string} reaction.reaction - Reaction
|
|
||||||
* @param {boolean} reaction.read - Read
|
|
||||||
* @param {object} reaction.msgId - Parent message id
|
|
||||||
* @param {string} reaction.senderId - Sender id
|
|
||||||
* @param {?number} reaction.ack - Ack
|
|
||||||
*/
|
|
||||||
|
|
||||||
this.emit(Events.MESSAGE_REACTION, new Reaction(this, reaction));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
|
window.Store.Msg.on('add', (msg) => { if (msg.isNewMsg) window.onAddMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
||||||
window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
||||||
window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(window.WWebJS.getMessageModel(msg)); });
|
window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(window.WWebJS.getMessageModel(msg)); });
|
||||||
window.Store.Msg.on('change:ack', (msg, ack) => { window.onMessageAckEvent(window.WWebJS.getMessageModel(msg), ack); });
|
window.Store.Msg.on('change:ack', (msg,ack) => { window.onMessageAckEvent(window.WWebJS.getMessageModel(msg), ack); });
|
||||||
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if (msg.id.fromMe &amp;&amp; !unsent) window.onMessageMediaUploadedEvent(window.WWebJS.getMessageModel(msg)); });
|
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if (msg.id.fromMe &amp;&amp; !unsent) window.onMessageMediaUploadedEvent(window.WWebJS.getMessageModel(msg)); });
|
||||||
window.Store.Msg.on('remove', (msg) => { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
window.Store.Msg.on('remove', (msg) => { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
||||||
window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); });
|
window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); });
|
||||||
window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); });
|
window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); });
|
||||||
window.Store.Call.on('add', (call) => { window.onIncomingCall(call); });
|
window.Store.Call.on('add', (call) => { window.onIncomingCall(call); });
|
||||||
window.Store.Msg.on('add', (msg) => {
|
|
||||||
if (msg.isNewMsg) {
|
|
||||||
if(msg.type === 'ciphertext') {
|
|
||||||
// defer message event until ciphertext is resolved (type changed)
|
|
||||||
msg.once('change:type', (_msg) => window.onAddMessageEvent(window.WWebJS.getMessageModel(_msg)));
|
|
||||||
} else {
|
|
||||||
window.onAddMessageEvent(window.WWebJS.getMessageModel(msg));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
{
|
|
||||||
const module = window.Store.createOrUpdateReactionsModule;
|
|
||||||
const ogMethod = module.createOrUpdateReactions;
|
|
||||||
module.createOrUpdateReactions = ((...args) => {
|
|
||||||
window.onReaction(args[0].map(reaction => {
|
|
||||||
const msgKey = window.Store.MsgKey.fromString(reaction.msgKey);
|
|
||||||
const parentMsgKey = window.Store.MsgKey.fromString(reaction.parentMsgKey);
|
|
||||||
const timestamp = reaction.timestamp / 1000;
|
|
||||||
|
|
||||||
return {...reaction, msgKey, parentMsgKey, timestamp };
|
|
||||||
}));
|
|
||||||
|
|
||||||
return ogMethod(...args);
|
|
||||||
}).bind(module);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -580,16 +436,12 @@ class Client extends EventEmitter {
|
|||||||
* @event Client#ready
|
* @event Client#ready
|
||||||
*/
|
*/
|
||||||
this.emit(Events.READY);
|
this.emit(Events.READY);
|
||||||
this.authStrategy.afterAuthReady();
|
|
||||||
|
|
||||||
// Disconnect when navigating away when in PAIRING state (detect logout)
|
// Disconnect when navigating away
|
||||||
|
// Because WhatsApp Web now reloads when logging out from the device, this also covers that case
|
||||||
this.pupPage.on('framenavigated', async () => {
|
this.pupPage.on('framenavigated', async () => {
|
||||||
const appState = await this.getState();
|
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||||
if(!appState || appState === WAState.PAIRING) {
|
await this.destroy();
|
||||||
await this.authStrategy.disconnect();
|
|
||||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
|
||||||
await this.destroy();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,19 +449,19 @@ class Client extends EventEmitter {
|
|||||||
* Closes the client
|
* Closes the client
|
||||||
*/
|
*/
|
||||||
async destroy() {
|
async destroy() {
|
||||||
|
if (this._qrRefreshInterval) {
|
||||||
|
clearInterval(this._qrRefreshInterval);
|
||||||
|
}
|
||||||
await this.pupBrowser.close();
|
await this.pupBrowser.close();
|
||||||
await this.authStrategy.destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs out the client, closing the current session
|
* Logs out the client, closing the current session
|
||||||
*/
|
*/
|
||||||
async logout() {
|
async logout() {
|
||||||
await this.pupPage.evaluate(() => {
|
return await this.pupPage.evaluate(() => {
|
||||||
return window.Store.AppState.logout();
|
return window.Store.AppState.logout();
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.authStrategy.logout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -639,7 +491,7 @@ class Client extends EventEmitter {
|
|||||||
/**
|
/**
|
||||||
* Message options.
|
* Message options.
|
||||||
* @typedef {Object} MessageSendOptions
|
* @typedef {Object} MessageSendOptions
|
||||||
* @property {boolean} [linkPreview=true] - Show links preview. Has no effect on multi-device accounts.
|
* @property {boolean} [linkPreview=true] - Show links preview
|
||||||
* @property {boolean} [sendAudioAsVoice=false] - Send audio as voice message
|
* @property {boolean} [sendAudioAsVoice=false] - Send audio as voice message
|
||||||
* @property {boolean} [sendVideoAsGif=false] - Send video as gif
|
* @property {boolean} [sendVideoAsGif=false] - Send video as gif
|
||||||
* @property {boolean} [sendMediaAsSticker=false] - Send media as a sticker
|
* @property {boolean} [sendMediaAsSticker=false] - Send media as a sticker
|
||||||
@@ -658,7 +510,7 @@ class Client extends EventEmitter {
|
|||||||
/**
|
/**
|
||||||
* Send a message to a specific chatId
|
* Send a message to a specific chatId
|
||||||
* @param {string} chatId
|
* @param {string} chatId
|
||||||
* @param {string|MessageMedia|Location|Contact|Array&lt;Contact>|Buttons|List} content
|
* @param {string|MessageMedia|Location|Contact|Array&lt;Contact>} content
|
||||||
* @param {MessageSendOptions} [options] - Options used when sending the message
|
* @param {MessageSendOptions} [options] - Options used when sending the message
|
||||||
*
|
*
|
||||||
* @returns {Promise&lt;Message>} Message that was just sent
|
* @returns {Promise&lt;Message>} Message that was just sent
|
||||||
@@ -674,7 +526,7 @@ class Client extends EventEmitter {
|
|||||||
quotedMessageId: options.quotedMessageId,
|
quotedMessageId: options.quotedMessageId,
|
||||||
parseVCards: options.parseVCards === false ? false : true,
|
parseVCards: options.parseVCards === false ? false : true,
|
||||||
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : [],
|
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : [],
|
||||||
extraOptions: options.extra
|
...options.extra
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
||||||
@@ -689,36 +541,27 @@ class Client extends EventEmitter {
|
|||||||
} else if (content instanceof Location) {
|
} else if (content instanceof Location) {
|
||||||
internalOptions.location = content;
|
internalOptions.location = content;
|
||||||
content = '';
|
content = '';
|
||||||
} else if (content instanceof Contact) {
|
} else if(content instanceof Contact) {
|
||||||
internalOptions.contactCard = content.id._serialized;
|
internalOptions.contactCard = content.id._serialized;
|
||||||
content = '';
|
content = '';
|
||||||
} else if (Array.isArray(content) &amp;&amp; content.length > 0 &amp;&amp; content[0] instanceof Contact) {
|
} else if(Array.isArray(content) &amp;&amp; content.length > 0 &amp;&amp; content[0] instanceof Contact) {
|
||||||
internalOptions.contactCardList = content.map(contact => contact.id._serialized);
|
internalOptions.contactCardList = content.map(contact => contact.id._serialized);
|
||||||
content = '';
|
content = '';
|
||||||
} else if (content instanceof Buttons) {
|
|
||||||
if (content.type !== 'chat') { internalOptions.attachment = content.body; }
|
|
||||||
internalOptions.buttons = content;
|
|
||||||
content = '';
|
|
||||||
} else if (content instanceof List) {
|
|
||||||
internalOptions.list = content;
|
|
||||||
content = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (internalOptions.sendMediaAsSticker &amp;&amp; internalOptions.attachment) {
|
if (internalOptions.sendMediaAsSticker &amp;&amp; internalOptions.attachment) {
|
||||||
internalOptions.attachment = await Util.formatToWebpSticker(
|
internalOptions.attachment =
|
||||||
internalOptions.attachment, {
|
await Util.formatToWebpSticker(internalOptions.attachment, {
|
||||||
name: options.stickerName,
|
name: options.stickerName,
|
||||||
author: options.stickerAuthor,
|
author: options.stickerAuthor,
|
||||||
categories: options.stickerCategories
|
categories: options.stickerCategories
|
||||||
}, this.pupPage
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
|
const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
const chat = await window.Store.Chat.find(chatWid);
|
||||||
|
|
||||||
|
|
||||||
if (sendSeen) {
|
if (sendSeen) {
|
||||||
window.WWebJS.sendSeen(chatId);
|
window.WWebJS.sendSeen(chatId);
|
||||||
}
|
}
|
||||||
@@ -805,7 +648,7 @@ class Client extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
async getInviteInfo(inviteCode) {
|
async getInviteInfo(inviteCode) {
|
||||||
return await this.pupPage.evaluate(inviteCode => {
|
return await this.pupPage.evaluate(inviteCode => {
|
||||||
return window.Store.InviteInfo.queryGroupInvite(inviteCode);
|
return window.Store.Wap.groupInviteInfo(inviteCode);
|
||||||
}, inviteCode);
|
}, inviteCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,34 +658,34 @@ class Client extends EventEmitter {
|
|||||||
* @returns {Promise&lt;string>} Id of the joined Chat
|
* @returns {Promise&lt;string>} Id of the joined Chat
|
||||||
*/
|
*/
|
||||||
async acceptInvite(inviteCode) {
|
async acceptInvite(inviteCode) {
|
||||||
const res = await this.pupPage.evaluate(async inviteCode => {
|
const chatId = await this.pupPage.evaluate(async inviteCode => {
|
||||||
return await window.Store.Invite.joinGroupViaInvite(inviteCode);
|
return await window.Store.Invite.sendJoinGroupViaInvite(inviteCode);
|
||||||
}, inviteCode);
|
}, inviteCode);
|
||||||
|
|
||||||
return res.gid._serialized;
|
return chatId._serialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts a private invitation to join a group
|
* Accepts a private invitation to join a group
|
||||||
* @param {object} inviteInfo Invite V4 Info
|
* @param {object} inviteV4 Invite V4 Info
|
||||||
* @returns {Promise&lt;Object>}
|
* @returns {Promise&lt;Object>}
|
||||||
*/
|
*/
|
||||||
async acceptGroupV4Invite(inviteInfo) {
|
async acceptGroupV4Invite(inviteInfo) {
|
||||||
if (!inviteInfo.inviteCode) throw 'Invalid invite code, try passing the message.inviteV4 object';
|
if(!inviteInfo.inviteCode) throw 'Invalid invite code, try passing the message.inviteV4 object';
|
||||||
if (inviteInfo.inviteCodeExp == 0) throw 'Expired invite code';
|
if (inviteInfo.inviteCodeExp == 0) throw 'Expired invite code';
|
||||||
return this.pupPage.evaluate(async inviteInfo => {
|
return await this.pupPage.evaluate(async inviteInfo => {
|
||||||
let { groupId, fromId, inviteCode, inviteCodeExp } = inviteInfo;
|
let { groupId, fromId, inviteCode, inviteCodeExp, toId } = inviteInfo;
|
||||||
return await window.Store.JoinInviteV4.sendJoinGroupViaInviteV4(inviteCode, String(inviteCodeExp), groupId, fromId);
|
return await window.Store.Wap.acceptGroupV4Invite(groupId, fromId, inviteCode, String(inviteCodeExp), toId);
|
||||||
}, inviteInfo);
|
}, inviteInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current user's status message
|
* Sets the current user's status message
|
||||||
* @param {string} status New status message
|
* @param {string} status New status message
|
||||||
*/
|
*/
|
||||||
async setStatus(status) {
|
async setStatus(status) {
|
||||||
await this.pupPage.evaluate(async status => {
|
await this.pupPage.evaluate(async status => {
|
||||||
return await window.Store.StatusUtils.setMyStatus(status);
|
return await window.Store.Wap.sendSetStatus(status);
|
||||||
}, status);
|
}, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,31 +693,19 @@ class Client extends EventEmitter {
|
|||||||
* Sets the current user's display name.
|
* Sets the current user's display name.
|
||||||
* This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
|
* This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
|
||||||
* @param {string} displayName New display name
|
* @param {string} displayName New display name
|
||||||
* @returns {Promise&lt;Boolean>}
|
|
||||||
*/
|
*/
|
||||||
async setDisplayName(displayName) {
|
async setDisplayName(displayName) {
|
||||||
const couldSet = await this.pupPage.evaluate(async displayName => {
|
await this.pupPage.evaluate(async displayName => {
|
||||||
if(!window.Store.Conn.canSetMyPushname()) return false;
|
return await window.Store.Wap.setPushname(displayName);
|
||||||
|
|
||||||
if(window.Store.MDBackend) {
|
|
||||||
// TODO
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
const res = await window.Store.Wap.setPushname(displayName);
|
|
||||||
return !res.status || res.status === 200;
|
|
||||||
}
|
|
||||||
}, displayName);
|
}, displayName);
|
||||||
|
|
||||||
return couldSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current connection state for the client
|
* Gets the current connection state for the client
|
||||||
* @returns {WAState}
|
* @returns {WAState}
|
||||||
*/
|
*/
|
||||||
async getState() {
|
async getState() {
|
||||||
return await this.pupPage.evaluate(() => {
|
return await this.pupPage.evaluate(() => {
|
||||||
if(!window.Store) return null;
|
|
||||||
return window.Store.AppState.state;
|
return window.Store.AppState.state;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -884,16 +715,7 @@ class Client extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
async sendPresenceAvailable() {
|
async sendPresenceAvailable() {
|
||||||
return await this.pupPage.evaluate(() => {
|
return await this.pupPage.evaluate(() => {
|
||||||
return window.Store.PresenceUtils.sendPresenceAvailable();
|
return window.Store.Wap.sendPresenceAvailable();
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks the client as unavailable
|
|
||||||
*/
|
|
||||||
async sendPresenceUnavailable() {
|
|
||||||
return await this.pupPage.evaluate(() => {
|
|
||||||
return window.Store.PresenceUtils.sendPresenceUnavailable();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -905,7 +727,7 @@ class Client extends EventEmitter {
|
|||||||
return await this.pupPage.evaluate(async chatId => {
|
return await this.pupPage.evaluate(async chatId => {
|
||||||
let chat = await window.Store.Chat.get(chatId);
|
let chat = await window.Store.Chat.get(chatId);
|
||||||
await window.Store.Cmd.archiveChat(chat, true);
|
await window.Store.Cmd.archiveChat(chat, true);
|
||||||
return true;
|
return chat.archive;
|
||||||
}, chatId);
|
}, chatId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -917,7 +739,7 @@ class Client extends EventEmitter {
|
|||||||
return await this.pupPage.evaluate(async chatId => {
|
return await this.pupPage.evaluate(async chatId => {
|
||||||
let chat = await window.Store.Chat.get(chatId);
|
let chat = await window.Store.Chat.get(chatId);
|
||||||
await window.Store.Cmd.archiveChat(chat, false);
|
await window.Store.Cmd.archiveChat(chat, false);
|
||||||
return false;
|
return chat.archive;
|
||||||
}, chatId);
|
}, chatId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -932,9 +754,8 @@ class Client extends EventEmitter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const MAX_PIN_COUNT = 3;
|
const MAX_PIN_COUNT = 3;
|
||||||
const chatModels = window.Store.Chat.getModelsArray();
|
if (window.Store.Chat.models.length > MAX_PIN_COUNT) {
|
||||||
if (chatModels.length > MAX_PIN_COUNT) {
|
let maxPinned = window.Store.Chat.models[MAX_PIN_COUNT - 1].pin;
|
||||||
let maxPinned = chatModels[MAX_PIN_COUNT - 1].pin;
|
|
||||||
if (maxPinned) {
|
if (maxPinned) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -960,16 +781,15 @@ class Client extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutes this chat forever, unless a date is specified
|
* Mutes the Chat until a specified date
|
||||||
* @param {string} chatId ID of the chat that will be muted
|
* @param {string} chatId ID of the chat that will be muted
|
||||||
* @param {?Date} unmuteDate Date when the chat will be unmuted, leave as is to mute forever
|
* @param {Date} unmuteDate Date when the chat will be unmuted
|
||||||
*/
|
*/
|
||||||
async muteChat(chatId, unmuteDate) {
|
async muteChat(chatId, unmuteDate) {
|
||||||
unmuteDate = unmuteDate ? unmuteDate.getTime() / 1000 : -1;
|
|
||||||
await this.pupPage.evaluate(async (chatId, timestamp) => {
|
await this.pupPage.evaluate(async (chatId, timestamp) => {
|
||||||
let chat = await window.Store.Chat.get(chatId);
|
let chat = await window.Store.Chat.get(chatId);
|
||||||
await chat.mute.mute({expiration: timestamp, sendDevice:!0});
|
await chat.mute.mute(timestamp, !0);
|
||||||
}, chatId, unmuteDate || -1);
|
}, chatId, unmuteDate.getTime() / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1000,49 +820,13 @@ class Client extends EventEmitter {
|
|||||||
* @returns {Promise&lt;string>}
|
* @returns {Promise&lt;string>}
|
||||||
*/
|
*/
|
||||||
async getProfilePicUrl(contactId) {
|
async getProfilePicUrl(contactId) {
|
||||||
const profilePic = await this.pupPage.evaluate(async contactId => {
|
const profilePic = await this.pupPage.evaluate((contactId) => {
|
||||||
try {
|
return window.Store.Wap.profilePicFind(contactId);
|
||||||
const chatWid = window.Store.WidFactory.createWid(contactId);
|
|
||||||
return await window.Store.ProfilePic.profilePicFind(chatWid);
|
|
||||||
} catch (err) {
|
|
||||||
if(err.name === 'ServerStatusCodeError') return undefined;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}, contactId);
|
}, contactId);
|
||||||
|
|
||||||
return profilePic ? profilePic.eurl : undefined;
|
return profilePic ? profilePic.eurl : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
|
|
||||||
* @param {string} contactId the whatsapp user's ID (_serialized format)
|
|
||||||
* @returns {Promise&lt;WAWebJS.ChatId[]>}
|
|
||||||
*/
|
|
||||||
async getCommonGroups(contactId) {
|
|
||||||
const commonGroups = await this.pupPage.evaluate(async (contactId) => {
|
|
||||||
let contact = window.Store.Contact.get(contactId);
|
|
||||||
if (!contact) {
|
|
||||||
const wid = window.Store.WidFactory.createUserWid(contactId);
|
|
||||||
const chatConstructor = window.Store.Contact.getModelsArray().find(c=>!c.isGroup).constructor;
|
|
||||||
contact = new chatConstructor({id: wid});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contact.commonGroups) {
|
|
||||||
return contact.commonGroups.serialize();
|
|
||||||
}
|
|
||||||
const status = await window.Store.findCommonGroups(contact);
|
|
||||||
if (status) {
|
|
||||||
return contact.commonGroups.serialize();
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}, contactId);
|
|
||||||
const chats = [];
|
|
||||||
for (const group of commonGroups) {
|
|
||||||
chats.push(group.id);
|
|
||||||
}
|
|
||||||
return chats;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force reset of connection state for the client
|
* Force reset of connection state for the client
|
||||||
*/
|
*/
|
||||||
@@ -1058,7 +842,10 @@ class Client extends EventEmitter {
|
|||||||
* @returns {Promise&lt;Boolean>}
|
* @returns {Promise&lt;Boolean>}
|
||||||
*/
|
*/
|
||||||
async isRegisteredUser(id) {
|
async isRegisteredUser(id) {
|
||||||
return Boolean(await this.getNumberId(id));
|
return await this.pupPage.evaluate(async (id) => {
|
||||||
|
let result = await window.Store.Wap.queryExist(id);
|
||||||
|
return result.jid !== undefined;
|
||||||
|
}, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1068,43 +855,17 @@ class Client extends EventEmitter {
|
|||||||
* @returns {Promise&lt;Object|null>}
|
* @returns {Promise&lt;Object|null>}
|
||||||
*/
|
*/
|
||||||
async getNumberId(number) {
|
async getNumberId(number) {
|
||||||
if (!number.endsWith('@c.us')) {
|
if(!number.endsWith('@c.us')) {
|
||||||
number += '@c.us';
|
number += '@c.us';
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.pupPage.evaluate(async number => {
|
try {
|
||||||
const wid = window.Store.WidFactory.createWid(number);
|
return await this.pupPage.evaluate(async numberId => {
|
||||||
const result = await window.Store.QueryExist(wid);
|
return window.WWebJS.getNumberId(numberId);
|
||||||
if (!result || result.wid === undefined) return null;
|
}, number);
|
||||||
return result.wid;
|
} catch(_) {
|
||||||
}, number);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the formatted number of a WhatsApp ID.
|
|
||||||
* @param {string} number Number or ID
|
|
||||||
* @returns {Promise&lt;string>}
|
|
||||||
*/
|
|
||||||
async getFormattedNumber(number) {
|
|
||||||
if (!number.endsWith('@s.whatsapp.net')) number = number.replace('c.us', 's.whatsapp.net');
|
|
||||||
if (!number.includes('@s.whatsapp.net')) number = `${number}@s.whatsapp.net`;
|
|
||||||
|
|
||||||
return await this.pupPage.evaluate(async numberId => {
|
|
||||||
return window.Store.NumberInfo.formattedPhoneNumber(numberId);
|
|
||||||
}, number);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the country code of a WhatsApp ID.
|
|
||||||
* @param {string} number Number or ID
|
|
||||||
* @returns {Promise&lt;string>}
|
|
||||||
*/
|
|
||||||
async getCountryCode(number) {
|
|
||||||
number = number.replace(' ', '').replace('+', '').replace('@c.us', '');
|
|
||||||
|
|
||||||
return await this.pupPage.evaluate(async numberId => {
|
|
||||||
return window.Store.NumberInfo.findCC(numberId);
|
|
||||||
}, number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1125,18 +886,23 @@ class Client extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createRes = await this.pupPage.evaluate(async (name, participantIds) => {
|
const createRes = await this.pupPage.evaluate(async (name, participantIds) => {
|
||||||
const participantWIDs = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
const res = await window.Store.Wap.createGroup(name, participantIds);
|
||||||
return await window.Store.GroupUtils.createGroup(name, participantWIDs, 0);
|
console.log(res);
|
||||||
|
if (!res.status === 200) {
|
||||||
|
throw 'An error occurred while creating the group!';
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
}, name, participants);
|
}, name, participants);
|
||||||
|
|
||||||
const missingParticipants = createRes.participants.reduce(((missing, c) => {
|
const missingParticipants = createRes.participants.reduce(((missing, c) => {
|
||||||
const id = c.wid._serialized;
|
const id = Object.keys(c)[0];
|
||||||
const statusCode = c.error ? c.error.toString() : '200';
|
const statusCode = c[id].code;
|
||||||
if (statusCode != 200) return Object.assign(missing, { [id]: statusCode });
|
if (statusCode != 200) return Object.assign(missing, { [id]: statusCode });
|
||||||
return missing;
|
return missing;
|
||||||
}), {});
|
}), {});
|
||||||
|
|
||||||
return { gid: createRes.wid, missingParticipants };
|
return { gid: createRes.gid, missingParticipants };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1146,9 +912,9 @@ class Client extends EventEmitter {
|
|||||||
async getLabels() {
|
async getLabels() {
|
||||||
const labels = await this.pupPage.evaluate(async () => {
|
const labels = await this.pupPage.evaluate(async () => {
|
||||||
return window.WWebJS.getLabels();
|
return window.WWebJS.getLabels();
|
||||||
});
|
});
|
||||||
|
|
||||||
return labels.map(data => new Label(this, data));
|
return labels.map(data => new Label(this , data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1159,7 +925,7 @@ class Client extends EventEmitter {
|
|||||||
async getLabelById(labelId) {
|
async getLabelById(labelId) {
|
||||||
const label = await this.pupPage.evaluate(async (labelId) => {
|
const label = await this.pupPage.evaluate(async (labelId) => {
|
||||||
return window.WWebJS.getLabel(labelId);
|
return window.WWebJS.getLabel(labelId);
|
||||||
}, labelId);
|
}, labelId);
|
||||||
|
|
||||||
return new Label(this, label);
|
return new Label(this, label);
|
||||||
}
|
}
|
||||||
@@ -1169,12 +935,12 @@ class Client extends EventEmitter {
|
|||||||
* @param {string} chatId
|
* @param {string} chatId
|
||||||
* @returns {Promise&lt;Array&lt;Label>>}
|
* @returns {Promise&lt;Array&lt;Label>>}
|
||||||
*/
|
*/
|
||||||
async getChatLabels(chatId) {
|
async getChatLabels(chatId){
|
||||||
const labels = await this.pupPage.evaluate(async (chatId) => {
|
const labels = await this.pupPage.evaluate(async (chatId) => {
|
||||||
return window.WWebJS.getChatLabels(chatId);
|
return window.WWebJS.getChatLabels(chatId);
|
||||||
}, chatId);
|
}, chatId);
|
||||||
|
|
||||||
return labels.map(data => new Label(this, data));
|
return labels.map(data => new Label(this, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1182,33 +948,20 @@ class Client extends EventEmitter {
|
|||||||
* @param {string} labelId
|
* @param {string} labelId
|
||||||
* @returns {Promise&lt;Array&lt;Chat>>}
|
* @returns {Promise&lt;Array&lt;Chat>>}
|
||||||
*/
|
*/
|
||||||
async getChatsByLabelId(labelId) {
|
async getChatsByLabelId(labelId){
|
||||||
const chatIds = await this.pupPage.evaluate(async (labelId) => {
|
const chatIds = await this.pupPage.evaluate(async (labelId) => {
|
||||||
const label = window.Store.Label.get(labelId);
|
const label = window.Store.Label.get(labelId);
|
||||||
const labelItems = label.labelItemCollection.getModelsArray();
|
const labelItems = label.labelItemCollection.models;
|
||||||
return labelItems.reduce((result, item) => {
|
return labelItems.reduce((result, item) => {
|
||||||
if (item.parentType === 'Chat') {
|
if(item.parentType === 'Chat'){
|
||||||
result.push(item.parentId);
|
result.push(item.parentId);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}, []);
|
},[]);
|
||||||
}, labelId);
|
}, labelId);
|
||||||
|
|
||||||
return Promise.all(chatIds.map(id => this.getChatById(id)));
|
return Promise.all(chatIds.map(id => this.getChatById(id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all blocked contacts by host account
|
|
||||||
* @returns {Promise&lt;Array&lt;Contact>>}
|
|
||||||
*/
|
|
||||||
async getBlockedContacts() {
|
|
||||||
const blockedContacts = await this.pupPage.evaluate(() => {
|
|
||||||
let chatIds = window.Store.Blocklist.getModelsArray().map(a => a.id._serialized);
|
|
||||||
return Promise.all(chatIds.map(id => window.WWebJS.getContact(id)));
|
|
||||||
});
|
|
||||||
|
|
||||||
return blockedContacts.map(contact => ContactFactory.create(this.client, contact));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Client;
|
module.exports = Client;
|
||||||
@@ -1222,7 +975,7 @@ module.exports = Client;
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: ClientInfo</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<h3 id="phone"><span class="symbol-name">phone</span><small class="property-type">
|
<h3 id="phone"><span class="symbol-name">phone</span><small class="property-type">
|
||||||
object</small></h3>
|
object</small></h3>
|
||||||
<p>Information about the phone this client is connected to. Not available in multi-device.</p>
|
<p>Information about the phone this client is connected to</p>
|
||||||
<section>
|
<section>
|
||||||
<h4>Properties</h4>
|
<h4>Properties</h4>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
@@ -188,12 +188,10 @@
|
|||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Deprecated</dt>
|
|
||||||
<dd></dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="platform"><span class="symbol-name">platform</span><small class="property-type">
|
<h3 id="platform"><span class="symbol-name">platform</span><small class="property-type">
|
||||||
string</small></h3>
|
string</small></h3>
|
||||||
<p>Platform WhatsApp is running on</p>
|
<p>Platform the phone is running on</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="pushname"><span class="symbol-name">pushname</span><small class="property-type">
|
<h3 id="pushname"><span class="symbol-name">pushname</span><small class="property-type">
|
||||||
@@ -213,22 +211,17 @@
|
|||||||
<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>
|
<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>
|
<p>Get current battery percentage and charging status for the attached device</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Deprecated</dt>
|
|
||||||
<dd></dd>
|
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>object</code>
|
<p><code>object</code> <p>batteryStatus</p>
|
||||||
<p>batteryStatus</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>number</code>
|
<p><code>number</code> <p>batteryStatus.battery - The current battery percentage</p>
|
||||||
<p>batteryStatus.battery - The current battery percentage</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>boolean</code>
|
<p><code>boolean</code> <p>batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)</p>
|
||||||
<p>batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -242,7 +235,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Contact</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -101,29 +101,20 @@
|
|||||||
<dt><a href="Contact.html#getAbout">getAbout()</a></dt>
|
<dt><a href="Contact.html#getAbout">getAbout()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="summary-column">
|
||||||
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="Contact.html#getChat">getChat()</a></dt>
|
<dt><a href="Contact.html#getChat">getChat()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="Contact.html#getCommonGroups">getCommonGroups()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Contact.html#getCountryCode">getCountryCode()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Contact.html#getFormattedNumber">getFormattedNumber()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="Contact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
<dt><a href="Contact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="summary-column">
|
||||||
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="Contact.html#unblock">unblock()</a></dt>
|
<dt><a href="Contact.html#unblock">unblock()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -239,33 +230,6 @@
|
|||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="getCommonGroups"><span class="symbol-name">getCommonGroups</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of WAWebJS.ChatId</span></span></h3>
|
|
||||||
<p>Gets the Contact's common groups with you. Returns empty array if you don't have any common group.</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Promise containing Array of WAWebJS.ChatId</code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getCountryCode"><span class="symbol-name">getCountryCode</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
|
||||||
<p>Returns the contact's countrycode, (1541859685@c.us) => (1)</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Promise containing string</code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getFormattedNumber"><span class="symbol-name">getFormattedNumber</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
|
||||||
<p>Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901)</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Promise containing string</code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
<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>
|
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
@@ -293,7 +257,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: GroupChat</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -405,8 +405,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing {status: number}</code>
|
<p><code>Promise containing {status: number}</code> <p>Object with status code indicating if the operation was successful</p>
|
||||||
<p>Object with status code indicating if the operation was successful</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -436,7 +435,7 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>Options for searching messages. Right now only limit and fromMe is supported.</p>
|
<p>Options for searching messages. Right now only limit is supported.</p>
|
||||||
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -459,21 +458,8 @@
|
|||||||
<p>Yes</p>
|
<p>Yes</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
<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>
|
||||||
</td>
|
<p>Defaults to <code>50</code>.</p>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>fromMe</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Yes</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.</p>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -504,8 +490,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing string</code>
|
<p><code>Promise containing string</code> <p>Group's invite code</p>
|
||||||
<p>Group's invite code</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -536,7 +521,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<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>
|
<h3 id="mute"><span class="symbol-name">mute</span><span class="signature"><span class="signature-params">(unmuteDate)</span></span></h3>
|
||||||
<p>Mutes this chat forever, unless a date is specified</p>
|
<p>Mutes this chat until a specified date</p>
|
||||||
<section>
|
<section>
|
||||||
<h4>Parameter</h4>
|
<h4>Parameter</h4>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
@@ -560,8 +545,7 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>Date at which the Chat will be unmuted, leave as is to mute forever</p>
|
<p>Date at which the Chat will be unmuted</p>
|
||||||
<p>Value can be null.</p>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -616,8 +600,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing {status: number}</code>
|
<p><code>Promise containing {status: number}</code> <p>Object with status code indicating if the operation was successful</p>
|
||||||
<p>Object with status code indicating if the operation was successful</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -659,14 +642,12 @@
|
|||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<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 class="signature-returns"> Promise containing string</span></span></h3>
|
<h3 id="revokeInvite"><span class="symbol-name">revokeInvite</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||||
<p>Invalidates the current group invite code and generates a new one</p>
|
<p>Invalidates the current group invite code and generates a new one</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing string</code>
|
<p><code>Promise</code> </p>
|
||||||
<p>New invite code</p>
|
|
||||||
</p>
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
@@ -747,7 +728,7 @@
|
|||||||
<dd><a href="Chat.html#sendStateTyping">Chat#sendStateTyping</a></dd>
|
<dd><a href="Chat.html#sendStateTyping">Chat#sendStateTyping</a></dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<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 class="signature-returns"> Promise containing boolean</span></span></h3>
|
<h3 id="setDescription"><span class="symbol-name">setDescription</span><span class="signature"><span class="signature-params">(description)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||||
<p>Updates the group description</p>
|
<p>Updates the group description</p>
|
||||||
<section>
|
<section>
|
||||||
<h4>Parameter</h4>
|
<h4>Parameter</h4>
|
||||||
@@ -780,9 +761,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing boolean</code>
|
<p><code>Promise</code> </p>
|
||||||
<p>Returns true if the description was properly updated. This can return false if the user does not have the necessary permissions.</p>
|
|
||||||
</p>
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
@@ -821,8 +800,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing boolean</code>
|
<p><code>Promise containing boolean</code> <p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
|
||||||
<p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -862,13 +840,12 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing boolean</code>
|
<p><code>Promise containing boolean</code> <p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
|
||||||
<p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="setSubject"><span class="symbol-name">setSubject</span><span class="signature"><span class="signature-params">(subject)</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
<h3 id="setSubject"><span class="symbol-name">setSubject</span><span class="signature"><span class="signature-params">(subject)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||||
<p>Updates the group subject</p>
|
<p>Updates the group subject</p>
|
||||||
<section>
|
<section>
|
||||||
<h4>Parameter</h4>
|
<h4>Parameter</h4>
|
||||||
@@ -901,9 +878,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing boolean</code>
|
<p><code>Promise</code> </p>
|
||||||
<p>Returns true if the subject was properly updated. This can return false if the user does not have the necessary permissions.</p>
|
|
||||||
</p>
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
@@ -941,7 +916,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: GroupNotification</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -233,7 +233,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: InterfaceController</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -382,7 +382,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Label</title>
|
<title>whatsapp-web.js 1.14.1 » Class: Label</title>
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -163,7 +163,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -1,188 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: LegacySessionAuth</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>19.<wbr>4</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">LegacySessionAuth</span></h1>
|
|
||||||
<p class="source-link">Source: <a href="authStrategies_LegacySessionAuth.js.html#source-line-16">authStrategies/<wbr>LegacySessionAuth.<wbr>js:16</a></p>
|
|
||||||
<div class="symbol-classdesc">
|
|
||||||
<p>Legacy session auth strategy
|
|
||||||
Not compatible with multi-device accounts.</p>
|
|
||||||
</div>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</header>
|
|
||||||
<section id="summary">
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2 id="LegacySessionAuth">new <span class="symbol-name">LegacySessionAuth</span><span class="signature"><span class="signature-params">(options)</span></span></h2>
|
|
||||||
<section>
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>options</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>options</p>
|
|
||||||
<p>Values in <code>options</code> have the following properties:</p>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>restartOnAuthFail</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Restart client with a new session (i.e. use null 'session' var) if authentication fails</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>session</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Whatsapp session to restore. If not set, will start a new session</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>session.WABrowserId</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>session.WASecretBundle</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>session.WAToken1</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>session.WAToken2</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<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.11 on February 11, 2023.
|
|
||||||
</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>
|
|
||||||
271
docs/List.html
271
docs/List.html
@@ -1,271 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: List</title>
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
|
||||||
<link href="css/baseline.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body onload="prettyPrint()">
|
|
||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
|
||||||
<div id="jsdoc-navbar-container">
|
|
||||||
<div id="jsdoc-navbar-content">
|
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<div id="jsdoc-body-container">
|
|
||||||
<div id="jsdoc-content">
|
|
||||||
<div id="jsdoc-content-container">
|
|
||||||
<div id="jsdoc-main" role="main">
|
|
||||||
<header class="page-header">
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
|
||||||
<h1><small></small><span class="symbol-name">List</span></h1>
|
|
||||||
<p class="source-link">Source: <a href="structures_List.js.html#source-line-8">structures/<wbr>List.<wbr>js:8</a></p>
|
|
||||||
<div class="symbol-classdesc">
|
|
||||||
<p>Message type List</p>
|
|
||||||
</div>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</header>
|
|
||||||
<section id="summary">
|
|
||||||
<div class="summary-callout">
|
|
||||||
<h2 class="summary-callout-heading">Properties</h2>
|
|
||||||
<div class="summary-content">
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="List.html#buttonText">buttonText</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="List.html#description">description</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="List.html#footer">footer</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="List.html#sections">sections</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="List.html#title">title</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="summary-callout">
|
|
||||||
<h2 class="summary-callout-heading">Method</h2>
|
|
||||||
<div class="summary-content">
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="List.html#_format">_format(sections)</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2 id="List">new <span class="symbol-name">List</span><span class="signature"><span class="signature-params">(body, buttonText, sections, title, footer)</span></span></h2>
|
|
||||||
<section>
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>body</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>buttonText</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>sections</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>title</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Value can be null.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>footer</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Value can be null.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2>Properties</h2>
|
|
||||||
<section>
|
|
||||||
<h3 id="buttonText"><span class="symbol-name">buttonText</span><small class="property-type">
|
|
||||||
string</small></h3>
|
|
||||||
<p>List button text</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="description"><span class="symbol-name">description</span><small class="property-type">
|
|
||||||
string</small></h3>
|
|
||||||
<p>Message body</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="footer"><span class="symbol-name">footer</span><small class="property-type">
|
|
||||||
string</small></h3>
|
|
||||||
<p>footer of message</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="sections"><span class="symbol-name">sections</span><small class="property-type">
|
|
||||||
Array of any</small></h3>
|
|
||||||
<p>sections of message</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="title"><span class="symbol-name">title</span><small class="property-type">
|
|
||||||
string</small></h3>
|
|
||||||
<p>title of message</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</section>
|
|
||||||
<h2>Method</h2>
|
|
||||||
<section>
|
|
||||||
<h3 id="_format"><span class="symbol-name">_format</span><span class="signature"><span class="signature-params">(sections)</span> → <span class="signature-returns"> Array of any</span></span></h3>
|
|
||||||
<p>Creates section array from simple array</p>
|
|
||||||
<section>
|
|
||||||
<h4>
|
|
||||||
Example
|
|
||||||
</h4>
|
|
||||||
<div>
|
|
||||||
<pre class="prettyprint"><code>Input: [{title:'sectionTitle',rows:[{id:'customId', title:'ListItem2', description: 'desc'},{title:'ListItem2'}]}}]
|
|
||||||
Returns: [{'title':'sectionTitle','rows':[{'rowId':'customId','title':'ListItem1','description':'desc'},{'rowId':'oGSRoD','title':'ListItem2','description':''}]}]</code></pre>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h4>Parameter</h4>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>sections</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Array of any</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Array of any</code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
|
||||||
<div id="jsdoc-footer-container">
|
|
||||||
<p>
|
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: LocalAuth</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>19.<wbr>4</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">LocalAuth</span></h1>
|
|
||||||
<p class="source-link">Source: <a href="authStrategies_LocalAuth.js.html#source-line-13">authStrategies/<wbr>LocalAuth.<wbr>js:13</a></p>
|
|
||||||
<div class="symbol-classdesc">
|
|
||||||
<p>Local directory-based authentication</p>
|
|
||||||
</div>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</header>
|
|
||||||
<section id="summary">
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2 id="LocalAuth">new <span class="symbol-name">LocalAuth</span><span class="signature"><span class="signature-params">(options)</span></span></h2>
|
|
||||||
<section>
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>options</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>options</p>
|
|
||||||
<p>Values in <code>options</code> have the following properties:</p>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>clientId</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>dataPath</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Change the default path for saving session files, default is: "./.wwebjs_auth/"</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<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.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Location</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -149,7 +149,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Message</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||||
<h1><small></small><span class="symbol-name">Message</span></h1>
|
<h1><small></small><span class="symbol-name">Message</span></h1>
|
||||||
<p class="source-link">Source: <a href="structures_Message.js.html#source-line-14">structures/<wbr>Message.<wbr>js:14</a></p>
|
<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">
|
<div class="symbol-classdesc">
|
||||||
<p>Represents a Message on WhatsApp</p>
|
<p>Represents a Message on WhatsApp</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -54,9 +54,6 @@
|
|||||||
<dt><a href="Message.html#deviceType">deviceType</a></dt>
|
<dt><a href="Message.html#deviceType">deviceType</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Message.html#duration">duration</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Message.html#forwardingScore">forwardingScore</a></dt>
|
<dt><a href="Message.html#forwardingScore">forwardingScore</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -82,15 +79,9 @@
|
|||||||
<dt><a href="Message.html#inviteV4">inviteV4</a></dt>
|
<dt><a href="Message.html#inviteV4">inviteV4</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Message.html#isEphemeral">isEphemeral</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Message.html#isForwarded">isForwarded</a></dt>
|
<dt><a href="Message.html#isForwarded">isForwarded</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Message.html#isGif">isGif</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Message.html#isStarred">isStarred</a></dt>
|
<dt><a href="Message.html#isStarred">isStarred</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -103,22 +94,19 @@
|
|||||||
<dt><a href="Message.html#location">location</a></dt>
|
<dt><a href="Message.html#location">location</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
|
<dt><a href="Message.html#mediaKey">mediaKey</a></dt>
|
||||||
|
<dd>
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="summary-column">
|
<div class="summary-column">
|
||||||
<dl class="dl-summary-callout">
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="Message.html#mediaKey">mediaKey</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Message.html#mentionedIds">mentionedIds</a></dt>
|
<dt><a href="Message.html#mentionedIds">mentionedIds</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Message.html#orderId">orderId</a></dt>
|
<dt><a href="Message.html#orderId">orderId</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Message.html#rawData">rawData</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Message.html#timestamp">timestamp</a></dt>
|
<dt><a href="Message.html#timestamp">timestamp</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -158,13 +146,13 @@
|
|||||||
<dt><a href="Message.html#getChat">getChat()</a></dt>
|
<dt><a href="Message.html#getChat">getChat()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Message.html#getContact">getContact()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="summary-column">
|
<div class="summary-column">
|
||||||
<dl class="dl-summary-callout">
|
<dl class="dl-summary-callout">
|
||||||
|
<dt><a href="Message.html#getContact">getContact()</a></dt>
|
||||||
|
<dd>
|
||||||
|
</dd>
|
||||||
<dt><a href="Message.html#getInfo">getInfo()</a></dt>
|
<dt><a href="Message.html#getInfo">getInfo()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -174,22 +162,13 @@
|
|||||||
<dt><a href="Message.html#getOrder">getOrder()</a></dt>
|
<dt><a href="Message.html#getOrder">getOrder()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Message.html#getPayment">getPayment()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Message.html#getQuotedMessage">getQuotedMessage()</a></dt>
|
<dt><a href="Message.html#getQuotedMessage">getQuotedMessage()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="Message.html#react">react(reaction)</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="summary-column">
|
<div class="summary-column">
|
||||||
<dl class="dl-summary-callout">
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="Message.html#reload">reload()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Message.html#reply">reply(content[, chatId][, options])</a></dt>
|
<dt><a href="Message.html#reply">reply(content[, chatId][, options])</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -239,11 +218,6 @@
|
|||||||
<p>String that represents from which device type the message was sent</p>
|
<p>String that represents from which device type the message was sent</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="duration"><span class="symbol-name">duration</span><small class="property-type">
|
|
||||||
string</small></h3>
|
|
||||||
<p>Indicates the duration of the message in seconds</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="forwardingScore"><span class="symbol-name">forwardingScore</span><small class="property-type">
|
<h3 id="forwardingScore"><span class="symbol-name">forwardingScore</span><small class="property-type">
|
||||||
number</small></h3>
|
number</small></h3>
|
||||||
<p>Indicates how many times the message was forwarded.</p>
|
<p>Indicates how many times the message was forwarded.</p>
|
||||||
@@ -280,21 +254,11 @@
|
|||||||
<p>Group Invite Data</p>
|
<p>Group Invite Data</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="isEphemeral"><span class="symbol-name">isEphemeral</span><small class="property-type">
|
|
||||||
boolean</small></h3>
|
|
||||||
<p>Indicates if the message will disappear after it expires</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="isForwarded"><span class="symbol-name">isForwarded</span><small class="property-type">
|
<h3 id="isForwarded"><span class="symbol-name">isForwarded</span><small class="property-type">
|
||||||
boolean</small></h3>
|
boolean</small></h3>
|
||||||
<p>Indicates if the message was forwarded</p>
|
<p>Indicates if the message was forwarded</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="isGif"><span class="symbol-name">isGif</span><small class="property-type">
|
|
||||||
boolean</small></h3>
|
|
||||||
<p>Indicates whether the message is a Gif</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="isStarred"><span class="symbol-name">isStarred</span><small class="property-type">
|
<h3 id="isStarred"><span class="symbol-name">isStarred</span><small class="property-type">
|
||||||
boolean</small></h3>
|
boolean</small></h3>
|
||||||
<p>Indicates if the message was starred</p>
|
<p>Indicates if the message was starred</p>
|
||||||
@@ -330,11 +294,6 @@
|
|||||||
<p>Order ID for message type ORDER</p>
|
<p>Order ID for message type ORDER</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="rawData"><span class="symbol-name">rawData</span><small class="property-type">
|
|
||||||
Object</small></h3>
|
|
||||||
<p>Returns message in a raw format</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
|
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
|
||||||
number</small></h3>
|
number</small></h3>
|
||||||
<p>Unix timestamp for when the message was created</p>
|
<p>Unix timestamp for when the message was created</p>
|
||||||
@@ -400,7 +359,7 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>If true and the message is sent by the current user or the user is an admin, will delete it for everyone in the chat.</p>
|
<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>
|
<p>Value can be null.</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -420,7 +379,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="forward"><span class="symbol-name">forward</span><span class="signature"><span class="signature-params">(chat)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
<h3 id="forward"><span class="symbol-name">forward</span><span class="signature"><span class="signature-params">(chat)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||||
<p>Forwards this message to another chat (that you chatted before, otherwise it will fail)</p>
|
<p>Forwards this message to another chat</p>
|
||||||
<section>
|
<section>
|
||||||
<h4>Parameter</h4>
|
<h4>Parameter</h4>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
@@ -500,15 +459,6 @@
|
|||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="getPayment"><span class="symbol-name">getPayment</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Payment.html">Payment</a></span></span></h3>
|
|
||||||
<p>Gets the payment details associated with a given message</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Promise containing <a href="Payment.html">Payment</a></code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getQuotedMessage"><span class="symbol-name">getQuotedMessage</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
<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>
|
<p>Returns the quoted message, if any</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
@@ -518,54 +468,6 @@
|
|||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="react"><span class="symbol-name">react</span><span class="signature"><span class="signature-params">(reaction)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
|
||||||
<p>React to this message with an emoji</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>reaction</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>string</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Emoji to react with. Send an empty string to remove the reaction.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd>
|
|
||||||
<p><code>Promise</code> </p>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="reload"><span class="symbol-name">reload</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>Reloads this Message object's data in-place with the latest values from WhatsApp Web.
|
|
||||||
Note that the Message must still be in the web app cache for this to work, otherwise will return null.</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>
|
<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
|
<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
|
through the specified Chat. If not, it will send the message
|
||||||
@@ -650,7 +552,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: MessageMedia</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||||
<h1><small></small><span class="symbol-name">MessageMedia</span></h1>
|
<h1><small></small><span class="symbol-name">MessageMedia</span></h1>
|
||||||
<p class="source-link">Source: <a href="structures_MessageMedia.js.html#source-line-16">structures/<wbr>MessageMedia.<wbr>js:16</a></p>
|
<p class="source-link">Source: <a href="structures_MessageMedia.js.html#source-line-15">structures/<wbr>MessageMedia.<wbr>js:15</a></p>
|
||||||
<div class="symbol-classdesc">
|
<div class="symbol-classdesc">
|
||||||
<p>Media attached to a message</p>
|
<p>Media attached to a message</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -42,6 +42,10 @@
|
|||||||
<dt><a href="MessageMedia.html#data">data</a></dt>
|
<dt><a href="MessageMedia.html#data">data</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="summary-column">
|
||||||
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="MessageMedia.html#filename">filename</a></dt>
|
<dt><a href="MessageMedia.html#filename">filename</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -49,16 +53,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="summary-column">
|
<div class="summary-column">
|
||||||
<dl class="dl-summary-callout">
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="MessageMedia.html#filesize">filesize</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="MessageMedia.html#mimetype">mimetype</a></dt>
|
<dt><a href="MessageMedia.html#mimetype">mimetype</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="summary-column">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="summary-callout">
|
<div class="summary-callout">
|
||||||
@@ -84,7 +83,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<h2 id="MessageMedia">new <span class="symbol-name">MessageMedia</span><span class="signature"><span class="signature-params">(mimetype, data, filename, filesize)</span></span></h2>
|
<h2 id="MessageMedia">new <span class="symbol-name">MessageMedia</span><span class="signature"><span class="signature-params">(mimetype, data, filename)</span></span></h2>
|
||||||
<section>
|
<section>
|
||||||
<h3>Parameters</h3>
|
<h3>Parameters</h3>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
@@ -136,22 +135,7 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>Document file name. Value can be null</p>
|
<p>Document file name</p>
|
||||||
<p>Value can be null.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>filesize</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Document file size in bytes. Value can be null</p>
|
|
||||||
<p>Value can be null.</p>
|
<p>Value can be null.</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -171,12 +155,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<h3 id="filename"><span class="symbol-name">filename</span><small class="property-type">
|
<h3 id="filename"><span class="symbol-name">filename</span><small class="property-type">
|
||||||
nullable string</small></h3>
|
nullable string</small></h3>
|
||||||
<p>Document file name. Value can be null</p>
|
<p>Name of the file (for documents)</p>
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="filesize"><span class="symbol-name">filesize</span><small class="property-type">
|
|
||||||
nullable number</small></h3>
|
|
||||||
<p>Document file size in bytes. Value can be null</p>
|
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="mimetype"><span class="symbol-name">mimetype</span><small class="property-type">
|
<h3 id="mimetype"><span class="symbol-name">mimetype</span><small class="property-type">
|
||||||
@@ -279,7 +258,7 @@
|
|||||||
<p>unsafeMime</p>
|
<p>unsafeMime</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>boolean</p>
|
<p>number</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>Yes</p>
|
<p>Yes</p>
|
||||||
@@ -288,19 +267,6 @@
|
|||||||
<p>Defaults to <code>false</code>.</p>
|
<p>Defaults to <code>false</code>.</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>filename</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>string</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Yes</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p>client</p>
|
<p>client</p>
|
||||||
@@ -364,7 +330,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: NoAuth</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>19.<wbr>4</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">NoAuth</span></h1>
|
|
||||||
<p class="source-link">Source: <a href="authStrategies_NoAuth.js.html#source-line-9">authStrategies/<wbr>NoAuth.<wbr>js:9</a></p>
|
|
||||||
<div class="symbol-classdesc">
|
|
||||||
<p>No session restoring functionality
|
|
||||||
Will need to authenticate via QR code every time</p>
|
|
||||||
</div>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</header>
|
|
||||||
<section id="summary">
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2 id="NoAuth">new <span class="symbol-name">NoAuth</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.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Order</title>
|
<title>whatsapp-web.js 1.14.1 » Class: Order</title>
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -102,7 +102,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: PrivateChat</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -295,7 +295,7 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>Options for searching messages. Right now only limit and fromMe is supported.</p>
|
<p>Options for searching messages. Right now only limit is supported.</p>
|
||||||
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -318,21 +318,8 @@
|
|||||||
<p>Yes</p>
|
<p>Yes</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
<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>
|
||||||
</td>
|
<p>Defaults to <code>50</code>.</p>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>fromMe</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Yes</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.</p>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -375,7 +362,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<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>
|
<h3 id="mute"><span class="symbol-name">mute</span><span class="signature"><span class="signature-params">(unmuteDate)</span></span></h3>
|
||||||
<p>Mutes this chat forever, unless a date is specified</p>
|
<p>Mutes this chat until a specified date</p>
|
||||||
<section>
|
<section>
|
||||||
<h4>Parameter</h4>
|
<h4>Parameter</h4>
|
||||||
<table class="jsdoc-details-table">
|
<table class="jsdoc-details-table">
|
||||||
@@ -399,8 +386,7 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>Date at which the Chat will be unmuted, leave as is to mute forever</p>
|
<p>Date at which the Chat will be unmuted</p>
|
||||||
<p>Value can be null.</p>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -533,7 +519,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: PrivateContact</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -101,29 +101,20 @@
|
|||||||
<dt><a href="PrivateContact.html#getAbout">getAbout()</a></dt>
|
<dt><a href="PrivateContact.html#getAbout">getAbout()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="summary-column">
|
||||||
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="PrivateContact.html#getChat">getChat()</a></dt>
|
<dt><a href="PrivateContact.html#getChat">getChat()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="PrivateContact.html#getCommonGroups">getCommonGroups()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="PrivateContact.html#getCountryCode">getCountryCode()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="PrivateContact.html#getFormattedNumber">getFormattedNumber()</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="PrivateContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
<dt><a href="PrivateContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="summary-column">
|
||||||
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="PrivateContact.html#unblock">unblock()</a></dt>
|
<dt><a href="PrivateContact.html#unblock">unblock()</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -265,33 +256,6 @@
|
|||||||
<dd></dd>
|
<dd></dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||||
<h3 id="getCommonGroups"><span class="symbol-name">getCommonGroups</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of WAWebJS.ChatId</span></span></h3>
|
|
||||||
<p>Gets the Contact's common groups with you. Returns empty array if you don't have any common group.</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Inherited from</dt>
|
|
||||||
<dd><a href="Contact.html#getCommonGroups">Contact#getCommonGroups</a></dd>
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd></dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getCountryCode"><span class="symbol-name">getCountryCode</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
|
||||||
<p>Returns the contact's countrycode, (1541859685@c.us) => (1)</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Inherited from</dt>
|
|
||||||
<dd><a href="Contact.html#getCountryCode">Contact#getCountryCode</a></dd>
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd></dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getFormattedNumber"><span class="symbol-name">getFormattedNumber</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
|
||||||
<p>Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901)</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
<dt>Inherited from</dt>
|
|
||||||
<dd><a href="Contact.html#getFormattedNumber">Contact#getFormattedNumber</a></dd>
|
|
||||||
<dt>Returns</dt>
|
|
||||||
<dd></dd>
|
|
||||||
</dl>
|
|
||||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
|
||||||
<h3 id="getProfilePicUrl"><span class="symbol-name">getProfilePicUrl</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
<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>
|
<p>Returns the contact's profile picture URL, if privacy settings allow it</p>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
@@ -319,7 +283,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Product</title>
|
<title>whatsapp-web.js 1.14.1 » Class: Product</title>
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -1,159 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Reaction</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>19.<wbr>4</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">Reaction</span></h1>
|
|
||||||
<p class="source-link">Source: <a href="structures_Reaction.js.html#source-line-9">structures/<wbr>Reaction.<wbr>js:9</a></p>
|
|
||||||
<div class="symbol-classdesc">
|
|
||||||
<p>Represents a Reaction 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="Reaction.html#ack">ack</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Reaction.html#id">id</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Reaction.html#msgId">msgId</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="Reaction.html#orphan">orphan</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Reaction.html#orphanReason">orphanReason</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Reaction.html#reaction">reaction</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
<div class="summary-column">
|
|
||||||
<dl class="dl-summary-callout">
|
|
||||||
<dt><a href="Reaction.html#read">read</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Reaction.html#senderId">senderId</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="Reaction.html#timestamp">timestamp</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2 id="Reaction">new <span class="symbol-name">Reaction</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">
|
|
||||||
nullable number</small></h3>
|
|
||||||
<p>ACK</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
|
||||||
object</small></h3>
|
|
||||||
<p>Reaction ID</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="msgId"><span class="symbol-name">msgId</span><small class="property-type">
|
|
||||||
object</small></h3>
|
|
||||||
<p>Message ID</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="orphan"><span class="symbol-name">orphan</span><small class="property-type">
|
|
||||||
number</small></h3>
|
|
||||||
<p>Orphan</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="orphanReason"><span class="symbol-name">orphanReason</span><small class="property-type">
|
|
||||||
nullable string</small></h3>
|
|
||||||
<p>Orphan reason</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="reaction"><span class="symbol-name">reaction</span><small class="property-type">
|
|
||||||
string</small></h3>
|
|
||||||
<p>Reaction</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="read"><span class="symbol-name">read</span><small class="property-type">
|
|
||||||
boolean</small></h3>
|
|
||||||
<p>Read</p>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="senderId"><span class="symbol-name">senderId</span><small class="property-type">
|
|
||||||
string</small></h3>
|
|
||||||
<p>Sender ID</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 reaction was created</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.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: RemoteAuth</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>19.<wbr>4</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">RemoteAuth</span></h1>
|
|
||||||
<p class="source-link">Source: <a href="authStrategies_RemoteAuth.js.html#source-line-26">authStrategies/<wbr>RemoteAuth.<wbr>js:26</a></p>
|
|
||||||
<div class="symbol-classdesc">
|
|
||||||
<p>Remote-based authentication</p>
|
|
||||||
</div>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
</header>
|
|
||||||
<section id="summary">
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2 id="RemoteAuth">new <span class="symbol-name">RemoteAuth</span><span class="signature"><span class="signature-params">(options)</span></span></h2>
|
|
||||||
<section>
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>options</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>options</p>
|
|
||||||
<p>Values in <code>options</code> have the following properties:</p>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>store</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Remote database store instance</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>clientId</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>dataPath</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Change the default path for saving session files, default is: "./.wwebjs_auth/"</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>backupSyncIntervalMs</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Sets the time interval for periodic session backups. Accepts values starting from 60000ms {1 minute}</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<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.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Class: Util</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
|
||||||
<h1><small></small><span class="symbol-name">Util</span></h1>
|
<h1><small></small><span class="symbol-name">Util</span></h1>
|
||||||
<p class="source-link">Source: <a href="util_Util.js.html#source-line-14">util/<wbr>Util.<wbr>js:14</a></p>
|
<p class="source-link">Source: <a href="util_Util.js.html#source-line-16">util/<wbr>Util.<wbr>js:16</a></p>
|
||||||
<div class="symbol-classdesc">
|
<div class="symbol-classdesc">
|
||||||
<p>Utility methods</p>
|
<p>Utility methods</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -104,8 +104,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code>
|
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> <p>media in webp format</p>
|
||||||
<p>media in webp format</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -156,8 +155,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code>
|
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> <p>media in webp format</p>
|
||||||
<p>media in webp format</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -195,8 +193,7 @@
|
|||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
<dt>Returns</dt>
|
<dt>Returns</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code>
|
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> <p>media in webp format</p>
|
||||||
<p>media in webp format</p>
|
|
||||||
</p>
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -243,7 +240,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -1,80 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: authStrategies/BaseAuthStrategy.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>19.<wbr>4</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: authStrategies/BaseAuthStrategy.js</h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
|
||||||
<pre class="prettyprint linenums"><code>'use strict';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class which all authentication strategies extend
|
|
||||||
*/
|
|
||||||
class BaseAuthStrategy {
|
|
||||||
constructor() {}
|
|
||||||
setup(client) {
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
async beforeBrowserInitialized() {}
|
|
||||||
async afterBrowserInitialized() {}
|
|
||||||
async onAuthenticationNeeded() {
|
|
||||||
return {
|
|
||||||
failed: false,
|
|
||||||
restart: false,
|
|
||||||
failureEventPayload: undefined
|
|
||||||
};
|
|
||||||
}
|
|
||||||
async getAuthEventPayload() {}
|
|
||||||
async afterAuthReady() {}
|
|
||||||
async disconnect() {}
|
|
||||||
async destroy() {}
|
|
||||||
async logout() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = BaseAuthStrategy;</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.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: authStrategies/LegacySessionAuth.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>19.<wbr>4</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: authStrategies/LegacySessionAuth.js</h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
|
||||||
<pre class="prettyprint linenums"><code>'use strict';
|
|
||||||
|
|
||||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Legacy session auth strategy
|
|
||||||
* Not compatible with multi-device accounts.
|
|
||||||
* @param {object} options - options
|
|
||||||
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
|
||||||
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
|
|
||||||
* @param {string} options.session.WABrowserId
|
|
||||||
* @param {string} options.session.WASecretBundle
|
|
||||||
* @param {string} options.session.WAToken1
|
|
||||||
* @param {string} options.session.WAToken2
|
|
||||||
*/
|
|
||||||
class LegacySessionAuth extends BaseAuthStrategy {
|
|
||||||
constructor({ session, restartOnAuthFail }={}) {
|
|
||||||
super();
|
|
||||||
this.session = session;
|
|
||||||
this.restartOnAuthFail = restartOnAuthFail;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterBrowserInitialized() {
|
|
||||||
if(this.session) {
|
|
||||||
await this.client.pupPage.evaluateOnNewDocument(session => {
|
|
||||||
if (document.referrer === 'https://whatsapp.com/') {
|
|
||||||
localStorage.clear();
|
|
||||||
localStorage.setItem('WABrowserId', session.WABrowserId);
|
|
||||||
localStorage.setItem('WASecretBundle', session.WASecretBundle);
|
|
||||||
localStorage.setItem('WAToken1', session.WAToken1);
|
|
||||||
localStorage.setItem('WAToken2', session.WAToken2);
|
|
||||||
}
|
|
||||||
|
|
||||||
localStorage.setItem('remember-me', 'true');
|
|
||||||
}, this.session);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async onAuthenticationNeeded() {
|
|
||||||
if(this.session) {
|
|
||||||
this.session = null;
|
|
||||||
return {
|
|
||||||
failed: true,
|
|
||||||
restart: this.restartOnAuthFail,
|
|
||||||
failureEventPayload: 'Unable to log in. Are the session details valid?'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return { failed: false };
|
|
||||||
}
|
|
||||||
|
|
||||||
async getAuthEventPayload() {
|
|
||||||
const isMD = await this.client.pupPage.evaluate(() => {
|
|
||||||
return window.Store.MDBackend;
|
|
||||||
});
|
|
||||||
|
|
||||||
if(isMD) throw new Error('Authenticating via JSON session is not supported for MultiDevice-enabled WhatsApp accounts.');
|
|
||||||
|
|
||||||
const localStorage = JSON.parse(await this.client.pupPage.evaluate(() => {
|
|
||||||
return JSON.stringify(window.localStorage);
|
|
||||||
}));
|
|
||||||
|
|
||||||
return {
|
|
||||||
WABrowserId: localStorage.WABrowserId,
|
|
||||||
WASecretBundle: localStorage.WASecretBundle,
|
|
||||||
WAToken1: localStorage.WAToken1,
|
|
||||||
WAToken2: localStorage.WAToken2
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = LegacySessionAuth;
|
|
||||||
</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.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: authStrategies/LocalAuth.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>19.<wbr>4</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: authStrategies/LocalAuth.js</h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
|
||||||
<pre class="prettyprint linenums"><code>'use strict';
|
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
|
||||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Local directory-based authentication
|
|
||||||
* @param {object} options - options
|
|
||||||
* @param {string} options.clientId - Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance
|
|
||||||
* @param {string} options.dataPath - Change the default path for saving session files, default is: "./.wwebjs_auth/"
|
|
||||||
*/
|
|
||||||
class LocalAuth extends BaseAuthStrategy {
|
|
||||||
constructor({ clientId, dataPath }={}) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
const idRegex = /^[-_\w]+$/i;
|
|
||||||
if(clientId &amp;&amp; !idRegex.test(clientId)) {
|
|
||||||
throw new Error('Invalid clientId. Only alphanumeric characters, underscores and hyphens are allowed.');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dataPath = path.resolve(dataPath || './.wwebjs_auth/');
|
|
||||||
this.clientId = clientId;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeBrowserInitialized() {
|
|
||||||
const puppeteerOpts = this.client.options.puppeteer;
|
|
||||||
const sessionDirName = this.clientId ? `session-${this.clientId}` : 'session';
|
|
||||||
const dirPath = path.join(this.dataPath, sessionDirName);
|
|
||||||
|
|
||||||
if(puppeteerOpts.userDataDir &amp;&amp; puppeteerOpts.userDataDir !== dirPath) {
|
|
||||||
throw new Error('LocalAuth is not compatible with a user-supplied userDataDir.');
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.mkdirSync(dirPath, { recursive: true });
|
|
||||||
|
|
||||||
this.client.options.puppeteer = {
|
|
||||||
...puppeteerOpts,
|
|
||||||
userDataDir: dirPath
|
|
||||||
};
|
|
||||||
|
|
||||||
this.userDataDir = dirPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
async logout() {
|
|
||||||
if (this.userDataDir) {
|
|
||||||
return (fs.rmSync ? fs.rmSync : fs.rmdirSync).call(this, this.userDataDir, { recursive: true });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = LocalAuth;</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.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: authStrategies/NoAuth.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>19.<wbr>4</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: authStrategies/NoAuth.js</h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
|
||||||
<pre class="prettyprint linenums"><code>'use strict';
|
|
||||||
|
|
||||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No session restoring functionality
|
|
||||||
* Will need to authenticate via QR code every time
|
|
||||||
*/
|
|
||||||
class NoAuth extends BaseAuthStrategy { }
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = NoAuth;</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.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -1,258 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: authStrategies/RemoteAuth.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>19.<wbr>4</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: authStrategies/RemoteAuth.js</h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
|
||||||
<pre class="prettyprint linenums"><code>'use strict';
|
|
||||||
|
|
||||||
/* Require Optional Dependencies */
|
|
||||||
try {
|
|
||||||
var fs = require('fs-extra');
|
|
||||||
var unzipper = require('unzipper');
|
|
||||||
var archiver = require('archiver');
|
|
||||||
} catch {
|
|
||||||
fs = undefined;
|
|
||||||
unzipper = undefined;
|
|
||||||
archiver = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const { Events } = require('./../util/Constants');
|
|
||||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remote-based authentication
|
|
||||||
* @param {object} options - options
|
|
||||||
* @param {object} options.store - Remote database store instance
|
|
||||||
* @param {string} options.clientId - Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance
|
|
||||||
* @param {string} options.dataPath - Change the default path for saving session files, default is: "./.wwebjs_auth/"
|
|
||||||
* @param {number} options.backupSyncIntervalMs - Sets the time interval for periodic session backups. Accepts values starting from 60000ms {1 minute}
|
|
||||||
*/
|
|
||||||
class RemoteAuth extends BaseAuthStrategy {
|
|
||||||
constructor({ clientId, dataPath, store, backupSyncIntervalMs } = {}) {
|
|
||||||
if (!fs &amp;&amp; !unzipper &amp;&amp; !archiver) throw new Error('Optional Dependencies [fs-extra, unzipper, archiver] are required to use RemoteAuth. Make sure to run npm install correctly and remove the --no-optional flag');
|
|
||||||
super();
|
|
||||||
|
|
||||||
const idRegex = /^[-_\w]+$/i;
|
|
||||||
if (clientId &amp;&amp; !idRegex.test(clientId)) {
|
|
||||||
throw new Error('Invalid clientId. Only alphanumeric characters, underscores and hyphens are allowed.');
|
|
||||||
}
|
|
||||||
if (!backupSyncIntervalMs || backupSyncIntervalMs &lt; 60000) {
|
|
||||||
throw new Error('Invalid backupSyncIntervalMs. Accepts values starting from 60000ms {1 minute}.');
|
|
||||||
}
|
|
||||||
if(!store) throw new Error('Remote database store is required.');
|
|
||||||
|
|
||||||
this.store = store;
|
|
||||||
this.clientId = clientId;
|
|
||||||
this.backupSyncIntervalMs = backupSyncIntervalMs;
|
|
||||||
this.dataPath = path.resolve(dataPath || './.wwebjs_auth/');
|
|
||||||
this.tempDir = `${this.dataPath}/wwebjs_temp_session`;
|
|
||||||
this.requiredDirs = ['Default', 'IndexedDB', 'Local Storage']; /* => Required Files &amp; Dirs in WWebJS to restore session */
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeBrowserInitialized() {
|
|
||||||
const puppeteerOpts = this.client.options.puppeteer;
|
|
||||||
const sessionDirName = this.clientId ? `RemoteAuth-${this.clientId}` : 'RemoteAuth';
|
|
||||||
const dirPath = path.join(this.dataPath, sessionDirName);
|
|
||||||
|
|
||||||
if (puppeteerOpts.userDataDir &amp;&amp; puppeteerOpts.userDataDir !== dirPath) {
|
|
||||||
throw new Error('RemoteAuth is not compatible with a user-supplied userDataDir.');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.userDataDir = dirPath;
|
|
||||||
this.sessionName = sessionDirName;
|
|
||||||
|
|
||||||
await this.extractRemoteSession();
|
|
||||||
|
|
||||||
this.client.options.puppeteer = {
|
|
||||||
...puppeteerOpts,
|
|
||||||
userDataDir: dirPath
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async logout() {
|
|
||||||
await this.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
async destroy() {
|
|
||||||
clearInterval(this.backupSync);
|
|
||||||
}
|
|
||||||
|
|
||||||
async disconnect() {
|
|
||||||
await this.deleteRemoteSession();
|
|
||||||
|
|
||||||
let pathExists = await this.isValidPath(this.userDataDir);
|
|
||||||
if (pathExists) {
|
|
||||||
await fs.promises.rm(this.userDataDir, {
|
|
||||||
recursive: true,
|
|
||||||
force: true
|
|
||||||
}).catch(() => {});
|
|
||||||
}
|
|
||||||
clearInterval(this.backupSync);
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterAuthReady() {
|
|
||||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
|
||||||
if(!sessionExists) {
|
|
||||||
await this.delay(60000); /* Initial delay sync required for session to be stable enough to recover */
|
|
||||||
await this.storeRemoteSession({emit: true});
|
|
||||||
}
|
|
||||||
var self = this;
|
|
||||||
this.backupSync = setInterval(async function () {
|
|
||||||
await self.storeRemoteSession();
|
|
||||||
}, this.backupSyncIntervalMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
async storeRemoteSession(options) {
|
|
||||||
/* Compress &amp; Store Session */
|
|
||||||
const pathExists = await this.isValidPath(this.userDataDir);
|
|
||||||
if (pathExists) {
|
|
||||||
await this.compressSession();
|
|
||||||
await this.store.save({session: this.sessionName});
|
|
||||||
await fs.promises.unlink(`${this.sessionName}.zip`);
|
|
||||||
await fs.promises.rm(`${this.tempDir}`, {
|
|
||||||
recursive: true,
|
|
||||||
force: true
|
|
||||||
}).catch(() => {});
|
|
||||||
if(options &amp;&amp; options.emit) this.client.emit(Events.REMOTE_SESSION_SAVED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async extractRemoteSession() {
|
|
||||||
const pathExists = await this.isValidPath(this.userDataDir);
|
|
||||||
const compressedSessionPath = `${this.sessionName}.zip`;
|
|
||||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
|
||||||
if (pathExists) {
|
|
||||||
await fs.promises.rm(this.userDataDir, {
|
|
||||||
recursive: true,
|
|
||||||
force: true
|
|
||||||
}).catch(() => {});
|
|
||||||
}
|
|
||||||
if (sessionExists) {
|
|
||||||
await this.store.extract({session: this.sessionName, path: compressedSessionPath});
|
|
||||||
await this.unCompressSession(compressedSessionPath);
|
|
||||||
} else {
|
|
||||||
fs.mkdirSync(this.userDataDir, { recursive: true });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteRemoteSession() {
|
|
||||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
|
||||||
if (sessionExists) await this.store.delete({session: this.sessionName});
|
|
||||||
}
|
|
||||||
|
|
||||||
async compressSession() {
|
|
||||||
const archive = archiver('zip');
|
|
||||||
const stream = fs.createWriteStream(`${this.sessionName}.zip`);
|
|
||||||
|
|
||||||
await fs.copy(this.userDataDir, this.tempDir).catch(() => {});
|
|
||||||
await this.deleteMetadata();
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
archive
|
|
||||||
.directory(this.tempDir, false)
|
|
||||||
.on('error', err => reject(err))
|
|
||||||
.pipe(stream);
|
|
||||||
|
|
||||||
stream.on('close', () => resolve());
|
|
||||||
archive.finalize();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async unCompressSession(compressedSessionPath) {
|
|
||||||
var stream = fs.createReadStream(compressedSessionPath);
|
|
||||||
await new Promise((resolve, reject) => {
|
|
||||||
stream.pipe(unzipper.Extract({
|
|
||||||
path: this.userDataDir
|
|
||||||
}))
|
|
||||||
.on('error', err => reject(err))
|
|
||||||
.on('finish', () => resolve());
|
|
||||||
});
|
|
||||||
await fs.promises.unlink(compressedSessionPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteMetadata() {
|
|
||||||
const sessionDirs = [this.tempDir, path.join(this.tempDir, 'Default')];
|
|
||||||
for (const dir of sessionDirs) {
|
|
||||||
const sessionFiles = await fs.promises.readdir(dir);
|
|
||||||
for (const element of sessionFiles) {
|
|
||||||
if (!this.requiredDirs.includes(element)) {
|
|
||||||
const dirElement = path.join(dir, element);
|
|
||||||
const stats = await fs.promises.lstat(dirElement);
|
|
||||||
|
|
||||||
if (stats.isDirectory()) {
|
|
||||||
await fs.promises.rm(dirElement, {
|
|
||||||
recursive: true,
|
|
||||||
force: true
|
|
||||||
}).catch(() => {});
|
|
||||||
} else {
|
|
||||||
await fs.promises.unlink(dirElement).catch(() => {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async isValidPath(path) {
|
|
||||||
try {
|
|
||||||
await fs.promises.access(path);
|
|
||||||
return true;
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async delay(ms) {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = RemoteAuth;
|
|
||||||
</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.11 on February 11, 2023.
|
|
||||||
</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>
|
|
||||||
423
docs/global.html
423
docs/global.html
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Globals</title>
|
<title>whatsapp-web.js 1.14.1 » Globals</title>
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -68,22 +68,16 @@
|
|||||||
<div class="summary-content">
|
<div class="summary-content">
|
||||||
<div class="summary-column">
|
<div class="summary-column">
|
||||||
<dl class="dl-summary-callout">
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="global.html#ButtonSpec">ButtonSpec</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="global.html#ContactId">ContactId</a></dt>
|
<dt><a href="global.html#ContactId">ContactId</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></dt>
|
<dt><a href="global.html#GroupParticipant">GroupParticipant</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="summary-column">
|
<div class="summary-column">
|
||||||
<dl class="dl-summary-callout">
|
<dl class="dl-summary-callout">
|
||||||
<dt><a href="global.html#GroupParticipant">GroupParticipant</a></dt>
|
|
||||||
<dd>
|
|
||||||
</dd>
|
|
||||||
<dt><a href="global.html#MessageInfo">MessageInfo</a></dt>
|
<dt><a href="global.html#MessageInfo">MessageInfo</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -285,19 +279,6 @@
|
|||||||
<td>
|
<td>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>MESSAGE_REACTION</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p>MEDIA_UPLOADED</p>
|
<p>MEDIA_UPLOADED</p>
|
||||||
@@ -363,19 +344,6 @@
|
|||||||
<td>
|
<td>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>LOADING_SCREEN</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p>DISCONNECTED</p>
|
<p>DISCONNECTED</p>
|
||||||
@@ -428,19 +396,6 @@
|
|||||||
<td>
|
<td>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>REMOTE_SESSION_SAVED</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
@@ -894,266 +849,6 @@
|
|||||||
<td>
|
<td>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>LIST</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>LIST_RESPONSE</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>BUTTONS_RESPONSE</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>PAYMENT</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>BROADCAST_NOTIFICATION</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>CALL_LOG</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>CIPHERTEXT</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>DEBUG</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>E2E_NOTIFICATION</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>GP2</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>GROUP_NOTIFICATION</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>HSM</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>INTERACTIVE</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>NATIVE_FLOW</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>NOTIFICATION</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>NOTIFICATION_TEMPLATE</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>OVERSIZED</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>PROTOCOL</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>REACTION</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>TEMPLATE_BUTTON_REPLY</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
@@ -1399,54 +1094,6 @@
|
|||||||
</section>
|
</section>
|
||||||
<h2>Abstract types</h2>
|
<h2>Abstract types</h2>
|
||||||
<section>
|
<section>
|
||||||
<h3 id="ButtonSpec"><span class="symbol-name">ButtonSpec</span><small class="property-type">
|
|
||||||
Object</small></h3>
|
|
||||||
<p>Button spec used in Buttons constructor</p>
|
|
||||||
<section>
|
|
||||||
<h4>Properties</h4>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>id</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>string</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Yes</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Custom ID to set on the button. A random one will be generated if one is not passed.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>body</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>string</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>The text to show on the button.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="ContactId"><span class="symbol-name">ContactId</span><small class="property-type">
|
<h3 id="ContactId"><span class="symbol-name">ContactId</span><small class="property-type">
|
||||||
Object</small></h3>
|
Object</small></h3>
|
||||||
<p>ID that represents a contact</p>
|
<p>ID that represents a contact</p>
|
||||||
@@ -1506,64 +1153,6 @@
|
|||||||
</section>
|
</section>
|
||||||
<dl class="dl-compact">
|
<dl class="dl-compact">
|
||||||
</dl>
|
</dl>
|
||||||
<h3 id="FormattedButtonSpec"><span class="symbol-name">FormattedButtonSpec</span><small class="property-type">
|
|
||||||
Object</small></h3>
|
|
||||||
<section>
|
|
||||||
<h4>Properties</h4>
|
|
||||||
<table class="jsdoc-details-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Optional</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>buttonId</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>string</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>type</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>number</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>buttonText</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>Object</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p> </p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
<dl class="dl-compact">
|
|
||||||
</dl>
|
|
||||||
<h3 id="GroupParticipant"><span class="symbol-name">GroupParticipant</span><small class="property-type">
|
<h3 id="GroupParticipant"><span class="symbol-name">GroupParticipant</span><small class="property-type">
|
||||||
Object</small></h3>
|
Object</small></h3>
|
||||||
<p>Group participant information</p>
|
<p>Group participant information</p>
|
||||||
@@ -1753,7 +1342,7 @@
|
|||||||
<p>Yes</p>
|
<p>Yes</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>Show links preview. Has no effect on multi-device accounts.</p>
|
<p>Show links preview</p>
|
||||||
<p>Defaults to <code>true</code>.</p>
|
<p>Defaults to <code>true</code>.</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -2019,7 +1608,7 @@
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
780
docs/index.html
780
docs/index.html
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
|||||||
treeNode.tree({
|
treeNode.tree({
|
||||||
autoEscape: false,
|
autoEscape: false,
|
||||||
closedIcon: '⇢',
|
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=\"BaseAuthStrategy.html\">BaseAuthStrategy</a>","id":"BaseAuthStrategy","children":[]},{"label":"<a href=\"BusinessContact.html\">BusinessContact</a>","id":"BusinessContact","children":[]},{"label":"<a href=\"Buttons.html\">Buttons</a>","id":"Buttons","children":[]},{"label":"<a href=\"Call.html\">Call</a>","id":"Call","children":[]},{"label":"<a href=\"Chat.html\">Chat</a>","id":"Chat","children":[]},{"label":"<a href=\"Client.html\">Client</a>","id":"Client","children":[]},{"label":"<a href=\"ClientInfo.html\">ClientInfo</a>","id":"ClientInfo","children":[]},{"label":"<a href=\"Contact.html\">Contact</a>","id":"Contact","children":[]},{"label":"<a href=\"GroupChat.html\">GroupChat</a>","id":"GroupChat","children":[]},{"label":"<a href=\"GroupNotification.html\">GroupNotification</a>","id":"GroupNotification","children":[]},{"label":"<a href=\"InterfaceController.html\">InterfaceController</a>","id":"InterfaceController","children":[]},{"label":"<a href=\"Label.html\">Label</a>","id":"Label","children":[]},{"label":"<a href=\"LegacySessionAuth.html\">LegacySessionAuth</a>","id":"LegacySessionAuth","children":[]},{"label":"<a href=\"List.html\">List</a>","id":"List","children":[]},{"label":"<a href=\"LocalAuth.html\">LocalAuth</a>","id":"LocalAuth","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=\"NoAuth.html\">NoAuth</a>","id":"NoAuth","children":[]},{"label":"<a href=\"Order.html\">Order</a>","id":"Order","children":[]},{"label":"<a href=\"PrivateChat.html\">PrivateChat</a>","id":"PrivateChat","children":[]},{"label":"<a href=\"PrivateContact.html\">PrivateContact</a>","id":"PrivateContact","children":[]},{"label":"<a href=\"Product.html\">Product</a>","id":"Product","children":[]},{"label":"<a href=\"Reaction.html\">Reaction</a>","id":"Reaction","children":[]},{"label":"<a href=\"RemoteAuth.html\">RemoteAuth</a>","id":"RemoteAuth","children":[]},{"label":"<a href=\"Util.html\">Util</a>","id":"Util","children":[]}],
|
data: [{"label":"<a href=\"global.html\">Globals</a>","id":"global","children":[]},{"label":"<a href=\"Base.html\">Base</a>","id":"Base","children":[]},{"label":"<a href=\"BusinessContact.html\">BusinessContact</a>","id":"BusinessContact","children":[]},{"label":"<a href=\"Call.html\">Call</a>","id":"Call","children":[]},{"label":"<a href=\"Chat.html\">Chat</a>","id":"Chat","children":[]},{"label":"<a href=\"Client.html\">Client</a>","id":"Client","children":[]},{"label":"<a href=\"ClientInfo.html\">ClientInfo</a>","id":"ClientInfo","children":[]},{"label":"<a href=\"Contact.html\">Contact</a>","id":"Contact","children":[]},{"label":"<a href=\"GroupChat.html\">GroupChat</a>","id":"GroupChat","children":[]},{"label":"<a href=\"GroupNotification.html\">GroupNotification</a>","id":"GroupNotification","children":[]},{"label":"<a href=\"InterfaceController.html\">InterfaceController</a>","id":"InterfaceController","children":[]},{"label":"<a href=\"Label.html\">Label</a>","id":"Label","children":[]},{"label":"<a href=\"Location.html\">Location</a>","id":"Location","children":[]},{"label":"<a href=\"Message.html\">Message</a>","id":"Message","children":[]},{"label":"<a href=\"MessageMedia.html\">MessageMedia</a>","id":"MessageMedia","children":[]},{"label":"<a href=\"Order.html\">Order</a>","id":"Order","children":[]},{"label":"<a href=\"PrivateChat.html\">PrivateChat</a>","id":"PrivateChat","children":[]},{"label":"<a href=\"PrivateContact.html\">PrivateContact</a>","id":"PrivateContact","children":[]},{"label":"<a href=\"Product.html\">Product</a>","id":"Product","children":[]},{"label":"<a href=\"Util.html\">Util</a>","id":"Util","children":[]}],
|
||||||
openedIcon: ' ⇣',
|
openedIcon: ' ⇣',
|
||||||
saveState: false,
|
saveState: false,
|
||||||
useContextMenu: false
|
useContextMenu: false
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Base.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -60,7 +60,7 @@ module.exports = Base;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/BusinessContact.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -59,7 +59,7 @@ module.exports = BusinessContact;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -1,135 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Buttons.js</title>
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
|
||||||
<link href="css/baseline.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body onload="prettyPrint()">
|
|
||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
|
||||||
<div id="jsdoc-navbar-container">
|
|
||||||
<div id="jsdoc-navbar-content">
|
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<div id="jsdoc-body-container">
|
|
||||||
<div id="jsdoc-content">
|
|
||||||
<div id="jsdoc-content-container">
|
|
||||||
<div id="jsdoc-banner" role="banner">
|
|
||||||
</div>
|
|
||||||
<div id="jsdoc-main" role="main">
|
|
||||||
<header class="page-header">
|
|
||||||
<h1>Source: structures/Buttons.js</h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
|
||||||
<pre class="prettyprint linenums"><code>'use strict';
|
|
||||||
|
|
||||||
const MessageMedia = require('./MessageMedia');
|
|
||||||
const Util = require('../util/Util');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Button spec used in Buttons constructor
|
|
||||||
* @typedef {Object} ButtonSpec
|
|
||||||
* @property {string=} id - Custom ID to set on the button. A random one will be generated if one is not passed.
|
|
||||||
* @property {string} body - The text to show on the button.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} FormattedButtonSpec
|
|
||||||
* @property {string} buttonId
|
|
||||||
* @property {number} type
|
|
||||||
* @property {Object} buttonText
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Message type buttons
|
|
||||||
*/
|
|
||||||
class Buttons {
|
|
||||||
/**
|
|
||||||
* @param {string|MessageMedia} body
|
|
||||||
* @param {ButtonSpec[]} buttons - See {@link ButtonSpec}
|
|
||||||
* @param {string?} title
|
|
||||||
* @param {string?} footer
|
|
||||||
*/
|
|
||||||
constructor(body, buttons, title, footer) {
|
|
||||||
/**
|
|
||||||
* Message body
|
|
||||||
* @type {string|MessageMedia}
|
|
||||||
*/
|
|
||||||
this.body = body;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* title of message
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.title = title;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* footer of message
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.footer = footer;
|
|
||||||
|
|
||||||
if (body instanceof MessageMedia) {
|
|
||||||
this.type = 'media';
|
|
||||||
this.title = '';
|
|
||||||
}else{
|
|
||||||
this.type = 'chat';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* buttons of message
|
|
||||||
* @type {FormattedButtonSpec[]}
|
|
||||||
*/
|
|
||||||
this.buttons = this._format(buttons);
|
|
||||||
if(!this.buttons.length){ throw '[BT01] No buttons';}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates button array from simple array
|
|
||||||
* @param {ButtonSpec[]} buttons
|
|
||||||
* @returns {FormattedButtonSpec[]}
|
|
||||||
* @example
|
|
||||||
* Input: [{id:'customId',body:'button1'},{body:'button2'},{body:'button3'},{body:'button4'}]
|
|
||||||
* Returns: [{ buttonId:'customId',buttonText:{'displayText':'button1'},type: 1 },{buttonId:'n3XKsL',buttonText:{'displayText':'button2'},type:1},{buttonId:'NDJk0a',buttonText:{'displayText':'button3'},type:1}]
|
|
||||||
*/
|
|
||||||
_format(buttons){
|
|
||||||
buttons = buttons.slice(0,3); // phone users can only see 3 buttons, so lets limit this
|
|
||||||
return buttons.map((btn) => {
|
|
||||||
return {'buttonId':btn.id ? String(btn.id) : Util.generateHash(6),'buttonText':{'displayText':btn.body},'type':1};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Buttons;</code></pre>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
|
||||||
<div id="jsdoc-footer-container">
|
|
||||||
<p>
|
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Call.js</title>
|
<title>whatsapp-web.js 1.14.1 » Source: structures/Call.js</title>
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -93,15 +93,7 @@ class Call extends Base {
|
|||||||
|
|
||||||
return super._patch(data);
|
return super._patch(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reject the call
|
|
||||||
*/
|
|
||||||
async reject() {
|
|
||||||
return this.client.pupPage.evaluate((peerJid, id) => {
|
|
||||||
return window.WWebJS.rejectCall(peerJid, id);
|
|
||||||
}, this.from, this.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Call;</code></pre>
|
module.exports = Call;</code></pre>
|
||||||
@@ -114,7 +106,7 @@ module.exports = Call;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Chat.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -96,7 +96,7 @@ class Chat extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the chat is muted or not
|
* Indicates if the chat is muted or not
|
||||||
* @type {boolean}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.isMuted = data.isMuted;
|
this.isMuted = data.isMuted;
|
||||||
|
|
||||||
@@ -178,8 +178,8 @@ class Chat extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutes this chat forever, unless a date is specified
|
* Mutes this chat until a specified date
|
||||||
* @param {?Date} unmuteDate Date at which the Chat will be unmuted, leave as is to mute forever
|
* @param {Date} unmuteDate Date at which the Chat will be unmuted
|
||||||
*/
|
*/
|
||||||
async mute(unmuteDate) {
|
async mute(unmuteDate) {
|
||||||
return this.client.muteChat(this.id._serialized, unmuteDate);
|
return this.client.muteChat(this.id._serialized, unmuteDate);
|
||||||
@@ -201,42 +201,31 @@ class Chat extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads chat messages, sorted from earliest to latest.
|
* Loads chat messages, sorted from earliest to latest.
|
||||||
* @param {Object} searchOptions Options for searching messages. Right now only limit and fromMe is supported.
|
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
||||||
* @param {Number} [searchOptions.limit] The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.
|
* @param {Number} [searchOptions.limit=50] The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.
|
||||||
* @param {Boolean} [searchOptions.fromMe] Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.
|
|
||||||
* @returns {Promise&lt;Array&lt;Message>>}
|
* @returns {Promise&lt;Array&lt;Message>>}
|
||||||
*/
|
*/
|
||||||
async fetchMessages(searchOptions) {
|
async fetchMessages(searchOptions) {
|
||||||
let messages = await this.client.pupPage.evaluate(async (chatId, searchOptions) => {
|
if (!searchOptions || !searchOptions.limit) {
|
||||||
const msgFilter = (m) => {
|
searchOptions = { limit: 50 };
|
||||||
if (m.isNotification) {
|
}
|
||||||
return false; // dont include notification messages
|
let messages = await this.client.pupPage.evaluate(async (chatId, limit) => {
|
||||||
}
|
const msgFilter = m => !m.isNotification; // dont include notification messages
|
||||||
if (searchOptions &amp;&amp; searchOptions.fromMe &amp;&amp; m.id.fromMe !== searchOptions.fromMe) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const chat = window.Store.Chat.get(chatId);
|
const chat = window.Store.Chat.get(chatId);
|
||||||
let msgs = chat.msgs.getModelsArray().filter(msgFilter);
|
let msgs = chat.msgs.models.filter(msgFilter);
|
||||||
|
|
||||||
if (searchOptions &amp;&amp; searchOptions.limit > 0) {
|
while (msgs.length &lt; limit) {
|
||||||
while (msgs.length &lt; searchOptions.limit) {
|
const loadedMessages = await chat.loadEarlierMsgs();
|
||||||
const loadedMessages = await window.Store.ConversationMsgs.loadEarlierMsgs(chat);
|
if (!loadedMessages) break;
|
||||||
if (!loadedMessages || !loadedMessages.length) break;
|
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msgs.length > searchOptions.limit) {
|
|
||||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
|
||||||
msgs = msgs.splice(msgs.length - searchOptions.limit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||||
|
if (msgs.length > limit) msgs = msgs.splice(msgs.length - limit);
|
||||||
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
||||||
|
|
||||||
}, this.id._serialized, searchOptions);
|
}, this.id._serialized, searchOptions.limit);
|
||||||
|
|
||||||
return messages.map(m => new Message(this.client, m));
|
return messages.map(m => new Message(this.client, m));
|
||||||
}
|
}
|
||||||
@@ -299,7 +288,7 @@ module.exports = Chat;
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/ClientInfo.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -51,12 +51,6 @@ class ClientInfo extends Base {
|
|||||||
*/
|
*/
|
||||||
this.pushname = data.pushname;
|
this.pushname = data.pushname;
|
||||||
|
|
||||||
/**
|
|
||||||
* Current user ID
|
|
||||||
* @type {object}
|
|
||||||
*/
|
|
||||||
this.wid = data.wid;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {object}
|
* @type {object}
|
||||||
* @deprecated Use .wid instead
|
* @deprecated Use .wid instead
|
||||||
@@ -64,19 +58,24 @@ class ClientInfo extends Base {
|
|||||||
this.me = data.wid;
|
this.me = data.wid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about the phone this client is connected to. Not available in multi-device.
|
* Current user ID
|
||||||
|
* @type {object}
|
||||||
|
*/
|
||||||
|
this.wid = data.wid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about the phone this client is connected to
|
||||||
* @type {object}
|
* @type {object}
|
||||||
* @property {string} wa_version WhatsApp Version running on the phone
|
* @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} os_version OS Version running on the phone (iOS or Android version)
|
||||||
* @property {string} device_manufacturer Device manufacturer
|
* @property {string} device_manufacturer Device manufacturer
|
||||||
* @property {string} device_model Device model
|
* @property {string} device_model Device model
|
||||||
* @property {string} os_build_number OS build number
|
* @property {string} os_build_number OS build number
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
this.phone = data.phone;
|
this.phone = data.phone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform WhatsApp is running on
|
* Platform the phone is running on
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.platform = data.platform;
|
this.platform = data.platform;
|
||||||
@@ -89,7 +88,6 @@ class ClientInfo extends Base {
|
|||||||
* @returns {object} batteryStatus
|
* @returns {object} batteryStatus
|
||||||
* @returns {number} batteryStatus.battery - The current battery percentage
|
* @returns {number} batteryStatus.battery - The current battery percentage
|
||||||
* @returns {boolean} batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)
|
* @returns {boolean} batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
async getBatteryStatus() {
|
async getBatteryStatus() {
|
||||||
return await this.client.pupPage.evaluate(() => {
|
return await this.client.pupPage.evaluate(() => {
|
||||||
@@ -97,6 +95,7 @@ class ClientInfo extends Base {
|
|||||||
return { battery, plugged };
|
return { battery, plugged };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ClientInfo;</code></pre>
|
module.exports = ClientInfo;</code></pre>
|
||||||
@@ -109,7 +108,7 @@ module.exports = ClientInfo;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Contact.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -139,7 +139,7 @@ class Contact extends Base {
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.isBlocked = data.isBlocked;
|
this.isBlocked = data.isBlocked;
|
||||||
|
|
||||||
return super._patch(data);
|
return super._patch(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,22 +151,6 @@ class Contact extends Base {
|
|||||||
return await this.client.getProfilePicUrl(this.id._serialized);
|
return await this.client.getProfilePicUrl(this.id._serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901)
|
|
||||||
* @returns {Promise&lt;string>}
|
|
||||||
*/
|
|
||||||
async getFormattedNumber() {
|
|
||||||
return await this.client.getFormattedNumber(this.id._serialized);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the contact's countrycode, (1541859685@c.us) => (1)
|
|
||||||
* @returns {Promise&lt;string>}
|
|
||||||
*/
|
|
||||||
async getCountryCode() {
|
|
||||||
return await this.client.getCountryCode(this.id._serialized);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Chat that corresponds to this Contact.
|
* Returns the Chat that corresponds to this Contact.
|
||||||
* Will return null when getting chat for currently logged in user.
|
* Will return null when getting chat for currently logged in user.
|
||||||
@@ -214,8 +198,7 @@ class Contact extends Base {
|
|||||||
*/
|
*/
|
||||||
async getAbout() {
|
async getAbout() {
|
||||||
const about = await this.client.pupPage.evaluate(async (contactId) => {
|
const about = await this.client.pupPage.evaluate(async (contactId) => {
|
||||||
const wid = window.Store.WidFactory.createWid(contactId);
|
return window.Store.Wap.statusFind(contactId);
|
||||||
return window.Store.StatusUtils.getStatus(wid);
|
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
if (typeof about.status !== 'string')
|
if (typeof about.status !== 'string')
|
||||||
@@ -223,19 +206,10 @@ class Contact extends Base {
|
|||||||
|
|
||||||
return about.status;
|
return about.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
|
|
||||||
* @returns {Promise&lt;WAWebJS.ChatId[]>}
|
|
||||||
*/
|
|
||||||
async getCommonGroups() {
|
|
||||||
return await this.client.getCommonGroups(this.id._serialized);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Contact;
|
module.exports = Contact;</code></pre>
|
||||||
</code></pre>
|
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -245,7 +219,7 @@ module.exports = Contact;
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/GroupChat.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -90,15 +90,8 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise&lt;Object>}
|
* @returns {Promise&lt;Object>}
|
||||||
*/
|
*/
|
||||||
async addParticipants(participantIds) {
|
async addParticipants(participantIds) {
|
||||||
return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
|
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.addParticipants(chatId, participantIds);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
|
||||||
const participants = await Promise.all(participantIds.map(async p => {
|
|
||||||
const wid = window.Store.WidFactory.createWid(p);
|
|
||||||
return await window.Store.Contact.get(wid);
|
|
||||||
}));
|
|
||||||
await window.Store.GroupParticipants.addParticipants(chat, participants);
|
|
||||||
return { status: 200 };
|
|
||||||
}, this.id._serialized, participantIds);
|
}, this.id._serialized, participantIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,14 +101,8 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise&lt;Object>}
|
* @returns {Promise&lt;Object>}
|
||||||
*/
|
*/
|
||||||
async removeParticipants(participantIds) {
|
async removeParticipants(participantIds) {
|
||||||
return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
|
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.removeParticipants(chatId, participantIds);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
|
||||||
const participants = participantIds.map(p => {
|
|
||||||
return chat.groupMetadata.participants.get(p);
|
|
||||||
}).filter(p => Boolean(p));
|
|
||||||
await window.Store.GroupParticipants.removeParticipants(chat, participants);
|
|
||||||
return { status: 200 };
|
|
||||||
}, this.id._serialized, participantIds);
|
}, this.id._serialized, participantIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,14 +112,8 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise&lt;{ status: number }>} Object with status code indicating if the operation was successful
|
* @returns {Promise&lt;{ status: number }>} Object with status code indicating if the operation was successful
|
||||||
*/
|
*/
|
||||||
async promoteParticipants(participantIds) {
|
async promoteParticipants(participantIds) {
|
||||||
return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
|
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.promoteParticipants(chatId, participantIds);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
|
||||||
const participants = participantIds.map(p => {
|
|
||||||
return chat.groupMetadata.participants.get(p);
|
|
||||||
}).filter(p => Boolean(p));
|
|
||||||
await window.Store.GroupParticipants.promoteParticipants(chat, participants);
|
|
||||||
return { status: 200 };
|
|
||||||
}, this.id._serialized, participantIds);
|
}, this.id._serialized, participantIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,81 +123,54 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise&lt;{ status: number }>} Object with status code indicating if the operation was successful
|
* @returns {Promise&lt;{ status: number }>} Object with status code indicating if the operation was successful
|
||||||
*/
|
*/
|
||||||
async demoteParticipants(participantIds) {
|
async demoteParticipants(participantIds) {
|
||||||
return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
|
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.demoteParticipants(chatId, participantIds);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
|
||||||
const participants = participantIds.map(p => {
|
|
||||||
return chat.groupMetadata.participants.get(p);
|
|
||||||
}).filter(p => Boolean(p));
|
|
||||||
await window.Store.GroupParticipants.demoteParticipants(chat, participants);
|
|
||||||
return { status: 200 };
|
|
||||||
}, this.id._serialized, participantIds);
|
}, this.id._serialized, participantIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the group subject
|
* Updates the group subject
|
||||||
* @param {string} subject
|
* @param {string} subject
|
||||||
* @returns {Promise&lt;boolean>} Returns true if the subject was properly updated. This can return false if the user does not have the necessary permissions.
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async setSubject(subject) {
|
async setSubject(subject) {
|
||||||
const success = await this.client.pupPage.evaluate(async (chatId, subject) => {
|
let res = await this.client.pupPage.evaluate((chatId, subject) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.changeSubject(chatId, subject);
|
||||||
try {
|
|
||||||
await window.Store.GroupUtils.setGroupSubject(chatWid, subject);
|
|
||||||
return true;
|
|
||||||
} catch (err) {
|
|
||||||
if(err.name === 'ServerStatusCodeError') return false;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}, this.id._serialized, subject);
|
}, this.id._serialized, subject);
|
||||||
|
|
||||||
if(!success) return false;
|
if(res.status == 200) {
|
||||||
this.name = subject;
|
this.name = subject;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the group description
|
* Updates the group description
|
||||||
* @param {string} description
|
* @param {string} description
|
||||||
* @returns {Promise&lt;boolean>} Returns true if the description was properly updated. This can return false if the user does not have the necessary permissions.
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async setDescription(description) {
|
async setDescription(description) {
|
||||||
const success = await this.client.pupPage.evaluate(async (chatId, description) => {
|
let res = await this.client.pupPage.evaluate((chatId, description) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
let descId = window.Store.GroupMetadata.get(chatId).descId;
|
||||||
let descId = window.Store.GroupMetadata.get(chatWid).descId;
|
return window.Store.Wap.setGroupDescription(chatId, description, window.Store.genId(), descId);
|
||||||
try {
|
|
||||||
await window.Store.GroupUtils.setGroupDescription(chatWid, description, window.Store.MsgKey.newId(), descId);
|
|
||||||
return true;
|
|
||||||
} catch (err) {
|
|
||||||
if(err.name === 'ServerStatusCodeError') return false;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}, this.id._serialized, description);
|
}, this.id._serialized, description);
|
||||||
|
|
||||||
if(!success) return false;
|
if (res.status == 200) {
|
||||||
this.groupMetadata.desc = description;
|
this.groupMetadata.desc = description;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the group settings to only allow admins to send messages.
|
* Updates the group settings to only allow admins to send messages.
|
||||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||||
* @returns {Promise&lt;boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
* @returns {Promise&lt;boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||||
*/
|
*/
|
||||||
async setMessagesAdminsOnly(adminsOnly=true) {
|
async setMessagesAdminsOnly(adminsOnly=true) {
|
||||||
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
|
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.setGroupProperty(chatId, 'announcement', value);
|
||||||
try {
|
|
||||||
await window.Store.GroupUtils.setGroupProperty(chatWid, 'announcement', adminsOnly ? 1 : 0);
|
|
||||||
return true;
|
|
||||||
} catch (err) {
|
|
||||||
if(err.name === 'ServerStatusCodeError') return false;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}, this.id._serialized, adminsOnly);
|
}, this.id._serialized, adminsOnly);
|
||||||
|
|
||||||
if(!success) return false;
|
if (res.status !== 200) return false;
|
||||||
|
|
||||||
this.groupMetadata.announce = adminsOnly;
|
this.groupMetadata.announce = adminsOnly;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -227,18 +181,11 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise&lt;boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
* @returns {Promise&lt;boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||||
*/
|
*/
|
||||||
async setInfoAdminsOnly(adminsOnly=true) {
|
async setInfoAdminsOnly(adminsOnly=true) {
|
||||||
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
|
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.setGroupProperty(chatId, 'restrict', value);
|
||||||
try {
|
|
||||||
await window.Store.GroupUtils.setGroupProperty(chatWid, 'restrict', adminsOnly ? 1 : 0);
|
|
||||||
return true;
|
|
||||||
} catch (err) {
|
|
||||||
if(err.name === 'ServerStatusCodeError') return false;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}, this.id._serialized, adminsOnly);
|
}, this.id._serialized, adminsOnly);
|
||||||
|
|
||||||
if(!success) return false;
|
if (res.status !== 200) return false;
|
||||||
|
|
||||||
this.groupMetadata.restrict = adminsOnly;
|
this.groupMetadata.restrict = adminsOnly;
|
||||||
return true;
|
return true;
|
||||||
@@ -249,25 +196,25 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise&lt;string>} Group's invite code
|
* @returns {Promise&lt;string>} Group's invite code
|
||||||
*/
|
*/
|
||||||
async getInviteCode() {
|
async getInviteCode() {
|
||||||
const codeRes = await this.client.pupPage.evaluate(async chatId => {
|
let res = await this.client.pupPage.evaluate(chatId => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.groupInviteCode(chatId);
|
||||||
return window.Store.Invite.queryGroupInviteCode(chatWid);
|
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
return codeRes.code;
|
if (res.status == 200) {
|
||||||
|
return res.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error('Not authorized');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates the current group invite code and generates a new one
|
* Invalidates the current group invite code and generates a new one
|
||||||
* @returns {Promise&lt;string>} New invite code
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async revokeInvite() {
|
async revokeInvite() {
|
||||||
const codeRes = await this.client.pupPage.evaluate(chatId => {
|
return await this.client.pupPage.evaluate(chatId => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.revokeGroupInvite(chatId);
|
||||||
return window.Store.Invite.resetGroupInviteCode(chatWid);
|
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
return codeRes.code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -275,10 +222,8 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async leave() {
|
async leave() {
|
||||||
await this.client.pupPage.evaluate(async chatId => {
|
return await this.client.pupPage.evaluate(chatId => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.leaveGroup(chatId);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
|
||||||
return window.Store.GroupUtils.sendExitGroup(chat);
|
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,7 +239,7 @@ module.exports = GroupChat;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/GroupNotification.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -74,7 +74,7 @@ class GroupNotification extends Base {
|
|||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.chatId = typeof (data.id.remote) === 'object' ? data.id.remote._serialized : data.id.remote;
|
this.chatId = typeof (data.from) === 'object' ? data.from._serialized : data.from;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ContactId for the user that produced the GroupNotification.
|
* ContactId for the user that produced the GroupNotification.
|
||||||
@@ -143,7 +143,7 @@ module.exports = GroupNotification;
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Label.js</title>
|
<title>whatsapp-web.js 1.14.1 » Source: structures/Label.js</title>
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -88,7 +88,7 @@ module.exports = Label;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -1,133 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/List.js</title>
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
|
||||||
<link href="css/baseline.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body onload="prettyPrint()">
|
|
||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
|
||||||
<div id="jsdoc-navbar-container">
|
|
||||||
<div id="jsdoc-navbar-content">
|
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<div id="jsdoc-body-container">
|
|
||||||
<div id="jsdoc-content">
|
|
||||||
<div id="jsdoc-content-container">
|
|
||||||
<div id="jsdoc-banner" role="banner">
|
|
||||||
</div>
|
|
||||||
<div id="jsdoc-main" role="main">
|
|
||||||
<header class="page-header">
|
|
||||||
<h1>Source: structures/List.js</h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
|
||||||
<pre class="prettyprint linenums"><code>'use strict';
|
|
||||||
|
|
||||||
const Util = require('../util/Util');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Message type List
|
|
||||||
*/
|
|
||||||
class List {
|
|
||||||
/**
|
|
||||||
* @param {string} body
|
|
||||||
* @param {string} buttonText
|
|
||||||
* @param {Array&lt;any>} sections
|
|
||||||
* @param {string?} title
|
|
||||||
* @param {string?} footer
|
|
||||||
*/
|
|
||||||
constructor(body, buttonText, sections, title, footer) {
|
|
||||||
/**
|
|
||||||
* Message body
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.description = body;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List button text
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.buttonText = buttonText;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* title of message
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.title = title;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* footer of message
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.footer = footer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sections of message
|
|
||||||
* @type {Array&lt;any>}
|
|
||||||
*/
|
|
||||||
this.sections = this._format(sections);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates section array from simple array
|
|
||||||
* @param {Array&lt;any>} sections
|
|
||||||
* @returns {Array&lt;any>}
|
|
||||||
* @example
|
|
||||||
* Input: [{title:'sectionTitle',rows:[{id:'customId', title:'ListItem2', description: 'desc'},{title:'ListItem2'}]}}]
|
|
||||||
* Returns: [{'title':'sectionTitle','rows':[{'rowId':'customId','title':'ListItem1','description':'desc'},{'rowId':'oGSRoD','title':'ListItem2','description':''}]}]
|
|
||||||
*/
|
|
||||||
_format(sections){
|
|
||||||
if(!sections.length){throw '[LT02] List without sections';}
|
|
||||||
if(sections.length > 1 &amp;&amp; sections.filter(s => typeof s.title == 'undefined').length > 1){throw '[LT05] You can\'t have more than one empty title.';}
|
|
||||||
return sections.map( (section) =>{
|
|
||||||
if(!section.rows.length){throw '[LT03] Section without rows';}
|
|
||||||
return {
|
|
||||||
title: section.title ? section.title : undefined,
|
|
||||||
rows: section.rows.map( (row) => {
|
|
||||||
if(!row.title){throw '[LT04] Row without title';}
|
|
||||||
return {
|
|
||||||
rowId: row.id ? row.id : Util.generateHash(6),
|
|
||||||
title: row.title,
|
|
||||||
description: row.description ? row.description : ''
|
|
||||||
};
|
|
||||||
})
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = List;
|
|
||||||
</code></pre>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
|
||||||
<div id="jsdoc-footer-container">
|
|
||||||
<p>
|
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Location.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -71,7 +71,7 @@ module.exports = Location;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Message.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -35,7 +35,6 @@ const Base = require('./Base');
|
|||||||
const MessageMedia = require('./MessageMedia');
|
const MessageMedia = require('./MessageMedia');
|
||||||
const Location = require('./Location');
|
const Location = require('./Location');
|
||||||
const Order = require('./Order');
|
const Order = require('./Order');
|
||||||
const Payment = require('./Payment');
|
|
||||||
const { MessageTypes } = require('../util/Constants');
|
const { MessageTypes } = require('../util/Constants');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,14 +49,13 @@ class Message extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_patch(data) {
|
_patch(data) {
|
||||||
this._data = data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MediaKey that represents the sticker 'ID'
|
* MediaKey that represents the sticker 'ID'
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.mediaKey = data.mediaKey;
|
this.mediaKey = data.mediaKey;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID that represents the message
|
* ID that represents the message
|
||||||
* @type {object}
|
* @type {object}
|
||||||
@@ -82,7 +80,7 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
this.body = this.hasMedia ? data.caption || '' : data.body || '';
|
this.body = this.hasMedia ? data.caption || '' : data.body || '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message type
|
* Message type
|
||||||
* @type {MessageTypes}
|
* @type {MessageTypes}
|
||||||
*/
|
*/
|
||||||
@@ -102,9 +100,9 @@ class Message extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ID for who this message is for.
|
* 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 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.
|
* If the message is sent by another user, it will be the ID for the current user.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.to = (typeof (data.to) === 'object' &amp;&amp; data.to !== null) ? data.to._serialized : data.to;
|
this.to = (typeof (data.to) === 'object' &amp;&amp; data.to !== null) ? data.to._serialized : data.to;
|
||||||
@@ -119,8 +117,8 @@ class Message extends Base {
|
|||||||
* String that represents from which device type the message was sent
|
* String that represents from which device type the message was sent
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0, 2) == '3A' ? 'ios' : 'web';
|
this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0,2) =='3A' ? 'ios' : 'web';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the message was forwarded
|
* Indicates if the message was forwarded
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@@ -146,14 +144,14 @@ class Message extends Base {
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.isStarred = data.star;
|
this.isStarred = data.star;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the message was a broadcast
|
* Indicates if the message was a broadcast
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.broadcast = data.broadcast;
|
this.broadcast = data.broadcast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the message was sent by the current user
|
* Indicates if the message was sent by the current user
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
@@ -165,12 +163,6 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
this.hasQuotedMsg = data.quotedMsg ? true : false;
|
this.hasQuotedMsg = data.quotedMsg ? true : false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the duration of the message in seconds
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.duration = data.duration ? data.duration : undefined;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location information contained in the message, if the message is type "location"
|
* Location information contained in the message, if the message is type "location"
|
||||||
* @type {Location}
|
* @type {Location}
|
||||||
@@ -195,7 +187,7 @@ class Message extends Base {
|
|||||||
fromId: data.from._serialized,
|
fromId: data.from._serialized,
|
||||||
toId: data.to._serialized
|
toId: data.to._serialized
|
||||||
} : undefined;
|
} : undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates the mentions in the message body.
|
* Indicates the mentions in the message body.
|
||||||
* @type {Array&lt;string>}
|
* @type {Array&lt;string>}
|
||||||
@@ -217,18 +209,6 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
this.token = data.token ? data.token : undefined;
|
this.token = data.token ? data.token : undefined;
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether the message is a Gif
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
this.isGif = Boolean(data.isGif);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if the message will disappear after it expires
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
this.isEphemeral = data.isEphemeral;
|
|
||||||
|
|
||||||
/** Title */
|
/** Title */
|
||||||
if (data.title) {
|
if (data.title) {
|
||||||
this.title = data.title;
|
this.title = data.title;
|
||||||
@@ -252,25 +232,10 @@ class Message extends Base {
|
|||||||
/**
|
/**
|
||||||
* Links included in the message.
|
* Links included in the message.
|
||||||
* @type {Array&lt;{link: string, isSuspicious: boolean}>}
|
* @type {Array&lt;{link: string, isSuspicious: boolean}>}
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
this.links = data.links;
|
this.links = data.links;
|
||||||
|
|
||||||
/** Buttons */
|
|
||||||
if (data.dynamicReplyButtons) {
|
|
||||||
this.dynamicReplyButtons = data.dynamicReplyButtons;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Selected Button Id **/
|
|
||||||
if (data.selectedButtonId) {
|
|
||||||
this.selectedButtonId = data.selectedButtonId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Selected List row Id **/
|
|
||||||
if (data.listResponse &amp;&amp; data.listResponse.singleSelectReply.selectedRowId) {
|
|
||||||
this.selectedRowId = data.listResponse.singleSelectReply.selectedRowId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super._patch(data);
|
return super._patch(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,32 +243,6 @@ class Message extends Base {
|
|||||||
return this.fromMe ? this.to : this.from;
|
return this.fromMe ? this.to : this.from;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reloads this Message object's data in-place with the latest values from WhatsApp Web.
|
|
||||||
* Note that the Message must still be in the web app cache for this to work, otherwise will return null.
|
|
||||||
* @returns {Promise&lt;Message>}
|
|
||||||
*/
|
|
||||||
async reload() {
|
|
||||||
const newData = await this.client.pupPage.evaluate((msgId) => {
|
|
||||||
const msg = window.Store.Msg.get(msgId);
|
|
||||||
if(!msg) return null;
|
|
||||||
return window.WWebJS.getMessageModel(msg);
|
|
||||||
}, this.id._serialized);
|
|
||||||
|
|
||||||
if(!newData) return null;
|
|
||||||
|
|
||||||
this._patch(newData);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns message in a raw format
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
get rawData() {
|
|
||||||
return this._data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Chat this message was sent in
|
* Returns the Chat this message was sent in
|
||||||
* @returns {Promise&lt;Chat>}
|
* @returns {Promise&lt;Chat>}
|
||||||
@@ -336,21 +275,20 @@ class Message extends Base {
|
|||||||
if (!this.hasQuotedMsg) return undefined;
|
if (!this.hasQuotedMsg) return undefined;
|
||||||
|
|
||||||
const quotedMsg = await this.client.pupPage.evaluate((msgId) => {
|
const quotedMsg = await this.client.pupPage.evaluate((msgId) => {
|
||||||
const msg = window.Store.Msg.get(msgId);
|
let msg = window.Store.Msg.get(msgId);
|
||||||
const quotedMsg = window.Store.QuotedMsg.getQuotedMsgObj(msg);
|
return msg.quotedMsgObj().serialize();
|
||||||
return window.WWebJS.getMessageModel(quotedMsg);
|
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
return new Message(this.client, quotedMsg);
|
return new Message(this.client, quotedMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message as a reply to this message. If chatId is specified, it will be sent
|
* 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
|
* through the specified Chat. If not, it will send the message
|
||||||
* in the same Chat as the original message was sent.
|
* in the same Chat as the original message was sent.
|
||||||
*
|
*
|
||||||
* @param {string|MessageMedia|Location} content
|
* @param {string|MessageMedia|Location} content
|
||||||
* @param {string} [chatId]
|
* @param {string} [chatId]
|
||||||
* @param {MessageSendOptions} [options]
|
* @param {MessageSendOptions} [options]
|
||||||
* @returns {Promise&lt;Message>}
|
* @returns {Promise&lt;Message>}
|
||||||
*/
|
*/
|
||||||
@@ -367,20 +305,6 @@ class Message extends Base {
|
|||||||
return this.client.sendMessage(chatId, content, options);
|
return this.client.sendMessage(chatId, content, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* React to this message with an emoji
|
|
||||||
* @param {string} reaction - Emoji to react with. Send an empty string to remove the reaction.
|
|
||||||
* @return {Promise}
|
|
||||||
*/
|
|
||||||
async react(reaction){
|
|
||||||
await this.client.pupPage.evaluate(async (messageId, reaction) => {
|
|
||||||
if (!messageId) { return undefined; }
|
|
||||||
|
|
||||||
const msg = await window.Store.Msg.get(messageId);
|
|
||||||
await window.Store.sendReactionToMsg(msg, reaction);
|
|
||||||
}, this.id._serialized, reaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept Group V4 Invite
|
* Accept Group V4 Invite
|
||||||
* @returns {Promise&lt;Object>}
|
* @returns {Promise&lt;Object>}
|
||||||
@@ -388,10 +312,10 @@ class Message extends Base {
|
|||||||
async acceptGroupV4Invite() {
|
async acceptGroupV4Invite() {
|
||||||
return await this.client.acceptGroupV4Invite(this.inviteV4);
|
return await this.client.acceptGroupV4Invite(this.inviteV4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forwards this message to another chat (that you chatted before, otherwise it will fail)
|
* Forwards this message to another chat
|
||||||
*
|
*
|
||||||
* @param {string|Chat} chat Chat model or chat ID to which the message will be forwarded
|
* @param {string|Chat} chat Chat model or chat ID to which the message will be forwarded
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
@@ -417,13 +341,11 @@ class Message extends Base {
|
|||||||
|
|
||||||
const result = await this.client.pupPage.evaluate(async (msgId) => {
|
const result = await this.client.pupPage.evaluate(async (msgId) => {
|
||||||
const msg = window.Store.Msg.get(msgId);
|
const msg = window.Store.Msg.get(msgId);
|
||||||
if (!msg) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
||||||
// try to resolve media
|
// try to resolve media
|
||||||
await msg.downloadMedia({
|
await msg.downloadMedia({
|
||||||
downloadEvenIfExpensive: true,
|
downloadEvenIfExpensive: true,
|
||||||
rmrReason: 1
|
rmrReason: 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -443,14 +365,13 @@ class Message extends Base {
|
|||||||
type: msg.type,
|
type: msg.type,
|
||||||
signal: (new AbortController).signal
|
signal: (new AbortController).signal
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await window.WWebJS.arrayBufferToBase64Async(decryptedMedia);
|
const data = window.WWebJS.arrayBufferToBase64(decryptedMedia);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
mimetype: msg.mimetype,
|
mimetype: msg.mimetype,
|
||||||
filename: msg.filename,
|
filename: msg.filename
|
||||||
filesize: msg.size
|
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if(e.status &amp;&amp; e.status === 404) return undefined;
|
if(e.status &amp;&amp; e.status === 404) return undefined;
|
||||||
@@ -459,20 +380,19 @@ class Message extends Base {
|
|||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
if (!result) return undefined;
|
if (!result) return undefined;
|
||||||
return new MessageMedia(result.mimetype, result.data, result.filename, result.filesize);
|
return new MessageMedia(result.mimetype, result.data, result.filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a message from the chat
|
* Deletes a message from the chat
|
||||||
* @param {?boolean} everyone If true and the message is sent by the current user or the user is an admin, will delete it for everyone in 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) {
|
async delete(everyone) {
|
||||||
await this.client.pupPage.evaluate((msgId, everyone) => {
|
await this.client.pupPage.evaluate((msgId, everyone) => {
|
||||||
let msg = window.Store.Msg.get(msgId);
|
let msg = window.Store.Msg.get(msgId);
|
||||||
|
|
||||||
const canRevoke = window.Store.MsgActionChecks.canSenderRevokeMsg(msg) || window.Store.MsgActionChecks.canAdminRevokeMsg(msg);
|
if (everyone &amp;&amp; msg.id.fromMe &amp;&amp; msg.canRevoke()) {
|
||||||
if (everyone &amp;&amp; canRevoke) {
|
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], true);
|
||||||
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], { type: msg.id.fromMe ? 'Sender' : 'Admin' });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
||||||
@@ -486,8 +406,8 @@ class Message extends Base {
|
|||||||
await this.client.pupPage.evaluate((msgId) => {
|
await this.client.pupPage.evaluate((msgId) => {
|
||||||
let msg = window.Store.Msg.get(msgId);
|
let msg = window.Store.Msg.get(msgId);
|
||||||
|
|
||||||
if (window.Store.MsgActionChecks.canStarMsg(msg)) {
|
if (msg.canStar()) {
|
||||||
return window.Store.Cmd.sendStarMsgs(msg.chat, [msg], false);
|
return msg.chat.sendStarMsgs([msg], true);
|
||||||
}
|
}
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
}
|
}
|
||||||
@@ -499,8 +419,8 @@ class Message extends Base {
|
|||||||
await this.client.pupPage.evaluate((msgId) => {
|
await this.client.pupPage.evaluate((msgId) => {
|
||||||
let msg = window.Store.Msg.get(msgId);
|
let msg = window.Store.Msg.get(msgId);
|
||||||
|
|
||||||
if (window.Store.MsgActionChecks.canStarMsg(msg)) {
|
if (msg.canStar()) {
|
||||||
return window.Store.Cmd.sendUnstarMsgs(msg.chat, [msg], false);
|
return msg.chat.sendStarMsgs([msg], false);
|
||||||
}
|
}
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
}
|
}
|
||||||
@@ -523,11 +443,15 @@ class Message extends Base {
|
|||||||
async getInfo() {
|
async getInfo() {
|
||||||
const info = await this.client.pupPage.evaluate(async (msgId) => {
|
const info = await this.client.pupPage.evaluate(async (msgId) => {
|
||||||
const msg = window.Store.Msg.get(msgId);
|
const msg = window.Store.Msg.get(msgId);
|
||||||
if (!msg) return null;
|
if(!msg) return null;
|
||||||
|
|
||||||
return await window.Store.MessageInfo.sendQueryMsgInfo(msg.id);
|
return await window.Store.Wap.queryMsgInfo(msg.id);
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
|
if(info.status) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,29 +461,14 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
async getOrder() {
|
async getOrder() {
|
||||||
if (this.type === MessageTypes.ORDER) {
|
if (this.type === MessageTypes.ORDER) {
|
||||||
const result = await this.client.pupPage.evaluate((orderId, token, chatId) => {
|
const result = await this.client.pupPage.evaluate((orderId, token) => {
|
||||||
return window.WWebJS.getOrderDetail(orderId, token, chatId);
|
return window.WWebJS.getOrderDetail(orderId, token);
|
||||||
}, this.orderId, this.token, this._getChatId());
|
}, this.orderId, this.token);
|
||||||
if (!result) return undefined;
|
if (!result) return undefined;
|
||||||
return new Order(this.client, result);
|
return new Order(this.client, result);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Gets the payment details associated with a given message
|
|
||||||
* @return {Promise&lt;Payment>}
|
|
||||||
*/
|
|
||||||
async getPayment() {
|
|
||||||
if (this.type === MessageTypes.PAYMENT) {
|
|
||||||
const msg = await this.client.pupPage.evaluate(async (msgId) => {
|
|
||||||
const msg = window.Store.Msg.get(msgId);
|
|
||||||
if(!msg) return null;
|
|
||||||
return msg.serialize();
|
|
||||||
}, this.id._serialized);
|
|
||||||
return new Payment(this.client, msg);
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Message;
|
module.exports = Message;
|
||||||
@@ -573,7 +482,7 @@ module.exports = Message;
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/MessageMedia.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -41,11 +41,10 @@ const { URL } = require('url');
|
|||||||
* Media attached to a message
|
* Media attached to a message
|
||||||
* @param {string} mimetype MIME type of the attachment
|
* @param {string} mimetype MIME type of the attachment
|
||||||
* @param {string} data Base64-encoded data of the file
|
* @param {string} data Base64-encoded data of the file
|
||||||
* @param {?string} filename Document file name. Value can be null
|
* @param {?string} filename Document file name
|
||||||
* @param {?number} filesize Document file size in bytes. Value can be null
|
|
||||||
*/
|
*/
|
||||||
class MessageMedia {
|
class MessageMedia {
|
||||||
constructor(mimetype, data, filename, filesize) {
|
constructor(mimetype, data, filename) {
|
||||||
/**
|
/**
|
||||||
* MIME type of the attachment
|
* MIME type of the attachment
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@@ -59,16 +58,10 @@ class MessageMedia {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document file name. Value can be null
|
* Name of the file (for documents)
|
||||||
* @type {?string}
|
* @type {?string}
|
||||||
*/
|
*/
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
|
|
||||||
/**
|
|
||||||
* Document file size in bytes. Value can be null
|
|
||||||
* @type {?number}
|
|
||||||
*/
|
|
||||||
this.filesize = filesize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,30 +81,29 @@ class MessageMedia {
|
|||||||
* Creates a MessageMedia instance from a URL
|
* Creates a MessageMedia instance from a URL
|
||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @param {Object} [options]
|
* @param {Object} [options]
|
||||||
* @param {boolean} [options.unsafeMime=false]
|
* @param {number} [options.unsafeMime=false]
|
||||||
* @param {string} [options.filename]
|
|
||||||
* @param {object} [options.client]
|
* @param {object} [options.client]
|
||||||
* @param {object} [options.reqOptions]
|
* @param {object} [options.reqOptions]
|
||||||
* @param {number} [options.reqOptions.size=0]
|
* @param {number} [options.reqOptions.size=0]
|
||||||
* @returns {Promise&lt;MessageMedia>}
|
* @returns {Promise&lt;MessageMedia>}
|
||||||
*/
|
*/
|
||||||
static async fromUrl(url, options = {}) {
|
static async fromUrl(url, options = {}) {
|
||||||
const pUrl = new URL(url);
|
let mimetype;
|
||||||
let mimetype = mime.getType(pUrl.pathname);
|
|
||||||
|
|
||||||
if (!mimetype &amp;&amp; !options.unsafeMime)
|
if (!options.unsafeMime) {
|
||||||
throw new Error('Unable to determine MIME type using URL. Set unsafeMime to true to download it anyway.');
|
const pUrl = new URL(url);
|
||||||
|
mimetype = mime.getType(pUrl.pathname);
|
||||||
|
|
||||||
|
if (!mimetype)
|
||||||
|
throw new Error('Unable to determine MIME type');
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchData (url, options) {
|
async function fetchData (url, options) {
|
||||||
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
||||||
const response = await fetch(url, reqOptions);
|
const response = await fetch(url, reqOptions);
|
||||||
const mime = response.headers.get('Content-Type');
|
const mime = response.headers.get('Content-Type');
|
||||||
const size = response.headers.get('Content-Length');
|
|
||||||
|
|
||||||
const contentDisposition = response.headers.get('Content-Disposition');
|
|
||||||
const name = contentDisposition ? contentDisposition.match(/((?&lt;=filename=")(.*)(?="))/) : null;
|
|
||||||
|
|
||||||
let data = '';
|
let data = '';
|
||||||
|
|
||||||
if (response.buffer) {
|
if (response.buffer) {
|
||||||
data = (await response.buffer()).toString('base64');
|
data = (await response.buffer()).toString('base64');
|
||||||
} else {
|
} else {
|
||||||
@@ -122,25 +114,21 @@ class MessageMedia {
|
|||||||
data = btoa(data);
|
data = btoa(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { data, mime, name, size };
|
return { data, mime };
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = options.client
|
const res = options.client
|
||||||
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
|
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
|
||||||
: (await fetchData(url, options.reqOptions));
|
: (await fetchData(url, options.reqOptions));
|
||||||
|
|
||||||
const filename = options.filename ||
|
|
||||||
(res.name ? res.name[0] : (pUrl.pathname.split('/').pop() || 'file'));
|
|
||||||
|
|
||||||
if (!mimetype)
|
if (!mimetype)
|
||||||
mimetype = res.mime;
|
mimetype = res.mime;
|
||||||
|
|
||||||
return new MessageMedia(mimetype, res.data, filename, res.size || null);
|
return new MessageMedia(mimetype, res.data, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = MessageMedia;
|
module.exports = MessageMedia;</code></pre>
|
||||||
</code></pre>
|
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -150,7 +138,7 @@ module.exports = MessageMedia;
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Order.js</title>
|
<title>whatsapp-web.js 1.14.1 » Source: structures/Order.js</title>
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -90,7 +90,7 @@ module.exports = Order;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -1,133 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Payment.js</title>
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
|
||||||
<link href="css/baseline.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body onload="prettyPrint()">
|
|
||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
|
||||||
<div id="jsdoc-navbar-container">
|
|
||||||
<div id="jsdoc-navbar-content">
|
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<div id="jsdoc-body-container">
|
|
||||||
<div id="jsdoc-content">
|
|
||||||
<div id="jsdoc-content-container">
|
|
||||||
<div id="jsdoc-banner" role="banner">
|
|
||||||
</div>
|
|
||||||
<div id="jsdoc-main" role="main">
|
|
||||||
<header class="page-header">
|
|
||||||
<h1>Source: structures/Payment.js</h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
|
||||||
<pre class="prettyprint linenums"><code>const Base = require('./Base');
|
|
||||||
|
|
||||||
class Payment extends Base {
|
|
||||||
constructor(client, data) {
|
|
||||||
super(client);
|
|
||||||
|
|
||||||
if (data) this._patch(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
_patch(data) {
|
|
||||||
/**
|
|
||||||
* The payment Id
|
|
||||||
* @type {object}
|
|
||||||
*/
|
|
||||||
this.id = data.id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The payment currency
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.paymentCurrency = data.paymentCurrency;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The payment ammount ( R$ 1.00 = 1000 )
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.paymentAmount1000 = data.paymentAmount1000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The payment receiver
|
|
||||||
* @type {object}
|
|
||||||
*/
|
|
||||||
this.paymentMessageReceiverJid = data.paymentMessageReceiverJid;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The payment transaction timestamp
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.paymentTransactionTimestamp = data.paymentTransactionTimestamp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The paymentStatus
|
|
||||||
*
|
|
||||||
* Possible Status
|
|
||||||
* 0:UNKNOWN_STATUS
|
|
||||||
* 1:PROCESSING
|
|
||||||
* 2:SENT
|
|
||||||
* 3:NEED_TO_ACCEPT
|
|
||||||
* 4:COMPLETE
|
|
||||||
* 5:COULD_NOT_COMPLETE
|
|
||||||
* 6:REFUNDED
|
|
||||||
* 7:EXPIRED
|
|
||||||
* 8:REJECTED
|
|
||||||
* 9:CANCELLED
|
|
||||||
* 10:WAITING_FOR_PAYER
|
|
||||||
* 11:WAITING
|
|
||||||
*
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.paymentStatus = data.paymentStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Integer that represents the payment Text
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.paymentTxnStatus = data.paymentTxnStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The note sent with the payment
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.paymentNote = !data.paymentNoteMsg ? undefined : data.paymentNoteMsg.body ? data.paymentNoteMsg.body : undefined ;
|
|
||||||
|
|
||||||
return super._patch(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Payment;
|
|
||||||
</code></pre>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<nav id="jsdoc-toc-nav" role="navigation"></nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
|
||||||
<div id="jsdoc-footer-container">
|
|
||||||
<p>
|
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/PrivateChat.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -51,7 +51,7 @@ module.exports = PrivateChat;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/PrivateContact.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -51,7 +51,7 @@ module.exports = PrivateContact;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Product.js</title>
|
<title>whatsapp-web.js 1.14.1 » Source: structures/Product.js</title>
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -106,7 +106,7 @@ module.exports = Product;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/ProductMetadata.js</title>
|
<title>whatsapp-web.js 1.14.1 » Source: structures/ProductMetadata.js</title>
|
||||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -63,7 +63,7 @@ module.exports = ProductMetadata;</code></pre>
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: structures/Reaction.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>19.<wbr>4</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/Reaction.js</h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
|
||||||
<pre class="prettyprint linenums"><code>'use strict';
|
|
||||||
|
|
||||||
const Base = require('./Base');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a Reaction on WhatsApp
|
|
||||||
* @extends {Base}
|
|
||||||
*/
|
|
||||||
class Reaction extends Base {
|
|
||||||
constructor(client, data) {
|
|
||||||
super(client);
|
|
||||||
|
|
||||||
if (data) this._patch(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
_patch(data) {
|
|
||||||
/**
|
|
||||||
* Reaction ID
|
|
||||||
* @type {object}
|
|
||||||
*/
|
|
||||||
this.id = data.msgKey;
|
|
||||||
/**
|
|
||||||
* Orphan
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.orphan = data.orphan;
|
|
||||||
/**
|
|
||||||
* Orphan reason
|
|
||||||
* @type {?string}
|
|
||||||
*/
|
|
||||||
this.orphanReason = data.orphanReason;
|
|
||||||
/**
|
|
||||||
* Unix timestamp for when the reaction was created
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.timestamp = data.timestamp;
|
|
||||||
/**
|
|
||||||
* Reaction
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.reaction = data.reactionText;
|
|
||||||
/**
|
|
||||||
* Read
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
this.read = data.read;
|
|
||||||
/**
|
|
||||||
* Message ID
|
|
||||||
* @type {object}
|
|
||||||
*/
|
|
||||||
this.msgId = data.parentMsgKey;
|
|
||||||
/**
|
|
||||||
* Sender ID
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.senderId = data.senderUserJid;
|
|
||||||
/**
|
|
||||||
* ACK
|
|
||||||
* @type {?number}
|
|
||||||
*/
|
|
||||||
this.ack = data.ack;
|
|
||||||
|
|
||||||
|
|
||||||
return super._patch(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Reaction;</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.11 on February 11, 2023.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="scripts/jquery.min.js"></script>
|
|
||||||
<script src="scripts/tree.jquery.js"></script>
|
|
||||||
<script src="scripts/prettify.js"></script>
|
|
||||||
<script src="scripts/jsdoc-toc.js"></script>
|
|
||||||
<script src="scripts/linenumber.js"></script>
|
|
||||||
<script src="scripts/scrollanchor.js"></script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: util/Constants.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -38,11 +38,13 @@ exports.DefaultOptions = {
|
|||||||
headless: true,
|
headless: true,
|
||||||
defaultViewport: null
|
defaultViewport: null
|
||||||
},
|
},
|
||||||
authTimeoutMs: 0,
|
session: false,
|
||||||
qrMaxRetries: 0,
|
qrTimeoutMs: 45000,
|
||||||
|
qrRefreshIntervalMs: 20000,
|
||||||
|
authTimeoutMs: 45000,
|
||||||
takeoverOnConflict: false,
|
takeoverOnConflict: false,
|
||||||
takeoverTimeoutMs: 0,
|
takeoverTimeoutMs: 0,
|
||||||
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36',
|
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36',
|
||||||
ffmpegPath: 'ffmpeg',
|
ffmpegPath: 'ffmpeg',
|
||||||
bypassCSP: false
|
bypassCSP: false
|
||||||
};
|
};
|
||||||
@@ -72,18 +74,15 @@ exports.Events = {
|
|||||||
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
|
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
|
||||||
MESSAGE_REVOKED_ME: 'message_revoke_me',
|
MESSAGE_REVOKED_ME: 'message_revoke_me',
|
||||||
MESSAGE_ACK: 'message_ack',
|
MESSAGE_ACK: 'message_ack',
|
||||||
MESSAGE_REACTION: 'message_reaction',
|
|
||||||
MEDIA_UPLOADED: 'media_uploaded',
|
MEDIA_UPLOADED: 'media_uploaded',
|
||||||
GROUP_JOIN: 'group_join',
|
GROUP_JOIN: 'group_join',
|
||||||
GROUP_LEAVE: 'group_leave',
|
GROUP_LEAVE: 'group_leave',
|
||||||
GROUP_UPDATE: 'group_update',
|
GROUP_UPDATE: 'group_update',
|
||||||
QR_RECEIVED: 'qr',
|
QR_RECEIVED: 'qr',
|
||||||
LOADING_SCREEN: 'loading_screen',
|
|
||||||
DISCONNECTED: 'disconnected',
|
DISCONNECTED: 'disconnected',
|
||||||
STATE_CHANGED: 'change_state',
|
STATE_CHANGED: 'change_state',
|
||||||
BATTERY_CHANGED: 'change_battery',
|
BATTERY_CHANGED: 'change_battery',
|
||||||
INCOMING_CALL: 'call',
|
INCOMING_CALL: 'incoming_call'
|
||||||
REMOTE_SESSION_SAVED: 'remote_session_saved'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,27 +105,7 @@ exports.MessageTypes = {
|
|||||||
REVOKED: 'revoked',
|
REVOKED: 'revoked',
|
||||||
PRODUCT: 'product',
|
PRODUCT: 'product',
|
||||||
UNKNOWN: 'unknown',
|
UNKNOWN: 'unknown',
|
||||||
GROUP_INVITE: 'groups_v4_invite',
|
GROUP_INVITE: 'groups_v4_invite'
|
||||||
LIST: 'list',
|
|
||||||
LIST_RESPONSE: 'list_response',
|
|
||||||
BUTTONS_RESPONSE: 'buttons_response',
|
|
||||||
PAYMENT: 'payment',
|
|
||||||
BROADCAST_NOTIFICATION: 'broadcast_notification',
|
|
||||||
CALL_LOG: 'call_log',
|
|
||||||
CIPHERTEXT: 'ciphertext',
|
|
||||||
DEBUG: 'debug',
|
|
||||||
E2E_NOTIFICATION: 'e2e_notification',
|
|
||||||
GP2: 'gp2',
|
|
||||||
GROUP_NOTIFICATION: 'group_notification',
|
|
||||||
HSM: 'hsm',
|
|
||||||
INTERACTIVE: 'interactive',
|
|
||||||
NATIVE_FLOW: 'native_flow',
|
|
||||||
NOTIFICATION: 'notification',
|
|
||||||
NOTIFICATION_TEMPLATE: 'notification_template',
|
|
||||||
OVERSIZED: 'oversized',
|
|
||||||
PROTOCOL: 'protocol',
|
|
||||||
REACTION: 'reaction',
|
|
||||||
TEMPLATE_BUTTON_REPLY: 'template_button_reply',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -200,7 +179,7 @@ exports.MessageAck = {
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: util/InterfaceController.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -59,7 +59,7 @@ class InterfaceController {
|
|||||||
async openChatDrawer(chatId) {
|
async openChatDrawer(chatId) {
|
||||||
await this.pupPage.evaluate(async chatId => {
|
await this.pupPage.evaluate(async chatId => {
|
||||||
let chat = await window.Store.Chat.get(chatId);
|
let chat = await window.Store.Chat.get(chatId);
|
||||||
await window.Store.Cmd.openDrawerMid(chat);
|
await window.Store.Cmd.chatInfoDrawer(chat);
|
||||||
}, chatId);
|
}, chatId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,6 @@ class InterfaceController {
|
|||||||
*/
|
*/
|
||||||
async getFeatures() {
|
async getFeatures() {
|
||||||
return await this.pupPage.evaluate(() => {
|
return await this.pupPage.evaluate(() => {
|
||||||
if(!window.Store.Features) throw new Error('This version of Whatsapp Web does not support features');
|
|
||||||
return window.Store.Features.F;
|
return window.Store.Features.F;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -121,7 +120,6 @@ class InterfaceController {
|
|||||||
*/
|
*/
|
||||||
async checkFeatureStatus(feature) {
|
async checkFeatureStatus(feature) {
|
||||||
return await this.pupPage.evaluate((feature) => {
|
return await this.pupPage.evaluate((feature) => {
|
||||||
if(!window.Store.Features) throw new Error('This version of Whatsapp Web does not support features');
|
|
||||||
return window.Store.Features.supportsFeature(feature);
|
return window.Store.Features.supportsFeature(feature);
|
||||||
}, feature);
|
}, feature);
|
||||||
}
|
}
|
||||||
@@ -132,7 +130,6 @@ class InterfaceController {
|
|||||||
*/
|
*/
|
||||||
async enableFeatures(features) {
|
async enableFeatures(features) {
|
||||||
await this.pupPage.evaluate((features) => {
|
await this.pupPage.evaluate((features) => {
|
||||||
if(!window.Store.Features) throw new Error('This version of Whatsapp Web does not support features');
|
|
||||||
for (const feature in features) {
|
for (const feature in features) {
|
||||||
window.Store.Features.setFeature(features[feature], true);
|
window.Store.Features.setFeature(features[feature], true);
|
||||||
}
|
}
|
||||||
@@ -145,7 +142,6 @@ class InterfaceController {
|
|||||||
*/
|
*/
|
||||||
async disableFeatures(features) {
|
async disableFeatures(features) {
|
||||||
await this.pupPage.evaluate((features) => {
|
await this.pupPage.evaluate((features) => {
|
||||||
if(!window.Store.Features) throw new Error('This version of Whatsapp Web does not support features');
|
|
||||||
for (const feature in features) {
|
for (const feature in features) {
|
||||||
window.Store.Features.setFeature(features[feature], false);
|
window.Store.Features.setFeature(features[feature], false);
|
||||||
}
|
}
|
||||||
@@ -164,7 +160,7 @@ module.exports = InterfaceController;
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="JSDoc 3.6.11">
|
<meta name="generator" content="JSDoc 3.6.7">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>whatsapp-web.js 1.19.4 » Source: util/Util.js</title>
|
<title>whatsapp-web.js 1.14.1 » 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/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/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 rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||||
<div id="jsdoc-navbar-container">
|
<div id="jsdoc-navbar-container">
|
||||||
<div id="jsdoc-navbar-content">
|
<div id="jsdoc-navbar-content">
|
||||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>4</a>
|
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -31,18 +31,21 @@
|
|||||||
<article>
|
<article>
|
||||||
<pre class="prettyprint linenums"><code>'use strict';
|
<pre class="prettyprint linenums"><code>'use strict';
|
||||||
|
|
||||||
|
const sharp = require('sharp');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const Crypto = require('crypto');
|
const Crypto = require('crypto');
|
||||||
const { tmpdir } = require('os');
|
const { tmpdir } = require('os');
|
||||||
const ffmpeg = require('fluent-ffmpeg');
|
const ffmpeg = require('fluent-ffmpeg');
|
||||||
const webp = require('node-webpmux');
|
const webp = require('node-webpmux');
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
|
|
||||||
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods
|
* Utility methods
|
||||||
*/
|
*/
|
||||||
class Util {
|
class Util {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
|
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
|
||||||
}
|
}
|
||||||
@@ -51,7 +54,7 @@ class Util {
|
|||||||
var result = '';
|
var result = '';
|
||||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
var charactersLength = characters.length;
|
var charactersLength = characters.length;
|
||||||
for (var i = 0; i &lt; length; i++) {
|
for ( var i = 0; i &lt; length; i++ ) {
|
||||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -83,19 +86,33 @@ class Util {
|
|||||||
*
|
*
|
||||||
* @returns {Promise&lt;MessageMedia>} media in webp format
|
* @returns {Promise&lt;MessageMedia>} media in webp format
|
||||||
*/
|
*/
|
||||||
static async formatImageToWebpSticker(media, pupPage) {
|
static async formatImageToWebpSticker(media) {
|
||||||
if (!media.mimetype.includes('image'))
|
if (!media.mimetype.includes('image'))
|
||||||
throw new Error('media is not a image');
|
throw new Error('media is not a image');
|
||||||
|
|
||||||
if (media.mimetype.includes('webp')) {
|
if (media.mimetype.includes('webp')) {
|
||||||
return media;
|
return media;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pupPage.evaluate((media) => {
|
const buff = Buffer.from(media.data, 'base64');
|
||||||
return window.WWebJS.toStickerData(media);
|
|
||||||
}, media);
|
let sharpImg = sharp(buff);
|
||||||
|
sharpImg = sharpImg.webp();
|
||||||
|
|
||||||
|
sharpImg = sharpImg.resize(512, 512, {
|
||||||
|
fit: 'contain',
|
||||||
|
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||||
|
});
|
||||||
|
|
||||||
|
let webpBase64 = (await sharpImg.toBuffer()).toString('base64');
|
||||||
|
|
||||||
|
return {
|
||||||
|
mimetype: 'image/webp',
|
||||||
|
data: webpBase64,
|
||||||
|
filename: media.filename,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a video to webp
|
* Formats a video to webp
|
||||||
* @param {MessageMedia} media
|
* @param {MessageMedia} media
|
||||||
@@ -105,14 +122,14 @@ class Util {
|
|||||||
static async formatVideoToWebpSticker(media) {
|
static async formatVideoToWebpSticker(media) {
|
||||||
if (!media.mimetype.includes('video'))
|
if (!media.mimetype.includes('video'))
|
||||||
throw new Error('media is not a video');
|
throw new Error('media is not a video');
|
||||||
|
|
||||||
const videoType = media.mimetype.split('/')[1];
|
const videoType = media.mimetype.split('/')[1];
|
||||||
|
|
||||||
const tempFile = path.join(
|
const tempFile = path.join(
|
||||||
tmpdir(),
|
tmpdir(),
|
||||||
`${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`
|
`${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`
|
||||||
);
|
);
|
||||||
|
|
||||||
const stream = new (require('stream').Readable)();
|
const stream = new (require('stream').Readable)();
|
||||||
const buffer = Buffer.from(
|
const buffer = Buffer.from(
|
||||||
media.data.replace(`data:${media.mimetype};base64,`, ''),
|
media.data.replace(`data:${media.mimetype};base64,`, ''),
|
||||||
@@ -149,17 +166,17 @@ class Util {
|
|||||||
.toFormat('webp')
|
.toFormat('webp')
|
||||||
.save(tempFile);
|
.save(tempFile);
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await fs.readFile(tempFile, 'base64');
|
const data = await fs.readFile(tempFile, 'base64');
|
||||||
await fs.unlink(tempFile);
|
await fs.unlink(tempFile);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mimetype: 'image/webp',
|
mimetype: 'image/webp',
|
||||||
data: data,
|
data: data,
|
||||||
filename: media.filename,
|
filename: media.filename,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sticker metadata.
|
* Sticker metadata.
|
||||||
* @typedef {Object} StickerMetadata
|
* @typedef {Object} StickerMetadata
|
||||||
@@ -175,14 +192,14 @@ class Util {
|
|||||||
*
|
*
|
||||||
* @returns {Promise&lt;MessageMedia>} media in webp format
|
* @returns {Promise&lt;MessageMedia>} media in webp format
|
||||||
*/
|
*/
|
||||||
static async formatToWebpSticker(media, metadata, pupPage) {
|
static async formatToWebpSticker(media, metadata) {
|
||||||
let webpMedia;
|
let webpMedia;
|
||||||
|
|
||||||
if (media.mimetype.includes('image'))
|
if (media.mimetype.includes('image'))
|
||||||
webpMedia = await this.formatImageToWebpSticker(media, pupPage);
|
webpMedia = await this.formatImageToWebpSticker(media);
|
||||||
else if (media.mimetype.includes('video'))
|
else if (media.mimetype.includes('video'))
|
||||||
webpMedia = await this.formatVideoToWebpSticker(media);
|
webpMedia = await this.formatVideoToWebpSticker(media);
|
||||||
else
|
else
|
||||||
throw new Error('Invalid media format');
|
throw new Error('Invalid media format');
|
||||||
|
|
||||||
if (metadata.name || metadata.author) {
|
if (metadata.name || metadata.author) {
|
||||||
@@ -225,7 +242,7 @@ module.exports = Util;
|
|||||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||||
<div id="jsdoc-footer-container">
|
<div id="jsdoc-footer-container">
|
||||||
<p>
|
<p>
|
||||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on February 11, 2023.
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
89
example.js
89
example.js
@@ -1,27 +1,42 @@
|
|||||||
const { Client, Location, List, Buttons, LocalAuth} = require('./index');
|
const fs = require('fs');
|
||||||
|
const { Client, Location, List, Buttons } = require('./index');
|
||||||
|
|
||||||
const client = new Client({
|
const SESSION_FILE_PATH = './session.json';
|
||||||
authStrategy: new LocalAuth(),
|
let sessionCfg;
|
||||||
puppeteer: { headless: false }
|
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.
|
||||||
|
|
||||||
|
// You also could connect to an existing instance of a browser
|
||||||
|
// {
|
||||||
|
// puppeteer: {
|
||||||
|
// browserWSEndpoint: `ws://localhost:3000`
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
client.initialize();
|
client.initialize();
|
||||||
|
|
||||||
client.on('loading_screen', (percent, message) => {
|
|
||||||
console.log('LOADING SCREEN', percent, message);
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('qr', (qr) => {
|
client.on('qr', (qr) => {
|
||||||
// NOTE: This event will not be fired if a session is specified.
|
// NOTE: This event will not be fired if a session is specified.
|
||||||
console.log('QR RECEIVED', qr);
|
console.log('QR RECEIVED', qr);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('authenticated', () => {
|
client.on('authenticated', (session) => {
|
||||||
console.log('AUTHENTICATED');
|
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 => {
|
client.on('auth_failure', msg => {
|
||||||
// Fired if session restore was unsuccessful
|
// Fired if session restore was unsuccessfull
|
||||||
console.error('AUTHENTICATION FAILURE', msg);
|
console.error('AUTHENTICATION FAILURE', msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -32,12 +47,6 @@ client.on('ready', () => {
|
|||||||
client.on('message', async msg => {
|
client.on('message', async msg => {
|
||||||
console.log('MESSAGE RECEIVED', msg);
|
console.log('MESSAGE RECEIVED', msg);
|
||||||
|
|
||||||
if (msg.selectedButtonId == 'test') {
|
|
||||||
return msg.reply('You clicked the button!');
|
|
||||||
} else if (msg.selectedRowId == 'test') {
|
|
||||||
return msg.reply('You clicked that section');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg.body === '!ping reply') {
|
if (msg.body === '!ping reply') {
|
||||||
// Send a new message as a reply to the current one
|
// Send a new message as a reply to the current one
|
||||||
msg.reply('pong');
|
msg.reply('pong');
|
||||||
@@ -115,8 +124,9 @@ client.on('message', async msg => {
|
|||||||
client.sendMessage(msg.from, `
|
client.sendMessage(msg.from, `
|
||||||
*Connection info*
|
*Connection info*
|
||||||
User name: ${info.pushname}
|
User name: ${info.pushname}
|
||||||
My number: ${info.wid.user}
|
My number: ${info.me.user}
|
||||||
Platform: ${info.platform}
|
Platform: ${info.platform}
|
||||||
|
WhatsApp version: ${info.phone.wa_version}
|
||||||
`);
|
`);
|
||||||
} else if (msg.body === '!mediainfo' && msg.hasMedia) {
|
} else if (msg.body === '!mediainfo' && msg.hasMedia) {
|
||||||
const attachmentData = await msg.downloadMedia();
|
const attachmentData = await msg.downloadMedia();
|
||||||
@@ -195,30 +205,12 @@ client.on('message', async msg => {
|
|||||||
client.interface.openChatWindowAt(quotedMsg.id._serialized);
|
client.interface.openChatWindowAt(quotedMsg.id._serialized);
|
||||||
}
|
}
|
||||||
} else if (msg.body === '!buttons') {
|
} else if (msg.body === '!buttons') {
|
||||||
let button = new Buttons(
|
let button = new Buttons('Button body',[{body:'bt1'},{body:'bt2'},{body:'bt3'}],'title','footer');
|
||||||
'Button body\n\nWant to test buttons some more? Check out https://github.com/wwebjs/buttons-test',
|
|
||||||
[
|
|
||||||
{ body: 'Some text' },
|
|
||||||
{ body: 'Try clicking me (id:test)', id: 'test'},
|
|
||||||
],
|
|
||||||
'title',
|
|
||||||
'footer'
|
|
||||||
);
|
|
||||||
client.sendMessage(msg.from, button);
|
client.sendMessage(msg.from, button);
|
||||||
} else if (msg.body === '!list') {
|
} else if (msg.body === '!list') {
|
||||||
let sections = [
|
let sections = [{title:'sectionTitle',rows:[{title:'ListItem1', description: 'desc'},{title:'ListItem2'}]}];
|
||||||
{
|
let list = new List('List body','btnText',sections,'Title','footer');
|
||||||
title: 'Secton title',
|
client.sendMessage(msg.from, list);
|
||||||
rows: [
|
|
||||||
{title:'ListItem1', description: 'desc'},
|
|
||||||
{title: 'Try clicking me (id: test)', id: 'test'}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];
|
|
||||||
let list = new List('List body', 'btnText', sections, 'Custom title', 'custom footer, google.com');
|
|
||||||
await client.sendMessage(msg.from, list);
|
|
||||||
} else if (msg.body === '!reaction') {
|
|
||||||
await msg.react('👍');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -275,17 +267,14 @@ client.on('group_update', (notification) => {
|
|||||||
console.log('update', notification);
|
console.log('update', notification);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('change_state', state => {
|
client.on('change_battery', (batteryInfo) => {
|
||||||
console.log('CHANGE STATE', state );
|
// Battery percentage for attached device has changed
|
||||||
|
const { battery, plugged } = batteryInfo;
|
||||||
|
console.log(`Battery: ${battery}% - Charging? ${plugged}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Change to false if you don't want to reject incoming calls
|
client.on('change_state', state => {
|
||||||
let rejectCalls = true;
|
console.log('CHANGE STATE', state );
|
||||||
|
|
||||||
client.on('call', async (call) => {
|
|
||||||
console.log('Call received, rejecting. GOTO Line 261 to disable', call);
|
|
||||||
if (rejectCalls) await call.reject();
|
|
||||||
await client.sendMessage(call.from, `[${call.fromMe ? 'Outgoing' : 'Incoming'}] Phone call from ${call.from}, type ${call.isGroup ? 'group' : ''} ${call.isVideo ? 'video' : 'audio'} call. ${rejectCalls ? 'This call was automatically rejected by the script.' : ''}`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('disconnected', (reason) => {
|
client.on('disconnected', (reason) => {
|
||||||
|
|||||||
287
index.d.ts
vendored
287
index.d.ts
vendored
@@ -1,9 +1,7 @@
|
|||||||
|
|
||||||
import { EventEmitter } from 'events'
|
import { EventEmitter } from 'events'
|
||||||
import { RequestInit } from 'node-fetch'
|
import { RequestInit } from 'node-fetch'
|
||||||
import { ButtonSpec, FormattedButtonSpec } from './src/structures/Buttons'
|
import puppeteer = require('puppeteer')
|
||||||
import { FormattedSectionSpec, SectionSpec } from './src/structures/List'
|
|
||||||
import * as puppeteer from 'puppeteer'
|
|
||||||
|
|
||||||
declare namespace WAWebJS {
|
declare namespace WAWebJS {
|
||||||
|
|
||||||
@@ -50,9 +48,6 @@ declare namespace WAWebJS {
|
|||||||
/** Logs out the client, closing the current session */
|
/** Logs out the client, closing the current session */
|
||||||
logout(): Promise<void>
|
logout(): Promise<void>
|
||||||
|
|
||||||
/** Get all blocked contacts by host account */
|
|
||||||
getBlockedContacts(): Promise<Contact[]>
|
|
||||||
|
|
||||||
/** Get chat instance by ID */
|
/** Get chat instance by ID */
|
||||||
getChatById(chatId: string): Promise<Chat>
|
getChatById(chatId: string): Promise<Chat>
|
||||||
|
|
||||||
@@ -64,12 +59,6 @@ declare namespace WAWebJS {
|
|||||||
|
|
||||||
/** Get all current contact instances */
|
/** Get all current contact instances */
|
||||||
getContacts(): Promise<Contact[]>
|
getContacts(): Promise<Contact[]>
|
||||||
|
|
||||||
/** Get the country code of a WhatsApp ID. (154185968@c.us) => (1) */
|
|
||||||
getCountryCode(number: string): Promise<string>
|
|
||||||
|
|
||||||
/** Get the formatted number of a WhatsApp ID. (12345678901@c.us) => (+1 (234) 5678-901) */
|
|
||||||
getFormattedNumber(number: string): Promise<string>
|
|
||||||
|
|
||||||
/** Get all current Labels */
|
/** Get all current Labels */
|
||||||
getLabels(): Promise<Label[]>
|
getLabels(): Promise<Label[]>
|
||||||
@@ -86,9 +75,6 @@ declare namespace WAWebJS {
|
|||||||
/** Returns the contact ID's profile picture URL, if privacy settings allow it */
|
/** Returns the contact ID's profile picture URL, if privacy settings allow it */
|
||||||
getProfilePicUrl(contactId: string): Promise<string>
|
getProfilePicUrl(contactId: string): Promise<string>
|
||||||
|
|
||||||
/** Gets the Contact's common groups with you. Returns empty array if you don't have any common group. */
|
|
||||||
getCommonGroups(contactId: string): Promise<ChatId[]>
|
|
||||||
|
|
||||||
/** Gets the current connection state for the client */
|
/** Gets the current connection state for the client */
|
||||||
getState(): Promise<WAState>
|
getState(): Promise<WAState>
|
||||||
|
|
||||||
@@ -105,27 +91,24 @@ declare namespace WAWebJS {
|
|||||||
getNumberId(number: string): Promise<ContactId | null>
|
getNumberId(number: string): Promise<ContactId | null>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutes this chat forever, unless a date is specified
|
* Mutes the Chat until a specified date
|
||||||
* @param chatId ID of the chat that will be muted
|
* @param chatId ID of the chat that will be muted
|
||||||
* @param unmuteDate Date when the chat will be unmuted, leave as is to mute forever
|
* @param unmuteDate Date when the chat will be unmuted
|
||||||
*/
|
*/
|
||||||
muteChat(chatId: string, unmuteDate?: Date): Promise<void>
|
muteChat(chatId: string, unmuteDate: Date): Promise<void>
|
||||||
|
|
||||||
/** Force reset of connection state for the client */
|
/** Force reset of connection state for the client */
|
||||||
resetState(): Promise<void>
|
resetState(): Promise<void>
|
||||||
|
|
||||||
/** Send a message to a specific chatId */
|
/** Send a message to a specific chatId */
|
||||||
sendMessage(chatId: string, content: MessageContent, options?: MessageSendOptions): Promise<Message>
|
sendMessage(chatId: string, content: MessageContent, options?: MessageSendOptions): Promise<Message>
|
||||||
|
|
||||||
/** Searches for messages */
|
/** Searches for messages */
|
||||||
searchMessages(query: string, options?: { chatId?: string, page?: number, limit?: number }): Promise<Message[]>
|
searchMessages(query: string, options?: { chatId?: string, page?: number, limit?: number }): Promise<Message[]>
|
||||||
|
|
||||||
/** Marks the client as online */
|
/** Marks the client as online */
|
||||||
sendPresenceAvailable(): Promise<void>
|
sendPresenceAvailable(): Promise<void>
|
||||||
|
|
||||||
/** Marks the client as offline */
|
|
||||||
sendPresenceUnavailable(): Promise<void>
|
|
||||||
|
|
||||||
/** Mark as seen for the Chat */
|
/** Mark as seen for the Chat */
|
||||||
sendSeen(chatId: string): Promise<boolean>
|
sendSeen(chatId: string): Promise<boolean>
|
||||||
|
|
||||||
@@ -142,8 +125,8 @@ declare namespace WAWebJS {
|
|||||||
* Sets the current user's display name
|
* Sets the current user's display name
|
||||||
* @param displayName New display name
|
* @param displayName New display name
|
||||||
*/
|
*/
|
||||||
setDisplayName(displayName: string): Promise<boolean>
|
setDisplayName(displayName: string): Promise<void>
|
||||||
|
|
||||||
/** Changes and returns the archive state of the Chat */
|
/** Changes and returns the archive state of the Chat */
|
||||||
unarchiveChat(chatId: string): Promise<boolean>
|
unarchiveChat(chatId: string): Promise<boolean>
|
||||||
|
|
||||||
@@ -158,16 +141,11 @@ declare namespace WAWebJS {
|
|||||||
|
|
||||||
/** Emitted when authentication is successful */
|
/** Emitted when authentication is successful */
|
||||||
on(event: 'authenticated', listener: (
|
on(event: 'authenticated', listener: (
|
||||||
/**
|
/** Object containing session information. Can be used to restore the session */
|
||||||
* Object containing session information, when using LegacySessionAuth. Can be used to restore the session
|
session: ClientSession
|
||||||
*/
|
|
||||||
session?: ClientSession
|
|
||||||
) => void): this
|
) => void): this
|
||||||
|
|
||||||
/**
|
/** Emitted when the battery percentage for the attached device changes */
|
||||||
* Emitted when the battery percentage for the attached device changes
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
on(event: 'change_battery', listener: (batteryInfo: BatteryInfo) => void): this
|
on(event: 'change_battery', listener: (batteryInfo: BatteryInfo) => void): this
|
||||||
|
|
||||||
/** Emitted when the connection state changes */
|
/** Emitted when the connection state changes */
|
||||||
@@ -179,7 +157,7 @@ declare namespace WAWebJS {
|
|||||||
/** Emitted when the client has been disconnected */
|
/** Emitted when the client has been disconnected */
|
||||||
on(event: 'disconnected', listener: (
|
on(event: 'disconnected', listener: (
|
||||||
/** reason that caused the disconnect */
|
/** reason that caused the disconnect */
|
||||||
reason: WAState | "NAVIGATION"
|
reason: WAState | "NAVIGATED"
|
||||||
) => void): this
|
) => void): this
|
||||||
|
|
||||||
/** Emitted when a user joins the chat via invite link or is added by an admin */
|
/** Emitted when a user joins the chat via invite link or is added by an admin */
|
||||||
@@ -243,15 +221,6 @@ declare namespace WAWebJS {
|
|||||||
message: Message
|
message: Message
|
||||||
) => void): this
|
) => void): this
|
||||||
|
|
||||||
/** Emitted when a reaction is sent, received, updated or removed */
|
|
||||||
on(event: 'message_reaction', listener: (
|
|
||||||
/** The reaction object */
|
|
||||||
reaction: Reaction
|
|
||||||
) => void): this
|
|
||||||
|
|
||||||
/** Emitted when loading screen is appearing */
|
|
||||||
on(event: 'loading_screen', listener: (percent: string, message: string) => void): this
|
|
||||||
|
|
||||||
/** Emitted when the QR code is received */
|
/** Emitted when the QR code is received */
|
||||||
on(event: 'qr', listener: (
|
on(event: 'qr', listener: (
|
||||||
/** qr code string
|
/** qr code string
|
||||||
@@ -267,9 +236,6 @@ declare namespace WAWebJS {
|
|||||||
|
|
||||||
/** Emitted when the client has initialized and is ready to receive messages */
|
/** Emitted when the client has initialized and is ready to receive messages */
|
||||||
on(event: 'ready', listener: () => void): this
|
on(event: 'ready', listener: () => void): this
|
||||||
|
|
||||||
/** Emitted when the RemoteAuth session is saved successfully on the external Database */
|
|
||||||
on(event: 'remote_session_saved', listener: () => void): this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Current connection information */
|
/** Current connection information */
|
||||||
@@ -281,10 +247,7 @@ declare namespace WAWebJS {
|
|||||||
me: ContactId
|
me: ContactId
|
||||||
/** Current user ID */
|
/** Current user ID */
|
||||||
wid: ContactId
|
wid: ContactId
|
||||||
/**
|
/** Information about the phone this client is connected to */
|
||||||
* Information about the phone this client is connected to. Not available in multi-device.
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
phone: ClientInfoPhone
|
phone: ClientInfoPhone
|
||||||
/** Platform the phone is running on */
|
/** Platform the phone is running on */
|
||||||
platform: string
|
platform: string
|
||||||
@@ -295,10 +258,7 @@ declare namespace WAWebJS {
|
|||||||
getBatteryStatus: () => Promise<BatteryInfo>
|
getBatteryStatus: () => Promise<BatteryInfo>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Information about the phone this client is connected to */
|
||||||
* Information about the phone this client is connected to
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export interface ClientInfoPhone {
|
export interface ClientInfoPhone {
|
||||||
/** WhatsApp Version running on the phone */
|
/** WhatsApp Version running on the phone */
|
||||||
wa_version: string
|
wa_version: string
|
||||||
@@ -315,22 +275,20 @@ declare namespace WAWebJS {
|
|||||||
/** Options for initializing the whatsapp client */
|
/** Options for initializing the whatsapp client */
|
||||||
export interface ClientOptions {
|
export interface ClientOptions {
|
||||||
/** Timeout for authentication selector in puppeteer
|
/** Timeout for authentication selector in puppeteer
|
||||||
* @default 0 */
|
* @default 45000 */
|
||||||
authTimeoutMs?: number,
|
authTimeoutMs?: number,
|
||||||
/** Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/ */
|
/** Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/ */
|
||||||
puppeteer?: puppeteer.PuppeteerNodeLaunchOptions & puppeteer.ConnectOptions
|
puppeteer?: puppeteer.LaunchOptions
|
||||||
/** Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used. */
|
/** Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
|
||||||
authStrategy?: AuthStrategy,
|
* @default 20000 */
|
||||||
/** How many times should the qrcode be refreshed before giving up
|
qrRefreshIntervalMs?: number
|
||||||
* @default 0 (disabled) */
|
/** Timeout for qr code selector in puppeteer
|
||||||
qrMaxRetries?: number,
|
* @default 45000 */
|
||||||
/**
|
qrTimeoutMs?: number,
|
||||||
* @deprecated This option should be set directly on the LegacySessionAuth
|
/** Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||||
*/
|
* @default false */
|
||||||
restartOnAuthFail?: boolean
|
restartOnAuthFail?: boolean
|
||||||
/**
|
/** Whatsapp session to restore. If not set, will start a new session */
|
||||||
* @deprecated Only here for backwards-compatibility. You should move to using LocalAuth, or set the authStrategy to LegacySessionAuth explicitly.
|
|
||||||
*/
|
|
||||||
session?: ClientSession
|
session?: ClientSession
|
||||||
/** If another whatsapp web session is detected (another browser), take over the session in the current browser
|
/** If another whatsapp web session is detected (another browser), take over the session in the current browser
|
||||||
* @default false */
|
* @default false */
|
||||||
@@ -346,81 +304,7 @@ declare namespace WAWebJS {
|
|||||||
ffmpegPath?: string
|
ffmpegPath?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Represents a Whatsapp client session */
|
||||||
* Base class which all authentication strategies extend
|
|
||||||
*/
|
|
||||||
export abstract class AuthStrategy {
|
|
||||||
setup: (client: Client) => void;
|
|
||||||
beforeBrowserInitialized: () => Promise<void>;
|
|
||||||
afterBrowserInitialized: () => Promise<void>;
|
|
||||||
onAuthenticationNeeded: () => Promise<{
|
|
||||||
failed?: boolean;
|
|
||||||
restart?: boolean;
|
|
||||||
failureEventPayload?: any
|
|
||||||
}>;
|
|
||||||
getAuthEventPayload: () => Promise<any>;
|
|
||||||
afterAuthReady: () => Promise<void>;
|
|
||||||
disconnect: () => Promise<void>;
|
|
||||||
destroy: () => Promise<void>;
|
|
||||||
logout: () => Promise<void>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No session restoring functionality
|
|
||||||
* Will need to authenticate via QR code every time
|
|
||||||
*/
|
|
||||||
export class NoAuth extends AuthStrategy {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Local directory-based authentication
|
|
||||||
*/
|
|
||||||
export class LocalAuth extends AuthStrategy {
|
|
||||||
public clientId?: string;
|
|
||||||
public dataPath?: string;
|
|
||||||
constructor(options?: {
|
|
||||||
clientId?: string,
|
|
||||||
dataPath?: string
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remote-based authentication
|
|
||||||
*/
|
|
||||||
export class RemoteAuth extends AuthStrategy {
|
|
||||||
public clientId?: string;
|
|
||||||
public dataPath?: string;
|
|
||||||
constructor(options?: {
|
|
||||||
store: Store,
|
|
||||||
clientId?: string,
|
|
||||||
dataPath?: string,
|
|
||||||
backupSyncIntervalMs: number
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remote store interface
|
|
||||||
*/
|
|
||||||
export interface Store {
|
|
||||||
sessionExists: (options: { session: string }) => Promise<boolean> | boolean,
|
|
||||||
delete: (options: { session: string }) => Promise<any> | any,
|
|
||||||
save: (options: { session: string }) => Promise<any> | any,
|
|
||||||
extract: (options: { session: string, path: string }) => Promise<any> | any,
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Legacy session auth strategy
|
|
||||||
* Not compatible with multi-device accounts.
|
|
||||||
*/
|
|
||||||
export class LegacySessionAuth extends AuthStrategy {
|
|
||||||
constructor(options?: {
|
|
||||||
session?: ClientSession,
|
|
||||||
restartOnAuthFail?: boolean,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a WhatsApp client session
|
|
||||||
*/
|
|
||||||
export interface ClientSession {
|
export interface ClientSession {
|
||||||
WABrowserId: string,
|
WABrowserId: string,
|
||||||
WASecretBundle: string,
|
WASecretBundle: string,
|
||||||
@@ -428,9 +312,6 @@ declare namespace WAWebJS {
|
|||||||
WAToken2: string,
|
WAToken2: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export interface BatteryInfo {
|
export interface BatteryInfo {
|
||||||
/** The current battery percentage */
|
/** The current battery percentage */
|
||||||
battery: number,
|
battery: number,
|
||||||
@@ -504,12 +385,9 @@ declare namespace WAWebJS {
|
|||||||
GROUP_LEAVE = 'group_leave',
|
GROUP_LEAVE = 'group_leave',
|
||||||
GROUP_UPDATE = 'group_update',
|
GROUP_UPDATE = 'group_update',
|
||||||
QR_RECEIVED = 'qr',
|
QR_RECEIVED = 'qr',
|
||||||
LOADING_SCREEN = 'loading_screen',
|
|
||||||
DISCONNECTED = 'disconnected',
|
DISCONNECTED = 'disconnected',
|
||||||
STATE_CHANGED = 'change_state',
|
STATE_CHANGED = 'change_state',
|
||||||
BATTERY_CHANGED = 'change_battery',
|
BATTERY_CHANGED = 'change_battery',
|
||||||
REMOTE_SESSION_SAVED = 'remote_session_saved',
|
|
||||||
CALL = 'call'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Group notification types */
|
/** Group notification types */
|
||||||
@@ -553,25 +431,6 @@ declare namespace WAWebJS {
|
|||||||
PAYMENT = 'payment',
|
PAYMENT = 'payment',
|
||||||
UNKNOWN = 'unknown',
|
UNKNOWN = 'unknown',
|
||||||
GROUP_INVITE = 'groups_v4_invite',
|
GROUP_INVITE = 'groups_v4_invite',
|
||||||
LIST = 'list',
|
|
||||||
LIST_RESPONSE = 'list_response',
|
|
||||||
BUTTONS_RESPONSE = 'buttons_response',
|
|
||||||
BROADCAST_NOTIFICATION = 'broadcast_notification',
|
|
||||||
CALL_LOG = 'call_log',
|
|
||||||
CIPHERTEXT = 'ciphertext',
|
|
||||||
DEBUG = 'debug',
|
|
||||||
E2E_NOTIFICATION = 'e2e_notification',
|
|
||||||
GP2 = 'gp2',
|
|
||||||
GROUP_NOTIFICATION = 'group_notification',
|
|
||||||
HSM = 'hsm',
|
|
||||||
INTERACTIVE = 'interactive',
|
|
||||||
NATIVE_FLOW = 'native_flow',
|
|
||||||
NOTIFICATION = 'notification',
|
|
||||||
NOTIFICATION_TEMPLATE = 'notification_template',
|
|
||||||
OVERSIZED = 'oversized',
|
|
||||||
PROTOCOL = 'protocol',
|
|
||||||
REACTION = 'reaction',
|
|
||||||
TEMPLATE_BUTTON_REPLY = 'template_button_reply',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Client status */
|
/** Client status */
|
||||||
@@ -648,18 +507,12 @@ declare namespace WAWebJS {
|
|||||||
ack: MessageAck,
|
ack: MessageAck,
|
||||||
/** If the message was sent to a group, this field will contain the user that sent the message. */
|
/** If the message was sent to a group, this field will contain the user that sent the message. */
|
||||||
author?: string,
|
author?: string,
|
||||||
/** String that represents from which device type the message was sent */
|
|
||||||
deviceType: string,
|
|
||||||
/** Message content */
|
/** Message content */
|
||||||
body: string,
|
body: string,
|
||||||
/** Indicates if the message was a broadcast */
|
/** Indicates if the message was a broadcast */
|
||||||
broadcast: boolean,
|
broadcast: boolean,
|
||||||
/** Indicates if the message was a status update */
|
/** Indicates if the message was a status update */
|
||||||
isStatus: boolean,
|
isStatus: boolean,
|
||||||
/** Indicates if the message is a Gif */
|
|
||||||
isGif: boolean,
|
|
||||||
/** Indicates if the message will disappear after it expires */
|
|
||||||
isEphemeral: boolean,
|
|
||||||
/** ID for the Chat that this message was sent to, except if the message was sent by the current user */
|
/** ID for the Chat that this message was sent to, except if the message was sent by the current user */
|
||||||
from: string,
|
from: string,
|
||||||
/** Indicates if the message was sent by the current user */
|
/** Indicates if the message was sent by the current user */
|
||||||
@@ -668,8 +521,6 @@ declare namespace WAWebJS {
|
|||||||
hasMedia: boolean,
|
hasMedia: boolean,
|
||||||
/** Indicates if the message was sent as a reply to another message */
|
/** Indicates if the message was sent as a reply to another message */
|
||||||
hasQuotedMsg: boolean,
|
hasQuotedMsg: boolean,
|
||||||
/** Indicates the duration of the message in seconds */
|
|
||||||
duration: string,
|
|
||||||
/** ID that represents the message */
|
/** ID that represents the message */
|
||||||
id: MessageId,
|
id: MessageId,
|
||||||
/** Indicates if the message was forwarded */
|
/** Indicates if the message was forwarded */
|
||||||
@@ -722,18 +573,11 @@ declare namespace WAWebJS {
|
|||||||
selectedButtonId?: string,
|
selectedButtonId?: string,
|
||||||
/** Selected list row ID */
|
/** Selected list row ID */
|
||||||
selectedRowId?: string,
|
selectedRowId?: string,
|
||||||
/** Returns message in a raw format */
|
|
||||||
rawData: object,
|
|
||||||
/*
|
|
||||||
* Reloads this Message object's data in-place with the latest values from WhatsApp Web.
|
|
||||||
* Note that the Message must still be in the web app cache for this to work, otherwise will return null.
|
|
||||||
*/
|
|
||||||
reload: () => Promise<Message>,
|
|
||||||
/** Accept the Group V4 Invite in message */
|
/** Accept the Group V4 Invite in message */
|
||||||
acceptGroupV4Invite: () => Promise<{status: number}>,
|
acceptGroupV4Invite: () => Promise<{status: number}>,
|
||||||
/** Deletes the message from the chat */
|
/** Deletes the message from the chat */
|
||||||
delete: (everyone?: boolean) => Promise<void>,
|
delete: (everyone?: boolean) => Promise<void>,
|
||||||
/** Downloads and returns the attached message media */
|
/** Downloads and returns the attatched message media */
|
||||||
downloadMedia: () => Promise<MessageMedia>,
|
downloadMedia: () => Promise<MessageMedia>,
|
||||||
/** Returns the Chat this message was sent in */
|
/** Returns the Chat this message was sent in */
|
||||||
getChat: () => Promise<Chat>,
|
getChat: () => Promise<Chat>,
|
||||||
@@ -749,26 +593,24 @@ declare namespace WAWebJS {
|
|||||||
* If not, it will send the message in the same Chat as the original message was sent.
|
* 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>,
|
reply: (content: MessageContent, chatId?: string, options?: MessageSendOptions) => Promise<Message>,
|
||||||
/** React to this message with an emoji*/
|
|
||||||
react: (reaction: string) => Promise<void>,
|
|
||||||
/**
|
/**
|
||||||
* Forwards this message to another chat (that you chatted before, otherwise it will fail)
|
* Forwards this message to another chat
|
||||||
*/
|
*/
|
||||||
forward: (chat: Chat | string) => Promise<void>,
|
forward: (chat: Chat | string) => Promise<void>,
|
||||||
/** Star this message */
|
/** Star this message */
|
||||||
star: () => Promise<void>,
|
star: () => Promise<void>,
|
||||||
/** Unstar this message */
|
/** Unstar this message */
|
||||||
unstar: () => Promise<void>,
|
unstar: () => Promise<void>,
|
||||||
/** Get information about message delivery status */
|
/** Get information about message delivery statuso */
|
||||||
getInfo: () => Promise<MessageInfo | null>,
|
getInfo: () => Promise<MessageInfo | null>,
|
||||||
/**
|
/**
|
||||||
* Gets the order associated with a given message
|
* Gets the order associated with a given message
|
||||||
*/
|
*/
|
||||||
getOrder: () => Promise<Order>,
|
getOrder: () => Order,
|
||||||
/**
|
/**
|
||||||
* Gets the payment details associated with a given message
|
* Gets the payment details associated with a given message
|
||||||
*/
|
*/
|
||||||
getPayment: () => Promise<Payment>,
|
getPayment: () => Payment,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ID that represents a message */
|
/** ID that represents a message */
|
||||||
@@ -802,7 +644,7 @@ declare namespace WAWebJS {
|
|||||||
|
|
||||||
/** Options for sending a message */
|
/** Options for sending a message */
|
||||||
export interface MessageSendOptions {
|
export interface MessageSendOptions {
|
||||||
/** Show links preview. Has no effect on multi-device accounts. */
|
/** Show links preview */
|
||||||
linkPreview?: boolean
|
linkPreview?: boolean
|
||||||
/** Send audio as voice message */
|
/** Send audio as voice message */
|
||||||
sendAudioAsVoice?: boolean
|
sendAudioAsVoice?: boolean
|
||||||
@@ -836,7 +678,6 @@ declare namespace WAWebJS {
|
|||||||
|
|
||||||
export interface MediaFromURLOptions {
|
export interface MediaFromURLOptions {
|
||||||
client?: Client
|
client?: Client
|
||||||
filename?: string
|
|
||||||
unsafeMime?: boolean
|
unsafeMime?: boolean
|
||||||
reqOptions?: RequestInit
|
reqOptions?: RequestInit
|
||||||
}
|
}
|
||||||
@@ -849,16 +690,13 @@ declare namespace WAWebJS {
|
|||||||
data: string
|
data: string
|
||||||
/** Document file name. Value can be null */
|
/** Document file name. Value can be null */
|
||||||
filename?: string | null
|
filename?: string | null
|
||||||
/** Document file size in bytes. Value can be null. */
|
|
||||||
filesize?: number | null
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} mimetype MIME type of the attachment
|
* @param {string} mimetype MIME type of the attachment
|
||||||
* @param {string} data Base64-encoded data of the file
|
* @param {string} data Base64-encoded data of the file
|
||||||
* @param {?string} filename Document file name. Value can be null
|
* @param {?string} filename Document file name. Value can be null
|
||||||
* @param {?number} filesize Document file size in bytes. Value can be null.
|
|
||||||
*/
|
*/
|
||||||
constructor(mimetype: string, data: string, filename?: string | null, filesize?: number | null)
|
constructor(mimetype: string, data: string, filename?: string | null)
|
||||||
|
|
||||||
/** Creates a MessageMedia instance from a local file path */
|
/** Creates a MessageMedia instance from a local file path */
|
||||||
static fromFilePath: (filePath: string) => MessageMedia
|
static fromFilePath: (filePath: string) => MessageMedia
|
||||||
@@ -867,7 +705,7 @@ declare namespace WAWebJS {
|
|||||||
static fromUrl: (url: string, options?: MediaFromURLOptions) => Promise<MessageMedia>
|
static fromUrl: (url: string, options?: MediaFromURLOptions) => Promise<MessageMedia>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MessageContent = string | MessageMedia | Location | Contact | Contact[] | List | Buttons
|
export type MessageContent = string | MessageMedia | Location | Contact | Contact[]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Contact on WhatsApp
|
* Represents a Contact on WhatsApp
|
||||||
@@ -945,24 +783,14 @@ declare namespace WAWebJS {
|
|||||||
* Will return null when getting chat for currently logged in user.
|
* Will return null when getting chat for currently logged in user.
|
||||||
*/
|
*/
|
||||||
getChat: () => Promise<Chat>,
|
getChat: () => Promise<Chat>,
|
||||||
|
|
||||||
/** Returns the contact's countrycode, (1541859685@c.us) => (1) */
|
|
||||||
getCountryCode(): Promise<string>,
|
|
||||||
|
|
||||||
/** Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901) */
|
|
||||||
getFormattedNumber(): Promise<string>,
|
|
||||||
|
|
||||||
/** Blocks this contact from WhatsApp */
|
/** Blocks this contact from WhatsApp */
|
||||||
block: () => Promise<boolean>,
|
block: () => Promise<boolean>,
|
||||||
|
|
||||||
/** Unlocks this contact from WhatsApp */
|
/** Unlocks this contact from WhatsApp */
|
||||||
unblock: () => Promise<boolean>,
|
unblock: () => Promise<boolean>,
|
||||||
|
|
||||||
/** Gets the Contact's current "about" info. Returns null if you don't have permission to read their status. */
|
/** Gets the Contact's current "about" info. Returns null if you don't have permission to read their status. */
|
||||||
getAbout: () => Promise<string | null>,
|
getAbout: () => Promise<string | null>,
|
||||||
|
|
||||||
/** Gets the Contact's common groups with you. Returns empty array if you don't have any common group. */
|
|
||||||
getCommonGroups: () => Promise<ChatId[]>
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1036,8 +864,8 @@ declare namespace WAWebJS {
|
|||||||
delete: () => Promise<boolean>,
|
delete: () => Promise<boolean>,
|
||||||
/** Loads chat messages, sorted from earliest to latest. */
|
/** Loads chat messages, sorted from earliest to latest. */
|
||||||
fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>,
|
fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>,
|
||||||
/** Mutes this chat forever, unless a date is specified */
|
/** Mutes this chat until a specified date */
|
||||||
mute: (unmuteDate?: Date) => Promise<void>,
|
mute: (unmuteDate: Date) => Promise<void>,
|
||||||
/** Send a message to this chat */
|
/** Send a message to this chat */
|
||||||
sendMessage: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
|
sendMessage: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
|
||||||
/** Set the message as seen */
|
/** Set the message as seen */
|
||||||
@@ -1060,15 +888,12 @@ declare namespace WAWebJS {
|
|||||||
|
|
||||||
export interface MessageSearchOptions {
|
export interface MessageSearchOptions {
|
||||||
/**
|
/**
|
||||||
* The amount of messages to return. If no limit is specified, the available messages will be returned.
|
* 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.
|
* 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.
|
* Set this to Infinity to load all messages.
|
||||||
|
* @default 50
|
||||||
*/
|
*/
|
||||||
limit?: number
|
limit?: number
|
||||||
/**
|
|
||||||
* Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.
|
|
||||||
*/
|
|
||||||
fromMe?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1110,7 +935,7 @@ declare namespace WAWebJS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Promotes or demotes participants by IDs to regular users or admins */
|
/** Promotes or demotes participants by IDs to regular users or admins */
|
||||||
export type ChangeParticipantsPermissions =
|
export type ChangeParticipantsPermisions =
|
||||||
(participantIds: Array<string>) => Promise<{ status: number }>
|
(participantIds: Array<string>) => Promise<{ status: number }>
|
||||||
|
|
||||||
/** Adds or removes a list of participants by ID to the group */
|
/** Adds or removes a list of participants by ID to the group */
|
||||||
@@ -1140,13 +965,13 @@ declare namespace WAWebJS {
|
|||||||
/** Removes a list of participants by ID to the group */
|
/** Removes a list of participants by ID to the group */
|
||||||
removeParticipants: ChangeGroupParticipants;
|
removeParticipants: ChangeGroupParticipants;
|
||||||
/** Promotes participants by IDs to admins */
|
/** Promotes participants by IDs to admins */
|
||||||
promoteParticipants: ChangeParticipantsPermissions;
|
promoteParticipants: ChangeParticipantsPermisions;
|
||||||
/** Demotes participants by IDs to regular users */
|
/** Demotes participants by IDs to regular users */
|
||||||
demoteParticipants: ChangeParticipantsPermissions;
|
demoteParticipants: ChangeParticipantsPermisions;
|
||||||
/** Updates the group subject */
|
/** Updates the group subject */
|
||||||
setSubject: (subject: string) => Promise<boolean>;
|
setSubject: (subject: string) => Promise<void>;
|
||||||
/** Updates the group description */
|
/** Updates the group description */
|
||||||
setDescription: (description: string) => Promise<boolean>;
|
setDescription: (description: string) => Promise<void>;
|
||||||
/** Updates the group settings to only allow admins to send messages
|
/** Updates the group settings to only allow admins to send messages
|
||||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||||
@@ -1329,43 +1154,27 @@ declare namespace WAWebJS {
|
|||||||
webClientShouldHandle: boolean,
|
webClientShouldHandle: boolean,
|
||||||
/** Object with participants */
|
/** Object with participants */
|
||||||
participants: object
|
participants: object
|
||||||
|
|
||||||
/** Reject the call */
|
|
||||||
reject: () => Promise<void>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Message type List */
|
/** Message type List */
|
||||||
export class List {
|
export class List {
|
||||||
body: string
|
body: string
|
||||||
buttonText: string
|
buttonText: string
|
||||||
sections: Array<FormattedSectionSpec>
|
sections: Array<any>
|
||||||
title?: string | null
|
title?: string | null
|
||||||
footer?: string | null
|
footer?: string | null
|
||||||
|
|
||||||
constructor(body: string, buttonText: string, sections: Array<SectionSpec>, title?: string | null, footer?: string | null)
|
constructor(body: string, buttonText: string, sections: Array<any>, title?: string | null, footer?: string | null)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Message type Buttons */
|
/** Message type buttons */
|
||||||
export class Buttons {
|
export class Buttons {
|
||||||
body: string | MessageMedia
|
body: string | MessageMedia
|
||||||
buttons: FormattedButtonSpec
|
buttons: Array<Array<string>>
|
||||||
title?: string | null
|
title?: string | null
|
||||||
footer?: string | null
|
footer?: string | null
|
||||||
|
|
||||||
constructor(body: string, buttons: Array<ButtonSpec>, title?: string | null, footer?: string | null)
|
constructor(body: string, buttons: Array<Array<string>>, title?: string | null, footer?: string | null)
|
||||||
}
|
|
||||||
|
|
||||||
/** Message type Reaction */
|
|
||||||
export class Reaction {
|
|
||||||
id: MessageId
|
|
||||||
orphan: number
|
|
||||||
orphanReason?: string
|
|
||||||
timestamp: number
|
|
||||||
reaction: string
|
|
||||||
read: boolean
|
|
||||||
msgId: MessageId
|
|
||||||
senderId: string
|
|
||||||
ack?: number
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
7
index.js
7
index.js
@@ -21,12 +21,5 @@ module.exports = {
|
|||||||
ProductMetadata: require('./src/structures/ProductMetadata'),
|
ProductMetadata: require('./src/structures/ProductMetadata'),
|
||||||
List: require('./src/structures/List'),
|
List: require('./src/structures/List'),
|
||||||
Buttons: require('./src/structures/Buttons'),
|
Buttons: require('./src/structures/Buttons'),
|
||||||
|
|
||||||
// Auth Strategies
|
|
||||||
NoAuth: require('./src/authStrategies/NoAuth'),
|
|
||||||
LocalAuth: require('./src/authStrategies/LocalAuth'),
|
|
||||||
RemoteAuth: require('./src/authStrategies/RemoteAuth'),
|
|
||||||
LegacySessionAuth: require('./src/authStrategies/LegacySessionAuth'),
|
|
||||||
|
|
||||||
...Constants
|
...Constants
|
||||||
};
|
};
|
||||||
|
|||||||
31
package.json
31
package.json
@@ -1,12 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "whatsapp-web.js",
|
"name": "whatsapp-web.js",
|
||||||
"version": "1.19.4",
|
"version": "1.14.1",
|
||||||
"description": "Library for interacting with the WhatsApp Web API - WaWJS2",
|
"description": "Library for interacting with the WhatsApp Web API ",
|
||||||
"main": "./index.js",
|
"main": "./index.js",
|
||||||
"typings": "./index.d.ts",
|
"typings": "./index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha tests --recursive --timeout 5000",
|
"test": "mocha tests",
|
||||||
"test-single": "mocha",
|
|
||||||
"shell": "node --experimental-repl-await ./shell.js",
|
"shell": "node --experimental-repl-await ./shell.js",
|
||||||
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
|
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
|
||||||
},
|
},
|
||||||
@@ -27,34 +26,28 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/pedroslopez/whatsapp-web.js/issues"
|
"url": "https://github.com/pedroslopez/whatsapp-web.js/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://wwebjs.dev/",
|
"homepage": "https://guide.wwebjs.dev/",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pedroslopez/moduleraid": "^5.0.2",
|
"@pedroslopez/moduleraid": "^5.0.2",
|
||||||
"fluent-ffmpeg": "^2.1.2",
|
"fluent-ffmpeg": "^2.1.2",
|
||||||
"jsqr": "^1.3.1",
|
"jsqr": "^1.3.1",
|
||||||
"mime": "^3.0.0",
|
"mime": "^2.4.5",
|
||||||
"node-fetch": "^2.6.5",
|
|
||||||
"node-webpmux": "^3.1.0",
|
"node-webpmux": "^3.1.0",
|
||||||
"puppeteer": "^13.0.0"
|
"puppeteer": "^10.1.0",
|
||||||
|
"sharp": "^0.28.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node-fetch": "^2.5.12",
|
"@types/node-fetch": "^2.5.11",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"chai-as-promised": "^7.1.1",
|
"dotenv": "^10.0.0",
|
||||||
"dotenv": "^16.0.0",
|
"eslint": "^7.27.0",
|
||||||
"eslint": "^8.4.1",
|
"eslint-plugin-mocha": "^9.0.0",
|
||||||
"eslint-plugin-mocha": "^10.0.3",
|
|
||||||
"jsdoc": "^3.6.4",
|
"jsdoc": "^3.6.4",
|
||||||
"jsdoc-baseline": "^0.1.5",
|
"jsdoc-baseline": "^0.1.5",
|
||||||
"mocha": "^9.0.2",
|
"mocha": "^9.0.2",
|
||||||
"sinon": "^13.0.1"
|
"sinon": "^11.1.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.0.0"
|
"node": ">=12.0.0"
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"archiver": "^5.3.1",
|
|
||||||
"fs-extra": "^10.1.0",
|
|
||||||
"unzipper": "^0.10.11"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
shell.js
17
shell.js
@@ -2,17 +2,24 @@
|
|||||||
* ==== wwebjs-shell ====
|
* ==== wwebjs-shell ====
|
||||||
* Used for quickly testing library features
|
* Used for quickly testing library features
|
||||||
*
|
*
|
||||||
* Running `npm run shell` will start WhatsApp Web with headless=false
|
* Running `npm run shell` will start WhatsApp Web in headless mode
|
||||||
* and then drop you into Node REPL with `client` in its context.
|
* and then drop you into Node REPL with `client` in its context.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
const { Client, LocalAuth } = require('./index');
|
const { Client } = require('./index');
|
||||||
|
|
||||||
|
const SESSION_FILE_PATH = './session.json';
|
||||||
|
let sessionCfg;
|
||||||
|
if (fs.existsSync(SESSION_FILE_PATH)) {
|
||||||
|
sessionCfg = require(SESSION_FILE_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
puppeteer: { headless: false },
|
puppeteer: { headless: false },
|
||||||
authStrategy: new LocalAuth()
|
session: sessionCfg
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Initializing...');
|
console.log('Initializing...');
|
||||||
@@ -23,10 +30,6 @@ client.on('qr', () => {
|
|||||||
console.log('Please scan the QR code on the browser.');
|
console.log('Please scan the QR code on the browser.');
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('authenticated', (session) => {
|
|
||||||
console.log(JSON.stringify(session));
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('ready', () => {
|
client.on('ready', () => {
|
||||||
const shell = repl.start('wwebjs> ');
|
const shell = repl.start('wwebjs> ');
|
||||||
shell.context.client = client;
|
shell.context.client = client;
|
||||||
|
|||||||
627
src/Client.js
627
src/Client.js
@@ -3,6 +3,7 @@
|
|||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const puppeteer = require('puppeteer');
|
const puppeteer = require('puppeteer');
|
||||||
const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
|
const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
|
||||||
|
const jsQR = require('jsqr');
|
||||||
|
|
||||||
const Util = require('./util/Util');
|
const Util = require('./util/Util');
|
||||||
const InterfaceController = require('./util/InterfaceController');
|
const InterfaceController = require('./util/InterfaceController');
|
||||||
@@ -10,20 +11,21 @@ const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./util/Constan
|
|||||||
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
||||||
const ChatFactory = require('./factories/ChatFactory');
|
const ChatFactory = require('./factories/ChatFactory');
|
||||||
const ContactFactory = require('./factories/ContactFactory');
|
const ContactFactory = require('./factories/ContactFactory');
|
||||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List, Reaction } = require('./structures');
|
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label, Call, Buttons, List} = require('./structures');
|
||||||
const LegacySessionAuth = require('./authStrategies/LegacySessionAuth');
|
|
||||||
const NoAuth = require('./authStrategies/NoAuth');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starting point for interacting with the WhatsApp Web API
|
* Starting point for interacting with the WhatsApp Web API
|
||||||
* @extends {EventEmitter}
|
* @extends {EventEmitter}
|
||||||
* @param {object} options - Client options
|
* @param {object} options - Client options
|
||||||
* @param {AuthStrategy} options.authStrategy - Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used.
|
|
||||||
* @param {number} options.authTimeoutMs - Timeout for authentication selector in puppeteer
|
* @param {number} options.authTimeoutMs - Timeout for authentication selector in puppeteer
|
||||||
* @param {object} options.puppeteer - Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/
|
* @param {object} options.puppeteer - Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/
|
||||||
* @param {number} options.qrMaxRetries - How many times should the qrcode be refreshed before giving up
|
* @param {number} options.qrRefreshIntervalMs - Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
|
||||||
* @param {string} options.restartOnAuthFail - @deprecated This option should be set directly on the LegacySessionAuth.
|
* @param {number} options.qrTimeoutMs - Timeout for qr code selector in puppeteer
|
||||||
* @param {object} options.session - @deprecated Only here for backwards-compatibility. You should move to using LocalAuth, or set the authStrategy to LegacySessionAuth explicitly.
|
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||||
|
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
|
||||||
|
* @param {string} options.session.WABrowserId
|
||||||
|
* @param {string} options.session.WASecretBundle
|
||||||
|
* @param {string} options.session.WAToken1
|
||||||
|
* @param {string} options.session.WAToken2
|
||||||
* @param {number} options.takeoverOnConflict - If another whatsapp web session is detected (another browser), take over the session in the current browser
|
* @param {number} options.takeoverOnConflict - If another whatsapp web session is detected (another browser), take over the session in the current browser
|
||||||
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
|
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
|
||||||
* @param {string} options.userAgent - User agent to use in puppeteer
|
* @param {string} options.userAgent - User agent to use in puppeteer
|
||||||
@@ -45,33 +47,13 @@ const NoAuth = require('./authStrategies/NoAuth');
|
|||||||
* @fires Client#group_update
|
* @fires Client#group_update
|
||||||
* @fires Client#disconnected
|
* @fires Client#disconnected
|
||||||
* @fires Client#change_state
|
* @fires Client#change_state
|
||||||
|
* @fires Client#change_battery
|
||||||
*/
|
*/
|
||||||
class Client extends EventEmitter {
|
class Client extends EventEmitter {
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.options = Util.mergeDefault(DefaultOptions, options);
|
this.options = Util.mergeDefault(DefaultOptions, options);
|
||||||
|
|
||||||
if(!this.options.authStrategy) {
|
|
||||||
if(Object.prototype.hasOwnProperty.call(this.options, 'session')) {
|
|
||||||
process.emitWarning(
|
|
||||||
'options.session is deprecated and will be removed in a future release due to incompatibility with multi-device. ' +
|
|
||||||
'Use the LocalAuth authStrategy, don\'t pass in a session as an option, or suppress this warning by using the LegacySessionAuth strategy explicitly (see https://wwebjs.dev/guide/authentication.html#legacysessionauth-strategy).',
|
|
||||||
'DeprecationWarning'
|
|
||||||
);
|
|
||||||
|
|
||||||
this.authStrategy = new LegacySessionAuth({
|
|
||||||
session: this.options.session,
|
|
||||||
restartOnAuthFail: this.options.restartOnAuthFail
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.authStrategy = new NoAuth();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.authStrategy = this.options.authStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.authStrategy.setup(this);
|
|
||||||
|
|
||||||
this.pupBrowser = null;
|
this.pupBrowser = null;
|
||||||
this.pupPage = null;
|
this.pupPage = null;
|
||||||
@@ -84,206 +66,126 @@ class Client extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
async initialize() {
|
async initialize() {
|
||||||
let [browser, page] = [null, null];
|
let [browser, page] = [null, null];
|
||||||
|
|
||||||
await this.authStrategy.beforeBrowserInitialized();
|
if(this.options.puppeteer && this.options.puppeteer.browserWSEndpoint) {
|
||||||
|
browser = await puppeteer.connect(this.options.puppeteer);
|
||||||
const puppeteerOpts = this.options.puppeteer;
|
|
||||||
if (puppeteerOpts && puppeteerOpts.browserWSEndpoint) {
|
|
||||||
browser = await puppeteer.connect(puppeteerOpts);
|
|
||||||
page = await browser.newPage();
|
page = await browser.newPage();
|
||||||
} else {
|
} else {
|
||||||
const browserArgs = [...(puppeteerOpts.args || [])];
|
browser = await puppeteer.launch(this.options.puppeteer);
|
||||||
if(!browserArgs.find(arg => arg.includes('--user-agent'))) {
|
|
||||||
browserArgs.push(`--user-agent=${this.options.userAgent}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
browser = await puppeteer.launch({...puppeteerOpts, args: browserArgs});
|
|
||||||
page = (await browser.pages())[0];
|
page = (await browser.pages())[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
await page.setUserAgent(this.options.userAgent);
|
page.setUserAgent(this.options.userAgent);
|
||||||
if (this.options.bypassCSP) await page.setBypassCSP(true);
|
|
||||||
|
|
||||||
this.pupBrowser = browser;
|
this.pupBrowser = browser;
|
||||||
this.pupPage = page;
|
this.pupPage = page;
|
||||||
|
|
||||||
await this.authStrategy.afterBrowserInitialized();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.options.bypassCSP) {
|
||||||
|
await page.setBypassCSP(true);
|
||||||
|
}
|
||||||
|
|
||||||
await page.goto(WhatsWebURL, {
|
await page.goto(WhatsWebURL, {
|
||||||
waitUntil: 'load',
|
waitUntil: 'load',
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
referer: 'https://whatsapp.com/'
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.evaluate(`function getElementByXpath(path) {
|
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||||
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
|
||||||
}`);
|
|
||||||
|
|
||||||
let lastPercent = null,
|
if (this.options.session) {
|
||||||
lastPercentMessage = null;
|
// Check if session restore was successfull
|
||||||
|
try {
|
||||||
await page.exposeFunction('loadingScreen', async (percent, message) => {
|
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: this.options.authTimeoutMs });
|
||||||
if (lastPercent !== percent || lastPercentMessage !== message) {
|
} catch (err) {
|
||||||
this.emit(Events.LOADING_SCREEN, percent, message);
|
if (err.name === 'TimeoutError') {
|
||||||
lastPercent = percent;
|
/**
|
||||||
lastPercentMessage = message;
|
* Emitted when there has been an error while trying to restore an existing session
|
||||||
}
|
* @event Client#auth_failure
|
||||||
});
|
* @param {string} message
|
||||||
|
*/
|
||||||
await page.evaluate(
|
this.emit(Events.AUTHENTICATION_FAILURE, 'Unable to log in. Are the session details valid?');
|
||||||
async function (selectors) {
|
browser.close();
|
||||||
var observer = new MutationObserver(function () {
|
if (this.options.restartOnAuthFail) {
|
||||||
let progressBar = window.getElementByXpath(
|
// session restore failed so try again but without session to force new authentication
|
||||||
selectors.PROGRESS
|
this.options.session = null;
|
||||||
);
|
this.initialize();
|
||||||
let progressMessage = window.getElementByXpath(
|
|
||||||
selectors.PROGRESS_MESSAGE
|
|
||||||
);
|
|
||||||
|
|
||||||
if (progressBar) {
|
|
||||||
window.loadingScreen(
|
|
||||||
progressBar.value,
|
|
||||||
progressMessage.innerText
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
return;
|
||||||
|
|
||||||
observer.observe(document, {
|
|
||||||
attributes: true,
|
|
||||||
childList: true,
|
|
||||||
characterData: true,
|
|
||||||
subtree: true,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
{
|
|
||||||
PROGRESS: '//*[@id=\'app\']/div/div/div[2]/progress',
|
|
||||||
PROGRESS_MESSAGE: '//*[@id=\'app\']/div/div/div[3]',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const INTRO_IMG_SELECTOR = '[data-testid="intro-md-beta-logo-dark"], [data-testid="intro-md-beta-logo-light"], [data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
|
||||||
const INTRO_QRCODE_SELECTOR = 'div[data-ref] canvas';
|
|
||||||
|
|
||||||
// Checks which selector appears first
|
|
||||||
const needAuthentication = await Promise.race([
|
|
||||||
new Promise(resolve => {
|
|
||||||
page.waitForSelector(INTRO_IMG_SELECTOR, { timeout: this.options.authTimeoutMs })
|
|
||||||
.then(() => resolve(false))
|
|
||||||
.catch((err) => resolve(err));
|
|
||||||
}),
|
|
||||||
new Promise(resolve => {
|
|
||||||
page.waitForSelector(INTRO_QRCODE_SELECTOR, { timeout: this.options.authTimeoutMs })
|
|
||||||
.then(() => resolve(true))
|
|
||||||
.catch((err) => resolve(err));
|
|
||||||
})
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Checks if an error occurred on the first found selector. The second will be discarded and ignored by .race;
|
|
||||||
if (needAuthentication instanceof Error) throw needAuthentication;
|
|
||||||
|
|
||||||
// Scan-qrcode selector was found. Needs authentication
|
|
||||||
if (needAuthentication) {
|
|
||||||
const { failed, failureEventPayload, restart } = await this.authStrategy.onAuthenticationNeeded();
|
|
||||||
if(failed) {
|
|
||||||
/**
|
|
||||||
* 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, failureEventPayload);
|
|
||||||
await this.destroy();
|
|
||||||
if (restart) {
|
|
||||||
// session restore failed so try again but without session to force new authentication
|
|
||||||
return this.initialize();
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QR_CONTAINER = 'div[data-ref]';
|
} else {
|
||||||
const QR_RETRY_BUTTON = 'div[data-ref] > span > button';
|
const getQrCode = async () => {
|
||||||
let qrRetries = 0;
|
// Check if retry button is present
|
||||||
await page.exposeFunction('qrChanged', async (qr) => {
|
var QR_RETRY_SELECTOR = 'div[data-ref] > span > button';
|
||||||
|
var qrRetry = await page.$(QR_RETRY_SELECTOR);
|
||||||
|
if (qrRetry) {
|
||||||
|
await qrRetry.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for QR Code
|
||||||
|
const QR_CANVAS_SELECTOR = 'canvas';
|
||||||
|
await page.waitForSelector(QR_CANVAS_SELECTOR, { 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 a QR code is received
|
* Emitted when the QR code is received
|
||||||
* @event Client#qr
|
* @event Client#qr
|
||||||
* @param {string} qr QR Code
|
* @param {string} qr QR Code
|
||||||
*/
|
*/
|
||||||
this.emit(Events.QR_RECEIVED, qr);
|
this.emit(Events.QR_RECEIVED, qr);
|
||||||
if (this.options.qrMaxRetries > 0) {
|
};
|
||||||
qrRetries++;
|
getQrCode();
|
||||||
if (qrRetries > this.options.qrMaxRetries) {
|
this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
|
||||||
this.emit(Events.DISCONNECTED, 'Max qrcode retries reached');
|
|
||||||
await this.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
await page.evaluate(function (selectors) {
|
|
||||||
const qr_container = document.querySelector(selectors.QR_CONTAINER);
|
|
||||||
window.qrChanged(qr_container.dataset.ref);
|
|
||||||
|
|
||||||
const obs = new MutationObserver((muts) => {
|
|
||||||
muts.forEach(mut => {
|
|
||||||
// Listens to qr token change
|
|
||||||
if (mut.type === 'attributes' && mut.attributeName === 'data-ref') {
|
|
||||||
window.qrChanged(mut.target.dataset.ref);
|
|
||||||
} else
|
|
||||||
// Listens to retry button, when found, click it
|
|
||||||
if (mut.type === 'childList') {
|
|
||||||
const retry_button = document.querySelector(selectors.QR_RETRY_BUTTON);
|
|
||||||
if (retry_button) retry_button.click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
obs.observe(qr_container.parentElement, {
|
|
||||||
subtree: true,
|
|
||||||
childList: true,
|
|
||||||
attributes: true,
|
|
||||||
attributeFilter: ['data-ref'],
|
|
||||||
});
|
|
||||||
}, {
|
|
||||||
QR_CONTAINER,
|
|
||||||
QR_RETRY_BUTTON
|
|
||||||
});
|
|
||||||
|
|
||||||
// Wait for code scan
|
// Wait for code scan
|
||||||
try {
|
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||||
await page.waitForSelector(INTRO_IMG_SELECTOR, { timeout: 0 });
|
clearInterval(this._qrRefreshInterval);
|
||||||
} catch(error) {
|
this._qrRefreshInterval = undefined;
|
||||||
if (
|
|
||||||
error.name === 'ProtocolError' &&
|
|
||||||
error.message &&
|
|
||||||
error.message.match(/Target closed/)
|
|
||||||
) {
|
|
||||||
// something has called .destroy() while waiting
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await page.evaluate(ExposeStore, moduleRaid.toString());
|
await page.evaluate(ExposeStore, moduleRaid.toString());
|
||||||
const authEventPayload = await this.authStrategy.getAuthEventPayload();
|
|
||||||
|
// 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
|
* Emitted when authentication is successful
|
||||||
* @event Client#authenticated
|
* @event Client#authenticated
|
||||||
|
* @param {object} session Object containing session information. Can be used to restore the session.
|
||||||
|
* @param {string} session.WABrowserId
|
||||||
|
* @param {string} session.WASecretBundle
|
||||||
|
* @param {string} session.WAToken1
|
||||||
|
* @param {string} session.WAToken2
|
||||||
*/
|
*/
|
||||||
this.emit(Events.AUTHENTICATED, authEventPayload);
|
this.emit(Events.AUTHENTICATED, session);
|
||||||
|
|
||||||
// Check window.Store Injection
|
// Check window.Store Injection
|
||||||
await page.waitForFunction('window.Store != undefined');
|
await page.waitForFunction('window.Store != undefined');
|
||||||
|
|
||||||
await page.evaluate(async () => {
|
|
||||||
// safely unregister service workers
|
|
||||||
const registrations = await navigator.serviceWorker.getRegistrations();
|
|
||||||
for (let registration of registrations) {
|
|
||||||
registration.unregister();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//Load util functions (serializers, helper functions)
|
//Load util functions (serializers, helper functions)
|
||||||
await page.evaluate(LoadUtils);
|
await page.evaluate(LoadUtils);
|
||||||
|
|
||||||
@@ -293,7 +195,7 @@ class Client extends EventEmitter {
|
|||||||
* @type {ClientInfo}
|
* @type {ClientInfo}
|
||||||
*/
|
*/
|
||||||
this.info = new ClientInfo(this, await page.evaluate(() => {
|
this.info = new ClientInfo(this, await page.evaluate(() => {
|
||||||
return { ...window.Store.Conn.serialize(), wid: window.Store.User.getMeUser() };
|
return window.Store.Conn.serialize();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Add InterfaceController
|
// Add InterfaceController
|
||||||
@@ -301,6 +203,8 @@ class Client extends EventEmitter {
|
|||||||
|
|
||||||
// Register events
|
// Register events
|
||||||
await page.exposeFunction('onAddMessageEvent', msg => {
|
await page.exposeFunction('onAddMessageEvent', msg => {
|
||||||
|
if (!msg.isNewMsg) return;
|
||||||
|
|
||||||
if (msg.type === 'gp2') {
|
if (msg.type === 'gp2') {
|
||||||
const notification = new GroupNotification(this, msg);
|
const notification = new GroupNotification(this, msg);
|
||||||
if (msg.subtype === 'add' || msg.subtype === 'invite') {
|
if (msg.subtype === 'add' || msg.subtype === 'invite') {
|
||||||
@@ -419,7 +323,7 @@ class Client extends EventEmitter {
|
|||||||
this.emit(Events.MEDIA_UPLOADED, message);
|
this.emit(Events.MEDIA_UPLOADED, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.exposeFunction('onAppStateChangedEvent', async (state) => {
|
await page.exposeFunction('onAppStateChangedEvent', (state) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when the connection state changes
|
* Emitted when the connection state changes
|
||||||
@@ -446,7 +350,6 @@ class Client extends EventEmitter {
|
|||||||
* @event Client#disconnected
|
* @event Client#disconnected
|
||||||
* @param {WAState|"NAVIGATION"} reason reason that caused the disconnect
|
* @param {WAState|"NAVIGATION"} reason reason that caused the disconnect
|
||||||
*/
|
*/
|
||||||
await this.authStrategy.disconnect();
|
|
||||||
this.emit(Events.DISCONNECTED, state);
|
this.emit(Events.DISCONNECTED, state);
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
@@ -458,12 +361,11 @@ class Client extends EventEmitter {
|
|||||||
if (battery === undefined) return;
|
if (battery === undefined) return;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when the battery percentage for the attached device changes. Will not be sent if using multi-device.
|
* Emitted when the battery percentage for the attached device changes
|
||||||
* @event Client#change_battery
|
* @event Client#change_battery
|
||||||
* @param {object} batteryInfo
|
* @param {object} batteryInfo
|
||||||
* @param {number} batteryInfo.battery - The current battery percentage
|
* @param {number} batteryInfo.battery - The current battery percentage
|
||||||
* @param {boolean} batteryInfo.plugged - Indicates if the phone is plugged in (true) or not (false)
|
* @param {boolean} batteryInfo.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
|
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
|
||||||
});
|
});
|
||||||
@@ -482,66 +384,20 @@ class Client extends EventEmitter {
|
|||||||
* @param {boolean} call.webClientShouldHandle - If Waweb should handle
|
* @param {boolean} call.webClientShouldHandle - If Waweb should handle
|
||||||
* @param {object} call.participants - Participants
|
* @param {object} call.participants - Participants
|
||||||
*/
|
*/
|
||||||
const cll = new Call(this, call);
|
const cll = new Call(this,call);
|
||||||
this.emit(Events.INCOMING_CALL, cll);
|
this.emit(Events.INCOMING_CALL, cll);
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.exposeFunction('onReaction', (reactions) => {
|
|
||||||
for (const reaction of reactions) {
|
|
||||||
/**
|
|
||||||
* Emitted when a reaction is sent, received, updated or removed
|
|
||||||
* @event Client#message_reaction
|
|
||||||
* @param {object} reaction
|
|
||||||
* @param {object} reaction.id - Reaction id
|
|
||||||
* @param {number} reaction.orphan - Orphan
|
|
||||||
* @param {?string} reaction.orphanReason - Orphan reason
|
|
||||||
* @param {number} reaction.timestamp - Timestamp
|
|
||||||
* @param {string} reaction.reaction - Reaction
|
|
||||||
* @param {boolean} reaction.read - Read
|
|
||||||
* @param {object} reaction.msgId - Parent message id
|
|
||||||
* @param {string} reaction.senderId - Sender id
|
|
||||||
* @param {?number} reaction.ack - Ack
|
|
||||||
*/
|
|
||||||
|
|
||||||
this.emit(Events.MESSAGE_REACTION, new Reaction(this, reaction));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
|
window.Store.Msg.on('add', (msg) => { if (msg.isNewMsg) window.onAddMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
||||||
window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
||||||
window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(window.WWebJS.getMessageModel(msg)); });
|
window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(window.WWebJS.getMessageModel(msg)); });
|
||||||
window.Store.Msg.on('change:ack', (msg, ack) => { window.onMessageAckEvent(window.WWebJS.getMessageModel(msg), ack); });
|
window.Store.Msg.on('change:ack', (msg,ack) => { window.onMessageAckEvent(window.WWebJS.getMessageModel(msg), ack); });
|
||||||
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if (msg.id.fromMe && !unsent) window.onMessageMediaUploadedEvent(window.WWebJS.getMessageModel(msg)); });
|
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if (msg.id.fromMe && !unsent) window.onMessageMediaUploadedEvent(window.WWebJS.getMessageModel(msg)); });
|
||||||
window.Store.Msg.on('remove', (msg) => { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
window.Store.Msg.on('remove', (msg) => { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); });
|
||||||
window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); });
|
window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); });
|
||||||
window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); });
|
window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); });
|
||||||
window.Store.Call.on('add', (call) => { window.onIncomingCall(call); });
|
window.Store.Call.on('add', (call) => { window.onIncomingCall(call); });
|
||||||
window.Store.Msg.on('add', (msg) => {
|
|
||||||
if (msg.isNewMsg) {
|
|
||||||
if(msg.type === 'ciphertext') {
|
|
||||||
// defer message event until ciphertext is resolved (type changed)
|
|
||||||
msg.once('change:type', (_msg) => window.onAddMessageEvent(window.WWebJS.getMessageModel(_msg)));
|
|
||||||
} else {
|
|
||||||
window.onAddMessageEvent(window.WWebJS.getMessageModel(msg));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
{
|
|
||||||
const module = window.Store.createOrUpdateReactionsModule;
|
|
||||||
const ogMethod = module.createOrUpdateReactions;
|
|
||||||
module.createOrUpdateReactions = ((...args) => {
|
|
||||||
window.onReaction(args[0].map(reaction => {
|
|
||||||
const msgKey = window.Store.MsgKey.fromString(reaction.msgKey);
|
|
||||||
const parentMsgKey = window.Store.MsgKey.fromString(reaction.parentMsgKey);
|
|
||||||
const timestamp = reaction.timestamp / 1000;
|
|
||||||
|
|
||||||
return {...reaction, msgKey, parentMsgKey, timestamp };
|
|
||||||
}));
|
|
||||||
|
|
||||||
return ogMethod(...args);
|
|
||||||
}).bind(module);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -549,16 +405,12 @@ class Client extends EventEmitter {
|
|||||||
* @event Client#ready
|
* @event Client#ready
|
||||||
*/
|
*/
|
||||||
this.emit(Events.READY);
|
this.emit(Events.READY);
|
||||||
this.authStrategy.afterAuthReady();
|
|
||||||
|
|
||||||
// Disconnect when navigating away when in PAIRING state (detect logout)
|
// Disconnect when navigating away
|
||||||
|
// Because WhatsApp Web now reloads when logging out from the device, this also covers that case
|
||||||
this.pupPage.on('framenavigated', async () => {
|
this.pupPage.on('framenavigated', async () => {
|
||||||
const appState = await this.getState();
|
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||||
if(!appState || appState === WAState.PAIRING) {
|
await this.destroy();
|
||||||
await this.authStrategy.disconnect();
|
|
||||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
|
||||||
await this.destroy();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,19 +418,19 @@ class Client extends EventEmitter {
|
|||||||
* Closes the client
|
* Closes the client
|
||||||
*/
|
*/
|
||||||
async destroy() {
|
async destroy() {
|
||||||
|
if (this._qrRefreshInterval) {
|
||||||
|
clearInterval(this._qrRefreshInterval);
|
||||||
|
}
|
||||||
await this.pupBrowser.close();
|
await this.pupBrowser.close();
|
||||||
await this.authStrategy.destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs out the client, closing the current session
|
* Logs out the client, closing the current session
|
||||||
*/
|
*/
|
||||||
async logout() {
|
async logout() {
|
||||||
await this.pupPage.evaluate(() => {
|
return await this.pupPage.evaluate(() => {
|
||||||
return window.Store.AppState.logout();
|
return window.Store.AppState.logout();
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.authStrategy.logout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -608,7 +460,7 @@ class Client extends EventEmitter {
|
|||||||
/**
|
/**
|
||||||
* Message options.
|
* Message options.
|
||||||
* @typedef {Object} MessageSendOptions
|
* @typedef {Object} MessageSendOptions
|
||||||
* @property {boolean} [linkPreview=true] - Show links preview. Has no effect on multi-device accounts.
|
* @property {boolean} [linkPreview=true] - Show links preview
|
||||||
* @property {boolean} [sendAudioAsVoice=false] - Send audio as voice message
|
* @property {boolean} [sendAudioAsVoice=false] - Send audio as voice message
|
||||||
* @property {boolean} [sendVideoAsGif=false] - Send video as gif
|
* @property {boolean} [sendVideoAsGif=false] - Send video as gif
|
||||||
* @property {boolean} [sendMediaAsSticker=false] - Send media as a sticker
|
* @property {boolean} [sendMediaAsSticker=false] - Send media as a sticker
|
||||||
@@ -643,7 +495,7 @@ class Client extends EventEmitter {
|
|||||||
quotedMessageId: options.quotedMessageId,
|
quotedMessageId: options.quotedMessageId,
|
||||||
parseVCards: options.parseVCards === false ? false : true,
|
parseVCards: options.parseVCards === false ? false : true,
|
||||||
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : [],
|
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : [],
|
||||||
extraOptions: options.extra
|
...options.extra
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
||||||
@@ -658,42 +510,40 @@ class Client extends EventEmitter {
|
|||||||
} else if (content instanceof Location) {
|
} else if (content instanceof Location) {
|
||||||
internalOptions.location = content;
|
internalOptions.location = content;
|
||||||
content = '';
|
content = '';
|
||||||
} else if (content instanceof Contact) {
|
} else if(content instanceof Contact) {
|
||||||
internalOptions.contactCard = content.id._serialized;
|
internalOptions.contactCard = content.id._serialized;
|
||||||
content = '';
|
content = '';
|
||||||
} else if (Array.isArray(content) && content.length > 0 && content[0] instanceof Contact) {
|
} else if(Array.isArray(content) && content.length > 0 && content[0] instanceof Contact) {
|
||||||
internalOptions.contactCardList = content.map(contact => contact.id._serialized);
|
internalOptions.contactCardList = content.map(contact => contact.id._serialized);
|
||||||
content = '';
|
content = '';
|
||||||
} else if (content instanceof Buttons) {
|
} else if(content instanceof Buttons){
|
||||||
if (content.type !== 'chat') { internalOptions.attachment = content.body; }
|
if(content.type !== 'chat'){internalOptions.attachment = content.body;}
|
||||||
internalOptions.buttons = content;
|
internalOptions.buttons = content;
|
||||||
content = '';
|
content = '';
|
||||||
} else if (content instanceof List) {
|
} else if(content instanceof List){
|
||||||
internalOptions.list = content;
|
internalOptions.list = content;
|
||||||
content = '';
|
content = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (internalOptions.sendMediaAsSticker && internalOptions.attachment) {
|
if (internalOptions.sendMediaAsSticker && internalOptions.attachment) {
|
||||||
internalOptions.attachment = await Util.formatToWebpSticker(
|
internalOptions.attachment =
|
||||||
internalOptions.attachment, {
|
await Util.formatToWebpSticker(internalOptions.attachment, {
|
||||||
name: options.stickerName,
|
name: options.stickerName,
|
||||||
author: options.stickerAuthor,
|
author: options.stickerAuthor,
|
||||||
categories: options.stickerCategories
|
categories: options.stickerCategories
|
||||||
}, this.pupPage
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
|
const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
const chat = await window.Store.Chat.find(chatWid);
|
||||||
|
|
||||||
|
|
||||||
if (sendSeen) {
|
if (sendSeen) {
|
||||||
window.WWebJS.sendSeen(chatId);
|
window.WWebJS.sendSeen(chatId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const msg = await window.WWebJS.sendMessage(chat, message, options, sendSeen);
|
const msg = await window.WWebJS.sendMessage(chat, message, options, sendSeen);
|
||||||
return JSON.parse(JSON.stringify(msg));
|
return msg.serialize();
|
||||||
}, chatId, content, internalOptions, sendSeen);
|
}, chatId, content, internalOptions, sendSeen);
|
||||||
|
|
||||||
return new Message(this, newMessage);
|
return new Message(this, newMessage);
|
||||||
@@ -767,6 +617,37 @@ class Client extends EventEmitter {
|
|||||||
return ContactFactory.create(this, contact);
|
return ContactFactory.create(this, contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getMessageById(messageId) {
|
||||||
|
const msg = await this.pupPage.evaluate(async messageId => {
|
||||||
|
let msg = window.Store.Msg.get(messageId);
|
||||||
|
if(msg) return window.WWebJS.getMessageModel(msg);
|
||||||
|
|
||||||
|
const params = messageId.split('_');
|
||||||
|
if(params.length !== 3) throw new Error('Invalid serialized message id specified');
|
||||||
|
|
||||||
|
const [fromMe, chatId, id] = params;
|
||||||
|
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||||
|
const fullMsgId = {
|
||||||
|
fromMe: Boolean(fromMe),
|
||||||
|
remote: chatWid,
|
||||||
|
id,
|
||||||
|
};
|
||||||
|
|
||||||
|
const msgKey = new window.Store.MsgKey(fullMsgId);
|
||||||
|
const chat = await window.Store.Chat.find(msgKey.remote);
|
||||||
|
const ctx = await chat.getSearchContext(msgKey);
|
||||||
|
if(ctx.collection && ctx.collection.loadAroundPromise) {
|
||||||
|
await ctx.collection.loadAroundPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = window.Store.Msg.get(messageId);
|
||||||
|
if(msg) return window.WWebJS.getMessageModel(msg);
|
||||||
|
}, messageId);
|
||||||
|
|
||||||
|
if(msg) return new Message(this, msg);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an object with information about the invite code's group
|
* Returns an object with information about the invite code's group
|
||||||
* @param {string} inviteCode
|
* @param {string} inviteCode
|
||||||
@@ -774,7 +655,7 @@ class Client extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
async getInviteInfo(inviteCode) {
|
async getInviteInfo(inviteCode) {
|
||||||
return await this.pupPage.evaluate(inviteCode => {
|
return await this.pupPage.evaluate(inviteCode => {
|
||||||
return window.Store.InviteInfo.queryGroupInvite(inviteCode);
|
return window.Store.Wap.groupInviteInfo(inviteCode);
|
||||||
}, inviteCode);
|
}, inviteCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -784,34 +665,34 @@ class Client extends EventEmitter {
|
|||||||
* @returns {Promise<string>} Id of the joined Chat
|
* @returns {Promise<string>} Id of the joined Chat
|
||||||
*/
|
*/
|
||||||
async acceptInvite(inviteCode) {
|
async acceptInvite(inviteCode) {
|
||||||
const res = await this.pupPage.evaluate(async inviteCode => {
|
const chatId = await this.pupPage.evaluate(async inviteCode => {
|
||||||
return await window.Store.Invite.joinGroupViaInvite(inviteCode);
|
return await window.Store.Invite.sendJoinGroupViaInvite(inviteCode);
|
||||||
}, inviteCode);
|
}, inviteCode);
|
||||||
|
|
||||||
return res.gid._serialized;
|
return chatId._serialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts a private invitation to join a group
|
* Accepts a private invitation to join a group
|
||||||
* @param {object} inviteInfo Invite V4 Info
|
* @param {object} inviteV4 Invite V4 Info
|
||||||
* @returns {Promise<Object>}
|
* @returns {Promise<Object>}
|
||||||
*/
|
*/
|
||||||
async acceptGroupV4Invite(inviteInfo) {
|
async acceptGroupV4Invite(inviteInfo) {
|
||||||
if (!inviteInfo.inviteCode) throw 'Invalid invite code, try passing the message.inviteV4 object';
|
if(!inviteInfo.inviteCode) throw 'Invalid invite code, try passing the message.inviteV4 object';
|
||||||
if (inviteInfo.inviteCodeExp == 0) throw 'Expired invite code';
|
if (inviteInfo.inviteCodeExp == 0) throw 'Expired invite code';
|
||||||
return this.pupPage.evaluate(async inviteInfo => {
|
return await this.pupPage.evaluate(async inviteInfo => {
|
||||||
let { groupId, fromId, inviteCode, inviteCodeExp } = inviteInfo;
|
let { groupId, fromId, inviteCode, inviteCodeExp, toId } = inviteInfo;
|
||||||
return await window.Store.JoinInviteV4.sendJoinGroupViaInviteV4(inviteCode, String(inviteCodeExp), groupId, fromId);
|
return await window.Store.Wap.acceptGroupV4Invite(groupId, fromId, inviteCode, String(inviteCodeExp), toId);
|
||||||
}, inviteInfo);
|
}, inviteInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current user's status message
|
* Sets the current user's status message
|
||||||
* @param {string} status New status message
|
* @param {string} status New status message
|
||||||
*/
|
*/
|
||||||
async setStatus(status) {
|
async setStatus(status) {
|
||||||
await this.pupPage.evaluate(async status => {
|
await this.pupPage.evaluate(async status => {
|
||||||
return await window.Store.StatusUtils.setMyStatus(status);
|
return await window.Store.Wap.sendSetStatus(status);
|
||||||
}, status);
|
}, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -819,31 +700,19 @@ class Client extends EventEmitter {
|
|||||||
* Sets the current user's display name.
|
* Sets the current user's display name.
|
||||||
* This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
|
* This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
|
||||||
* @param {string} displayName New display name
|
* @param {string} displayName New display name
|
||||||
* @returns {Promise<Boolean>}
|
|
||||||
*/
|
*/
|
||||||
async setDisplayName(displayName) {
|
async setDisplayName(displayName) {
|
||||||
const couldSet = await this.pupPage.evaluate(async displayName => {
|
await this.pupPage.evaluate(async displayName => {
|
||||||
if(!window.Store.Conn.canSetMyPushname()) return false;
|
return await window.Store.Wap.setPushname(displayName);
|
||||||
|
|
||||||
if(window.Store.MDBackend) {
|
|
||||||
// TODO
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
const res = await window.Store.Wap.setPushname(displayName);
|
|
||||||
return !res.status || res.status === 200;
|
|
||||||
}
|
|
||||||
}, displayName);
|
}, displayName);
|
||||||
|
|
||||||
return couldSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current connection state for the client
|
* Gets the current connection state for the client
|
||||||
* @returns {WAState}
|
* @returns {WAState}
|
||||||
*/
|
*/
|
||||||
async getState() {
|
async getState() {
|
||||||
return await this.pupPage.evaluate(() => {
|
return await this.pupPage.evaluate(() => {
|
||||||
if(!window.Store) return null;
|
|
||||||
return window.Store.AppState.state;
|
return window.Store.AppState.state;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -853,16 +722,7 @@ class Client extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
async sendPresenceAvailable() {
|
async sendPresenceAvailable() {
|
||||||
return await this.pupPage.evaluate(() => {
|
return await this.pupPage.evaluate(() => {
|
||||||
return window.Store.PresenceUtils.sendPresenceAvailable();
|
return window.Store.Wap.sendPresenceAvailable();
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks the client as unavailable
|
|
||||||
*/
|
|
||||||
async sendPresenceUnavailable() {
|
|
||||||
return await this.pupPage.evaluate(() => {
|
|
||||||
return window.Store.PresenceUtils.sendPresenceUnavailable();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -874,7 +734,7 @@ class Client extends EventEmitter {
|
|||||||
return await this.pupPage.evaluate(async chatId => {
|
return await this.pupPage.evaluate(async chatId => {
|
||||||
let chat = await window.Store.Chat.get(chatId);
|
let chat = await window.Store.Chat.get(chatId);
|
||||||
await window.Store.Cmd.archiveChat(chat, true);
|
await window.Store.Cmd.archiveChat(chat, true);
|
||||||
return true;
|
return chat.archive;
|
||||||
}, chatId);
|
}, chatId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -886,7 +746,7 @@ class Client extends EventEmitter {
|
|||||||
return await this.pupPage.evaluate(async chatId => {
|
return await this.pupPage.evaluate(async chatId => {
|
||||||
let chat = await window.Store.Chat.get(chatId);
|
let chat = await window.Store.Chat.get(chatId);
|
||||||
await window.Store.Cmd.archiveChat(chat, false);
|
await window.Store.Cmd.archiveChat(chat, false);
|
||||||
return false;
|
return chat.archive;
|
||||||
}, chatId);
|
}, chatId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -901,9 +761,8 @@ class Client extends EventEmitter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const MAX_PIN_COUNT = 3;
|
const MAX_PIN_COUNT = 3;
|
||||||
const chatModels = window.Store.Chat.getModelsArray();
|
if (window.Store.Chat.models.length > MAX_PIN_COUNT) {
|
||||||
if (chatModels.length > MAX_PIN_COUNT) {
|
let maxPinned = window.Store.Chat.models[MAX_PIN_COUNT - 1].pin;
|
||||||
let maxPinned = chatModels[MAX_PIN_COUNT - 1].pin;
|
|
||||||
if (maxPinned) {
|
if (maxPinned) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -929,16 +788,15 @@ class Client extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutes this chat forever, unless a date is specified
|
* Mutes the Chat until a specified date
|
||||||
* @param {string} chatId ID of the chat that will be muted
|
* @param {string} chatId ID of the chat that will be muted
|
||||||
* @param {?Date} unmuteDate Date when the chat will be unmuted, leave as is to mute forever
|
* @param {Date} unmuteDate Date when the chat will be unmuted
|
||||||
*/
|
*/
|
||||||
async muteChat(chatId, unmuteDate) {
|
async muteChat(chatId, unmuteDate) {
|
||||||
unmuteDate = unmuteDate ? unmuteDate.getTime() / 1000 : -1;
|
|
||||||
await this.pupPage.evaluate(async (chatId, timestamp) => {
|
await this.pupPage.evaluate(async (chatId, timestamp) => {
|
||||||
let chat = await window.Store.Chat.get(chatId);
|
let chat = await window.Store.Chat.get(chatId);
|
||||||
await chat.mute.mute(timestamp, !0);
|
await chat.mute.mute(timestamp, !0);
|
||||||
}, chatId, unmuteDate || -1);
|
}, chatId, unmuteDate.getTime() / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -969,49 +827,13 @@ class Client extends EventEmitter {
|
|||||||
* @returns {Promise<string>}
|
* @returns {Promise<string>}
|
||||||
*/
|
*/
|
||||||
async getProfilePicUrl(contactId) {
|
async getProfilePicUrl(contactId) {
|
||||||
const profilePic = await this.pupPage.evaluate(async contactId => {
|
const profilePic = await this.pupPage.evaluate((contactId) => {
|
||||||
try {
|
return window.Store.Wap.profilePicFind(contactId);
|
||||||
const chatWid = window.Store.WidFactory.createWid(contactId);
|
|
||||||
return await window.Store.ProfilePic.profilePicFind(chatWid);
|
|
||||||
} catch (err) {
|
|
||||||
if(err.name === 'ServerStatusCodeError') return undefined;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}, contactId);
|
}, contactId);
|
||||||
|
|
||||||
return profilePic ? profilePic.eurl : undefined;
|
return profilePic ? profilePic.eurl : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
|
|
||||||
* @param {string} contactId the whatsapp user's ID (_serialized format)
|
|
||||||
* @returns {Promise<WAWebJS.ChatId[]>}
|
|
||||||
*/
|
|
||||||
async getCommonGroups(contactId) {
|
|
||||||
const commonGroups = await this.pupPage.evaluate(async (contactId) => {
|
|
||||||
let contact = window.Store.Contact.get(contactId);
|
|
||||||
if (!contact) {
|
|
||||||
const wid = window.Store.WidFactory.createUserWid(contactId);
|
|
||||||
const chatConstructor = window.Store.Contact.getModelsArray().find(c=>!c.isGroup).constructor;
|
|
||||||
contact = new chatConstructor({id: wid});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contact.commonGroups) {
|
|
||||||
return contact.commonGroups.serialize();
|
|
||||||
}
|
|
||||||
const status = await window.Store.findCommonGroups(contact);
|
|
||||||
if (status) {
|
|
||||||
return contact.commonGroups.serialize();
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}, contactId);
|
|
||||||
const chats = [];
|
|
||||||
for (const group of commonGroups) {
|
|
||||||
chats.push(group.id);
|
|
||||||
}
|
|
||||||
return chats;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force reset of connection state for the client
|
* Force reset of connection state for the client
|
||||||
*/
|
*/
|
||||||
@@ -1027,7 +849,10 @@ class Client extends EventEmitter {
|
|||||||
* @returns {Promise<Boolean>}
|
* @returns {Promise<Boolean>}
|
||||||
*/
|
*/
|
||||||
async isRegisteredUser(id) {
|
async isRegisteredUser(id) {
|
||||||
return Boolean(await this.getNumberId(id));
|
return await this.pupPage.evaluate(async (id) => {
|
||||||
|
let result = await window.Store.Wap.queryExist(id);
|
||||||
|
return result.jid !== undefined;
|
||||||
|
}, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1037,43 +862,17 @@ class Client extends EventEmitter {
|
|||||||
* @returns {Promise<Object|null>}
|
* @returns {Promise<Object|null>}
|
||||||
*/
|
*/
|
||||||
async getNumberId(number) {
|
async getNumberId(number) {
|
||||||
if (!number.endsWith('@c.us')) {
|
if(!number.endsWith('@c.us')) {
|
||||||
number += '@c.us';
|
number += '@c.us';
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.pupPage.evaluate(async number => {
|
try {
|
||||||
const wid = window.Store.WidFactory.createWid(number);
|
return await this.pupPage.evaluate(async numberId => {
|
||||||
const result = await window.Store.QueryExist(wid);
|
return window.WWebJS.getNumberId(numberId);
|
||||||
if (!result || result.wid === undefined) return null;
|
}, number);
|
||||||
return result.wid;
|
} catch(_) {
|
||||||
}, number);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the formatted number of a WhatsApp ID.
|
|
||||||
* @param {string} number Number or ID
|
|
||||||
* @returns {Promise<string>}
|
|
||||||
*/
|
|
||||||
async getFormattedNumber(number) {
|
|
||||||
if (!number.endsWith('@s.whatsapp.net')) number = number.replace('c.us', 's.whatsapp.net');
|
|
||||||
if (!number.includes('@s.whatsapp.net')) number = `${number}@s.whatsapp.net`;
|
|
||||||
|
|
||||||
return await this.pupPage.evaluate(async numberId => {
|
|
||||||
return window.Store.NumberInfo.formattedPhoneNumber(numberId);
|
|
||||||
}, number);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the country code of a WhatsApp ID.
|
|
||||||
* @param {string} number Number or ID
|
|
||||||
* @returns {Promise<string>}
|
|
||||||
*/
|
|
||||||
async getCountryCode(number) {
|
|
||||||
number = number.replace(' ', '').replace('+', '').replace('@c.us', '');
|
|
||||||
|
|
||||||
return await this.pupPage.evaluate(async numberId => {
|
|
||||||
return window.Store.NumberInfo.findCC(numberId);
|
|
||||||
}, number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1094,18 +893,23 @@ class Client extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createRes = await this.pupPage.evaluate(async (name, participantIds) => {
|
const createRes = await this.pupPage.evaluate(async (name, participantIds) => {
|
||||||
const participantWIDs = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
const res = await window.Store.Wap.createGroup(name, participantIds);
|
||||||
return await window.Store.GroupUtils.createGroup(name, participantWIDs, 0);
|
console.log(res);
|
||||||
|
if (!res.status === 200) {
|
||||||
|
throw 'An error occurred while creating the group!';
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
}, name, participants);
|
}, name, participants);
|
||||||
|
|
||||||
const missingParticipants = createRes.participants.reduce(((missing, c) => {
|
const missingParticipants = createRes.participants.reduce(((missing, c) => {
|
||||||
const id = c.wid._serialized;
|
const id = Object.keys(c)[0];
|
||||||
const statusCode = c.error ? c.error.toString() : '200';
|
const statusCode = c[id].code;
|
||||||
if (statusCode != 200) return Object.assign(missing, { [id]: statusCode });
|
if (statusCode != 200) return Object.assign(missing, { [id]: statusCode });
|
||||||
return missing;
|
return missing;
|
||||||
}), {});
|
}), {});
|
||||||
|
|
||||||
return { gid: createRes.wid, missingParticipants };
|
return { gid: createRes.gid, missingParticipants };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1115,9 +919,9 @@ class Client extends EventEmitter {
|
|||||||
async getLabels() {
|
async getLabels() {
|
||||||
const labels = await this.pupPage.evaluate(async () => {
|
const labels = await this.pupPage.evaluate(async () => {
|
||||||
return window.WWebJS.getLabels();
|
return window.WWebJS.getLabels();
|
||||||
});
|
});
|
||||||
|
|
||||||
return labels.map(data => new Label(this, data));
|
return labels.map(data => new Label(this , data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1128,7 +932,7 @@ class Client extends EventEmitter {
|
|||||||
async getLabelById(labelId) {
|
async getLabelById(labelId) {
|
||||||
const label = await this.pupPage.evaluate(async (labelId) => {
|
const label = await this.pupPage.evaluate(async (labelId) => {
|
||||||
return window.WWebJS.getLabel(labelId);
|
return window.WWebJS.getLabel(labelId);
|
||||||
}, labelId);
|
}, labelId);
|
||||||
|
|
||||||
return new Label(this, label);
|
return new Label(this, label);
|
||||||
}
|
}
|
||||||
@@ -1138,12 +942,12 @@ class Client extends EventEmitter {
|
|||||||
* @param {string} chatId
|
* @param {string} chatId
|
||||||
* @returns {Promise<Array<Label>>}
|
* @returns {Promise<Array<Label>>}
|
||||||
*/
|
*/
|
||||||
async getChatLabels(chatId) {
|
async getChatLabels(chatId){
|
||||||
const labels = await this.pupPage.evaluate(async (chatId) => {
|
const labels = await this.pupPage.evaluate(async (chatId) => {
|
||||||
return window.WWebJS.getChatLabels(chatId);
|
return window.WWebJS.getChatLabels(chatId);
|
||||||
}, chatId);
|
}, chatId);
|
||||||
|
|
||||||
return labels.map(data => new Label(this, data));
|
return labels.map(data => new Label(this, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1151,33 +955,20 @@ class Client extends EventEmitter {
|
|||||||
* @param {string} labelId
|
* @param {string} labelId
|
||||||
* @returns {Promise<Array<Chat>>}
|
* @returns {Promise<Array<Chat>>}
|
||||||
*/
|
*/
|
||||||
async getChatsByLabelId(labelId) {
|
async getChatsByLabelId(labelId){
|
||||||
const chatIds = await this.pupPage.evaluate(async (labelId) => {
|
const chatIds = await this.pupPage.evaluate(async (labelId) => {
|
||||||
const label = window.Store.Label.get(labelId);
|
const label = window.Store.Label.get(labelId);
|
||||||
const labelItems = label.labelItemCollection.getModelsArray();
|
const labelItems = label.labelItemCollection.models;
|
||||||
return labelItems.reduce((result, item) => {
|
return labelItems.reduce((result, item) => {
|
||||||
if (item.parentType === 'Chat') {
|
if(item.parentType === 'Chat'){
|
||||||
result.push(item.parentId);
|
result.push(item.parentId);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}, []);
|
},[]);
|
||||||
}, labelId);
|
}, labelId);
|
||||||
|
|
||||||
return Promise.all(chatIds.map(id => this.getChatById(id)));
|
return Promise.all(chatIds.map(id => this.getChatById(id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all blocked contacts by host account
|
|
||||||
* @returns {Promise<Array<Contact>>}
|
|
||||||
*/
|
|
||||||
async getBlockedContacts() {
|
|
||||||
const blockedContacts = await this.pupPage.evaluate(() => {
|
|
||||||
let chatIds = window.Store.Blocklist.getModelsArray().map(a => a.id._serialized);
|
|
||||||
return Promise.all(chatIds.map(id => window.WWebJS.getContact(id)));
|
|
||||||
});
|
|
||||||
|
|
||||||
return blockedContacts.map(contact => ContactFactory.create(this.client, contact));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Client;
|
module.exports = Client;
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class which all authentication strategies extend
|
|
||||||
*/
|
|
||||||
class BaseAuthStrategy {
|
|
||||||
constructor() {}
|
|
||||||
setup(client) {
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
async beforeBrowserInitialized() {}
|
|
||||||
async afterBrowserInitialized() {}
|
|
||||||
async onAuthenticationNeeded() {
|
|
||||||
return {
|
|
||||||
failed: false,
|
|
||||||
restart: false,
|
|
||||||
failureEventPayload: undefined
|
|
||||||
};
|
|
||||||
}
|
|
||||||
async getAuthEventPayload() {}
|
|
||||||
async afterAuthReady() {}
|
|
||||||
async disconnect() {}
|
|
||||||
async destroy() {}
|
|
||||||
async logout() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = BaseAuthStrategy;
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Legacy session auth strategy
|
|
||||||
* Not compatible with multi-device accounts.
|
|
||||||
* @param {object} options - options
|
|
||||||
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
|
||||||
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
|
|
||||||
* @param {string} options.session.WABrowserId
|
|
||||||
* @param {string} options.session.WASecretBundle
|
|
||||||
* @param {string} options.session.WAToken1
|
|
||||||
* @param {string} options.session.WAToken2
|
|
||||||
*/
|
|
||||||
class LegacySessionAuth extends BaseAuthStrategy {
|
|
||||||
constructor({ session, restartOnAuthFail }={}) {
|
|
||||||
super();
|
|
||||||
this.session = session;
|
|
||||||
this.restartOnAuthFail = restartOnAuthFail;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterBrowserInitialized() {
|
|
||||||
if(this.session) {
|
|
||||||
await this.client.pupPage.evaluateOnNewDocument(session => {
|
|
||||||
if (document.referrer === 'https://whatsapp.com/') {
|
|
||||||
localStorage.clear();
|
|
||||||
localStorage.setItem('WABrowserId', session.WABrowserId);
|
|
||||||
localStorage.setItem('WASecretBundle', session.WASecretBundle);
|
|
||||||
localStorage.setItem('WAToken1', session.WAToken1);
|
|
||||||
localStorage.setItem('WAToken2', session.WAToken2);
|
|
||||||
}
|
|
||||||
|
|
||||||
localStorage.setItem('remember-me', 'true');
|
|
||||||
}, this.session);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async onAuthenticationNeeded() {
|
|
||||||
if(this.session) {
|
|
||||||
this.session = null;
|
|
||||||
return {
|
|
||||||
failed: true,
|
|
||||||
restart: this.restartOnAuthFail,
|
|
||||||
failureEventPayload: 'Unable to log in. Are the session details valid?'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return { failed: false };
|
|
||||||
}
|
|
||||||
|
|
||||||
async getAuthEventPayload() {
|
|
||||||
const isMD = await this.client.pupPage.evaluate(() => {
|
|
||||||
return window.Store.MDBackend;
|
|
||||||
});
|
|
||||||
|
|
||||||
if(isMD) throw new Error('Authenticating via JSON session is not supported for MultiDevice-enabled WhatsApp accounts.');
|
|
||||||
|
|
||||||
const localStorage = JSON.parse(await this.client.pupPage.evaluate(() => {
|
|
||||||
return JSON.stringify(window.localStorage);
|
|
||||||
}));
|
|
||||||
|
|
||||||
return {
|
|
||||||
WABrowserId: localStorage.WABrowserId,
|
|
||||||
WASecretBundle: localStorage.WASecretBundle,
|
|
||||||
WAToken1: localStorage.WAToken1,
|
|
||||||
WAToken2: localStorage.WAToken2
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = LegacySessionAuth;
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
|
||||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Local directory-based authentication
|
|
||||||
* @param {object} options - options
|
|
||||||
* @param {string} options.clientId - Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance
|
|
||||||
* @param {string} options.dataPath - Change the default path for saving session files, default is: "./.wwebjs_auth/"
|
|
||||||
*/
|
|
||||||
class LocalAuth extends BaseAuthStrategy {
|
|
||||||
constructor({ clientId, dataPath }={}) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
const idRegex = /^[-_\w]+$/i;
|
|
||||||
if(clientId && !idRegex.test(clientId)) {
|
|
||||||
throw new Error('Invalid clientId. Only alphanumeric characters, underscores and hyphens are allowed.');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dataPath = path.resolve(dataPath || './.wwebjs_auth/');
|
|
||||||
this.clientId = clientId;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeBrowserInitialized() {
|
|
||||||
const puppeteerOpts = this.client.options.puppeteer;
|
|
||||||
const sessionDirName = this.clientId ? `session-${this.clientId}` : 'session';
|
|
||||||
const dirPath = path.join(this.dataPath, sessionDirName);
|
|
||||||
|
|
||||||
if(puppeteerOpts.userDataDir && puppeteerOpts.userDataDir !== dirPath) {
|
|
||||||
throw new Error('LocalAuth is not compatible with a user-supplied userDataDir.');
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.mkdirSync(dirPath, { recursive: true });
|
|
||||||
|
|
||||||
this.client.options.puppeteer = {
|
|
||||||
...puppeteerOpts,
|
|
||||||
userDataDir: dirPath
|
|
||||||
};
|
|
||||||
|
|
||||||
this.userDataDir = dirPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
async logout() {
|
|
||||||
if (this.userDataDir) {
|
|
||||||
return (fs.rmSync ? fs.rmSync : fs.rmdirSync).call(this, this.userDataDir, { recursive: true });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = LocalAuth;
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No session restoring functionality
|
|
||||||
* Will need to authenticate via QR code every time
|
|
||||||
*/
|
|
||||||
class NoAuth extends BaseAuthStrategy { }
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = NoAuth;
|
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
/* Require Optional Dependencies */
|
|
||||||
try {
|
|
||||||
var fs = require('fs-extra');
|
|
||||||
var unzipper = require('unzipper');
|
|
||||||
var archiver = require('archiver');
|
|
||||||
} catch {
|
|
||||||
fs = undefined;
|
|
||||||
unzipper = undefined;
|
|
||||||
archiver = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const { Events } = require('./../util/Constants');
|
|
||||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remote-based authentication
|
|
||||||
* @param {object} options - options
|
|
||||||
* @param {object} options.store - Remote database store instance
|
|
||||||
* @param {string} options.clientId - Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance
|
|
||||||
* @param {string} options.dataPath - Change the default path for saving session files, default is: "./.wwebjs_auth/"
|
|
||||||
* @param {number} options.backupSyncIntervalMs - Sets the time interval for periodic session backups. Accepts values starting from 60000ms {1 minute}
|
|
||||||
*/
|
|
||||||
class RemoteAuth extends BaseAuthStrategy {
|
|
||||||
constructor({ clientId, dataPath, store, backupSyncIntervalMs } = {}) {
|
|
||||||
if (!fs && !unzipper && !archiver) throw new Error('Optional Dependencies [fs-extra, unzipper, archiver] are required to use RemoteAuth. Make sure to run npm install correctly and remove the --no-optional flag');
|
|
||||||
super();
|
|
||||||
|
|
||||||
const idRegex = /^[-_\w]+$/i;
|
|
||||||
if (clientId && !idRegex.test(clientId)) {
|
|
||||||
throw new Error('Invalid clientId. Only alphanumeric characters, underscores and hyphens are allowed.');
|
|
||||||
}
|
|
||||||
if (!backupSyncIntervalMs || backupSyncIntervalMs < 60000) {
|
|
||||||
throw new Error('Invalid backupSyncIntervalMs. Accepts values starting from 60000ms {1 minute}.');
|
|
||||||
}
|
|
||||||
if(!store) throw new Error('Remote database store is required.');
|
|
||||||
|
|
||||||
this.store = store;
|
|
||||||
this.clientId = clientId;
|
|
||||||
this.backupSyncIntervalMs = backupSyncIntervalMs;
|
|
||||||
this.dataPath = path.resolve(dataPath || './.wwebjs_auth/');
|
|
||||||
this.tempDir = `${this.dataPath}/wwebjs_temp_session`;
|
|
||||||
this.requiredDirs = ['Default', 'IndexedDB', 'Local Storage']; /* => Required Files & Dirs in WWebJS to restore session */
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeBrowserInitialized() {
|
|
||||||
const puppeteerOpts = this.client.options.puppeteer;
|
|
||||||
const sessionDirName = this.clientId ? `RemoteAuth-${this.clientId}` : 'RemoteAuth';
|
|
||||||
const dirPath = path.join(this.dataPath, sessionDirName);
|
|
||||||
|
|
||||||
if (puppeteerOpts.userDataDir && puppeteerOpts.userDataDir !== dirPath) {
|
|
||||||
throw new Error('RemoteAuth is not compatible with a user-supplied userDataDir.');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.userDataDir = dirPath;
|
|
||||||
this.sessionName = sessionDirName;
|
|
||||||
|
|
||||||
await this.extractRemoteSession();
|
|
||||||
|
|
||||||
this.client.options.puppeteer = {
|
|
||||||
...puppeteerOpts,
|
|
||||||
userDataDir: dirPath
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async logout() {
|
|
||||||
await this.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
async destroy() {
|
|
||||||
clearInterval(this.backupSync);
|
|
||||||
}
|
|
||||||
|
|
||||||
async disconnect() {
|
|
||||||
await this.deleteRemoteSession();
|
|
||||||
|
|
||||||
let pathExists = await this.isValidPath(this.userDataDir);
|
|
||||||
if (pathExists) {
|
|
||||||
await fs.promises.rm(this.userDataDir, {
|
|
||||||
recursive: true,
|
|
||||||
force: true
|
|
||||||
}).catch(() => {});
|
|
||||||
}
|
|
||||||
clearInterval(this.backupSync);
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterAuthReady() {
|
|
||||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
|
||||||
if(!sessionExists) {
|
|
||||||
await this.delay(60000); /* Initial delay sync required for session to be stable enough to recover */
|
|
||||||
await this.storeRemoteSession({emit: true});
|
|
||||||
}
|
|
||||||
var self = this;
|
|
||||||
this.backupSync = setInterval(async function () {
|
|
||||||
await self.storeRemoteSession();
|
|
||||||
}, this.backupSyncIntervalMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
async storeRemoteSession(options) {
|
|
||||||
/* Compress & Store Session */
|
|
||||||
const pathExists = await this.isValidPath(this.userDataDir);
|
|
||||||
if (pathExists) {
|
|
||||||
await this.compressSession();
|
|
||||||
await this.store.save({session: this.sessionName});
|
|
||||||
await fs.promises.unlink(`${this.sessionName}.zip`);
|
|
||||||
await fs.promises.rm(`${this.tempDir}`, {
|
|
||||||
recursive: true,
|
|
||||||
force: true
|
|
||||||
}).catch(() => {});
|
|
||||||
if(options && options.emit) this.client.emit(Events.REMOTE_SESSION_SAVED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async extractRemoteSession() {
|
|
||||||
const pathExists = await this.isValidPath(this.userDataDir);
|
|
||||||
const compressedSessionPath = `${this.sessionName}.zip`;
|
|
||||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
|
||||||
if (pathExists) {
|
|
||||||
await fs.promises.rm(this.userDataDir, {
|
|
||||||
recursive: true,
|
|
||||||
force: true
|
|
||||||
}).catch(() => {});
|
|
||||||
}
|
|
||||||
if (sessionExists) {
|
|
||||||
await this.store.extract({session: this.sessionName, path: compressedSessionPath});
|
|
||||||
await this.unCompressSession(compressedSessionPath);
|
|
||||||
} else {
|
|
||||||
fs.mkdirSync(this.userDataDir, { recursive: true });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteRemoteSession() {
|
|
||||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
|
||||||
if (sessionExists) await this.store.delete({session: this.sessionName});
|
|
||||||
}
|
|
||||||
|
|
||||||
async compressSession() {
|
|
||||||
const archive = archiver('zip');
|
|
||||||
const stream = fs.createWriteStream(`${this.sessionName}.zip`);
|
|
||||||
|
|
||||||
await fs.copy(this.userDataDir, this.tempDir).catch(() => {});
|
|
||||||
await this.deleteMetadata();
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
archive
|
|
||||||
.directory(this.tempDir, false)
|
|
||||||
.on('error', err => reject(err))
|
|
||||||
.pipe(stream);
|
|
||||||
|
|
||||||
stream.on('close', () => resolve());
|
|
||||||
archive.finalize();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async unCompressSession(compressedSessionPath) {
|
|
||||||
var stream = fs.createReadStream(compressedSessionPath);
|
|
||||||
await new Promise((resolve, reject) => {
|
|
||||||
stream.pipe(unzipper.Extract({
|
|
||||||
path: this.userDataDir
|
|
||||||
}))
|
|
||||||
.on('error', err => reject(err))
|
|
||||||
.on('finish', () => resolve());
|
|
||||||
});
|
|
||||||
await fs.promises.unlink(compressedSessionPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteMetadata() {
|
|
||||||
const sessionDirs = [this.tempDir, path.join(this.tempDir, 'Default')];
|
|
||||||
for (const dir of sessionDirs) {
|
|
||||||
const sessionFiles = await fs.promises.readdir(dir);
|
|
||||||
for (const element of sessionFiles) {
|
|
||||||
if (!this.requiredDirs.includes(element)) {
|
|
||||||
const dirElement = path.join(dir, element);
|
|
||||||
const stats = await fs.promises.lstat(dirElement);
|
|
||||||
|
|
||||||
if (stats.isDirectory()) {
|
|
||||||
await fs.promises.rm(dirElement, {
|
|
||||||
recursive: true,
|
|
||||||
force: true
|
|
||||||
}).catch(() => {});
|
|
||||||
} else {
|
|
||||||
await fs.promises.unlink(dirElement).catch(() => {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async isValidPath(path) {
|
|
||||||
try {
|
|
||||||
await fs.promises.access(path);
|
|
||||||
return true;
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async delay(ms) {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = RemoteAuth;
|
|
||||||
@@ -1,23 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const MessageMedia = require('./MessageMedia');
|
const MessageMedia = require('./MessageMedia');
|
||||||
|
const Util = require('../util/Util');
|
||||||
/**
|
|
||||||
* Button spec used in Buttons constructor
|
|
||||||
* @typedef {Object} ButtonSpec
|
|
||||||
* @property {string} body - The text to show on the button.
|
|
||||||
* @property {string=} id - Custom ID to set on the button. A random one will be generated if one is not passed.
|
|
||||||
* @ property {string=} url - Custom URL to set on the button. Optional and will change the type of the button
|
|
||||||
* @ property {string=} number - Custom URL to set on the button. Optional and will change the type of the button
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} FormattedButtonSpec
|
|
||||||
* @property {number} index
|
|
||||||
* @property {{displayText: string, url: string}=} urlButton
|
|
||||||
* @property {{displayText: string, phoneNumber: string}=} callButton
|
|
||||||
* @property {{displayText: string, id: string}=} quickReplyButton
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message type buttons
|
* Message type buttons
|
||||||
@@ -25,7 +9,7 @@ const MessageMedia = require('./MessageMedia');
|
|||||||
class Buttons {
|
class Buttons {
|
||||||
/**
|
/**
|
||||||
* @param {string|MessageMedia} body
|
* @param {string|MessageMedia} body
|
||||||
* @param {ButtonSpec[]} buttons - See {@link ButtonSpec}
|
* @param {Array<Array<string>>} buttons
|
||||||
* @param {string?} title
|
* @param {string?} title
|
||||||
* @param {string?} footer
|
* @param {string?} footer
|
||||||
*/
|
*/
|
||||||
@@ -57,7 +41,7 @@ class Buttons {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* buttons of message
|
* buttons of message
|
||||||
* @type {FormattedButtonSpec[]}
|
* @type {Array<Array<string>>}
|
||||||
*/
|
*/
|
||||||
this.buttons = this._format(buttons);
|
this.buttons = this._format(buttons);
|
||||||
if(!this.buttons.length){ throw '[BT01] No buttons';}
|
if(!this.buttons.length){ throw '[BT01] No buttons';}
|
||||||
@@ -66,48 +50,19 @@ class Buttons {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates button array from simple array
|
* Creates button array from simple array
|
||||||
* @param {ButtonSpec[]} buttons
|
* @param {Array<Array<string>>} buttons
|
||||||
* @returns {FormattedButtonSpec[]}
|
* @returns {Array<Array<string>>}
|
||||||
|
* @example
|
||||||
|
* Input: [{id:'customId',body:'button1'},{body:'button2'},{body:'button3'},{body:'button4'}]
|
||||||
|
* Returns: [{ buttonId:'customId',buttonText:{'displayText':'button1'},type: 1 },{buttonId:'n3XKsL',buttonText:{'displayText':'button2'},type:1},{buttonId:'NDJk0a',buttonText:{'displayText':'button3'},type:1}]
|
||||||
*/
|
*/
|
||||||
_format(buttons){
|
_format(buttons){
|
||||||
// Limit the buttons (max 3 of regular and 3 of special buttons) 5 buttons total at the same time
|
buttons = buttons.slice(0,3); // phone users can only see 3 buttons, so lets limit this
|
||||||
const templateButtons = buttons.filter(button => button.url || button.number).slice(0,3);
|
return buttons.map((btn) => {
|
||||||
const regularButtons = buttons.filter(button => !button.url && !button.number).slice(0,3);
|
return {'buttonId':btn.id ? btn.id : Util.generateHash(6),'buttonText':{'displayText':btn.body},'type':1};
|
||||||
buttons = templateButtons.concat(regularButtons).slice(0,5);
|
|
||||||
|
|
||||||
return buttons.map((button, index) => {
|
|
||||||
if (button.url && button.number && button.id) throw 'Only pick one of the following (url/number/id)';
|
|
||||||
if (button.number) {
|
|
||||||
throw 'Not supported, URL and Call buttons are not supported on IOS';
|
|
||||||
/* return {
|
|
||||||
index,
|
|
||||||
callButton: {
|
|
||||||
displayText: button.body,
|
|
||||||
phoneNumber: button.number || ''
|
|
||||||
}
|
|
||||||
}; */
|
|
||||||
} else if (button.url) {
|
|
||||||
throw 'Not supported, URL and Call buttons are not supported on IOS';
|
|
||||||
/* return {
|
|
||||||
index,
|
|
||||||
urlButton: {
|
|
||||||
displayText: button.body,
|
|
||||||
url: button.url || ''
|
|
||||||
}
|
|
||||||
}; */
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
index,
|
|
||||||
quickReplyButton: {
|
|
||||||
displayText: button.body,
|
|
||||||
id: button.id || `${index}`
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Buttons;
|
module.exports = Buttons;
|
||||||
@@ -62,15 +62,7 @@ class Call extends Base {
|
|||||||
|
|
||||||
return super._patch(data);
|
return super._patch(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reject the call
|
|
||||||
*/
|
|
||||||
async reject() {
|
|
||||||
return this.client.pupPage.evaluate((peerJid, id) => {
|
|
||||||
return window.WWebJS.rejectCall(peerJid, id);
|
|
||||||
}, this.from, this.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Call;
|
module.exports = Call;
|
||||||
@@ -65,7 +65,7 @@ class Chat extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the chat is muted or not
|
* Indicates if the chat is muted or not
|
||||||
* @type {boolean}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.isMuted = data.isMuted;
|
this.isMuted = data.isMuted;
|
||||||
|
|
||||||
@@ -147,8 +147,8 @@ class Chat extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutes this chat forever, unless a date is specified
|
* Mutes this chat until a specified date
|
||||||
* @param {?Date} unmuteDate Date at which the Chat will be unmuted, leave as is to mute forever
|
* @param {Date} unmuteDate Date at which the Chat will be unmuted
|
||||||
*/
|
*/
|
||||||
async mute(unmuteDate) {
|
async mute(unmuteDate) {
|
||||||
return this.client.muteChat(this.id._serialized, unmuteDate);
|
return this.client.muteChat(this.id._serialized, unmuteDate);
|
||||||
@@ -170,42 +170,31 @@ class Chat extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads chat messages, sorted from earliest to latest.
|
* Loads chat messages, sorted from earliest to latest.
|
||||||
* @param {Object} searchOptions Options for searching messages. Right now only limit and fromMe is supported.
|
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
||||||
* @param {Number} [searchOptions.limit] The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.
|
* @param {Number} [searchOptions.limit=50] The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.
|
||||||
* @param {Boolean} [searchOptions.fromMe] Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.
|
|
||||||
* @returns {Promise<Array<Message>>}
|
* @returns {Promise<Array<Message>>}
|
||||||
*/
|
*/
|
||||||
async fetchMessages(searchOptions) {
|
async fetchMessages(searchOptions) {
|
||||||
let messages = await this.client.pupPage.evaluate(async (chatId, searchOptions) => {
|
if (!searchOptions || !searchOptions.limit) {
|
||||||
const msgFilter = (m) => {
|
searchOptions = { limit: 50 };
|
||||||
if (m.isNotification) {
|
}
|
||||||
return false; // dont include notification messages
|
let messages = await this.client.pupPage.evaluate(async (chatId, limit) => {
|
||||||
}
|
const msgFilter = m => !m.isNotification; // dont include notification messages
|
||||||
if (searchOptions && searchOptions.fromMe && m.id.fromMe !== searchOptions.fromMe) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const chat = window.Store.Chat.get(chatId);
|
const chat = window.Store.Chat.get(chatId);
|
||||||
let msgs = chat.msgs.getModelsArray().filter(msgFilter);
|
let msgs = chat.msgs.models.filter(msgFilter);
|
||||||
|
|
||||||
if (searchOptions && searchOptions.limit > 0) {
|
while (msgs.length < limit) {
|
||||||
while (msgs.length < searchOptions.limit) {
|
const loadedMessages = await chat.loadEarlierMsgs();
|
||||||
const loadedMessages = await window.Store.ConversationMsgs.loadEarlierMsgs(chat);
|
if (!loadedMessages) break;
|
||||||
if (!loadedMessages || !loadedMessages.length) break;
|
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msgs.length > searchOptions.limit) {
|
|
||||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
|
||||||
msgs = msgs.splice(msgs.length - searchOptions.limit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||||
|
if (msgs.length > limit) msgs = msgs.splice(msgs.length - limit);
|
||||||
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
||||||
|
|
||||||
}, this.id._serialized, searchOptions);
|
}, this.id._serialized, searchOptions.limit);
|
||||||
|
|
||||||
return messages.map(m => new Message(this.client, m));
|
return messages.map(m => new Message(this.client, m));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,6 @@ class ClientInfo extends Base {
|
|||||||
*/
|
*/
|
||||||
this.pushname = data.pushname;
|
this.pushname = data.pushname;
|
||||||
|
|
||||||
/**
|
|
||||||
* Current user ID
|
|
||||||
* @type {object}
|
|
||||||
*/
|
|
||||||
this.wid = data.wid;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {object}
|
* @type {object}
|
||||||
* @deprecated Use .wid instead
|
* @deprecated Use .wid instead
|
||||||
@@ -33,19 +27,24 @@ class ClientInfo extends Base {
|
|||||||
this.me = data.wid;
|
this.me = data.wid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about the phone this client is connected to. Not available in multi-device.
|
* Current user ID
|
||||||
|
* @type {object}
|
||||||
|
*/
|
||||||
|
this.wid = data.wid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about the phone this client is connected to
|
||||||
* @type {object}
|
* @type {object}
|
||||||
* @property {string} wa_version WhatsApp Version running on the phone
|
* @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} os_version OS Version running on the phone (iOS or Android version)
|
||||||
* @property {string} device_manufacturer Device manufacturer
|
* @property {string} device_manufacturer Device manufacturer
|
||||||
* @property {string} device_model Device model
|
* @property {string} device_model Device model
|
||||||
* @property {string} os_build_number OS build number
|
* @property {string} os_build_number OS build number
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
this.phone = data.phone;
|
this.phone = data.phone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform WhatsApp is running on
|
* Platform the phone is running on
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.platform = data.platform;
|
this.platform = data.platform;
|
||||||
@@ -58,7 +57,6 @@ class ClientInfo extends Base {
|
|||||||
* @returns {object} batteryStatus
|
* @returns {object} batteryStatus
|
||||||
* @returns {number} batteryStatus.battery - The current battery percentage
|
* @returns {number} batteryStatus.battery - The current battery percentage
|
||||||
* @returns {boolean} batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)
|
* @returns {boolean} batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
async getBatteryStatus() {
|
async getBatteryStatus() {
|
||||||
return await this.client.pupPage.evaluate(() => {
|
return await this.client.pupPage.evaluate(() => {
|
||||||
@@ -66,6 +64,7 @@ class ClientInfo extends Base {
|
|||||||
return { battery, plugged };
|
return { battery, plugged };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ClientInfo;
|
module.exports = ClientInfo;
|
||||||
@@ -108,7 +108,7 @@ class Contact extends Base {
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.isBlocked = data.isBlocked;
|
this.isBlocked = data.isBlocked;
|
||||||
|
|
||||||
return super._patch(data);
|
return super._patch(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,22 +120,6 @@ class Contact extends Base {
|
|||||||
return await this.client.getProfilePicUrl(this.id._serialized);
|
return await this.client.getProfilePicUrl(this.id._serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901)
|
|
||||||
* @returns {Promise<string>}
|
|
||||||
*/
|
|
||||||
async getFormattedNumber() {
|
|
||||||
return await this.client.getFormattedNumber(this.id._serialized);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the contact's countrycode, (1541859685@c.us) => (1)
|
|
||||||
* @returns {Promise<string>}
|
|
||||||
*/
|
|
||||||
async getCountryCode() {
|
|
||||||
return await this.client.getCountryCode(this.id._serialized);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Chat that corresponds to this Contact.
|
* Returns the Chat that corresponds to this Contact.
|
||||||
* Will return null when getting chat for currently logged in user.
|
* Will return null when getting chat for currently logged in user.
|
||||||
@@ -183,8 +167,7 @@ class Contact extends Base {
|
|||||||
*/
|
*/
|
||||||
async getAbout() {
|
async getAbout() {
|
||||||
const about = await this.client.pupPage.evaluate(async (contactId) => {
|
const about = await this.client.pupPage.evaluate(async (contactId) => {
|
||||||
const wid = window.Store.WidFactory.createWid(contactId);
|
return window.Store.Wap.statusFind(contactId);
|
||||||
return window.Store.StatusUtils.getStatus(wid);
|
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
if (typeof about.status !== 'string')
|
if (typeof about.status !== 'string')
|
||||||
@@ -192,15 +175,7 @@ class Contact extends Base {
|
|||||||
|
|
||||||
return about.status;
|
return about.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
|
|
||||||
* @returns {Promise<WAWebJS.ChatId[]>}
|
|
||||||
*/
|
|
||||||
async getCommonGroups() {
|
|
||||||
return await this.client.getCommonGroups(this.id._serialized);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Contact;
|
module.exports = Contact;
|
||||||
@@ -59,15 +59,8 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise<Object>}
|
* @returns {Promise<Object>}
|
||||||
*/
|
*/
|
||||||
async addParticipants(participantIds) {
|
async addParticipants(participantIds) {
|
||||||
return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
|
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.addParticipants(chatId, participantIds);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
|
||||||
const participants = await Promise.all(participantIds.map(async p => {
|
|
||||||
const wid = window.Store.WidFactory.createWid(p);
|
|
||||||
return await window.Store.Contact.get(wid);
|
|
||||||
}));
|
|
||||||
await window.Store.GroupParticipants.addParticipants(chat, participants);
|
|
||||||
return { status: 200 };
|
|
||||||
}, this.id._serialized, participantIds);
|
}, this.id._serialized, participantIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,14 +70,8 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise<Object>}
|
* @returns {Promise<Object>}
|
||||||
*/
|
*/
|
||||||
async removeParticipants(participantIds) {
|
async removeParticipants(participantIds) {
|
||||||
return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
|
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.removeParticipants(chatId, participantIds);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
|
||||||
const participants = participantIds.map(p => {
|
|
||||||
return chat.groupMetadata.participants.get(p);
|
|
||||||
}).filter(p => Boolean(p));
|
|
||||||
await window.Store.GroupParticipants.removeParticipants(chat, participants);
|
|
||||||
return { status: 200 };
|
|
||||||
}, this.id._serialized, participantIds);
|
}, this.id._serialized, participantIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,14 +81,8 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful
|
* @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful
|
||||||
*/
|
*/
|
||||||
async promoteParticipants(participantIds) {
|
async promoteParticipants(participantIds) {
|
||||||
return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
|
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.promoteParticipants(chatId, participantIds);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
|
||||||
const participants = participantIds.map(p => {
|
|
||||||
return chat.groupMetadata.participants.get(p);
|
|
||||||
}).filter(p => Boolean(p));
|
|
||||||
await window.Store.GroupParticipants.promoteParticipants(chat, participants);
|
|
||||||
return { status: 200 };
|
|
||||||
}, this.id._serialized, participantIds);
|
}, this.id._serialized, participantIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,81 +92,54 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful
|
* @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful
|
||||||
*/
|
*/
|
||||||
async demoteParticipants(participantIds) {
|
async demoteParticipants(participantIds) {
|
||||||
return await this.client.pupPage.evaluate(async (chatId, participantIds) => {
|
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.demoteParticipants(chatId, participantIds);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
|
||||||
const participants = participantIds.map(p => {
|
|
||||||
return chat.groupMetadata.participants.get(p);
|
|
||||||
}).filter(p => Boolean(p));
|
|
||||||
await window.Store.GroupParticipants.demoteParticipants(chat, participants);
|
|
||||||
return { status: 200 };
|
|
||||||
}, this.id._serialized, participantIds);
|
}, this.id._serialized, participantIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the group subject
|
* Updates the group subject
|
||||||
* @param {string} subject
|
* @param {string} subject
|
||||||
* @returns {Promise<boolean>} Returns true if the subject was properly updated. This can return false if the user does not have the necessary permissions.
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async setSubject(subject) {
|
async setSubject(subject) {
|
||||||
const success = await this.client.pupPage.evaluate(async (chatId, subject) => {
|
let res = await this.client.pupPage.evaluate((chatId, subject) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.changeSubject(chatId, subject);
|
||||||
try {
|
|
||||||
await window.Store.GroupUtils.setGroupSubject(chatWid, subject);
|
|
||||||
return true;
|
|
||||||
} catch (err) {
|
|
||||||
if(err.name === 'ServerStatusCodeError') return false;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}, this.id._serialized, subject);
|
}, this.id._serialized, subject);
|
||||||
|
|
||||||
if(!success) return false;
|
if(res.status == 200) {
|
||||||
this.name = subject;
|
this.name = subject;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the group description
|
* Updates the group description
|
||||||
* @param {string} description
|
* @param {string} description
|
||||||
* @returns {Promise<boolean>} Returns true if the description was properly updated. This can return false if the user does not have the necessary permissions.
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async setDescription(description) {
|
async setDescription(description) {
|
||||||
const success = await this.client.pupPage.evaluate(async (chatId, description) => {
|
let res = await this.client.pupPage.evaluate((chatId, description) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
let descId = window.Store.GroupMetadata.get(chatId).descId;
|
||||||
let descId = window.Store.GroupMetadata.get(chatWid).descId;
|
return window.Store.Wap.setGroupDescription(chatId, description, window.Store.genId(), descId);
|
||||||
try {
|
|
||||||
await window.Store.GroupUtils.setGroupDescription(chatWid, description, window.Store.MsgKey.newId(), descId);
|
|
||||||
return true;
|
|
||||||
} catch (err) {
|
|
||||||
if(err.name === 'ServerStatusCodeError') return false;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}, this.id._serialized, description);
|
}, this.id._serialized, description);
|
||||||
|
|
||||||
if(!success) return false;
|
if (res.status == 200) {
|
||||||
this.groupMetadata.desc = description;
|
this.groupMetadata.desc = description;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the group settings to only allow admins to send messages.
|
* Updates the group settings to only allow admins to send messages.
|
||||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||||
*/
|
*/
|
||||||
async setMessagesAdminsOnly(adminsOnly=true) {
|
async setMessagesAdminsOnly(adminsOnly=true) {
|
||||||
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
|
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.setGroupProperty(chatId, 'announcement', value);
|
||||||
try {
|
|
||||||
await window.Store.GroupUtils.setGroupProperty(chatWid, 'announcement', adminsOnly ? 1 : 0);
|
|
||||||
return true;
|
|
||||||
} catch (err) {
|
|
||||||
if(err.name === 'ServerStatusCodeError') return false;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}, this.id._serialized, adminsOnly);
|
}, this.id._serialized, adminsOnly);
|
||||||
|
|
||||||
if(!success) return false;
|
if (res.status !== 200) return false;
|
||||||
|
|
||||||
this.groupMetadata.announce = adminsOnly;
|
this.groupMetadata.announce = adminsOnly;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -196,18 +150,11 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||||
*/
|
*/
|
||||||
async setInfoAdminsOnly(adminsOnly=true) {
|
async setInfoAdminsOnly(adminsOnly=true) {
|
||||||
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
|
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.setGroupProperty(chatId, 'restrict', value);
|
||||||
try {
|
|
||||||
await window.Store.GroupUtils.setGroupProperty(chatWid, 'restrict', adminsOnly ? 1 : 0);
|
|
||||||
return true;
|
|
||||||
} catch (err) {
|
|
||||||
if(err.name === 'ServerStatusCodeError') return false;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}, this.id._serialized, adminsOnly);
|
}, this.id._serialized, adminsOnly);
|
||||||
|
|
||||||
if(!success) return false;
|
if (res.status !== 200) return false;
|
||||||
|
|
||||||
this.groupMetadata.restrict = adminsOnly;
|
this.groupMetadata.restrict = adminsOnly;
|
||||||
return true;
|
return true;
|
||||||
@@ -218,25 +165,25 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise<string>} Group's invite code
|
* @returns {Promise<string>} Group's invite code
|
||||||
*/
|
*/
|
||||||
async getInviteCode() {
|
async getInviteCode() {
|
||||||
const codeRes = await this.client.pupPage.evaluate(async chatId => {
|
let res = await this.client.pupPage.evaluate(chatId => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.groupInviteCode(chatId);
|
||||||
return window.Store.Invite.queryGroupInviteCode(chatWid);
|
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
return codeRes.code;
|
if (res.status == 200) {
|
||||||
|
return res.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error('Not authorized');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates the current group invite code and generates a new one
|
* Invalidates the current group invite code and generates a new one
|
||||||
* @returns {Promise<string>} New invite code
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async revokeInvite() {
|
async revokeInvite() {
|
||||||
const codeRes = await this.client.pupPage.evaluate(chatId => {
|
return await this.client.pupPage.evaluate(chatId => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.revokeGroupInvite(chatId);
|
||||||
return window.Store.Invite.resetGroupInviteCode(chatWid);
|
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
return codeRes.code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -244,10 +191,8 @@ class GroupChat extends Chat {
|
|||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async leave() {
|
async leave() {
|
||||||
await this.client.pupPage.evaluate(async chatId => {
|
return await this.client.pupPage.evaluate(chatId => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.Wap.leaveGroup(chatId);
|
||||||
const chat = await window.Store.Chat.find(chatWid);
|
|
||||||
return window.Store.GroupUtils.sendExitGroup(chat);
|
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class GroupNotification extends Base {
|
|||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.chatId = typeof (data.id.remote) === 'object' ? data.id.remote._serialized : data.id.remote;
|
this.chatId = typeof (data.from) === 'object' ? data.from._serialized : data.from;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ContactId for the user that produced the GroupNotification.
|
* ContactId for the user that produced the GroupNotification.
|
||||||
|
|||||||
@@ -2,38 +2,16 @@
|
|||||||
|
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
|
|
||||||
/**
|
|
||||||
* Section spec used in List constructor
|
|
||||||
* @typedef {Object} SectionSpec
|
|
||||||
* @property {string=} title - The title of the section, can be empty on the first section only.
|
|
||||||
* @property {RowSpec[]} rows - The rows of the section.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Row spec used in List constructor
|
|
||||||
* @typedef {Object} RowSpec
|
|
||||||
* @property {string} title - The text to show on the row.
|
|
||||||
* @property {string=} id - Custom ID to set on the row. A random one will be generated if one is not passed.
|
|
||||||
* @property {string=} description - Custom description for the row, will appear after clicked in the list response message (appended)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Formatted section spec
|
|
||||||
* @typedef {Object} FormattedSectionSpec
|
|
||||||
* @property {string} title
|
|
||||||
* @property {{rowId: string; title: string; description: string}[]} rows
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message type List
|
* Message type List
|
||||||
*/
|
*/
|
||||||
class List {
|
class List {
|
||||||
/**
|
/**
|
||||||
* @param {string} body - A text body, no media.
|
* @param {string} body
|
||||||
* @param {string} buttonText - The text to put on the click to open button.
|
* @param {string} buttonText
|
||||||
* @param {Array<SectionSpec>} sections - The sections of the list
|
* @param {Array<any>} sections
|
||||||
* @param {string?} title - Custom boldfaced title property
|
* @param {string?} title
|
||||||
* @param {string?} footer - Custom footer added in a small font to the end of the message
|
* @param {string?} footer
|
||||||
*/
|
*/
|
||||||
constructor(body, buttonText, sections, title, footer) {
|
constructor(body, buttonText, sections, title, footer) {
|
||||||
/**
|
/**
|
||||||
@@ -71,28 +49,23 @@ class List {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates section array from simple array
|
* Creates section array from simple array
|
||||||
* @param {Array<SectionSpec>} sections
|
* @param {Array<any>} sections
|
||||||
* @returns {Array<FormattedSectionSpec>}
|
* @returns {Array<any>}
|
||||||
|
* @example
|
||||||
|
* Input: [{title:'sectionTitle',rows:[{id:'customId', title:'ListItem2', description: 'desc'},{title:'ListItem2'}]}}]
|
||||||
|
* Returns: [{'title':'sectionTitle','rows':[{'rowId':'customId','title':'ListItem1','description':'desc'},{'rowId':'oGSRoD','title':'ListItem2','description':''}]}]
|
||||||
*/
|
*/
|
||||||
_format(sections) {
|
_format(sections){
|
||||||
if(!sections.length) {
|
if(!sections.length){throw '[LT02] List without sections';}
|
||||||
throw '[LT02] List without sections';
|
if(sections.length > 1){throw '[LT05] Lists with more than one section are having problems';}
|
||||||
}
|
return sections.map( (section) =>{
|
||||||
if(sections.length > 1 && sections.filter(section => (typeof section.title == 'undefined' )|| section.title == '' ).length > 1) {
|
if(!section.rows.length){throw '[LT03] Section without rows';}
|
||||||
throw '[LT05] You can\'t have more than one empty title.';
|
|
||||||
}
|
|
||||||
return sections.map((section, index) => {
|
|
||||||
if(!section.rows.length) {
|
|
||||||
throw '[LT03] Section without rows';
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
title: section.title ? section.title : undefined,
|
title: section.title ? section.title : undefined,
|
||||||
rows: section.rows.map((row, rowIndex) => {
|
rows: section.rows.map( (row) => {
|
||||||
if (!row.title) {
|
if(!row.title){throw '[LT04] Row without title';}
|
||||||
throw `[LT04] Row without title at section index ${index} and row index ${rowIndex}`;
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
rowId: row.id ? row.id : Util.generateHash(8),
|
rowId: row.id ? row.id : Util.generateHash(6),
|
||||||
title: row.title,
|
title: row.title,
|
||||||
description: row.description ? row.description : ''
|
description: row.description ? row.description : ''
|
||||||
};
|
};
|
||||||
@@ -103,4 +76,4 @@ class List {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = List;
|
module.exports = List;
|
||||||
@@ -19,14 +19,13 @@ class Message extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_patch(data) {
|
_patch(data) {
|
||||||
this._data = data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MediaKey that represents the sticker 'ID'
|
* MediaKey that represents the sticker 'ID'
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.mediaKey = data.mediaKey;
|
this.mediaKey = data.mediaKey;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID that represents the message
|
* ID that represents the message
|
||||||
* @type {object}
|
* @type {object}
|
||||||
@@ -51,7 +50,7 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
this.body = this.hasMedia ? data.caption || '' : data.body || '';
|
this.body = this.hasMedia ? data.caption || '' : data.body || '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message type
|
* Message type
|
||||||
* @type {MessageTypes}
|
* @type {MessageTypes}
|
||||||
*/
|
*/
|
||||||
@@ -71,9 +70,9 @@ class Message extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ID for who this message is for.
|
* 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 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.
|
* If the message is sent by another user, it will be the ID for the current user.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.to = (typeof (data.to) === 'object' && data.to !== null) ? data.to._serialized : data.to;
|
this.to = (typeof (data.to) === 'object' && data.to !== null) ? data.to._serialized : data.to;
|
||||||
@@ -88,8 +87,8 @@ class Message extends Base {
|
|||||||
* String that represents from which device type the message was sent
|
* String that represents from which device type the message was sent
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0, 2) == '3A' ? 'ios' : 'web';
|
this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0,2) =='3A' ? 'ios' : 'web';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the message was forwarded
|
* Indicates if the message was forwarded
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@@ -115,14 +114,14 @@ class Message extends Base {
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.isStarred = data.star;
|
this.isStarred = data.star;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the message was a broadcast
|
* Indicates if the message was a broadcast
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.broadcast = data.broadcast;
|
this.broadcast = data.broadcast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the message was sent by the current user
|
* Indicates if the message was sent by the current user
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
@@ -134,12 +133,6 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
this.hasQuotedMsg = data.quotedMsg ? true : false;
|
this.hasQuotedMsg = data.quotedMsg ? true : false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the duration of the message in seconds
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.duration = data.duration ? data.duration : undefined;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location information contained in the message, if the message is type "location"
|
* Location information contained in the message, if the message is type "location"
|
||||||
* @type {Location}
|
* @type {Location}
|
||||||
@@ -164,7 +157,7 @@ class Message extends Base {
|
|||||||
fromId: data.from._serialized,
|
fromId: data.from._serialized,
|
||||||
toId: data.to._serialized
|
toId: data.to._serialized
|
||||||
} : undefined;
|
} : undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates the mentions in the message body.
|
* Indicates the mentions in the message body.
|
||||||
* @type {Array<string>}
|
* @type {Array<string>}
|
||||||
@@ -186,18 +179,6 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
this.token = data.token ? data.token : undefined;
|
this.token = data.token ? data.token : undefined;
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether the message is a Gif
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
this.isGif = Boolean(data.isGif);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if the message will disappear after it expires
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
this.isEphemeral = data.isEphemeral;
|
|
||||||
|
|
||||||
/** Title */
|
/** Title */
|
||||||
if (data.title) {
|
if (data.title) {
|
||||||
this.title = data.title;
|
this.title = data.title;
|
||||||
@@ -221,7 +202,7 @@ class Message extends Base {
|
|||||||
/**
|
/**
|
||||||
* Links included in the message.
|
* Links included in the message.
|
||||||
* @type {Array<{link: string, isSuspicious: boolean}>}
|
* @type {Array<{link: string, isSuspicious: boolean}>}
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
this.links = data.links;
|
this.links = data.links;
|
||||||
|
|
||||||
@@ -229,7 +210,7 @@ class Message extends Base {
|
|||||||
if (data.dynamicReplyButtons) {
|
if (data.dynamicReplyButtons) {
|
||||||
this.dynamicReplyButtons = data.dynamicReplyButtons;
|
this.dynamicReplyButtons = data.dynamicReplyButtons;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Selected Button Id **/
|
/** Selected Button Id **/
|
||||||
if (data.selectedButtonId) {
|
if (data.selectedButtonId) {
|
||||||
this.selectedButtonId = data.selectedButtonId;
|
this.selectedButtonId = data.selectedButtonId;
|
||||||
@@ -239,7 +220,7 @@ class Message extends Base {
|
|||||||
if (data.listResponse && data.listResponse.singleSelectReply.selectedRowId) {
|
if (data.listResponse && data.listResponse.singleSelectReply.selectedRowId) {
|
||||||
this.selectedRowId = data.listResponse.singleSelectReply.selectedRowId;
|
this.selectedRowId = data.listResponse.singleSelectReply.selectedRowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super._patch(data);
|
return super._patch(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,32 +228,6 @@ class Message extends Base {
|
|||||||
return this.fromMe ? this.to : this.from;
|
return this.fromMe ? this.to : this.from;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reloads this Message object's data in-place with the latest values from WhatsApp Web.
|
|
||||||
* Note that the Message must still be in the web app cache for this to work, otherwise will return null.
|
|
||||||
* @returns {Promise<Message>}
|
|
||||||
*/
|
|
||||||
async reload() {
|
|
||||||
const newData = await this.client.pupPage.evaluate((msgId) => {
|
|
||||||
const msg = window.Store.Msg.get(msgId);
|
|
||||||
if(!msg) return null;
|
|
||||||
return window.WWebJS.getMessageModel(msg);
|
|
||||||
}, this.id._serialized);
|
|
||||||
|
|
||||||
if(!newData) return null;
|
|
||||||
|
|
||||||
this._patch(newData);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns message in a raw format
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
get rawData() {
|
|
||||||
return this._data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Chat this message was sent in
|
* Returns the Chat this message was sent in
|
||||||
* @returns {Promise<Chat>}
|
* @returns {Promise<Chat>}
|
||||||
@@ -305,21 +260,20 @@ class Message extends Base {
|
|||||||
if (!this.hasQuotedMsg) return undefined;
|
if (!this.hasQuotedMsg) return undefined;
|
||||||
|
|
||||||
const quotedMsg = await this.client.pupPage.evaluate((msgId) => {
|
const quotedMsg = await this.client.pupPage.evaluate((msgId) => {
|
||||||
const msg = window.Store.Msg.get(msgId);
|
let msg = window.Store.Msg.get(msgId);
|
||||||
const quotedMsg = window.Store.QuotedMsg.getQuotedMsgObj(msg);
|
return msg.quotedMsgObj().serialize();
|
||||||
return window.WWebJS.getMessageModel(quotedMsg);
|
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
return new Message(this.client, quotedMsg);
|
return new Message(this.client, quotedMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message as a reply to this message. If chatId is specified, it will be sent
|
* 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
|
* through the specified Chat. If not, it will send the message
|
||||||
* in the same Chat as the original message was sent.
|
* in the same Chat as the original message was sent.
|
||||||
*
|
*
|
||||||
* @param {string|MessageMedia|Location} content
|
* @param {string|MessageMedia|Location} content
|
||||||
* @param {string} [chatId]
|
* @param {string} [chatId]
|
||||||
* @param {MessageSendOptions} [options]
|
* @param {MessageSendOptions} [options]
|
||||||
* @returns {Promise<Message>}
|
* @returns {Promise<Message>}
|
||||||
*/
|
*/
|
||||||
@@ -336,20 +290,6 @@ class Message extends Base {
|
|||||||
return this.client.sendMessage(chatId, content, options);
|
return this.client.sendMessage(chatId, content, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* React to this message with an emoji
|
|
||||||
* @param {string} reaction - Emoji to react with. Send an empty string to remove the reaction.
|
|
||||||
* @return {Promise}
|
|
||||||
*/
|
|
||||||
async react(reaction){
|
|
||||||
await this.client.pupPage.evaluate(async (messageId, reaction) => {
|
|
||||||
if (!messageId) { return undefined; }
|
|
||||||
|
|
||||||
const msg = await window.Store.Msg.get(messageId);
|
|
||||||
await window.Store.sendReactionToMsg(msg, reaction);
|
|
||||||
}, this.id._serialized, reaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept Group V4 Invite
|
* Accept Group V4 Invite
|
||||||
* @returns {Promise<Object>}
|
* @returns {Promise<Object>}
|
||||||
@@ -357,10 +297,10 @@ class Message extends Base {
|
|||||||
async acceptGroupV4Invite() {
|
async acceptGroupV4Invite() {
|
||||||
return await this.client.acceptGroupV4Invite(this.inviteV4);
|
return await this.client.acceptGroupV4Invite(this.inviteV4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forwards this message to another chat (that you chatted before, otherwise it will fail)
|
* Forwards this message to another chat
|
||||||
*
|
*
|
||||||
* @param {string|Chat} chat Chat model or chat ID to which the message will be forwarded
|
* @param {string|Chat} chat Chat model or chat ID to which the message will be forwarded
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
@@ -386,13 +326,11 @@ class Message extends Base {
|
|||||||
|
|
||||||
const result = await this.client.pupPage.evaluate(async (msgId) => {
|
const result = await this.client.pupPage.evaluate(async (msgId) => {
|
||||||
const msg = window.Store.Msg.get(msgId);
|
const msg = window.Store.Msg.get(msgId);
|
||||||
if (!msg) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
||||||
// try to resolve media
|
// try to resolve media
|
||||||
await msg.downloadMedia({
|
await msg.downloadMedia({
|
||||||
downloadEvenIfExpensive: true,
|
downloadEvenIfExpensive: true,
|
||||||
rmrReason: 1
|
rmrReason: 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -412,14 +350,13 @@ class Message extends Base {
|
|||||||
type: msg.type,
|
type: msg.type,
|
||||||
signal: (new AbortController).signal
|
signal: (new AbortController).signal
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await window.WWebJS.arrayBufferToBase64Async(decryptedMedia);
|
const data = window.WWebJS.arrayBufferToBase64(decryptedMedia);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
mimetype: msg.mimetype,
|
mimetype: msg.mimetype,
|
||||||
filename: msg.filename,
|
filename: msg.filename
|
||||||
filesize: msg.size
|
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if(e.status && e.status === 404) return undefined;
|
if(e.status && e.status === 404) return undefined;
|
||||||
@@ -428,20 +365,19 @@ class Message extends Base {
|
|||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
if (!result) return undefined;
|
if (!result) return undefined;
|
||||||
return new MessageMedia(result.mimetype, result.data, result.filename, result.filesize);
|
return new MessageMedia(result.mimetype, result.data, result.filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a message from the chat
|
* Deletes a message from the chat
|
||||||
* @param {?boolean} everyone If true and the message is sent by the current user or the user is an admin, will delete it for everyone in 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) {
|
async delete(everyone) {
|
||||||
await this.client.pupPage.evaluate((msgId, everyone) => {
|
await this.client.pupPage.evaluate((msgId, everyone) => {
|
||||||
let msg = window.Store.Msg.get(msgId);
|
let msg = window.Store.Msg.get(msgId);
|
||||||
|
|
||||||
const canRevoke = window.Store.MsgActionChecks.canSenderRevokeMsg(msg) || window.Store.MsgActionChecks.canAdminRevokeMsg(msg);
|
if (everyone && msg.id.fromMe && msg.canRevoke()) {
|
||||||
if (everyone && canRevoke) {
|
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], true);
|
||||||
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], { type: msg.id.fromMe ? 'Sender' : 'Admin' });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
||||||
@@ -455,8 +391,8 @@ class Message extends Base {
|
|||||||
await this.client.pupPage.evaluate((msgId) => {
|
await this.client.pupPage.evaluate((msgId) => {
|
||||||
let msg = window.Store.Msg.get(msgId);
|
let msg = window.Store.Msg.get(msgId);
|
||||||
|
|
||||||
if (window.Store.MsgActionChecks.canStarMsg(msg)) {
|
if (msg.canStar()) {
|
||||||
return window.Store.Cmd.sendStarMsgs(msg.chat, [msg], false);
|
return msg.chat.sendStarMsgs([msg], true);
|
||||||
}
|
}
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
}
|
}
|
||||||
@@ -468,8 +404,8 @@ class Message extends Base {
|
|||||||
await this.client.pupPage.evaluate((msgId) => {
|
await this.client.pupPage.evaluate((msgId) => {
|
||||||
let msg = window.Store.Msg.get(msgId);
|
let msg = window.Store.Msg.get(msgId);
|
||||||
|
|
||||||
if (window.Store.MsgActionChecks.canStarMsg(msg)) {
|
if (msg.canStar()) {
|
||||||
return window.Store.Cmd.sendUnstarMsgs(msg.chat, [msg], false);
|
return msg.chat.sendStarMsgs([msg], false);
|
||||||
}
|
}
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
}
|
}
|
||||||
@@ -492,11 +428,15 @@ class Message extends Base {
|
|||||||
async getInfo() {
|
async getInfo() {
|
||||||
const info = await this.client.pupPage.evaluate(async (msgId) => {
|
const info = await this.client.pupPage.evaluate(async (msgId) => {
|
||||||
const msg = window.Store.Msg.get(msgId);
|
const msg = window.Store.Msg.get(msgId);
|
||||||
if (!msg) return null;
|
if(!msg) return null;
|
||||||
|
|
||||||
return await window.Store.MessageInfo.sendQueryMsgInfo(msg.id);
|
return await window.Store.Wap.queryMsgInfo(msg.id);
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
|
if(info.status) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,9 +446,9 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
async getOrder() {
|
async getOrder() {
|
||||||
if (this.type === MessageTypes.ORDER) {
|
if (this.type === MessageTypes.ORDER) {
|
||||||
const result = await this.client.pupPage.evaluate((orderId, token, chatId) => {
|
const result = await this.client.pupPage.evaluate((orderId, token) => {
|
||||||
return window.WWebJS.getOrderDetail(orderId, token, chatId);
|
return window.WWebJS.getOrderDetail(orderId, token);
|
||||||
}, this.orderId, this.token, this._getChatId());
|
}, this.orderId, this.token);
|
||||||
if (!result) return undefined;
|
if (!result) return undefined;
|
||||||
return new Order(this.client, result);
|
return new Order(this.client, result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,10 @@ const { URL } = require('url');
|
|||||||
* Media attached to a message
|
* Media attached to a message
|
||||||
* @param {string} mimetype MIME type of the attachment
|
* @param {string} mimetype MIME type of the attachment
|
||||||
* @param {string} data Base64-encoded data of the file
|
* @param {string} data Base64-encoded data of the file
|
||||||
* @param {?string} filename Document file name. Value can be null
|
* @param {?string} filename Document file name
|
||||||
* @param {?number} filesize Document file size in bytes. Value can be null
|
|
||||||
*/
|
*/
|
||||||
class MessageMedia {
|
class MessageMedia {
|
||||||
constructor(mimetype, data, filename, filesize) {
|
constructor(mimetype, data, filename) {
|
||||||
/**
|
/**
|
||||||
* MIME type of the attachment
|
* MIME type of the attachment
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@@ -28,16 +27,10 @@ class MessageMedia {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document file name. Value can be null
|
* Name of the file (for documents)
|
||||||
* @type {?string}
|
* @type {?string}
|
||||||
*/
|
*/
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
|
|
||||||
/**
|
|
||||||
* Document file size in bytes. Value can be null
|
|
||||||
* @type {?number}
|
|
||||||
*/
|
|
||||||
this.filesize = filesize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,30 +50,29 @@ class MessageMedia {
|
|||||||
* Creates a MessageMedia instance from a URL
|
* Creates a MessageMedia instance from a URL
|
||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @param {Object} [options]
|
* @param {Object} [options]
|
||||||
* @param {boolean} [options.unsafeMime=false]
|
* @param {number} [options.unsafeMime=false]
|
||||||
* @param {string} [options.filename]
|
|
||||||
* @param {object} [options.client]
|
* @param {object} [options.client]
|
||||||
* @param {object} [options.reqOptions]
|
* @param {object} [options.reqOptions]
|
||||||
* @param {number} [options.reqOptions.size=0]
|
* @param {number} [options.reqOptions.size=0]
|
||||||
* @returns {Promise<MessageMedia>}
|
* @returns {Promise<MessageMedia>}
|
||||||
*/
|
*/
|
||||||
static async fromUrl(url, options = {}) {
|
static async fromUrl(url, options = {}) {
|
||||||
const pUrl = new URL(url);
|
let mimetype;
|
||||||
let mimetype = mime.getType(pUrl.pathname);
|
|
||||||
|
|
||||||
if (!mimetype && !options.unsafeMime)
|
if (!options.unsafeMime) {
|
||||||
throw new Error('Unable to determine MIME type using URL. Set unsafeMime to true to download it anyway.');
|
const pUrl = new URL(url);
|
||||||
|
mimetype = mime.getType(pUrl.pathname);
|
||||||
|
|
||||||
|
if (!mimetype)
|
||||||
|
throw new Error('Unable to determine MIME type');
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchData (url, options) {
|
async function fetchData (url, options) {
|
||||||
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
||||||
const response = await fetch(url, reqOptions);
|
const response = await fetch(url, reqOptions);
|
||||||
const mime = response.headers.get('Content-Type');
|
const mime = response.headers.get('Content-Type');
|
||||||
const size = response.headers.get('Content-Length');
|
|
||||||
|
|
||||||
const contentDisposition = response.headers.get('Content-Disposition');
|
|
||||||
const name = contentDisposition ? contentDisposition.match(/((?<=filename=")(.*)(?="))/) : null;
|
|
||||||
|
|
||||||
let data = '';
|
let data = '';
|
||||||
|
|
||||||
if (response.buffer) {
|
if (response.buffer) {
|
||||||
data = (await response.buffer()).toString('base64');
|
data = (await response.buffer()).toString('base64');
|
||||||
} else {
|
} else {
|
||||||
@@ -91,21 +83,18 @@ class MessageMedia {
|
|||||||
data = btoa(data);
|
data = btoa(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { data, mime, name, size };
|
return { data, mime };
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = options.client
|
const res = options.client
|
||||||
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
|
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
|
||||||
: (await fetchData(url, options.reqOptions));
|
: (await fetchData(url, options.reqOptions));
|
||||||
|
|
||||||
const filename = options.filename ||
|
|
||||||
(res.name ? res.name[0] : (pUrl.pathname.split('/').pop() || 'file'));
|
|
||||||
|
|
||||||
if (!mimetype)
|
if (!mimetype)
|
||||||
mimetype = res.mime;
|
mimetype = res.mime;
|
||||||
|
|
||||||
return new MessageMedia(mimetype, res.data, filename, res.size || null);
|
return new MessageMedia(mimetype, res.data, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = MessageMedia;
|
module.exports = MessageMedia;
|
||||||
@@ -40,6 +40,7 @@ class Payment extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The paymentStatus
|
* The paymentStatus
|
||||||
|
* @type {number}
|
||||||
*
|
*
|
||||||
* Possible Status
|
* Possible Status
|
||||||
* 0:UNKNOWN_STATUS
|
* 0:UNKNOWN_STATUS
|
||||||
@@ -54,8 +55,6 @@ class Payment extends Base {
|
|||||||
* 9:CANCELLED
|
* 9:CANCELLED
|
||||||
* 10:WAITING_FOR_PAYER
|
* 10:WAITING_FOR_PAYER
|
||||||
* 11:WAITING
|
* 11:WAITING
|
||||||
*
|
|
||||||
* @type {number}
|
|
||||||
*/
|
*/
|
||||||
this.paymentStatus = data.paymentStatus;
|
this.paymentStatus = data.paymentStatus;
|
||||||
|
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const Base = require('./Base');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a Reaction on WhatsApp
|
|
||||||
* @extends {Base}
|
|
||||||
*/
|
|
||||||
class Reaction extends Base {
|
|
||||||
constructor(client, data) {
|
|
||||||
super(client);
|
|
||||||
|
|
||||||
if (data) this._patch(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
_patch(data) {
|
|
||||||
/**
|
|
||||||
* Reaction ID
|
|
||||||
* @type {object}
|
|
||||||
*/
|
|
||||||
this.id = data.msgKey;
|
|
||||||
/**
|
|
||||||
* Orphan
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.orphan = data.orphan;
|
|
||||||
/**
|
|
||||||
* Orphan reason
|
|
||||||
* @type {?string}
|
|
||||||
*/
|
|
||||||
this.orphanReason = data.orphanReason;
|
|
||||||
/**
|
|
||||||
* Unix timestamp for when the reaction was created
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.timestamp = data.timestamp;
|
|
||||||
/**
|
|
||||||
* Reaction
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.reaction = data.reactionText;
|
|
||||||
/**
|
|
||||||
* Read
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
this.read = data.read;
|
|
||||||
/**
|
|
||||||
* Message ID
|
|
||||||
* @type {object}
|
|
||||||
*/
|
|
||||||
this.msgId = data.parentMsgKey;
|
|
||||||
/**
|
|
||||||
* Sender ID
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.senderId = data.senderUserJid;
|
|
||||||
/**
|
|
||||||
* ACK
|
|
||||||
* @type {?number}
|
|
||||||
*/
|
|
||||||
this.ack = data.ack;
|
|
||||||
|
|
||||||
|
|
||||||
return super._patch(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Reaction;
|
|
||||||
@@ -17,6 +17,5 @@ module.exports = {
|
|||||||
Call: require('./Call'),
|
Call: require('./Call'),
|
||||||
Buttons: require('./Buttons'),
|
Buttons: require('./Buttons'),
|
||||||
List: require('./List'),
|
List: require('./List'),
|
||||||
Payment: require('./Payment'),
|
Payment: require('./Payment')
|
||||||
Reaction: require('./Reaction'),
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ exports.DefaultOptions = {
|
|||||||
headless: true,
|
headless: true,
|
||||||
defaultViewport: null
|
defaultViewport: null
|
||||||
},
|
},
|
||||||
authTimeoutMs: 0,
|
session: false,
|
||||||
qrMaxRetries: 0,
|
qrTimeoutMs: 45000,
|
||||||
|
qrRefreshIntervalMs: 20000,
|
||||||
|
authTimeoutMs: 45000,
|
||||||
takeoverOnConflict: false,
|
takeoverOnConflict: false,
|
||||||
takeoverTimeoutMs: 0,
|
takeoverTimeoutMs: 0,
|
||||||
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36',
|
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36',
|
||||||
ffmpegPath: 'ffmpeg',
|
ffmpegPath: 'ffmpeg',
|
||||||
bypassCSP: false
|
bypassCSP: false
|
||||||
};
|
};
|
||||||
@@ -41,18 +43,15 @@ exports.Events = {
|
|||||||
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
|
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
|
||||||
MESSAGE_REVOKED_ME: 'message_revoke_me',
|
MESSAGE_REVOKED_ME: 'message_revoke_me',
|
||||||
MESSAGE_ACK: 'message_ack',
|
MESSAGE_ACK: 'message_ack',
|
||||||
MESSAGE_REACTION: 'message_reaction',
|
|
||||||
MEDIA_UPLOADED: 'media_uploaded',
|
MEDIA_UPLOADED: 'media_uploaded',
|
||||||
GROUP_JOIN: 'group_join',
|
GROUP_JOIN: 'group_join',
|
||||||
GROUP_LEAVE: 'group_leave',
|
GROUP_LEAVE: 'group_leave',
|
||||||
GROUP_UPDATE: 'group_update',
|
GROUP_UPDATE: 'group_update',
|
||||||
QR_RECEIVED: 'qr',
|
QR_RECEIVED: 'qr',
|
||||||
LOADING_SCREEN: 'loading_screen',
|
|
||||||
DISCONNECTED: 'disconnected',
|
DISCONNECTED: 'disconnected',
|
||||||
STATE_CHANGED: 'change_state',
|
STATE_CHANGED: 'change_state',
|
||||||
BATTERY_CHANGED: 'change_battery',
|
BATTERY_CHANGED: 'change_battery',
|
||||||
INCOMING_CALL: 'call',
|
INCOMING_CALL: 'incoming_call'
|
||||||
REMOTE_SESSION_SAVED: 'remote_session_saved'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,25 +76,8 @@ exports.MessageTypes = {
|
|||||||
UNKNOWN: 'unknown',
|
UNKNOWN: 'unknown',
|
||||||
GROUP_INVITE: 'groups_v4_invite',
|
GROUP_INVITE: 'groups_v4_invite',
|
||||||
LIST: 'list',
|
LIST: 'list',
|
||||||
LIST_RESPONSE: 'list_response',
|
|
||||||
BUTTONS_RESPONSE: 'buttons_response',
|
BUTTONS_RESPONSE: 'buttons_response',
|
||||||
PAYMENT: 'payment',
|
PAYMENT: 'payment'
|
||||||
BROADCAST_NOTIFICATION: 'broadcast_notification',
|
|
||||||
CALL_LOG: 'call_log',
|
|
||||||
CIPHERTEXT: 'ciphertext',
|
|
||||||
DEBUG: 'debug',
|
|
||||||
E2E_NOTIFICATION: 'e2e_notification',
|
|
||||||
GP2: 'gp2',
|
|
||||||
GROUP_NOTIFICATION: 'group_notification',
|
|
||||||
HSM: 'hsm',
|
|
||||||
INTERACTIVE: 'interactive',
|
|
||||||
NATIVE_FLOW: 'native_flow',
|
|
||||||
NOTIFICATION: 'notification',
|
|
||||||
NOTIFICATION_TEMPLATE: 'notification_template',
|
|
||||||
OVERSIZED: 'oversized',
|
|
||||||
PROTOCOL: 'protocol',
|
|
||||||
REACTION: 'reaction',
|
|
||||||
TEMPLATE_BUTTON_REPLY: 'template_button_reply',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,67 +5,40 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|||||||
eval('var moduleRaid = ' + moduleRaidStr);
|
eval('var moduleRaid = ' + moduleRaidStr);
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
window.mR = moduleRaid();
|
window.mR = moduleRaid();
|
||||||
window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
|
window.Store = window.mR.findModule('Chat')[0].default;
|
||||||
window.Store.AppState = window.mR.findModule('Socket')[0].Socket;
|
window.Store.AppState = window.mR.findModule('STREAM')[0].default;
|
||||||
window.Store.Conn = window.mR.findModule('Conn')[0].Conn;
|
window.Store.Conn = window.mR.findModule('Conn')[0].default;
|
||||||
window.Store.BlockContact = window.mR.findModule('blockContact')[0];
|
|
||||||
window.Store.Call = window.mR.findModule('CallCollection')[0].CallCollection;
|
|
||||||
window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
|
|
||||||
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
|
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
|
||||||
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;
|
window.Store.Wap = window.mR.findModule('Wap')[0].default;
|
||||||
window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata;
|
window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
|
||||||
window.Store.Invite = window.mR.findModule('resetGroupInviteCode')[0];
|
|
||||||
window.Store.InviteInfo = window.mR.findModule('queryGroupInvite')[0];
|
|
||||||
window.Store.Label = window.mR.findModule('LabelCollection')[0].LabelCollection;
|
|
||||||
window.Store.MediaPrep = window.mR.findModule('MediaPrep')[0];
|
|
||||||
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
|
|
||||||
window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
|
|
||||||
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
|
|
||||||
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
|
|
||||||
window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
|
|
||||||
window.Store.MessageInfo = window.mR.findModule('sendQueryMsgInfo')[0];
|
|
||||||
window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
|
|
||||||
window.Store.QueryExist = window.mR.findModule('queryExists')[0] ? window.mR.findModule('queryExists')[0].queryExists : window.mR.findModule('queryExist')[0].queryWidExists;
|
|
||||||
window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
|
|
||||||
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
|
|
||||||
window.Store.SendClear = window.mR.findModule('sendClear')[0];
|
window.Store.SendClear = window.mR.findModule('sendClear')[0];
|
||||||
window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
|
window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
|
||||||
|
window.Store.genId = window.mR.findModule('randomId')[0].default;
|
||||||
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
|
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
|
||||||
window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
|
window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
|
||||||
window.Store.User = window.mR.findModule('getMaybeMeUser')[0];
|
window.Store.Invite = window.mR.findModule('sendJoinGroupViaInvite')[0];
|
||||||
window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
|
window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
|
||||||
|
window.Store.MediaPrep = window.mR.findModule('MediaPrep')[0];
|
||||||
|
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
|
||||||
|
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
|
||||||
|
window.Store.Cmd = window.mR.findModule('Cmd')[0].default;
|
||||||
|
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
|
||||||
|
window.Store.VCard = window.mR.findModule('vcardFromContactModel')[0];
|
||||||
window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
|
window.Store.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.Validators = window.mR.findModule('findLinks')[0];
|
||||||
window.Store.VCard = window.mR.findModule('vcardFromContactModel')[0];
|
|
||||||
window.Store.WidFactory = window.mR.findModule('createWid')[0];
|
window.Store.WidFactory = window.mR.findModule('createWid')[0];
|
||||||
window.Store.ProfilePic = window.mR.findModule('profilePicResync')[0];
|
window.Store.BlockContact = window.mR.findModule('blockContact')[0];
|
||||||
window.Store.PresenceUtils = window.mR.findModule('sendPresenceAvailable')[0];
|
window.Store.GroupMetadata = window.mR.findModule((module) => module.default && module.default.handlePendingInvite)[0].default;
|
||||||
window.Store.ChatState = window.mR.findModule('sendChatStateComposing')[0];
|
window.Store.Sticker = window.mR.findModule('Sticker')[0].default.Sticker;
|
||||||
window.Store.GroupParticipants = window.mR.findModule('promoteParticipants')[1];
|
window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
|
||||||
window.Store.JoinInviteV4 = window.mR.findModule('sendJoinGroupViaInviteV4')[0];
|
window.Store.Label = window.mR.findModule('LabelCollection')[0].default;
|
||||||
window.Store.findCommonGroups = window.mR.findModule('findCommonGroups')[0].findCommonGroups;
|
window.Store.Features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0].default;
|
||||||
window.Store.StatusUtils = window.mR.findModule('setMyStatus')[0];
|
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
|
||||||
window.Store.ConversationMsgs = window.mR.findModule('loadEarlierMsgs')[0];
|
window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
|
||||||
window.Store.sendReactionToMsg = window.mR.findModule('sendReactionToMsg')[0].sendReactionToMsg;
|
window.Store.DownloadManager = window.mR.findModule('DownloadManager')[0].default;
|
||||||
window.Store.createOrUpdateReactionsModule = window.mR.findModule('createOrUpdateReactions')[0];
|
window.Store.Call = window.mR.findModule('CallCollection')[0].default;
|
||||||
window.Store.EphemeralFields = window.mR.findModule('getEphemeralFields')[0];
|
|
||||||
window.Store.ReplyUtils = window.mR.findModule('canReplyMsg').length > 0 && window.mR.findModule('canReplyMsg')[0];
|
|
||||||
window.Store.MsgActionChecks = window.mR.findModule('canSenderRevokeMsg')[0];
|
|
||||||
window.Store.QuotedMsg = window.mR.findModule('getQuotedMsgObj')[0];
|
|
||||||
window.Store.Socket = window.mR.findModule('deprecatedSendIq')[0];
|
|
||||||
window.Store.SocketWap = window.mR.findModule('wap')[0];
|
|
||||||
window.Store.StickerTools = {
|
|
||||||
...window.mR.findModule('toWebpSticker')[0],
|
|
||||||
...window.mR.findModule('addWebpMetadata')[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
window.Store.GroupUtils = {
|
if(!window.Store.Chat._find) {
|
||||||
...window.mR.findModule('createGroup')[0],
|
|
||||||
...window.mR.findModule('setGroupDescription')[0],
|
|
||||||
...window.mR.findModule('sendExitGroup')[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!window.Store.Chat._find) {
|
|
||||||
window.Store.Chat._find = e => {
|
window.Store.Chat._find = e => {
|
||||||
const target = window.Store.Chat.get(e);
|
const target = window.Store.Chat.get(e);
|
||||||
return target ? Promise.resolve(target) : Promise.resolve({
|
return target ? Promise.resolve(target) : Promise.resolve({
|
||||||
@@ -73,298 +46,19 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following was implemented and inspired from wppconnect/wa-js at
|
|
||||||
// https://github.com/wppconnect-team/wa-js/tree/main/src/chat/functions/prepareMessageButtons.ts
|
|
||||||
|
|
||||||
// Find proxy modules
|
|
||||||
window.findProxyModel = (name) => {
|
|
||||||
const baseName = name.replace(/Model$/, '');
|
|
||||||
|
|
||||||
const names = [baseName];
|
|
||||||
|
|
||||||
// ChatModel => "chat"
|
|
||||||
names.push(baseName.replace(/^(\w)/, (l) => l.toLowerCase()));
|
|
||||||
|
|
||||||
// CartItemModel => "cart-item"
|
|
||||||
// ProductListModel => "product_list"
|
|
||||||
const parts = baseName.split(/(?=[A-Z])/);
|
|
||||||
|
|
||||||
names.push(parts.join('-').toLowerCase());
|
|
||||||
names.push(parts.join('_').toLowerCase());
|
|
||||||
|
|
||||||
const results = window.mR.findModule((m) =>
|
|
||||||
names.includes(
|
|
||||||
m.default?.prototype?.proxyName ||
|
|
||||||
m[name]?.prototype?.proxyName ||
|
|
||||||
m[baseName]?.prototype?.proxyName
|
|
||||||
)
|
|
||||||
)[0];
|
|
||||||
|
|
||||||
return results.default || results[name] || results[baseName];
|
|
||||||
};
|
|
||||||
|
|
||||||
// Function to modify functions.
|
|
||||||
window.injectToFunction = (selector, callback) => {
|
|
||||||
const oldFunct = window.mR.findModule(selector.name)[selector.index][selector.property];
|
|
||||||
window.mR.findModule(selector.name)[selector.index][selector.property] = (...args) => callback(oldFunct, args);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Find button models
|
|
||||||
window.Store.TemplateButtonModel = window.findProxyModel('TemplateButtonModel');
|
|
||||||
window.Store.TemplateButtonCollection = window.mR.findModule('TemplateButtonCollection')[0].TemplateButtonCollection;
|
|
||||||
|
|
||||||
// Find quick reply models
|
|
||||||
window.Store.ReplyButtonModel = window.findProxyModel('ReplyButtonModel');
|
|
||||||
window.Store.ButtonCollection = window.mR.findModule('ButtonCollection')[0].ButtonCollection;
|
|
||||||
|
|
||||||
// Modify functions
|
|
||||||
window.injectToFunction({
|
|
||||||
index: 0,
|
|
||||||
name: 'createMsgProtobuf',
|
|
||||||
property: 'createMsgProtobuf'
|
|
||||||
}, (func, args) => {
|
|
||||||
const [message] = args;
|
|
||||||
const proto = func(...args);
|
|
||||||
if (message.hydratedButtons) {
|
|
||||||
const hydratedTemplate = {
|
|
||||||
hydratedButtons: message.hydratedButtons,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (message.footer) {
|
|
||||||
hydratedTemplate.hydratedFooterText = message.footer;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.caption) {
|
|
||||||
hydratedTemplate.hydratedContentText = message.caption;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.title) {
|
|
||||||
hydratedTemplate.hydratedTitleText = message.title;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (proto.conversation) {
|
|
||||||
hydratedTemplate.hydratedContentText = proto.conversation;
|
|
||||||
delete proto.conversation;
|
|
||||||
} else if (proto.extendedTextMessage?.text) {
|
|
||||||
hydratedTemplate.hydratedContentText = proto.extendedTextMessage.text;
|
|
||||||
delete proto.extendedTextMessage;
|
|
||||||
} else {
|
|
||||||
// Search media part in message
|
|
||||||
let found;
|
|
||||||
const mediaPart = [
|
|
||||||
'documentMessage',
|
|
||||||
'imageMessage',
|
|
||||||
'locationMessage',
|
|
||||||
'videoMessage',
|
|
||||||
];
|
|
||||||
for (const part of mediaPart) {
|
|
||||||
if (part in proto) {
|
|
||||||
found = part;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
return proto;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Media message doesn't allow title
|
|
||||||
hydratedTemplate[found] = proto[found];
|
|
||||||
|
|
||||||
// Copy title to caption if not setted
|
|
||||||
if (
|
|
||||||
hydratedTemplate.hydratedTitleText &&
|
|
||||||
!hydratedTemplate.hydratedContentText
|
|
||||||
) {
|
|
||||||
hydratedTemplate.hydratedContentText =
|
|
||||||
hydratedTemplate.hydratedTitleText;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove title for media messages
|
|
||||||
delete hydratedTemplate.hydratedTitleText;
|
|
||||||
|
|
||||||
if (found === 'locationMessage') {
|
|
||||||
if (
|
|
||||||
!hydratedTemplate.hydratedContentText &&
|
|
||||||
(message[found].name || message[found].address)
|
|
||||||
) {
|
|
||||||
hydratedTemplate.hydratedContentText =
|
|
||||||
message[found].name && message[found].address
|
|
||||||
? `${message[found].name}\n${message[found].address}`
|
|
||||||
: message[found].name || message[found].address || '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure a content text;
|
|
||||||
hydratedTemplate.hydratedContentText =
|
|
||||||
hydratedTemplate.hydratedContentText || ' ';
|
|
||||||
|
|
||||||
delete proto[found];
|
|
||||||
}
|
|
||||||
|
|
||||||
proto.templateMessage = {
|
|
||||||
hydratedTemplate,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return proto;
|
|
||||||
});
|
|
||||||
|
|
||||||
window.injectToFunction({
|
|
||||||
index: 0,
|
|
||||||
name: 'createMsgProtobuf',
|
|
||||||
property: 'createMsgProtobuf'
|
|
||||||
}, (func, args) => {
|
|
||||||
const proto = func(...args);
|
|
||||||
if (proto.templateMessage) {
|
|
||||||
proto.viewOnceMessage = {
|
|
||||||
message: {
|
|
||||||
templateMessage: proto.templateMessage,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
delete proto.templateMessage;
|
|
||||||
}
|
|
||||||
if (proto.buttonsMessage) {
|
|
||||||
proto.viewOnceMessage = {
|
|
||||||
message: {
|
|
||||||
buttonsMessage: proto.buttonsMessage,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
delete proto.buttonsMessage;
|
|
||||||
}
|
|
||||||
if (proto.listMessage) {
|
|
||||||
proto.viewOnceMessage = {
|
|
||||||
message: {
|
|
||||||
listMessage: proto.listMessage,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
delete proto.listMessage;
|
|
||||||
}
|
|
||||||
return proto;
|
|
||||||
});
|
|
||||||
|
|
||||||
window.injectToFunction({
|
|
||||||
index: 0,
|
|
||||||
name: 'typeAttributeFromProtobuf',
|
|
||||||
property: 'typeAttributeFromProtobuf'
|
|
||||||
}, (func, args) => {
|
|
||||||
const [proto] = args;
|
|
||||||
if (proto.templateMessage?.hydratedTemplate) {
|
|
||||||
const keys = Object.keys(proto.templateMessage?.hydratedTemplate);
|
|
||||||
const messagePart = [
|
|
||||||
'documentMessage',
|
|
||||||
'imageMessage',
|
|
||||||
'locationMessage',
|
|
||||||
'videoMessage',
|
|
||||||
];
|
|
||||||
if (messagePart.some((part) => keys.includes(part))) {
|
|
||||||
return 'media';
|
|
||||||
}
|
|
||||||
return 'text';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
proto.buttonsMessage?.headerType === 1 ||
|
|
||||||
proto.buttonsMessage?.headerType === 2
|
|
||||||
) {
|
|
||||||
return 'text';
|
|
||||||
}
|
|
||||||
|
|
||||||
return func(...args);
|
|
||||||
});
|
|
||||||
|
|
||||||
window.injectToFunction({
|
|
||||||
index: 0,
|
|
||||||
name: 'typeAttributeFromProtobuf',
|
|
||||||
property: 'typeAttributeFromProtobuf'
|
|
||||||
}, (func, args) => {
|
|
||||||
const [proto] = args;
|
|
||||||
|
|
||||||
if (proto.ephemeralMessage) {
|
|
||||||
const { message } = proto.ephemeralMessage;
|
|
||||||
return message ? func(message) : 'text';
|
|
||||||
}
|
|
||||||
if (proto.deviceSentMessage) {
|
|
||||||
const { message } = proto.deviceSentMessage;
|
|
||||||
return message ? func(message) : 'text';
|
|
||||||
}
|
|
||||||
if (proto.viewOnceMessage) {
|
|
||||||
const { message } = proto.viewOnceMessage;
|
|
||||||
return message ? func(message) : 'text';
|
|
||||||
}
|
|
||||||
|
|
||||||
return func(...args);
|
|
||||||
});
|
|
||||||
|
|
||||||
window.injectToFunction({
|
|
||||||
index: 0,
|
|
||||||
name: 'mediaTypeFromProtobuf',
|
|
||||||
property: 'mediaTypeFromProtobuf'
|
|
||||||
}, (func, args) => {
|
|
||||||
const [proto] = args;
|
|
||||||
if (proto.templateMessage?.hydratedTemplate) {
|
|
||||||
return func(proto.templateMessage.hydratedTemplate);
|
|
||||||
}
|
|
||||||
return func(...args);
|
|
||||||
});
|
|
||||||
|
|
||||||
window.injectToFunction({
|
|
||||||
index: 0,
|
|
||||||
name: 'mediaTypeFromProtobuf',
|
|
||||||
property: 'mediaTypeFromProtobuf'
|
|
||||||
}, (func, args) => {
|
|
||||||
const [proto] = args;
|
|
||||||
if (proto.deviceSentMessage) {
|
|
||||||
const { message } = proto.deviceSentMessage;
|
|
||||||
return message ? func(message) : null;
|
|
||||||
}
|
|
||||||
if (proto.ephemeralMessage) {
|
|
||||||
const { message } = proto.ephemeralMessage;
|
|
||||||
return message ? func(message) : null;
|
|
||||||
}
|
|
||||||
if (proto.viewOnceMessage) {
|
|
||||||
const { message } = proto.viewOnceMessage;
|
|
||||||
return message ? func(message) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return func(...args);
|
|
||||||
});
|
|
||||||
|
|
||||||
window.injectToFunction({
|
|
||||||
index: 0,
|
|
||||||
name: 'encodeMaybeMediaType',
|
|
||||||
property: 'encodeMaybeMediaType',
|
|
||||||
}, (func, args) => {
|
|
||||||
const [type] = args;
|
|
||||||
if (type === 'button') {
|
|
||||||
return window.mR.findModule('DROP_ATTR')[0].DROP_ATTR;
|
|
||||||
}
|
|
||||||
return func(...args);
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO remove these once everybody has been updated to WWebJS with legacy sessions removed
|
|
||||||
const _linkPreview = window.mR.findModule('queryLinkPreview');
|
|
||||||
if (_linkPreview && _linkPreview[0] && _linkPreview[0].default) {
|
|
||||||
window.Store.Wap = _linkPreview[0].default;
|
|
||||||
}
|
|
||||||
|
|
||||||
const _isMDBackend = window.mR.findModule('isMDBackend');
|
|
||||||
if(_isMDBackend && _isMDBackend[0] && _isMDBackend[0].isMDBackend) {
|
|
||||||
window.Store.MDBackend = _isMDBackend[0].isMDBackend();
|
|
||||||
} else {
|
|
||||||
window.Store.MDBackend = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const _features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0];
|
|
||||||
if(_features) {
|
|
||||||
window.Store.Features = _features.LegacyPhoneFeatures;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.LoadUtils = () => {
|
exports.LoadUtils = () => {
|
||||||
window.WWebJS = {};
|
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) => {
|
window.WWebJS.sendSeen = async (chatId) => {
|
||||||
let chat = window.Store.Chat.get(chatId);
|
let chat = window.Store.Chat.get(chatId);
|
||||||
if (chat !== undefined) {
|
if (chat !== undefined) {
|
||||||
@@ -374,80 +68,14 @@ exports.LoadUtils = () => {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.WWebJS.prepareMessageButtons = (buttonsOptions) => {
|
|
||||||
const returnObject = {};
|
|
||||||
if (!buttonsOptions.buttons) {
|
|
||||||
return returnObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof buttonsOptions.useTemplateButtons === 'undefined' || buttonsOptions.useTemplateButtons === null) {
|
|
||||||
buttonsOptions.useTemplateButtons = buttonsOptions.buttons.some((button) => {
|
|
||||||
return 'callButton' in button || 'urlButton' in button;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
returnObject.title = buttonsOptions.title;
|
|
||||||
returnObject.footer = buttonsOptions.footer;
|
|
||||||
|
|
||||||
if (buttonsOptions.useTemplateButtons) {
|
|
||||||
returnObject.isFromTemplate = true;
|
|
||||||
returnObject.hydratedButtons = buttonsOptions.buttons;
|
|
||||||
returnObject.buttons = new window.Store.TemplateButtonCollection;
|
|
||||||
|
|
||||||
returnObject.buttons.add(returnObject.hydratedButtons.map((button, index) => {
|
|
||||||
const buttonIndex = button.index ? button.index : index;
|
|
||||||
if (button.urlButton) {
|
|
||||||
return new window.Store.TemplateButtonModel({
|
|
||||||
id: buttonIndex,
|
|
||||||
displayText: button.urlButton?.displayText || '',
|
|
||||||
url: button.urlButton?.url,
|
|
||||||
subtype: 'url'
|
|
||||||
});
|
|
||||||
} else if (button.callButton) {
|
|
||||||
return new window.Store.TemplateButtonModel({
|
|
||||||
id: buttonIndex,
|
|
||||||
displayText: button.callButton?.displayText,
|
|
||||||
phoneNumber: button.callButton?.phoneNumber,
|
|
||||||
subtype: 'call'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return new window.Store.TemplateButtonModel({
|
|
||||||
id: buttonIndex,
|
|
||||||
displayText: button.quickReplyButton?.displayText,
|
|
||||||
selectionId: button.quickReplyButton?.id,
|
|
||||||
subtype: 'quick_reply'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
returnObject.isDynamicReplyButtonsMsg = true;
|
|
||||||
|
|
||||||
returnObject.dynamicReplyButtons = buttonsOptions.buttons.map((button, index) => ({
|
|
||||||
buttonId: button.quickReplyButton.id.toString() || `${index}`,
|
|
||||||
buttonText: {displayText: button.quickReplyButton?.displayText},
|
|
||||||
type: 1,
|
|
||||||
}));
|
|
||||||
|
|
||||||
// For UI only
|
|
||||||
returnObject.replyButtons = new window.Store.ButtonCollection();
|
|
||||||
returnObject.replyButtons.add(returnObject.dynamicReplyButtons.map((button) => new window.Store.ReplyButtonModel({
|
|
||||||
id: button.buttonId,
|
|
||||||
displayText: button.buttonText?.displayText || undefined,
|
|
||||||
})));
|
|
||||||
|
|
||||||
}
|
|
||||||
return returnObject;
|
|
||||||
};
|
|
||||||
|
|
||||||
window.WWebJS.sendMessage = async (chat, content, options = {}) => {
|
window.WWebJS.sendMessage = async (chat, content, options = {}) => {
|
||||||
let attOptions = {};
|
let attOptions = {};
|
||||||
if (options.attachment) {
|
if (options.attachment) {
|
||||||
attOptions = options.sendMediaAsSticker
|
attOptions = options.sendMediaAsSticker
|
||||||
? await window.WWebJS.processStickerData(options.attachment)
|
? await window.WWebJS.processStickerData(options.attachment)
|
||||||
: await window.WWebJS.processMediaData(options.attachment, {
|
: await window.WWebJS.processMediaData(options.attachment, {
|
||||||
forceVoice: options.sendAudioAsVoice,
|
forceVoice: options.sendAudioAsVoice,
|
||||||
forceDocument: options.sendMediaAsDocument,
|
forceDocument: options.sendMediaAsDocument,
|
||||||
forceGif: options.sendVideoAsGif
|
forceGif: options.sendVideoAsGif
|
||||||
});
|
});
|
||||||
@@ -457,16 +85,11 @@ exports.LoadUtils = () => {
|
|||||||
delete options.attachment;
|
delete options.attachment;
|
||||||
delete options.sendMediaAsSticker;
|
delete options.sendMediaAsSticker;
|
||||||
}
|
}
|
||||||
|
|
||||||
let quotedMsgOptions = {};
|
let quotedMsgOptions = {};
|
||||||
if (options.quotedMessageId) {
|
if (options.quotedMessageId) {
|
||||||
let quotedMessage = window.Store.Msg.get(options.quotedMessageId);
|
let quotedMessage = window.Store.Msg.get(options.quotedMessageId);
|
||||||
|
if (quotedMessage.canReply()) {
|
||||||
// TODO remove .canReply() once all clients are updated to >= v2.2241.6
|
|
||||||
const canReply = window.Store.ReplyUtils ?
|
|
||||||
window.Store.ReplyUtils.canReplyMsg(quotedMessage.unsafe()) :
|
|
||||||
quotedMessage.canReply();
|
|
||||||
|
|
||||||
if (canReply) {
|
|
||||||
quotedMsgOptions = quotedMessage.msgContextInfo(chat);
|
quotedMsgOptions = quotedMessage.msgContextInfo(chat);
|
||||||
}
|
}
|
||||||
delete options.quotedMessageId;
|
delete options.quotedMessageId;
|
||||||
@@ -522,40 +145,43 @@ exports.LoadUtils = () => {
|
|||||||
|
|
||||||
if (options.linkPreview) {
|
if (options.linkPreview) {
|
||||||
delete options.linkPreview;
|
delete options.linkPreview;
|
||||||
|
const link = window.Store.Validators.findLink(content);
|
||||||
// Not supported yet by WhatsApp Web on MD
|
if (link) {
|
||||||
if (!window.Store.MDBackend) {
|
const preview = await window.Store.Wap.queryLinkPreview(link.url);
|
||||||
const link = window.Store.Validators.findLink(content);
|
preview.preview = true;
|
||||||
if (link) {
|
preview.subtype = 'url';
|
||||||
const preview = await window.Store.Wap.queryLinkPreview(link.url);
|
options = { ...options, ...preview };
|
||||||
preview.preview = true;
|
|
||||||
preview.subtype = 'url';
|
|
||||||
options = { ...options, ...preview };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let buttonOptions = {};
|
let extraOptions = {};
|
||||||
if (options.buttons) {
|
if(options.buttons){
|
||||||
let caption;
|
let caption;
|
||||||
if (options.buttons.type === 'chat') {
|
if(options.buttons.type === 'chat') {
|
||||||
content = options.buttons.body;
|
content = options.buttons.body;
|
||||||
caption = content;
|
caption = content;
|
||||||
} else {
|
}else{
|
||||||
caption = options.caption ? options.caption : ' '; //Caption can't be empty
|
caption = options.caption ? options.caption : ' '; //Caption can't be empty
|
||||||
}
|
}
|
||||||
|
extraOptions = {
|
||||||
buttonOptions = window.WWebJS.prepareMessageButtons(options.buttons);
|
productHeaderImageRejected: false,
|
||||||
buttonOptions = {
|
isFromTemplate: false,
|
||||||
...buttonOptions,
|
isDynamicReplyButtonsMsg: true,
|
||||||
|
title: options.buttons.title ? options.buttons.title : undefined,
|
||||||
|
footer: options.buttons.footer ? options.buttons.footer : undefined,
|
||||||
|
dynamicReplyButtons: options.buttons.buttons,
|
||||||
|
replyButtons: options.buttons.buttons,
|
||||||
caption: caption
|
caption: caption
|
||||||
};
|
};
|
||||||
delete options.buttons;
|
delete options.buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
let listOptions = {};
|
if(options.list){
|
||||||
if (options.list) {
|
if(window.Store.Conn.platform === 'smba' || window.Store.Conn.platform === 'smbi'){
|
||||||
listOptions = {
|
throw '[LT01] Whatsapp business can\'t send this yet';
|
||||||
|
}
|
||||||
|
extraOptions = {
|
||||||
|
...extraOptions,
|
||||||
type: 'list',
|
type: 'list',
|
||||||
footer: options.list.footer,
|
footer: options.list.footer,
|
||||||
list: {
|
list: {
|
||||||
@@ -565,44 +191,31 @@ exports.LoadUtils = () => {
|
|||||||
body: options.list.description
|
body: options.list.description
|
||||||
};
|
};
|
||||||
delete options.list;
|
delete options.list;
|
||||||
delete listOptions.list.footer;
|
delete extraOptions.list.footer;
|
||||||
}
|
}
|
||||||
|
|
||||||
const meUser = window.Store.User.getMaybeMeUser();
|
|
||||||
const isMD = window.Store.MDBackend;
|
|
||||||
|
|
||||||
const newMsgId = new window.Store.MsgKey({
|
const newMsgId = new window.Store.MsgKey({
|
||||||
from: meUser,
|
fromMe: true,
|
||||||
to: chat.id,
|
remote: chat.id,
|
||||||
id: window.Store.MsgKey.newId(),
|
id: window.Store.genId(),
|
||||||
participant: isMD && chat.id.isGroup() ? meUser : undefined,
|
|
||||||
selfDir: 'out',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const extraOptions = options.extraOptions || {};
|
|
||||||
delete options.extraOptions;
|
|
||||||
|
|
||||||
const ephemeralFields = window.Store.EphemeralFields.getEphemeralFields(chat);
|
|
||||||
|
|
||||||
const message = {
|
const message = {
|
||||||
...options,
|
...options,
|
||||||
id: newMsgId,
|
id: newMsgId,
|
||||||
ack: 0,
|
ack: 0,
|
||||||
body: content,
|
body: content,
|
||||||
from: meUser,
|
from: window.Store.Conn.wid,
|
||||||
to: chat.id,
|
to: chat.id,
|
||||||
local: true,
|
local: true,
|
||||||
self: 'out',
|
self: 'out',
|
||||||
t: parseInt(new Date().getTime() / 1000),
|
t: parseInt(new Date().getTime() / 1000),
|
||||||
isNewMsg: true,
|
isNewMsg: true,
|
||||||
type: 'chat',
|
type: 'chat',
|
||||||
...ephemeralFields,
|
|
||||||
...locationOptions,
|
...locationOptions,
|
||||||
...attOptions,
|
...attOptions,
|
||||||
...quotedMsgOptions,
|
...quotedMsgOptions,
|
||||||
...vcardOptions,
|
...vcardOptions,
|
||||||
...buttonOptions,
|
|
||||||
...listOptions,
|
|
||||||
...extraOptions
|
...extraOptions
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -610,25 +223,11 @@ exports.LoadUtils = () => {
|
|||||||
return window.Store.Msg.get(newMsgId._serialized);
|
return window.Store.Msg.get(newMsgId._serialized);
|
||||||
};
|
};
|
||||||
|
|
||||||
window.WWebJS.toStickerData = async (mediaInfo) => {
|
|
||||||
if (mediaInfo.mimetype == 'image/webp') return mediaInfo;
|
|
||||||
|
|
||||||
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
|
|
||||||
const webpSticker = await window.Store.StickerTools.toWebpSticker(file);
|
|
||||||
const webpBuffer = await webpSticker.arrayBuffer();
|
|
||||||
const data = window.WWebJS.arrayBufferToBase64(webpBuffer);
|
|
||||||
|
|
||||||
return {
|
|
||||||
mimetype: 'image/webp',
|
|
||||||
data
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
window.WWebJS.processStickerData = async (mediaInfo) => {
|
window.WWebJS.processStickerData = async (mediaInfo) => {
|
||||||
if (mediaInfo.mimetype !== 'image/webp') throw new Error('Invalid media type');
|
if (mediaInfo.mimetype !== 'image/webp') throw new Error('Invalid media type');
|
||||||
|
|
||||||
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
|
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
|
||||||
let filehash = await window.WWebJS.getFileHash(file);
|
let filehash = await window.WWebJS.getFileHash(file);
|
||||||
let mediaKey = await window.WWebJS.generateHash(32);
|
let mediaKey = await window.WWebJS.generateHash(32);
|
||||||
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
@@ -714,11 +313,10 @@ exports.LoadUtils = () => {
|
|||||||
|
|
||||||
window.WWebJS.getMessageModel = message => {
|
window.WWebJS.getMessageModel = message => {
|
||||||
const msg = message.serialize();
|
const msg = message.serialize();
|
||||||
|
|
||||||
msg.isEphemeral = message.isEphemeral;
|
|
||||||
msg.isStatusV3 = message.isStatusV3;
|
msg.isStatusV3 = message.isStatusV3;
|
||||||
msg.links = (message.getRawLinks()).map(link => ({
|
msg.links = (message.getLinks()).map(link => ({
|
||||||
link: link.href,
|
link: link.href,
|
||||||
isSuspicious: Boolean(link.suspiciousCharacters && link.suspiciousCharacters.size)
|
isSuspicious: Boolean(link.suspiciousCharacters && link.suspiciousCharacters.size)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -728,30 +326,24 @@ exports.LoadUtils = () => {
|
|||||||
if (msg.dynamicReplyButtons) {
|
if (msg.dynamicReplyButtons) {
|
||||||
msg.dynamicReplyButtons = JSON.parse(JSON.stringify(msg.dynamicReplyButtons));
|
msg.dynamicReplyButtons = JSON.parse(JSON.stringify(msg.dynamicReplyButtons));
|
||||||
}
|
}
|
||||||
if (msg.replyButtons) {
|
if(msg.replyButtons) {
|
||||||
msg.replyButtons = JSON.parse(JSON.stringify(msg.replyButtons));
|
msg.replyButtons = JSON.parse(JSON.stringify(msg.replyButtons));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof msg.id.remote === 'object') {
|
|
||||||
msg.id = Object.assign({}, msg.id, { remote: msg.id.remote._serialized });
|
|
||||||
}
|
|
||||||
|
|
||||||
delete msg.pendingAckUpdate;
|
delete msg.pendingAckUpdate;
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
window.WWebJS.getChatModel = async chat => {
|
window.WWebJS.getChatModel = async chat => {
|
||||||
|
|
||||||
let res = chat.serialize();
|
let res = chat.serialize();
|
||||||
res.isGroup = chat.isGroup;
|
res.isGroup = chat.isGroup;
|
||||||
res.formattedTitle = chat.formattedTitle;
|
res.formattedTitle = chat.formattedTitle;
|
||||||
res.isMuted = chat.mute && chat.mute.isMuted;
|
res.isMuted = chat.mute && chat.mute.isMuted;
|
||||||
|
|
||||||
if (chat.groupMetadata) {
|
if (chat.groupMetadata) {
|
||||||
const chatWid = window.Store.WidFactory.createWid((chat.id._serialized));
|
await window.Store.GroupMetadata.update(chat.id._serialized);
|
||||||
await window.Store.GroupMetadata.update(chatWid);
|
|
||||||
res.groupMetadata = chat.groupMetadata.serialize();
|
res.groupMetadata = chat.groupMetadata.serialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -769,7 +361,7 @@ exports.LoadUtils = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.WWebJS.getChats = async () => {
|
window.WWebJS.getChats = async () => {
|
||||||
const chats = window.Store.Chat.getModelsArray();
|
const chats = window.Store.Chat.models;
|
||||||
|
|
||||||
const chatPromises = chats.map(chat => window.WWebJS.getChatModel(chat));
|
const chatPromises = chats.map(chat => window.WWebJS.getChatModel(chat));
|
||||||
return await Promise.all(chatPromises);
|
return await Promise.all(chatPromises);
|
||||||
@@ -801,12 +393,12 @@ exports.LoadUtils = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.WWebJS.getContacts = () => {
|
window.WWebJS.getContacts = () => {
|
||||||
const contacts = window.Store.Contact.getModelsArray();
|
const contacts = window.Store.Contact.models;
|
||||||
return contacts.map(contact => window.WWebJS.getContactModel(contact));
|
return contacts.map(contact => window.WWebJS.getContactModel(contact));
|
||||||
};
|
};
|
||||||
|
|
||||||
window.WWebJS.mediaInfoToFile = ({ data, mimetype, filename }) => {
|
window.WWebJS.mediaInfoToFile = ({ data, mimetype, filename }) => {
|
||||||
const binaryData = window.atob(data);
|
const binaryData = atob(data);
|
||||||
|
|
||||||
const buffer = new ArrayBuffer(binaryData.length);
|
const buffer = new ArrayBuffer(binaryData.length);
|
||||||
const view = new Uint8Array(buffer);
|
const view = new Uint8Array(buffer);
|
||||||
@@ -823,29 +415,15 @@ exports.LoadUtils = () => {
|
|||||||
|
|
||||||
window.WWebJS.arrayBufferToBase64 = (arrayBuffer) => {
|
window.WWebJS.arrayBufferToBase64 = (arrayBuffer) => {
|
||||||
let binary = '';
|
let binary = '';
|
||||||
const bytes = new Uint8Array(arrayBuffer);
|
const bytes = new Uint8Array( arrayBuffer );
|
||||||
const len = bytes.byteLength;
|
const len = bytes.byteLength;
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
binary += String.fromCharCode(bytes[i]);
|
binary += String.fromCharCode( bytes[ i ] );
|
||||||
}
|
}
|
||||||
return window.btoa(binary);
|
return window.btoa( binary );
|
||||||
};
|
};
|
||||||
|
|
||||||
window.WWebJS.arrayBufferToBase64Async = (arrayBuffer) =>
|
window.WWebJS.getFileHash = async (data) => {
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
const blob = new Blob([arrayBuffer], {
|
|
||||||
type: 'application/octet-stream',
|
|
||||||
});
|
|
||||||
const fileReader = new FileReader();
|
|
||||||
fileReader.onload = () => {
|
|
||||||
const [, data] = fileReader.result.split(',');
|
|
||||||
resolve(data);
|
|
||||||
};
|
|
||||||
fileReader.onerror = (e) => reject(e);
|
|
||||||
fileReader.readAsDataURL(blob);
|
|
||||||
});
|
|
||||||
|
|
||||||
window.WWebJS.getFileHash = async (data) => {
|
|
||||||
let buffer = await data.arrayBuffer();
|
let buffer = await data.arrayBuffer();
|
||||||
const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
|
const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
|
||||||
return btoa(String.fromCharCode(...new Uint8Array(hashBuffer)));
|
return btoa(String.fromCharCode(...new Uint8Array(hashBuffer)));
|
||||||
@@ -855,7 +433,7 @@ exports.LoadUtils = () => {
|
|||||||
var result = '';
|
var result = '';
|
||||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
var charactersLength = characters.length;
|
var charactersLength = characters.length;
|
||||||
for (var i = 0; i < length; i++) {
|
for ( var i = 0; i < length; i++ ) {
|
||||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -880,18 +458,15 @@ exports.LoadUtils = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.WWebJS.sendChatstate = async (state, chatId) => {
|
window.WWebJS.sendChatstate = async (state, chatId) => {
|
||||||
if (window.Store.MDBackend) {
|
|
||||||
chatId = window.Store.WidFactory.createWid(chatId);
|
|
||||||
}
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 'typing':
|
case 'typing':
|
||||||
await window.Store.ChatState.sendChatStateComposing(chatId);
|
await window.Store.Wap.sendChatstateComposing(chatId);
|
||||||
break;
|
break;
|
||||||
case 'recording':
|
case 'recording':
|
||||||
await window.Store.ChatState.sendChatStateRecording(chatId);
|
await window.Store.Wap.sendChatstateRecording(chatId);
|
||||||
break;
|
break;
|
||||||
case 'stop':
|
case 'stop':
|
||||||
await window.Store.ChatState.sendChatStatePaused(chatId);
|
await window.Store.Wap.sendChatstatePaused(chatId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw 'Invalid chatstate';
|
throw 'Invalid chatstate';
|
||||||
@@ -903,12 +478,12 @@ exports.LoadUtils = () => {
|
|||||||
window.WWebJS.getLabelModel = label => {
|
window.WWebJS.getLabelModel = label => {
|
||||||
let res = label.serialize();
|
let res = label.serialize();
|
||||||
res.hexColor = label.hexColor;
|
res.hexColor = label.hexColor;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
window.WWebJS.getLabels = () => {
|
window.WWebJS.getLabels = () => {
|
||||||
const labels = window.Store.Label.getModelsArray();
|
const labels = window.Store.Label.models;
|
||||||
return labels.map(label => window.WWebJS.getLabelModel(label));
|
return labels.map(label => window.WWebJS.getLabelModel(label));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -922,9 +497,8 @@ exports.LoadUtils = () => {
|
|||||||
return (chat.labels || []).map(id => window.WWebJS.getLabel(id));
|
return (chat.labels || []).map(id => window.WWebJS.getLabel(id));
|
||||||
};
|
};
|
||||||
|
|
||||||
window.WWebJS.getOrderDetail = async (orderId, token, chatId) => {
|
window.WWebJS.getOrderDetail = async (orderId, token) => {
|
||||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
return window.Store.QueryOrder.queryOrder(orderId, 80, 80, token);
|
||||||
return window.Store.QueryOrder.queryOrder(chatWid, orderId, 80, 80, token);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.WWebJS.getProductMetadata = async (productId) => {
|
window.WWebJS.getProductMetadata = async (productId) => {
|
||||||
@@ -936,21 +510,21 @@ exports.LoadUtils = () => {
|
|||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
window.WWebJS.rejectCall = async (peerJid, id) => {
|
|
||||||
peerJid = peerJid.split('@')[0] + '@s.whatsapp.net';
|
exports.MarkAllRead = () => {
|
||||||
let userId = window.Store.User.getMaybeMeUser().user + '@s.whatsapp.net';
|
let Chats = window.Store.Chat.models;
|
||||||
const stanza = window.Store.SocketWap.wap('call', {
|
|
||||||
id: window.Store.SocketWap.generateId(),
|
for (let chatIndex in Chats) {
|
||||||
from: window.Store.SocketWap.USER_JID(userId),
|
if (isNaN(chatIndex)) {
|
||||||
to: window.Store.SocketWap.USER_JID(peerJid),
|
continue;
|
||||||
}, [
|
}
|
||||||
window.Store.SocketWap.wap('reject', {
|
|
||||||
'call-id': id,
|
let chat = Chats[chatIndex];
|
||||||
'call-creator': window.Store.SocketWap.USER_JID(peerJid),
|
|
||||||
count: '0',
|
if (chat.unreadCount > 0) {
|
||||||
})
|
chat.markSeen();
|
||||||
]);
|
window.Store.Wap.sendConversationSeen(chat.id, chat.getLastMsgKeyForAction(), chat.unreadCount - chat.pendingSeenCount);
|
||||||
await window.Store.Socket.deprecatedCastStanza(stanza);
|
}
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class InterfaceController {
|
|||||||
async openChatDrawer(chatId) {
|
async openChatDrawer(chatId) {
|
||||||
await this.pupPage.evaluate(async chatId => {
|
await this.pupPage.evaluate(async chatId => {
|
||||||
let chat = await window.Store.Chat.get(chatId);
|
let chat = await window.Store.Chat.get(chatId);
|
||||||
await window.Store.Cmd.openDrawerMid(chat);
|
await window.Store.Cmd.chatInfoDrawer(chat);
|
||||||
}, chatId);
|
}, chatId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,6 @@ class InterfaceController {
|
|||||||
*/
|
*/
|
||||||
async getFeatures() {
|
async getFeatures() {
|
||||||
return await this.pupPage.evaluate(() => {
|
return await this.pupPage.evaluate(() => {
|
||||||
if(!window.Store.Features) throw new Error('This version of Whatsapp Web does not support features');
|
|
||||||
return window.Store.Features.F;
|
return window.Store.Features.F;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -90,7 +89,6 @@ class InterfaceController {
|
|||||||
*/
|
*/
|
||||||
async checkFeatureStatus(feature) {
|
async checkFeatureStatus(feature) {
|
||||||
return await this.pupPage.evaluate((feature) => {
|
return await this.pupPage.evaluate((feature) => {
|
||||||
if(!window.Store.Features) throw new Error('This version of Whatsapp Web does not support features');
|
|
||||||
return window.Store.Features.supportsFeature(feature);
|
return window.Store.Features.supportsFeature(feature);
|
||||||
}, feature);
|
}, feature);
|
||||||
}
|
}
|
||||||
@@ -101,7 +99,6 @@ class InterfaceController {
|
|||||||
*/
|
*/
|
||||||
async enableFeatures(features) {
|
async enableFeatures(features) {
|
||||||
await this.pupPage.evaluate((features) => {
|
await this.pupPage.evaluate((features) => {
|
||||||
if(!window.Store.Features) throw new Error('This version of Whatsapp Web does not support features');
|
|
||||||
for (const feature in features) {
|
for (const feature in features) {
|
||||||
window.Store.Features.setFeature(features[feature], true);
|
window.Store.Features.setFeature(features[feature], true);
|
||||||
}
|
}
|
||||||
@@ -114,7 +111,6 @@ class InterfaceController {
|
|||||||
*/
|
*/
|
||||||
async disableFeatures(features) {
|
async disableFeatures(features) {
|
||||||
await this.pupPage.evaluate((features) => {
|
await this.pupPage.evaluate((features) => {
|
||||||
if(!window.Store.Features) throw new Error('This version of Whatsapp Web does not support features');
|
|
||||||
for (const feature in features) {
|
for (const feature in features) {
|
||||||
window.Store.Features.setFeature(features[feature], false);
|
window.Store.Features.setFeature(features[feature], false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const sharp = require('sharp');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const Crypto = require('crypto');
|
const Crypto = require('crypto');
|
||||||
const { tmpdir } = require('os');
|
const { tmpdir } = require('os');
|
||||||
const ffmpeg = require('fluent-ffmpeg');
|
const ffmpeg = require('fluent-ffmpeg');
|
||||||
const webp = require('node-webpmux');
|
const webp = require('node-webpmux');
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
|
|
||||||
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods
|
* Utility methods
|
||||||
*/
|
*/
|
||||||
class Util {
|
class Util {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
|
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
|
||||||
}
|
}
|
||||||
@@ -20,7 +23,7 @@ class Util {
|
|||||||
var result = '';
|
var result = '';
|
||||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
var charactersLength = characters.length;
|
var charactersLength = characters.length;
|
||||||
for (var i = 0; i < length; i++) {
|
for ( var i = 0; i < length; i++ ) {
|
||||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -52,19 +55,33 @@ class Util {
|
|||||||
*
|
*
|
||||||
* @returns {Promise<MessageMedia>} media in webp format
|
* @returns {Promise<MessageMedia>} media in webp format
|
||||||
*/
|
*/
|
||||||
static async formatImageToWebpSticker(media, pupPage) {
|
static async formatImageToWebpSticker(media) {
|
||||||
if (!media.mimetype.includes('image'))
|
if (!media.mimetype.includes('image'))
|
||||||
throw new Error('media is not a image');
|
throw new Error('media is not a image');
|
||||||
|
|
||||||
if (media.mimetype.includes('webp')) {
|
if (media.mimetype.includes('webp')) {
|
||||||
return media;
|
return media;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pupPage.evaluate((media) => {
|
const buff = Buffer.from(media.data, 'base64');
|
||||||
return window.WWebJS.toStickerData(media);
|
|
||||||
}, media);
|
let sharpImg = sharp(buff);
|
||||||
|
sharpImg = sharpImg.webp();
|
||||||
|
|
||||||
|
sharpImg = sharpImg.resize(512, 512, {
|
||||||
|
fit: 'contain',
|
||||||
|
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||||
|
});
|
||||||
|
|
||||||
|
let webpBase64 = (await sharpImg.toBuffer()).toString('base64');
|
||||||
|
|
||||||
|
return {
|
||||||
|
mimetype: 'image/webp',
|
||||||
|
data: webpBase64,
|
||||||
|
filename: media.filename,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a video to webp
|
* Formats a video to webp
|
||||||
* @param {MessageMedia} media
|
* @param {MessageMedia} media
|
||||||
@@ -74,14 +91,14 @@ class Util {
|
|||||||
static async formatVideoToWebpSticker(media) {
|
static async formatVideoToWebpSticker(media) {
|
||||||
if (!media.mimetype.includes('video'))
|
if (!media.mimetype.includes('video'))
|
||||||
throw new Error('media is not a video');
|
throw new Error('media is not a video');
|
||||||
|
|
||||||
const videoType = media.mimetype.split('/')[1];
|
const videoType = media.mimetype.split('/')[1];
|
||||||
|
|
||||||
const tempFile = path.join(
|
const tempFile = path.join(
|
||||||
tmpdir(),
|
tmpdir(),
|
||||||
`${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`
|
`${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`
|
||||||
);
|
);
|
||||||
|
|
||||||
const stream = new (require('stream').Readable)();
|
const stream = new (require('stream').Readable)();
|
||||||
const buffer = Buffer.from(
|
const buffer = Buffer.from(
|
||||||
media.data.replace(`data:${media.mimetype};base64,`, ''),
|
media.data.replace(`data:${media.mimetype};base64,`, ''),
|
||||||
@@ -118,17 +135,17 @@ class Util {
|
|||||||
.toFormat('webp')
|
.toFormat('webp')
|
||||||
.save(tempFile);
|
.save(tempFile);
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await fs.readFile(tempFile, 'base64');
|
const data = await fs.readFile(tempFile, 'base64');
|
||||||
await fs.unlink(tempFile);
|
await fs.unlink(tempFile);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mimetype: 'image/webp',
|
mimetype: 'image/webp',
|
||||||
data: data,
|
data: data,
|
||||||
filename: media.filename,
|
filename: media.filename,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sticker metadata.
|
* Sticker metadata.
|
||||||
* @typedef {Object} StickerMetadata
|
* @typedef {Object} StickerMetadata
|
||||||
@@ -144,14 +161,14 @@ class Util {
|
|||||||
*
|
*
|
||||||
* @returns {Promise<MessageMedia>} media in webp format
|
* @returns {Promise<MessageMedia>} media in webp format
|
||||||
*/
|
*/
|
||||||
static async formatToWebpSticker(media, metadata, pupPage) {
|
static async formatToWebpSticker(media, metadata) {
|
||||||
let webpMedia;
|
let webpMedia;
|
||||||
|
|
||||||
if (media.mimetype.includes('image'))
|
if (media.mimetype.includes('image'))
|
||||||
webpMedia = await this.formatImageToWebpSticker(media, pupPage);
|
webpMedia = await this.formatImageToWebpSticker(media);
|
||||||
else if (media.mimetype.includes('video'))
|
else if (media.mimetype.includes('video'))
|
||||||
webpMedia = await this.formatVideoToWebpSticker(media);
|
webpMedia = await this.formatVideoToWebpSticker(media);
|
||||||
else
|
else
|
||||||
throw new Error('Invalid media format');
|
throw new Error('Invalid media format');
|
||||||
|
|
||||||
if (metadata.name || metadata.author) {
|
if (metadata.name || metadata.author) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user