@vanzxy/baileys 1.6.5 → 1.6.7
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/README.md +565 -54
- package/WAProto/index.js +774 -1
- package/lib/Defaults/index.d.ts +5 -0
- package/lib/Defaults/index.js +21 -4
- package/lib/Utils/A2UI.js +63 -3
- package/lib/Utils/anti-delete.d.ts +6 -0
- package/lib/Utils/anti-delete.js +29 -0
- package/lib/Utils/auth-utils.js +11 -6
- package/lib/Utils/auto-reply.js +4 -1
- package/lib/Utils/baileys-event-stream.d.ts +8 -0
- package/lib/Utils/baileys-event-stream.js +62 -0
- package/lib/Utils/business.js +8 -0
- package/lib/Utils/button-sender.js +8 -1
- package/lib/Utils/chat-control.d.ts +159 -0
- package/lib/Utils/chat-control.js +232 -0
- package/lib/Utils/generics.d.ts +6 -0
- package/lib/Utils/generics.js +24 -0
- package/lib/Utils/index.d.ts +4 -0
- package/lib/Utils/index.js +4 -0
- package/lib/Utils/message-search.js +20 -5
- package/lib/Utils/messages.js +5 -0
- package/lib/Utils/past-participants.d.ts +14 -0
- package/lib/Utils/past-participants.js +40 -0
- package/lib/Utils/process-message.js +6 -2
- package/lib/Utils/stickerpack.js +10 -11
- package/lib/Utils/use-cache-manager-auth-state.d.ts +13 -0
- package/lib/Utils/use-cache-manager-auth-state.js +82 -0
- package/lib/Utils/validate-connection.js +2 -6
- package/lib/Utils/vcard.js +15 -4
- package/package.json +40 -17
- package/postinstall-banner.js +37 -5
- package/NOTICE.md +0 -91
package/README.md
CHANGED
|
@@ -1,43 +1,156 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center" id="top">
|
|
2
|
+
|
|
3
|
+
<img src="https://capsule-render.vercel.app/api?type=waving&color=0:1d6a23,100:2ecc71&height=180§ion=header&text=%40vanzxy%2Fbaileys&fontSize=42&fontColor=ffffff&animation=fadeIn&fontAlignY=38&desc=Next-generation%20Baileys%20fork%20—%20built%20different,%20built%20by%20Vanzxy&descAlignY=58&descSize=16" width="100%"/>
|
|
4
|
+
|
|
5
|
+
<img src="https://files.catbox.moe/l72xji.svg" width="100%" alt="Sakura night banner"/>
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
<img src="https://readme-typing-svg.demolab.com?font=Fira+Code&size=18&pause=1200&color=2ECC71¢er=true&vCenter=true&width=650&lines=Extended+interactive+messages+%26+native+flow;Status+tools+%2B+quality-of-life+fixes;Built+on+top+of+WhiskeySockets%2FBaileys" alt="Typing SVG" />
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@vanzxy/baileys" target="_blank"><img src="https://img.shields.io/npm/v/@vanzxy/baileys?color=2ecc71&label=npm&style=for-the-badge" alt="npm version"/></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@vanzxy/baileys" target="_blank"><img src="https://img.shields.io/npm/dt/@vanzxy/baileys?color=3498db&style=for-the-badge" alt="npm downloads"/></a>
|
|
14
|
+
<a href="https://github.com/vanzxysenpai/vanzxybaileys/stargazers" target="_blank"><img src="https://img.shields.io/github/stars/vanzxysenpai/vanzxybaileys?color=f1c40f&style=for-the-badge" alt="GitHub stars"/></a>
|
|
15
|
+
<a href="https://github.com/vanzxysenpai/vanzxybaileys/issues" target="_blank"><img src="https://img.shields.io/github/issues/vanzxysenpai/vanzxybaileys?color=e74c3c&style=for-the-badge" alt="GitHub issues"/></a>
|
|
16
|
+
</p>
|
|
17
|
+
<p>
|
|
18
|
+
<img src="https://img.shields.io/github/last-commit/vanzxysenpai/vanzxybaileys?color=9b59b6&style=flat-square" alt="Last commit"/>
|
|
19
|
+
<img src="https://img.shields.io/github/commit-activity/m/vanzxysenpai/vanzxybaileys?color=1abc9c&style=flat-square" alt="Commit activity"/>
|
|
20
|
+
<img src="https://img.shields.io/github/languages/code-size/vanzxysenpai/vanzxybaileys?color=e67e22&style=flat-square" alt="Code size"/>
|
|
21
|
+
<img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen?style=flat-square" alt="Node >=20"/>
|
|
22
|
+
<img src="https://img.shields.io/badge/module-ESM-blue?style=flat-square" alt="ESM"/>
|
|
23
|
+
<img src="https://img.shields.io/badge/types-included-blue?style=flat-square" alt="TypeScript types included"/>
|
|
24
|
+
<img src="https://img.shields.io/badge/license-see%20NOTICE-lightgrey?style=flat-square" alt="License"/>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<p>
|
|
28
|
+
<a href="#-why-vanzxybaileys">About</a>  | 
|
|
29
|
+
<a href="#-comparison">Comparison</a>  | 
|
|
30
|
+
<a href="#-features">Features</a>  | 
|
|
31
|
+
<a href="#-installation">Installation</a>  | 
|
|
32
|
+
<a href="#-quick-start">Quick Start</a>  | 
|
|
33
|
+
<a href="#-usage-examples">Examples</a>  | 
|
|
34
|
+
<a href="#-faq--troubleshooting">FAQ</a>  | 
|
|
35
|
+
<a href="#-contributing">Contributing</a>  | 
|
|
36
|
+
<a href="#-credits">Credits</a>  | 
|
|
37
|
+
<a href="#-maintainer">Maintainer</a>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary>📖 Full table of contents</summary>
|
|
42
|
+
<br/>
|
|
43
|
+
|
|
44
|
+
- [🍃 Why @vanzxy/baileys](#-why-vanzxybaileys)
|
|
45
|
+
- [🆚 Comparison](#-comparison)
|
|
46
|
+
- [🧰 Built With](#-built-with)
|
|
47
|
+
- [🔥 Features](#-features)
|
|
48
|
+
- [✨ Exclusive Vanzxy Enhancements](#-exclusive-vanzxy-enhancements)
|
|
49
|
+
- [📦 Installation](#-installation)
|
|
50
|
+
- [🚀 Quick Start](#-quick-start)
|
|
51
|
+
- [🔐 Authentication](#-authentication)
|
|
52
|
+
- [🗄️ Store Backends](#-store-backends)
|
|
53
|
+
- [💡 Usage Examples](#-usage-examples)
|
|
54
|
+
- [Buttons & Native Flow](#buttons--native-flow)
|
|
55
|
+
- [Poll](#poll)
|
|
56
|
+
- [Carousel](#carousel)
|
|
57
|
+
- [AIRich — rich response cards](#airich--rich-response-cards)
|
|
58
|
+
- [📞 Voice & Video Calls](#-voice--video-calls)
|
|
59
|
+
- [🔎 User Sync Queries](#-user-sync-queries)
|
|
60
|
+
- [🧩 Utility Modules](#-utility-modules)
|
|
61
|
+
- [🛎️ System Notification Filter](#-system-notification-filter)
|
|
62
|
+
- [🛠 Recommended Environment](#-recommended-environment)
|
|
63
|
+
- [📘 TypeScript Support](#-typescript-support)
|
|
64
|
+
- [📚 Fork Lineage](#-fork-lineage)
|
|
65
|
+
- [❓ FAQ & Troubleshooting](#-faq--troubleshooting)
|
|
66
|
+
- [🤝 Contributing](#-contributing)
|
|
67
|
+
- [🙏 Credits](#-credits)
|
|
68
|
+
- [💖 Support](#-support)
|
|
69
|
+
- [👑 Maintainer](#-maintainer)
|
|
70
|
+
- [⚠️ Disclaimer](#-disclaimer)
|
|
71
|
+
- [📝 Patch Notes](#-v4-patch-notes)
|
|
72
|
+
|
|
73
|
+
</details>
|
|
74
|
+
|
|
75
|
+
</div>
|
|
2
76
|
|
|
3
|
-
|
|
4
|
-
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 🍃 Why @vanzxy/baileys?
|
|
80
|
+
|
|
81
|
+
This fork focuses on:
|
|
5
82
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
83
|
+
| | |
|
|
84
|
+
|---|---|
|
|
85
|
+
| 🚀 | Better developer experience |
|
|
86
|
+
| 🎯 | Extended native flow support |
|
|
87
|
+
| 📢 | Advanced status & broadcast features |
|
|
88
|
+
| 🧩 | More interactive message types |
|
|
89
|
+
| ⚡ | Cleaner implementation for bot developers |
|
|
90
|
+
| 🔧 | Extra utilities not available in standard Baileys forks |
|
|
91
|
+
| 🗄️ | Multiple auth & store backends out of the box (file, SQLite, MongoDB, MySQL, PostgreSQL, Redis) |
|
|
92
|
+
| 📞 | Experimental voice-call (VoIP) support |
|
|
9
93
|
|
|
10
94
|
---
|
|
11
95
|
|
|
12
|
-
|
|
96
|
+
## 🆚 Comparison
|
|
13
97
|
|
|
14
|
-
|
|
98
|
+
How `@vanzxy/baileys` stacks up against its own lineage and the wider Baileys fork ecosystem:
|
|
99
|
+
|
|
100
|
+
| Capability | `@vanzxy/baileys` | `@itsliaaa/baileys` | `WhiskeySockets/Baileys` |
|
|
101
|
+
|---|:---:|:---:|:---:|
|
|
102
|
+
| Native Flow buttons (V1/V2/V3) | ✅ | ✅ | ⚠️ basic only |
|
|
103
|
+
| Carousel messages | ✅ | ❌ | ❌ |
|
|
104
|
+
| Rich response cards (AIRich) | ✅ | ❌ | ❌ |
|
|
105
|
+
| Commerce flow (catalog/order/payment) | ✅ | ⚠️ partial | ❌ |
|
|
106
|
+
| Voice calling (VoIP) | ✅ experimental | ❌ | ❌ |
|
|
107
|
+
| Multi-backend store (SQL/Mongo/Redis) | ✅ | ⚠️ file/SQLite only | ⚠️ in-memory only |
|
|
108
|
+
| Full `.d.ts` TypeScript definitions | ✅ | ⚠️ partial | ⚠️ partial |
|
|
109
|
+
| User sync queries (WAUSync) | ✅ | ✅ | ✅ |
|
|
15
110
|
|
|
16
|
-
|
|
17
|
-
- 🎯 Extended native flow support
|
|
18
|
-
- 📢 Advanced status & broadcast features
|
|
19
|
-
- 🧩 More interactive message types
|
|
20
|
-
- ⚡ Cleaner implementation for bot developers
|
|
21
|
-
- 🔧 Extra utilities not available in standard Baileys forks
|
|
111
|
+
> Tabel ini menggambarkan fitur di level package, bukan benchmark performa. PR untuk memperbarui/mengoreksi tabel ini dipersilakan lewat [Contributing](#-contributing).
|
|
22
112
|
|
|
23
113
|
---
|
|
24
114
|
|
|
25
|
-
|
|
115
|
+
## 🧰 Built With
|
|
116
|
+
|
|
117
|
+
<p>
|
|
118
|
+
<img src="https://img.shields.io/badge/node.js-%2343853D.svg?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js"/>
|
|
119
|
+
<img src="https://img.shields.io/badge/javascript-%23323330.svg?style=for-the-badge&logo=javascript&logoColor=%23F7DF1E" alt="JavaScript"/>
|
|
120
|
+
<img src="https://img.shields.io/badge/esm-%23F7DF1E.svg?style=for-the-badge&logo=javascript&logoColor=black" alt="ESM"/>
|
|
121
|
+
<img src="https://img.shields.io/badge/websocket-%23000000.svg?style=for-the-badge&logo=socket.io&logoColor=white" alt="WebSocket"/>
|
|
122
|
+
<img src="https://img.shields.io/badge/signal%20protocol-%233A76F0.svg?style=for-the-badge&logo=signal&logoColor=white" alt="Signal Protocol"/>
|
|
123
|
+
<img src="https://img.shields.io/badge/protobuf-%23345?style=for-the-badge&logo=google&logoColor=white" alt="Protobuf"/>
|
|
124
|
+
<img src="https://img.shields.io/badge/npm-%23CB3837.svg?style=for-the-badge&logo=npm&logoColor=white" alt="npm"/>
|
|
125
|
+
</p>
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 🔥 Features
|
|
130
|
+
|
|
131
|
+
<table>
|
|
132
|
+
<tr>
|
|
133
|
+
<th align="center">💬 Interactive Messages</th>
|
|
134
|
+
<th align="center">🛒 Commerce & Business</th>
|
|
135
|
+
<th align="center">🧩 Utility Features</th>
|
|
136
|
+
</tr>
|
|
137
|
+
<tr>
|
|
138
|
+
<td valign="top">
|
|
26
139
|
|
|
27
|
-
## Interactive Messages
|
|
28
140
|
- Native Flow
|
|
29
|
-
- Buttons
|
|
141
|
+
- Buttons (V1 / V2 / V3)
|
|
30
142
|
- Lists
|
|
31
143
|
- Carousel Messages
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
- Reply Buttons
|
|
35
|
-
- URL Buttons
|
|
144
|
+
- Poll & Quiz Messages
|
|
145
|
+
- Rich Response Messages (AIRich)
|
|
146
|
+
- CTA / Reply / URL Buttons
|
|
36
147
|
- Call Buttons
|
|
37
148
|
- OTP Buttons
|
|
38
149
|
- Authentication Buttons
|
|
39
150
|
|
|
40
|
-
|
|
151
|
+
</td>
|
|
152
|
+
<td valign="top">
|
|
153
|
+
|
|
41
154
|
- Catalog Message
|
|
42
155
|
- Order Details
|
|
43
156
|
- Order Status
|
|
@@ -48,7 +161,9 @@ This fork focuses on:
|
|
|
48
161
|
- Reorder
|
|
49
162
|
- Cancel Order
|
|
50
163
|
|
|
51
|
-
|
|
164
|
+
</td>
|
|
165
|
+
<td valign="top">
|
|
166
|
+
|
|
52
167
|
- Group Status Support
|
|
53
168
|
- Mention All
|
|
54
169
|
- Lottie Sticker Support
|
|
@@ -58,43 +173,108 @@ This fork focuses on:
|
|
|
58
173
|
- Rich Formatting
|
|
59
174
|
- Code Highlighting
|
|
60
175
|
|
|
176
|
+
</td>
|
|
177
|
+
</tr>
|
|
178
|
+
</table>
|
|
179
|
+
|
|
180
|
+
<table>
|
|
181
|
+
<tr>
|
|
182
|
+
<th align="center">🔐 Auth & Storage</th>
|
|
183
|
+
<th align="center">📞 Realtime</th>
|
|
184
|
+
<th align="center">🛠 Developer Tooling</th>
|
|
185
|
+
</tr>
|
|
186
|
+
<tr>
|
|
187
|
+
<td valign="top">
|
|
188
|
+
|
|
189
|
+
- Multi-file auth state
|
|
190
|
+
- Single-file auth state
|
|
191
|
+
- SQLite auth state
|
|
192
|
+
- Cache-manager auth state
|
|
193
|
+
- In-memory store
|
|
194
|
+
- SQLite / MongoDB / MySQL /
|
|
195
|
+
PostgreSQL / Redis store adapters
|
|
196
|
+
|
|
197
|
+
</td>
|
|
198
|
+
<td valign="top">
|
|
199
|
+
|
|
200
|
+
- Voice calling (VoIP, WASM engine)
|
|
201
|
+
- User sync queries (WAUSync)
|
|
202
|
+
- Presence / status / device lookup
|
|
203
|
+
- Event buffer for high-volume bots
|
|
204
|
+
|
|
205
|
+
</td>
|
|
206
|
+
<td valign="top">
|
|
207
|
+
|
|
208
|
+
- Full TypeScript definitions (`.d.ts`)
|
|
209
|
+
- Anti-delete detection
|
|
210
|
+
- Message search helpers
|
|
211
|
+
- Auto-reply engine
|
|
212
|
+
- Scheduling helpers
|
|
213
|
+
- Message retry manager
|
|
214
|
+
|
|
215
|
+
</td>
|
|
216
|
+
</tr>
|
|
217
|
+
</table>
|
|
218
|
+
|
|
61
219
|
---
|
|
62
220
|
|
|
63
|
-
|
|
221
|
+
## ✨ Exclusive Vanzxy Enhancements
|
|
64
222
|
|
|
65
223
|
### Audio Group Status Fix
|
|
66
224
|
Audio status uses a more compatible implementation to avoid unsupported-version errors on older WhatsApp clients.
|
|
67
225
|
|
|
226
|
+
### AIRich — the rich-response message builder
|
|
227
|
+
A chainable builder (`AIRich`, also exported as `AIVanzxy` / `LeafRich` / `VanzxyAI` / `VanzxyRich`) with 40+ `add*()`/`set*()` methods covering headings, formatted text (hyperlinks/citations/LaTeX), code blocks, tables, image/video/product/post cards, task & progress cards, tip banners, and quick-reply suggestions — the kind of rich card layout you'd normally only see from an official AI/assistant-style bot. See [Usage Examples](#airich--rich-response-cards) below.
|
|
228
|
+
|
|
68
229
|
### Native Flow Expansion
|
|
69
|
-
Additional supported button types:
|
|
70
230
|
|
|
231
|
+
<table>
|
|
232
|
+
<tr>
|
|
233
|
+
<td valign="top" width="33%">
|
|
234
|
+
|
|
235
|
+
**Buttons & Actions**
|
|
71
236
|
- cta_reminder
|
|
72
237
|
- cta_cancel_reminder
|
|
73
|
-
- address_message
|
|
74
|
-
- send_location
|
|
75
|
-
- catalog_message
|
|
76
|
-
- mpm
|
|
77
238
|
- otp_button
|
|
78
239
|
- authentication_button
|
|
79
240
|
- call_button
|
|
80
241
|
- url_button
|
|
81
242
|
- reply_button
|
|
243
|
+
- voice_call
|
|
244
|
+
- video_call_button
|
|
245
|
+
|
|
246
|
+
</td>
|
|
247
|
+
<td valign="top" width="33%">
|
|
248
|
+
|
|
249
|
+
**Commerce Flow**
|
|
250
|
+
- catalog_message
|
|
251
|
+
- mpm
|
|
82
252
|
- card_message
|
|
83
253
|
- order_details
|
|
84
254
|
- order_status
|
|
85
255
|
- review_and_pay
|
|
86
256
|
- payment_status
|
|
87
257
|
- payment_method
|
|
258
|
+
|
|
259
|
+
</td>
|
|
260
|
+
<td valign="top" width="33%">
|
|
261
|
+
|
|
262
|
+
**Navigation & Misc**
|
|
263
|
+
- address_message
|
|
264
|
+
- send_location
|
|
88
265
|
- track_order
|
|
89
266
|
- reorder
|
|
90
267
|
- cancel_order
|
|
91
268
|
- clear_chat
|
|
92
269
|
- navigateToScreen
|
|
93
270
|
- flow_action
|
|
94
|
-
|
|
95
|
-
|
|
271
|
+
|
|
272
|
+
</td>
|
|
273
|
+
</tr>
|
|
274
|
+
</table>
|
|
96
275
|
|
|
97
276
|
### System Notification Filter
|
|
277
|
+
|
|
98
278
|
Messages include:
|
|
99
279
|
|
|
100
280
|
```js
|
|
@@ -109,77 +289,408 @@ Useful for filtering:
|
|
|
109
289
|
|
|
110
290
|
---
|
|
111
291
|
|
|
112
|
-
|
|
292
|
+
## 📦 Installation
|
|
113
293
|
|
|
114
294
|
```bash
|
|
115
295
|
npm install @vanzxy/baileys
|
|
116
296
|
```
|
|
117
297
|
|
|
118
|
-
GitHub:
|
|
298
|
+
Directly from GitHub:
|
|
119
299
|
|
|
120
300
|
```bash
|
|
121
|
-
npm install github:
|
|
301
|
+
npm install github:vanzxysenpai/vanzxybaileys
|
|
122
302
|
```
|
|
123
303
|
|
|
304
|
+
> Requires **Node.js 20+** — install will refuse to run below that (checked by `engine-requirements.js` on `preinstall`).
|
|
305
|
+
|
|
306
|
+
### Optional peer dependencies
|
|
307
|
+
|
|
308
|
+
Everything below is **optional** — the socket works without any of them. Install only what the features you use need; missing ones fail with a clear install hint instead of a silent crash.
|
|
309
|
+
|
|
310
|
+
| Package | Unlocks |
|
|
311
|
+
|---|---|
|
|
312
|
+
| `sharp` | Fast image resizing/processing (used by the message builders' `Toolkit.resize`) |
|
|
313
|
+
| `@napi-rs/image` | Lighter native alternative to `sharp` for image ops |
|
|
314
|
+
| `jimp` | Pure-JS image fallback when neither of the above is installed |
|
|
315
|
+
| `fluent-ffmpeg` | Audio/video conversion for media messages |
|
|
316
|
+
| `audio-decode` | Audio waveform/duration extraction (voice notes, VoIP capture) |
|
|
317
|
+
| `link-preview-js` | Rich link previews for URLs in outgoing text messages |
|
|
318
|
+
| `better-sqlite3` | SQLite auth state **and** SQLite store adapter |
|
|
319
|
+
| `mongodb` | MongoDB store adapter |
|
|
320
|
+
| `mysql2` | MySQL store adapter |
|
|
321
|
+
| `pg` | PostgreSQL store adapter |
|
|
322
|
+
| `ioredis` | Redis store adapter |
|
|
323
|
+
| `@roamhq/wrtc` | Native WebRTC bindings for [voice calling](#-voice--video-calls) |
|
|
324
|
+
|
|
124
325
|
---
|
|
125
326
|
|
|
126
|
-
|
|
327
|
+
## 🚀 Quick Start
|
|
127
328
|
|
|
128
329
|
```js
|
|
129
|
-
import { makeWASocket } from '@vanzxy/baileys'
|
|
330
|
+
import { makeWASocket, useMultiFileAuthState } from '@vanzxy/baileys'
|
|
331
|
+
|
|
332
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth_info')
|
|
130
333
|
|
|
131
334
|
const sock = makeWASocket({
|
|
132
|
-
|
|
335
|
+
auth: state
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
// persist credentials whenever Baileys updates them
|
|
339
|
+
sock.ev.on('creds.update', saveCreds)
|
|
340
|
+
|
|
341
|
+
sock.ev.on('connection.update', (update) => {
|
|
342
|
+
const { connection, qr } = update
|
|
343
|
+
|
|
344
|
+
// `printQRInTerminal` is deprecated upstream — render the QR yourself,
|
|
345
|
+
// e.g. with the `qrcode-terminal` package:
|
|
346
|
+
// import qrcode from 'qrcode-terminal'
|
|
347
|
+
// if (qr) qrcode.generate(qr, { small: true })
|
|
348
|
+
if (qr) console.log('Scan this QR:', qr)
|
|
349
|
+
|
|
350
|
+
if (connection === 'open') console.log('🍃 Connected!')
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
sock.ev.on('messages.upsert', ({ messages }) => {
|
|
354
|
+
const msg = messages[0]
|
|
355
|
+
if (!msg.message || msg.key.fromMe) return
|
|
356
|
+
console.log('New message from', msg.key.remoteJid)
|
|
133
357
|
})
|
|
134
358
|
```
|
|
135
359
|
|
|
136
360
|
---
|
|
137
361
|
|
|
138
|
-
|
|
362
|
+
## 🔐 Authentication
|
|
363
|
+
|
|
364
|
+
Four auth-state backends ship out of the box. All return the same `{ state, saveCreds }` shape expected by `makeWASocket({ auth })`, so they're drop-in interchangeable.
|
|
365
|
+
|
|
366
|
+
| Function | Storage | Best for |
|
|
367
|
+
|---|---|---|
|
|
368
|
+
| `useMultiFileAuthState(folder)` | One JSON file per key, on disk | Default choice — simple, debuggable, works everywhere |
|
|
369
|
+
| `useSingleFileAuthState(fileName)` | One JSON file, on disk | Small bots where a single file is easier to manage/back up |
|
|
370
|
+
| `useSqliteAuthState(opts)` | SQLite (`better-sqlite3`) | Bots that already use SQLite, or want auth in one embedded DB file |
|
|
371
|
+
| `useCacheManagerAuthState(store, sessionKey)` | Any [`cacheable`](https://www.npmjs.com/package/@cacheable/node-cache)-compatible store | Multi-session hosting panels, Redis-backed setups |
|
|
139
372
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
373
|
+
```js
|
|
374
|
+
import { makeWASocket, useMultiFileAuthState } from '@vanzxy/baileys'
|
|
375
|
+
|
|
376
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth_info')
|
|
377
|
+
const sock = makeWASocket({ auth: state })
|
|
378
|
+
sock.ev.on('creds.update', saveCreds)
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
```js
|
|
382
|
+
// SQLite variant
|
|
383
|
+
import { makeWASocket, useSqliteAuthState } from '@vanzxy/baileys'
|
|
384
|
+
|
|
385
|
+
const { state, saveCreds } = await useSqliteAuthState({ database: './auth.db' })
|
|
386
|
+
const sock = makeWASocket({ auth: state })
|
|
387
|
+
sock.ev.on('creds.update', saveCreds)
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
`useMultiFileAuthState` also exports `pruneStaleAuthFiles(folder, options)` to clean up old sender-key files on a schedule — useful for long-running bots that accumulate thousands of stale key files.
|
|
143
391
|
|
|
144
392
|
---
|
|
145
393
|
|
|
146
|
-
|
|
394
|
+
## 🗄️ Store Backends
|
|
395
|
+
|
|
396
|
+
`makeInMemoryStore()` from `lib/Store` gives you the classic in-memory chat/contact/message cache. For anything that needs to survive a restart, `makePersistentStore()` (from `PersistentStore.js`) wraps one of five backends behind the same interface:
|
|
397
|
+
|
|
398
|
+
| Backend | Function |
|
|
399
|
+
|---|---|
|
|
400
|
+
| SQLite | `createSqliteStoreAdapter(opts)` |
|
|
401
|
+
| MongoDB | `createMongoStoreAdapter(opts)` |
|
|
402
|
+
| MySQL | `createMysqlStoreAdapter(opts)` |
|
|
403
|
+
| PostgreSQL | `createPostgresStoreAdapter(opts)` |
|
|
404
|
+
| Redis | `createRedisStoreAdapter(opts)` |
|
|
405
|
+
|
|
406
|
+
```js
|
|
407
|
+
import { makeWASocket, makeInMemoryStore } from '@vanzxy/baileys'
|
|
408
|
+
|
|
409
|
+
const store = makeInMemoryStore({})
|
|
410
|
+
store.readFromFile('./baileys_store.json')
|
|
411
|
+
setInterval(() => store.writeToFile('./baileys_store.json'), 10_000)
|
|
412
|
+
|
|
413
|
+
const sock = makeWASocket({ /* ...auth etc */ })
|
|
414
|
+
store.bind(sock.ev)
|
|
415
|
+
```
|
|
147
416
|
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## 💡 Usage Examples
|
|
420
|
+
|
|
421
|
+
### Buttons & Native Flow
|
|
422
|
+
|
|
423
|
+
```js
|
|
424
|
+
import { Button } from '@vanzxy/baileys'
|
|
425
|
+
|
|
426
|
+
await new Button(sock)
|
|
427
|
+
.setTitle('Promo Spesial')
|
|
428
|
+
.setBody('Diskon 20% cuma hari ini')
|
|
429
|
+
.setFooter('@vanzxy/baileys')
|
|
430
|
+
.addReply('Klaim Sekarang', 'claim_promo')
|
|
431
|
+
.addUrl('Lihat Katalog', 'https://example.com/catalog')
|
|
432
|
+
.addCall('Hubungi Kami', '628123456789')
|
|
433
|
+
.send(jid)
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Poll
|
|
437
|
+
|
|
438
|
+
```js
|
|
439
|
+
import { Poll } from '@vanzxy/baileys'
|
|
440
|
+
|
|
441
|
+
await new Poll(sock)
|
|
442
|
+
.setName('Mau makan apa hari ini?')
|
|
443
|
+
.addOptions(['Nasi Goreng', 'Mie Ayam', 'Bakso'])
|
|
444
|
+
.setSelectable(1)
|
|
445
|
+
.send(jid)
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Carousel
|
|
449
|
+
|
|
450
|
+
> Each card must be built with `Button(...).toCard()` first — a carousel card is really just a button card with an image/video header.
|
|
451
|
+
|
|
452
|
+
```js
|
|
453
|
+
import { Button, Carousel } from '@vanzxy/baileys'
|
|
454
|
+
|
|
455
|
+
const cardA = await new Button(sock)
|
|
456
|
+
.setImage('https://example.com/a.jpg')
|
|
457
|
+
.setTitle('Produk A')
|
|
458
|
+
.addUrl('Lihat', 'https://example.com/a')
|
|
459
|
+
.toCard()
|
|
460
|
+
|
|
461
|
+
const cardB = await new Button(sock)
|
|
462
|
+
.setImage('https://example.com/b.jpg')
|
|
463
|
+
.setTitle('Produk B')
|
|
464
|
+
.addUrl('Lihat', 'https://example.com/b')
|
|
465
|
+
.toCard()
|
|
466
|
+
|
|
467
|
+
await new Carousel(sock)
|
|
468
|
+
.setBody('Pilih salah satu produk di bawah ini')
|
|
469
|
+
.addCard([cardA, cardB])
|
|
470
|
+
.send(jid)
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### AIRich — rich response cards
|
|
474
|
+
|
|
475
|
+
```js
|
|
476
|
+
import { AIRich } from '@vanzxy/baileys'
|
|
477
|
+
|
|
478
|
+
await new AIRich(sock)
|
|
479
|
+
.addHeading('Ringkasan Order')
|
|
480
|
+
.addText('Pesananmu sedang diproses.')
|
|
481
|
+
.addTable([
|
|
482
|
+
['Item', 'Qty'],
|
|
483
|
+
['Kopi Susu', '2']
|
|
484
|
+
])
|
|
485
|
+
.addTip('Pesanan biasanya siap dalam 15 menit')
|
|
486
|
+
.addSuggest('Lacak Order')
|
|
487
|
+
.send(jid)
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
`AIRich` supports `{ id, insertAt }` on every `add*()`/`set*()` call, so you can insert a block relative to one you added earlier instead of always appending to the end — handy for streaming/edit-in-place style responses combined with `sendEdit(jid, id)`.
|
|
491
|
+
|
|
492
|
+
Other builders worth knowing about: **`ButtonV2`** (simpler quick-reply-only buttons), **`ButtonV3`** (`loadFrom(msg)` to edit an existing template message in place), and **`Toolkit`** (static helpers: `Toolkit.resize()`, `Toolkit.fetchBuffer()`, `Toolkit.waitAllPromises()`, `Toolkit.extractIE()` for parsing `[label](url)` links/citations/LaTeX out of plain text).
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
## 📞 Voice & Video Calls
|
|
497
|
+
|
|
498
|
+
Experimental audio-call support (ported from ourin-baileys) via a WASM call stack + WebRTC relay. Requires the optional `@roamhq/wrtc` peer dependency.
|
|
499
|
+
|
|
500
|
+
```js
|
|
501
|
+
import { VoipClient } from '@vanzxy/baileys'
|
|
502
|
+
|
|
503
|
+
const voip = new VoipClient({ resourcesPath: './voip-resources' })
|
|
504
|
+
await voip.connectWithSocket(sock)
|
|
505
|
+
|
|
506
|
+
const call = await voip.call('628123456789')
|
|
507
|
+
|
|
508
|
+
call.on('ringing', () => console.log('Ringing...'))
|
|
509
|
+
call.on('connected', () => console.log('Call connected'))
|
|
510
|
+
call.on('ended', (reason) => console.log('Call ended:', reason))
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
`ActiveCall` (returned by `.call()`) and `CallState` are also exported directly if you need finer-grained control over call state.
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## 🔎 User Sync Queries
|
|
518
|
+
|
|
519
|
+
`WAUSync` (`USyncQuery` / `USyncUser` + protocols) lets you check things like WhatsApp registration, device lists, status, and username info for a JID before you message it — the same mechanism behind `sock.onWhatsApp()`.
|
|
520
|
+
|
|
521
|
+
```js
|
|
522
|
+
import { USyncQuery, USyncUser, USyncContactProtocol } from '@vanzxy/baileys'
|
|
523
|
+
|
|
524
|
+
const query = new USyncQuery()
|
|
525
|
+
.withContext('interactive')
|
|
526
|
+
.withMode('query')
|
|
527
|
+
.withUser(new USyncUser().withPhone('628123456789'))
|
|
528
|
+
|
|
529
|
+
query.protocols.push(new USyncContactProtocol())
|
|
530
|
+
|
|
531
|
+
const result = await sock.executeUSyncQuery(query)
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
Available protocols: `USyncContactProtocol`, `USyncDeviceProtocol`, `USyncStatusProtocol`, `USyncUsernameProtocol`, `USyncDisappearingModeProtocol`, `UsyncBotProfileProtocol`, `UsyncLIDProtocol`.
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
## 🧩 Utility Modules
|
|
539
|
+
|
|
540
|
+
A sample of the utilities exported from `lib/Utils` beyond the message builders above:
|
|
541
|
+
|
|
542
|
+
| Module | What it does |
|
|
543
|
+
|---|---|
|
|
544
|
+
| `anti-delete` | Detect and recover messages the sender deleted for everyone |
|
|
545
|
+
| `auto-reply` | Simple keyword/pattern-based auto-responder engine |
|
|
546
|
+
| `message-search` | Search cached/stored messages, peeling off ephemeral/view-once wrappers first |
|
|
547
|
+
| `message-retry-manager` | Handles WhatsApp's retry-receipt protocol for undecryptable messages |
|
|
548
|
+
| `scheduling` | Schedule messages/actions for later delivery |
|
|
549
|
+
| `business` | Business-profile & catalog helpers |
|
|
550
|
+
| `chat-control` | Pin, mute, archive, and mark-read/unread helpers |
|
|
551
|
+
| `chat-history-helpers` | Work with synced chat history payloads |
|
|
552
|
+
| `link-preview` | Generate link preview metadata for outgoing messages |
|
|
553
|
+
| `stickerpack` | Build and send sticker packs (including animated/Lottie) |
|
|
554
|
+
| `templates` | Legacy WhatsApp Business template message helpers |
|
|
555
|
+
| `vcard` | Build vCard (contact card) payloads |
|
|
556
|
+
| `status` | Post and manage WhatsApp Status updates |
|
|
557
|
+
| `event-buffer` | Buffers/coalesces high-volume socket events for heavier bots |
|
|
558
|
+
|
|
559
|
+
Every module above ships a matching `.d.ts`, so your editor will show full hover-docs regardless of which ones you import.
|
|
560
|
+
|
|
561
|
+
---
|
|
562
|
+
|
|
563
|
+
## 🛠 Recommended Environment
|
|
564
|
+
|
|
565
|
+
| Requirement | Version |
|
|
566
|
+
|---|---|
|
|
567
|
+
| Node.js | 20+ |
|
|
568
|
+
| Module system | ESM |
|
|
569
|
+
| WhatsApp | Latest Multi Device |
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
|
|
573
|
+
## 📘 TypeScript Support
|
|
574
|
+
|
|
575
|
+
Every file in `lib/` ships a matching `.d.ts`, including the message builders (`MessageBuilder_d.ts`) and all `Types/*` definitions (Auth, Chat, Contact, Events, GroupMetadata, Message, Product, Signal, USync, and more). No `@types/` package needed — plain `import { ... } from '@vanzxy/baileys'` gets full autocomplete in TS or JS-with-checkJS projects.
|
|
576
|
+
|
|
577
|
+
---
|
|
578
|
+
|
|
579
|
+
## 📚 Fork Lineage
|
|
580
|
+
|
|
581
|
+
```
|
|
148
582
|
@vanzxy/baileys
|
|
149
583
|
└── @itsliaaa/baileys
|
|
150
584
|
└── WhiskeySockets/Baileys
|
|
585
|
+
```
|
|
151
586
|
|
|
152
587
|
Respect to all original maintainers and contributors.
|
|
153
588
|
|
|
154
589
|
---
|
|
155
590
|
|
|
156
|
-
|
|
591
|
+
## ❓ FAQ & Troubleshooting
|
|
157
592
|
|
|
158
|
-
|
|
593
|
+
<details>
|
|
594
|
+
<summary><b>Koneksi terus putus / reconnect loop</b></summary>
|
|
595
|
+
<br/>
|
|
159
596
|
|
|
160
|
-
|
|
161
|
-
https://github.com/vanzxy
|
|
597
|
+
Cek `connection.update` untuk field `lastDisconnect.error`. Kalau status code-nya `401` (loggedOut), sesi memang sudah invalid dan perlu scan ulang QR — jangan auto-reconnect di kondisi ini. Untuk status lain (`428`, `440`, dsb.), reconnect dengan backoff biasanya cukup.
|
|
162
598
|
|
|
163
|
-
|
|
164
|
-
|
|
599
|
+
</details>
|
|
600
|
+
|
|
601
|
+
<details>
|
|
602
|
+
<summary><b>QR tidak muncul / tidak ke-scan</b></summary>
|
|
603
|
+
<br/>
|
|
604
|
+
|
|
605
|
+
`printQRInTerminal` sudah deprecated di upstream Baileys — pastikan kamu render QR sendiri dari event `qr` (lihat contoh di [Quick Start](#-quick-start)). Kalau QR muncul tapi gagal linking, biasanya karena versi WA Web (`version` di `makeWASocket`) sudah kedaluwarsa; fetch versi terbaru lewat `fetchLatestBaileysVersion()`.
|
|
606
|
+
|
|
607
|
+
</details>
|
|
608
|
+
|
|
609
|
+
<details>
|
|
610
|
+
<summary><b>Error "Bad MAC" / pesan gagal didekripsi</b></summary>
|
|
611
|
+
<br/>
|
|
612
|
+
|
|
613
|
+
Umumnya terjadi kalau folder auth state korup atau sesi dipakai di lebih dari satu proses secara bersamaan. Pastikan hanya satu instance yang menulis ke folder auth state yang sama, dan pertimbangkan `pruneStaleAuthFiles()` untuk membersihkan sender-key lama secara berkala.
|
|
614
|
+
|
|
615
|
+
</details>
|
|
616
|
+
|
|
617
|
+
<details>
|
|
618
|
+
<summary><b>Memory terus naik di bot yang jalan lama</b></summary>
|
|
619
|
+
<br/>
|
|
620
|
+
|
|
621
|
+
Kalau pakai `makeInMemoryStore()`, cache chat/message/contact akan terus tumbuh tanpa batas. Untuk bot yang jalan lama, pertimbangkan pindah ke salah satu backend `makePersistentStore()` (SQLite/Redis/dst) dan pakai `event-buffer` untuk meredam lonjakan event di trafik tinggi.
|
|
622
|
+
|
|
623
|
+
</details>
|
|
624
|
+
|
|
625
|
+
<details>
|
|
626
|
+
<summary><b>Voice call gagal connect</b></summary>
|
|
627
|
+
<br/>
|
|
628
|
+
|
|
629
|
+
Fitur ini masih experimental dan butuh peer dependency `@roamhq/wrtc` — pastikan sudah terinstall dan platform kamu didukung native binding-nya. Cek event `call.on('ended', reason => ...)` untuk detail penyebab gagalnya.
|
|
630
|
+
|
|
631
|
+
</details>
|
|
165
632
|
|
|
166
633
|
---
|
|
167
634
|
|
|
168
|
-
|
|
635
|
+
## 🤝 Contributing
|
|
169
636
|
|
|
170
|
-
|
|
171
|
-
|
|
637
|
+
Kontribusi dipersilakan, terutama untuk perbaikan bug, dokumentasi, dan enhancement pada `MessageBuilder` / `AIRich`.
|
|
638
|
+
|
|
639
|
+
1. Fork repo ini, buat branch dari `main` (`feat/nama-fitur` atau `fix/nama-bug`)
|
|
640
|
+
2. Pastikan perubahan tetap ESM-only dan menyertakan/menyesuaikan `.d.ts` terkait
|
|
641
|
+
3. Uji perubahan pada minimal satu jalur auth state + satu store backend sebelum PR
|
|
642
|
+
4. Buka Pull Request dengan deskripsi singkat: apa yang berubah dan kenapa
|
|
643
|
+
|
|
644
|
+
Untuk laporan bug, sertakan versi Node.js, cara reproduksi, dan potongan log `lastDisconnect.error` bila relevan.
|
|
172
645
|
|
|
173
646
|
---
|
|
174
647
|
|
|
175
|
-
|
|
648
|
+
## 🙏 Credits
|
|
649
|
+
|
|
650
|
+
- **Nixel** (with contributions from **Ahmad tumbuh kembang**) — base implementation of the `MessageBuilder` (AIRich / Button / Carousel / Toolkit), originally "NIXCODE — Advanced WhatsApp Interactive Message Builder"
|
|
651
|
+
- **vinikjkkj** ([zapo](https://github.com/vinikjkkj/zapo)) — button/list addon-kind resolution logic
|
|
652
|
+
- **QueenAnya** (`@queenanya/baileys`) — interactive/native-flow button send layer
|
|
653
|
+
- **WhiskeySockets/Baileys** & **@itsliaaa/baileys** — upstream base
|
|
176
654
|
|
|
655
|
+
Full details and license terms per component: see [`NOTICE.md`](./NOTICE.md).
|
|
656
|
+
|
|
657
|
+
---
|
|
177
658
|
|
|
178
|
-
##
|
|
659
|
+
## 👑 Maintainer
|
|
660
|
+
|
|
661
|
+
**Vanzxy**
|
|
662
|
+
|
|
663
|
+
- GitHub: [github.com/vanzxysenpai](https://github.com/vanzxysenpai)
|
|
664
|
+
- Package: [`@vanzxy/baileys`](https://www.npmjs.com/package/@vanzxy/baileys)
|
|
665
|
+
|
|
666
|
+
---
|
|
667
|
+
|
|
668
|
+
## ⚠️ Disclaimer
|
|
669
|
+
|
|
670
|
+
This project is an independent fork.
|
|
671
|
+
Use responsibly and follow WhatsApp Terms of Service.
|
|
672
|
+
|
|
673
|
+
---
|
|
674
|
+
|
|
675
|
+
## 📝 V4 Patch Notes
|
|
179
676
|
|
|
180
677
|
- Kept the existing Vanzxy custom MessageBuilder classes and AIRich implementation intact.
|
|
181
678
|
- Added `whatsapp-rust-bridge@0.5.5` as a runtime dependency. The library already dynamically imports this module for LT Hash/app-state and crypto helpers; declaring it prevents accidental missing-module fallbacks in normal installations.
|
|
182
679
|
- Existing guarded fallbacks for platforms where the native bridge cannot load remain in place.
|
|
183
680
|
- ESM-only package metadata is preserved; no CommonJS build is included.
|
|
184
681
|
|
|
185
|
-
Reference audit: the supplied Ourin, Elaina, ItsLiaaa, and Noxleyss packages were compared before this patch. Their broader core changes were not copied wholesale because the current Vanzxy tree already contains additional LID, retry, media, interactive,
|
|
682
|
+
Reference audit: the supplied Ourin, Elaina, ItsLiaaa, and Noxleyss packages were compared before this patch. Their broader core changes were not copied wholesale because the current Vanzxy tree already contains additional LID, retry, media, interactive, angd AIRich fixes that would risk regressions if replaced.
|
|
683
|
+
|
|
684
|
+
---
|
|
685
|
+
|
|
686
|
+
<div align="center">
|
|
687
|
+
|
|
688
|
+
<img src="https://capsule-render.vercel.app/api?type=waving&color=0:2ecc71,100:1d6a23&height=100§ion=footer" width="100%"/>
|
|
689
|
+
|
|
690
|
+
Made with 🍃 by **Vanzxy**
|
|
691
|
+
|
|
692
|
+
Thanks for stopping by! ✌️
|
|
693
|
+
|
|
694
|
+
<a href="#top">⬆️ Back to top</a>
|
|
695
|
+
|
|
696
|
+
</div>
|