@pney/whatsapp-web 1.34.6 → 1.34.7-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +0 -1
- package/.gitattributes +4 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +1 -0
- package/.lintstagedrc.json +6 -0
- package/.prettierignore +8 -0
- package/.prettierrc.json +10 -0
- package/README.md +83 -80
- package/commitlint.config.js +29 -0
- package/eslint.config.mjs +67 -0
- package/example.js +151 -71
- package/index.d.ts +982 -734
- package/index.js +4 -4
- package/package.json +3 -3
- package/shell.js +4 -4
- package/src/Client.js +1860 -920
- package/src/authStrategies/BaseAuthStrategy.js +4 -2
- package/src/authStrategies/LocalAuth.js +25 -12
- package/src/authStrategies/NoAuth.js +3 -4
- package/src/authStrategies/RemoteAuth.js +92 -43
- package/src/factories/ChatFactory.js +1 -1
- package/src/factories/ContactFactory.js +2 -2
- package/src/structures/Base.js +5 -3
- package/src/structures/Broadcast.js +1 -2
- package/src/structures/BusinessContact.js +1 -2
- package/src/structures/Buttons.js +14 -10
- package/src/structures/Call.js +10 -6
- package/src/structures/Channel.js +171 -91
- package/src/structures/Chat.js +57 -41
- package/src/structures/ClientInfo.js +1 -1
- package/src/structures/Contact.js +37 -16
- package/src/structures/GroupChat.js +425 -228
- package/src/structures/GroupNotification.js +21 -12
- package/src/structures/Label.js +6 -6
- package/src/structures/List.js +22 -14
- package/src/structures/Location.js +5 -4
- package/src/structures/Message.js +412 -168
- package/src/structures/MessageMedia.js +31 -18
- package/src/structures/Order.js +4 -4
- package/src/structures/Payment.js +6 -3
- package/src/structures/Poll.js +2 -2
- package/src/structures/PollVote.js +9 -6
- package/src/structures/PrivateChat.js +2 -4
- package/src/structures/PrivateContact.js +2 -4
- package/src/structures/Product.js +1 -1
- package/src/structures/ProductMetadata.js +1 -2
- package/src/structures/Reaction.js +2 -4
- package/src/structures/ScheduledEvent.js +22 -10
- package/src/util/Constants.js +8 -6
- package/src/util/Injected/AuthStore/AuthStore.js +7 -3
- package/src/util/Injected/Utils.js +753 -345
- package/src/util/InterfaceController.js +72 -25
- package/src/util/Puppeteer.js +1 -1
- package/src/util/Util.js +28 -15
- package/src/webCache/LocalWebCache.js +7 -5
- package/src/webCache/RemoteWebCache.js +10 -4
- package/src/webCache/WebCache.js +8 -5
- package/src/webCache/WebCacheFactory.js +9 -9
- package/CODE_OF_CONDUCT.md +0 -133
package/.env.example
CHANGED
package/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx lint-staged
|
package/.prettierignore
ADDED
package/.prettierrc.json
ADDED
package/README.md
CHANGED
|
@@ -1,59 +1,65 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<br />
|
|
3
2
|
<p>
|
|
4
|
-
<a href="https://wwebjs.dev"
|
|
3
|
+
<a href="https://wwebjs.dev">
|
|
4
|
+
<img src="https://github.com/wwebjs/Assets/blob/main/Collection/GitHub/whatsapp-web.js.png?raw=true"
|
|
5
|
+
title="whatsapp-web.js" alt="WWebJS Website" />
|
|
6
|
+
</a>
|
|
5
7
|
</p>
|
|
6
|
-
<br />
|
|
7
8
|
<p>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
<a href="https://www.npmjs.com/package/whatsapp-web.js"><img
|
|
10
|
+
src="https://img.shields.io/npm/v/whatsapp-web.js.svg" alt="npm" /></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/whatsapp-web.js"><img alt="NPM Downloads"
|
|
12
|
+
src="https://img.shields.io/npm/d18m/whatsapp-web.js" /></a>
|
|
13
|
+
<a href="https://github.com/wwebjs/whatsapp-web.js/graphs/contributors"><img alt="GitHub contributors"
|
|
14
|
+
src="https://img.shields.io/github/contributors-anon/wwebjs/whatsapp-web.js" /></a>
|
|
15
|
+
<a href="https://depfu.com/github/wwebjs/whatsapp-web.js?project_id=9765"><img
|
|
16
|
+
src="https://badges.depfu.com/badges/4a65a0de96ece65fdf39e294e0c8dcba/overview.svg" alt="Depfu" /></a>
|
|
17
|
+
<a href="https://discord.wwebjs.dev"><img
|
|
18
|
+
src="https://img.shields.io/discord/698610475432411196.svg?logo=discord" alt="Discord server" /></a>
|
|
19
|
+
</p>
|
|
14
20
|
</div>
|
|
15
21
|
|
|
16
22
|
## About
|
|
17
|
-
**A WhatsApp API client that operates via the WhatsApp Web browser.**
|
|
18
|
-
|
|
19
|
-
The library launches the WhatsApp Web browser app via Puppeteer, accessing its internal functions and creating a managed instance to reduce the risk of being blocked. This gives the API client nearly all WhatsApp Web features for dynamic use in a Node.js application.
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
> **It is not guaranteed you will not be blocked by using this method. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.**
|
|
24
|
+
whatsapp‑web.js is a powerful [Node.js][nodejs] library that lets you interact with WhatsApp Web, making it easy to build a dynamic WhatsApp API with nearly all features of the web client. It uses [Puppeteer][puppeteer] to access WhatsApp Web’s internal functions and runs them in a managed browser instance to reduce the risk of being blocked.
|
|
23
25
|
|
|
24
26
|
## Links
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
- [GitHub][gitHub]
|
|
29
|
+
- [Guide][guide] ([source][guide-source])
|
|
30
|
+
- [Documentation][documentation] ([source][documentation-source])
|
|
31
|
+
- [Discord Server][discord]
|
|
32
|
+
- [npm][npm]
|
|
31
33
|
|
|
32
34
|
## Installation
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
**Node.js `v18.0.0` or higher, is required.**
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm install whatsapp-web.js
|
|
40
|
+
yarn add whatsapp-web.js
|
|
41
|
+
pnpm add whatsapp-web.js
|
|
42
|
+
```
|
|
35
43
|
|
|
36
|
-
|
|
37
|
-
> **Node ``v18`` or higher, is required.**
|
|
38
|
-
> See the [Guide][guide] for quick upgrade instructions.
|
|
44
|
+
Having trouble installing? Take a peak at the [Guide][guide] for more detailed instructions.
|
|
39
45
|
|
|
40
46
|
## Example usage
|
|
41
47
|
|
|
42
48
|
```js
|
|
43
49
|
const { Client } = require('whatsapp-web.js');
|
|
50
|
+
const qrcode = require('qrcode-terminal');
|
|
44
51
|
|
|
45
52
|
const client = new Client();
|
|
46
53
|
|
|
47
54
|
client.on('qr', (qr) => {
|
|
48
|
-
|
|
49
|
-
console.log('QR RECEIVED', qr);
|
|
55
|
+
qrcode.generate(qr, { small: true });
|
|
50
56
|
});
|
|
51
57
|
|
|
52
58
|
client.on('ready', () => {
|
|
53
59
|
console.log('Client is ready!');
|
|
54
60
|
});
|
|
55
61
|
|
|
56
|
-
client.on('message', msg => {
|
|
62
|
+
client.on('message', (msg) => {
|
|
57
63
|
if (msg.body == '!ping') {
|
|
58
64
|
msg.reply('pong');
|
|
59
65
|
}
|
|
@@ -62,60 +68,58 @@ client.on('message', msg => {
|
|
|
62
68
|
client.initialize();
|
|
63
69
|
```
|
|
64
70
|
|
|
65
|
-
Take a look at [example.js][examples] for
|
|
66
|
-
For
|
|
67
|
-
|
|
71
|
+
Take a look at [example.js][examples] for additional examples and use cases.
|
|
72
|
+
For more details on saving and restoring sessions, check out the [Authentication Strategies][auth-strategies].
|
|
68
73
|
|
|
69
74
|
## Supported features
|
|
70
75
|
|
|
71
|
-
| Feature
|
|
72
|
-
|
|
|
73
|
-
| Multi Device
|
|
74
|
-
| Send messages
|
|
75
|
-
| Receive messages
|
|
76
|
-
| Send media (images/audio/documents)
|
|
77
|
-
| Send media (video)
|
|
78
|
-
| Send stickers
|
|
79
|
-
| Receive media (images/audio/video/documents)
|
|
80
|
-
| Send contact cards
|
|
81
|
-
| Send location
|
|
82
|
-
| Send buttons
|
|
83
|
-
| Send lists
|
|
84
|
-
| Receive location
|
|
85
|
-
| Message replies
|
|
86
|
-
| Join groups by invite
|
|
87
|
-
| Get invite for group
|
|
88
|
-
| Modify group info (subject, description)
|
|
89
|
-
| Modify group settings (send messages, edit info)
|
|
90
|
-
| Add group participants
|
|
91
|
-
| Kick group participants
|
|
92
|
-
| Promote/demote group participants
|
|
93
|
-
| Mention users
|
|
94
|
-
| Mention groups
|
|
95
|
-
| Mute/unmute chats
|
|
96
|
-
| Block/unblock contacts
|
|
97
|
-
| Get contact info
|
|
98
|
-
| Get profile pictures
|
|
99
|
-
| Set user status message
|
|
100
|
-
| React to messages
|
|
101
|
-
| Create polls
|
|
102
|
-
| Channels
|
|
103
|
-
| Vote in polls
|
|
104
|
-
| Communities
|
|
76
|
+
| Feature | Status |
|
|
77
|
+
| ------------------------------------------------ | -------------------------------------------- |
|
|
78
|
+
| Multi Device | ✅ |
|
|
79
|
+
| Send messages | ✅ |
|
|
80
|
+
| Receive messages | ✅ |
|
|
81
|
+
| Send media (images/audio/documents) | ✅ |
|
|
82
|
+
| Send media (video) | ✅ [(requires Google Chrome)][google-chrome] |
|
|
83
|
+
| Send stickers | ✅ |
|
|
84
|
+
| Receive media (images/audio/video/documents) | ✅ |
|
|
85
|
+
| Send contact cards | ✅ |
|
|
86
|
+
| Send location | ✅ |
|
|
87
|
+
| Send buttons | ❌ [(DEPRECATED)][deprecated-video] |
|
|
88
|
+
| Send lists | ❌ [(DEPRECATED)][deprecated-video] |
|
|
89
|
+
| Receive location | ✅ |
|
|
90
|
+
| Message replies | ✅ |
|
|
91
|
+
| Join groups by invite | ✅ |
|
|
92
|
+
| Get invite for group | ✅ |
|
|
93
|
+
| Modify group info (subject, description) | ✅ |
|
|
94
|
+
| Modify group settings (send messages, edit info) | ✅ |
|
|
95
|
+
| Add group participants | ✅ |
|
|
96
|
+
| Kick group participants | ✅ |
|
|
97
|
+
| Promote/demote group participants | ✅ |
|
|
98
|
+
| Mention users | ✅ |
|
|
99
|
+
| Mention groups | ✅ |
|
|
100
|
+
| Mute/unmute chats | ✅ |
|
|
101
|
+
| Block/unblock contacts | ✅ |
|
|
102
|
+
| Get contact info | ✅ |
|
|
103
|
+
| Get profile pictures | ✅ |
|
|
104
|
+
| Set user status message | ✅ |
|
|
105
|
+
| React to messages | ✅ |
|
|
106
|
+
| Create polls | ✅ |
|
|
107
|
+
| Channels | ✅ |
|
|
108
|
+
| Vote in polls | ✅ |
|
|
109
|
+
| Communities | 🔜 |
|
|
105
110
|
|
|
106
111
|
Something missing? Make an issue and let us know!
|
|
107
112
|
|
|
108
|
-
## Contributing
|
|
109
|
-
|
|
110
|
-
Feel free to open pull requests; we welcome contributions! However, for significant changes, it's best to open an issue beforehand. Make sure to review our [contribution guidelines][contributing] before creating a pull request. Before creating your own issue or pull request, always check to see if one already exists!
|
|
111
|
-
|
|
112
113
|
## Supporting the project
|
|
113
114
|
|
|
114
|
-
You can support the maintainer of this project through the links below
|
|
115
|
+
You can support the maintainer of this project through the links below:
|
|
115
116
|
|
|
116
117
|
- [Support via GitHub Sponsors][gitHub-sponsors]
|
|
117
118
|
- [Support via PayPal][support-payPal]
|
|
118
|
-
|
|
119
|
+
|
|
120
|
+
## Contributing
|
|
121
|
+
|
|
122
|
+
Feel free to open pull requests; we welcome contributions! However, for significant changes, it's best to open an issue beforehand. Make sure to review our [contribution guidelines][contributing] before creating a pull request. Before creating your own issue or pull request, always check to see if one already exists!
|
|
119
123
|
|
|
120
124
|
## Disclaimer
|
|
121
125
|
|
|
@@ -123,33 +127,32 @@ This project is not affiliated, associated, authorized, endorsed by, or in any w
|
|
|
123
127
|
|
|
124
128
|
## License
|
|
125
129
|
|
|
126
|
-
Copyright 2019 Pedro S Lopez
|
|
130
|
+
Copyright 2019 Pedro S Lopez
|
|
127
131
|
|
|
128
132
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
129
133
|
you may not use this project except in compliance with the License.
|
|
130
|
-
You may obtain a copy of the License at
|
|
134
|
+
You may obtain a copy of the License at <https://www.apache.org/licenses/LICENSE-2.0>.
|
|
131
135
|
|
|
132
136
|
Unless required by applicable law or agreed to in writing, software
|
|
133
137
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
134
138
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
135
139
|
See the License for the specific language governing permissions and
|
|
136
|
-
limitations under the License.
|
|
137
|
-
|
|
140
|
+
limitations under the License.
|
|
138
141
|
|
|
139
142
|
[guide]: https://guide.wwebjs.dev/guide
|
|
140
143
|
[guide-source]: https://github.com/wwebjs/wwebjs.dev/tree/main
|
|
141
144
|
[documentation]: https://docs.wwebjs.dev/
|
|
142
|
-
[documentation-source]: https://github.com/
|
|
143
|
-
[discord]: https://discord.
|
|
144
|
-
[gitHub]: https://github.com/
|
|
145
|
+
[documentation-source]: https://github.com/wwebjs/whatsapp-web.js/tree/main/docs
|
|
146
|
+
[discord]: https://discord.wwebjs.dev
|
|
147
|
+
[gitHub]: https://github.com/wwebjs/whatsapp-web.js
|
|
145
148
|
[npm]: https://npmjs.org/package/whatsapp-web.js
|
|
146
149
|
[nodejs]: https://nodejs.org/en/download/
|
|
147
|
-
[examples]: https://github.com/
|
|
150
|
+
[examples]: https://github.com/wwebjs/whatsapp-web.js/blob/main/example.js
|
|
148
151
|
[auth-strategies]: https://wwebjs.dev/guide/creating-your-bot/authentication.html
|
|
149
152
|
[google-chrome]: https://wwebjs.dev/guide/creating-your-bot/handling-attachments.html#caveat-for-sending-videos-and-gifs
|
|
150
153
|
[deprecated-video]: https://www.youtube.com/watch?v=hv1R1rLeVVE
|
|
151
|
-
[gitHub-sponsors]: https://github.com/sponsors/
|
|
154
|
+
[gitHub-sponsors]: https://github.com/sponsors/wwebjs
|
|
152
155
|
[support-payPal]: https://www.paypal.me/psla/
|
|
153
|
-
[
|
|
154
|
-
[contributing]: https://github.com/pedroslopez/whatsapp-web.js/blob/main/CODE_OF_CONDUCT.md
|
|
156
|
+
[contributing]: .github/CONTRIBUTING.md
|
|
155
157
|
[whatsapp]: https://whatsapp.com
|
|
158
|
+
[puppeteer]: https://pptr.dev/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['@commitlint/config-conventional'],
|
|
3
|
+
rules: {
|
|
4
|
+
'header-max-length': [2, 'always', 72],
|
|
5
|
+
'type-enum': [
|
|
6
|
+
2,
|
|
7
|
+
'always',
|
|
8
|
+
[
|
|
9
|
+
'feat',
|
|
10
|
+
'fix',
|
|
11
|
+
'docs',
|
|
12
|
+
'style',
|
|
13
|
+
'refactor',
|
|
14
|
+
'perf',
|
|
15
|
+
'test',
|
|
16
|
+
'build',
|
|
17
|
+
'ci',
|
|
18
|
+
'chore',
|
|
19
|
+
'types',
|
|
20
|
+
'revert',
|
|
21
|
+
'infra',
|
|
22
|
+
],
|
|
23
|
+
],
|
|
24
|
+
'type-case': [0],
|
|
25
|
+
'scope-case': [0],
|
|
26
|
+
'subject-case': [0],
|
|
27
|
+
'subject-exclamation-mark': [0],
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
import pluginEslintJs from '@eslint/js';
|
|
3
|
+
import pluginMocha from 'eslint-plugin-mocha';
|
|
4
|
+
import configEslintConfigPrettier from 'eslint-plugin-prettier/recommended';
|
|
5
|
+
|
|
6
|
+
export default [
|
|
7
|
+
pluginEslintJs.configs.recommended,
|
|
8
|
+
{
|
|
9
|
+
name: 'whatsapp-web.js/default/rules',
|
|
10
|
+
plugins: {
|
|
11
|
+
mocha: pluginMocha,
|
|
12
|
+
},
|
|
13
|
+
languageOptions: {
|
|
14
|
+
ecmaVersion: 2025,
|
|
15
|
+
|
|
16
|
+
globals: {
|
|
17
|
+
...globals.browser,
|
|
18
|
+
...globals.commonjs,
|
|
19
|
+
...globals.es6,
|
|
20
|
+
...globals.node,
|
|
21
|
+
|
|
22
|
+
Atomics: 'readonly',
|
|
23
|
+
SharedArrayBuffer: 'readonly',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
rules: {
|
|
27
|
+
'no-unused-vars': [
|
|
28
|
+
'error',
|
|
29
|
+
{
|
|
30
|
+
// TODO: args can be uncommented, but there is code, that causes lint-errors
|
|
31
|
+
// args: 'all',
|
|
32
|
+
vars: 'all',
|
|
33
|
+
caughtErrorsIgnorePattern: '^ignoredError',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
// be careful, "recommended" settings object has 4 fields:
|
|
40
|
+
// - name (string)
|
|
41
|
+
// - plugins (object)
|
|
42
|
+
// - languageOptions (object)
|
|
43
|
+
// - rules (object)
|
|
44
|
+
//
|
|
45
|
+
// by simple "adding" any of mentioned fields to this object
|
|
46
|
+
// you REPLACE the "recommended" value.
|
|
47
|
+
// If you want to PATCH it - consider nested "..." spread operator
|
|
48
|
+
...pluginMocha.configs.recommended,
|
|
49
|
+
name: 'whatsapp-web.js/default/mocha',
|
|
50
|
+
|
|
51
|
+
files: ['tests/**/*'],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'whatsapp-web.js/default/ignores',
|
|
55
|
+
ignores: [
|
|
56
|
+
'node_modules',
|
|
57
|
+
'dist',
|
|
58
|
+
'coverage',
|
|
59
|
+
'docs',
|
|
60
|
+
'*.min.js',
|
|
61
|
+
'.wa-version',
|
|
62
|
+
'.wwebjs_auth',
|
|
63
|
+
'.wwebjs_cache',
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
configEslintConfigPrettier,
|
|
67
|
+
];
|