@badzz88/baileys 8.5.6 → 8.5.8
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 +337 -1055
- package/WAProto/WAProto.proto +28 -1189
- package/WAProto/fix-imports.js +79 -69
- package/WAProto/index.d.ts +71491 -15254
- package/WAProto/index.js +126436 -19814
- package/engine-requirements.js +8 -15
- package/lib/Defaults/index.js +130 -0
- package/{src → lib}/Signal/Group/ciphertext-message.js +2 -5
- package/lib/Signal/Group/group-session-builder.js +30 -0
- package/{src → lib}/Signal/Group/group_cipher.js +11 -11
- package/lib/Signal/Group/index.js +12 -0
- package/lib/Signal/Group/keyhelper.js +18 -0
- package/{src → lib}/Signal/Group/sender-chain-key.js +6 -9
- package/{src → lib}/Signal/Group/sender-key-distribution-message.js +6 -9
- package/{src → lib}/Signal/Group/sender-key-message.js +9 -12
- package/{src → lib}/Signal/Group/sender-key-name.js +2 -5
- package/{src → lib}/Signal/Group/sender-key-record.js +8 -11
- package/{src → lib}/Signal/Group/sender-key-state.js +6 -9
- package/lib/Signal/Group/sender-message-key.js +26 -0
- package/{src → lib}/Signal/libsignal.js +131 -155
- package/{src → lib}/Signal/lid-mapping.js +27 -23
- package/lib/Socket/Client/index.js +3 -0
- package/lib/Socket/Client/types.js +11 -0
- package/{src → lib}/Socket/Client/websocket.js +11 -18
- package/{src → lib}/Socket/business.js +35 -67
- package/{src → lib}/Socket/chats.js +294 -550
- package/{src → lib}/Socket/communities.js +82 -114
- package/lib/Socket/graphql.js +716 -0
- package/lib/Socket/groups.js +374 -0
- package/lib/Socket/index.js +18 -0
- package/lib/Socket/interop.js +463 -0
- package/{src → lib}/Socket/luxu.js +120 -82
- package/lib/Socket/messages-recv.js +1916 -0
- package/lib/Socket/messages-send.js +1436 -0
- package/lib/Socket/mex.js +54 -0
- package/lib/Socket/newsletter.js +757 -0
- package/lib/Socket/privacy.js +318 -0
- package/{src → lib}/Socket/socket.js +356 -244
- package/lib/Socket/username.js +236 -0
- package/lib/Store/index.js +10 -0
- package/{src → lib}/Store/keyed-db.js +11 -21
- package/lib/Store/make-cache-manager-store.js +85 -0
- package/lib/Store/make-in-memory-store.js +244 -0
- package/{src → lib}/Store/make-ordered-dictionary.js +19 -25
- package/{src → lib}/Store/object-repository.js +11 -5
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +8 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.js +25 -0
- package/lib/Types/LabelAssociation.js +7 -0
- package/lib/Types/Message.js +11 -0
- package/lib/Types/Mex.js +111 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +3 -0
- package/lib/Types/State.js +56 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +26 -0
- package/{src → lib}/Utils/auth-utils.js +91 -43
- package/lib/Utils/browser-utils.js +48 -0
- package/lib/Utils/business.js +231 -0
- package/lib/Utils/chat-utils.js +872 -0
- package/lib/Utils/companion-reg-client-utils.js +35 -0
- package/lib/Utils/crypto.js +118 -0
- package/lib/Utils/decode-wa-message.js +350 -0
- package/{src → lib}/Utils/event-buffer.js +81 -39
- package/lib/Utils/generics.js +403 -0
- package/lib/Utils/history.js +134 -0
- package/{src → lib}/Utils/identity-change-handler.js +9 -11
- package/lib/Utils/index.js +23 -0
- package/lib/Utils/link-preview.js +85 -0
- package/lib/Utils/logger.js +3 -0
- package/lib/Utils/lt-hash.js +8 -0
- package/{src → lib}/Utils/make-mutex.js +7 -10
- package/lib/Utils/message-composer.js +273 -0
- package/{src → lib}/Utils/message-retry-manager.js +76 -28
- package/lib/Utils/messages-media.js +870 -0
- package/lib/Utils/messages.js +1337 -0
- package/lib/Utils/noise-handler.js +201 -0
- package/{src → lib}/Utils/offline-node-processor.js +10 -4
- package/{src → lib}/Utils/pre-key-manager.js +27 -11
- package/lib/Utils/process-message.js +630 -0
- package/{src → lib}/Utils/reporting-utils.js +12 -15
- package/lib/Utils/signal.js +201 -0
- package/{src → lib}/Utils/stanza-ack.js +12 -4
- package/lib/Utils/sticker.js +110 -0
- package/{src → lib}/Utils/sync-action-utils.js +14 -10
- package/{src → lib}/Utils/tc-token-utils.js +48 -43
- package/{src → lib}/Utils/use-multi-file-auth-state.js +35 -25
- package/lib/Utils/validate-connection.js +203 -0
- package/{src → lib}/WABinary/constants.js +9 -12
- package/{src → lib}/WABinary/decode.js +38 -118
- package/{src → lib}/WABinary/encode.js +6 -11
- package/lib/WABinary/generic-utils.js +204 -0
- package/lib/WABinary/index.js +6 -0
- package/lib/WABinary/jid-utils.js +98 -0
- package/lib/WABinary/types.js +2 -0
- package/{src → lib}/WAM/BinaryInfo.js +2 -5
- package/{src → lib}/WAM/constants.js +4 -16635
- package/{src → lib}/WAM/encode.js +18 -17
- package/lib/WAM/index.js +4 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +54 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +58 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +39 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +27 -0
- package/lib/WAUSync/Protocols/index.js +12 -0
- package/lib/WAUSync/USyncQuery.js +151 -0
- package/lib/WAUSync/USyncUser.js +56 -0
- package/lib/WAUSync/index.js +3 -0
- package/{src → lib}/index.js +16 -51
- package/package.json +129 -99
- package/LICENSE +0 -21
- package/src/Defaults/index.js +0 -186
- package/src/Defaults/phonenumber-mcc.json +0 -223
- package/src/Signal/Group/group-session-builder.js +0 -86
- package/src/Signal/Group/index.js +0 -140
- package/src/Signal/Group/keyhelper.js +0 -77
- package/src/Signal/Group/sender-message-key.js +0 -29
- package/src/Socket/Client/index.js +0 -31
- package/src/Socket/Client/types.js +0 -13
- package/src/Socket/aigroups.js +0 -221
- package/src/Socket/graphql.js +0 -523
- package/src/Socket/groups.js +0 -516
- package/src/Socket/index.js +0 -31
- package/src/Socket/interactive-handler.js +0 -527
- package/src/Socket/interop.js +0 -339
- package/src/Socket/managed-account.js +0 -98
- package/src/Socket/messages-recv.js +0 -2685
- package/src/Socket/messages-send.js +0 -2047
- package/src/Socket/mex.js +0 -57
- package/src/Socket/newsletter.js +0 -455
- package/src/Socket/privacy.js +0 -125
- package/src/Socket/registration.js +0 -236
- package/src/Socket/text-router.js +0 -65
- package/src/Socket/username.js +0 -130
- package/src/Store/index.js +0 -33
- package/src/Store/make-cache-manager-store.js +0 -84
- package/src/Store/make-in-memory-store.js +0 -551
- package/src/Types/Auth.js +0 -31
- package/src/Types/Bussines.js +0 -2
- package/src/Types/Call.js +0 -2
- package/src/Types/Chat.js +0 -4
- package/src/Types/Contact.js +0 -2
- package/src/Types/Events.js +0 -2
- package/src/Types/GroupMetadata.js +0 -2
- package/src/Types/Label.js +0 -26
- package/src/Types/LabelAssociation.js +0 -8
- package/src/Types/Message.js +0 -93
- package/src/Types/Mex.js +0 -112
- package/src/Types/Newsletter.js +0 -109
- package/src/Types/Product.js +0 -2
- package/src/Types/Signal.js +0 -2
- package/src/Types/Socket.js +0 -2
- package/src/Types/State.js +0 -62
- package/src/Types/USync.js +0 -2
- package/src/Types/index.js +0 -56
- package/src/Utils/browser-utils.js +0 -112
- package/src/Utils/business.js +0 -240
- package/src/Utils/chat-utils.js +0 -1230
- package/src/Utils/command-loader.d.ts +0 -27
- package/src/Utils/command-loader.js +0 -89
- package/src/Utils/companion-reg-client-utils.js +0 -40
- package/src/Utils/consumer-application.js +0 -105
- package/src/Utils/crypto.js +0 -118
- package/src/Utils/curve25519-js.js +0 -242
- package/src/Utils/decode-wa-message.js +0 -529
- package/src/Utils/generics.js +0 -483
- package/src/Utils/group-history.js +0 -44
- package/src/Utils/history.js +0 -232
- package/src/Utils/index.js +0 -58
- package/src/Utils/jid-display-normalization.js +0 -195
- package/src/Utils/link-preview.js +0 -135
- package/src/Utils/logger.js +0 -8
- package/src/Utils/lt-hash.js +0 -25
- package/src/Utils/message-composer.js +0 -471
- package/src/Utils/messages-media.js +0 -843
- package/src/Utils/messages.js +0 -2817
- package/src/Utils/meta-ai-msmsg.js +0 -222
- package/src/Utils/native-bridge.js +0 -68
- package/src/Utils/noise-handler.js +0 -169
- package/src/Utils/process-message.js +0 -950
- package/src/Utils/session-pool.d.ts +0 -14
- package/src/Utils/session-pool.js +0 -70
- package/src/Utils/signal.js +0 -217
- package/src/Utils/sticker.d.ts +0 -13
- package/src/Utils/sticker.js +0 -123
- package/src/Utils/validate-connection.js +0 -209
- package/src/Utils/view-once-cache.d.ts +0 -12
- package/src/Utils/view-once-cache.js +0 -63
- package/src/Utils/voip-rekey.js +0 -22
- package/src/WABinary/generic-utils.js +0 -238
- package/src/WABinary/index.js +0 -34
- package/src/WABinary/jid-utils.js +0 -351
- package/src/WABinary/types.js +0 -2
- package/src/WAM/index.js +0 -32
- package/src/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -53
- package/src/WAUSync/Protocols/USyncBusinessProtocol.js +0 -44
- package/src/WAUSync/Protocols/USyncContactProtocol.js +0 -55
- package/src/WAUSync/Protocols/USyncDeviceProtocol.js +0 -55
- package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -31
- package/src/WAUSync/Protocols/USyncFeatureProtocol.js +0 -54
- package/src/WAUSync/Protocols/USyncLIDProtocol.js +0 -32
- package/src/WAUSync/Protocols/USyncNewsletterProtocol.js +0 -473
- package/src/WAUSync/Protocols/USyncPictureProtocol.js +0 -34
- package/src/WAUSync/Protocols/USyncSidelistProtocol.js +0 -29
- package/src/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
- package/src/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -38
- package/src/WAUSync/Protocols/USyncUsernameProtocol.js +0 -28
- package/src/WAUSync/Protocols/index.js +0 -40
- package/src/WAUSync/USyncQuery.js +0 -126
- package/src/WAUSync/USyncUser.js +0 -50
- package/src/WAUSync/index.js +0 -32
- package/src/antiban.js +0 -4152
package/README.md
CHANGED
|
@@ -1,1111 +1,393 @@
|
|
|
1
|
-
#
|
|
1
|
+
# WhatsApp Baileys Badzz
|
|
2
2
|
|
|
3
|
-
A high-performance WhatsApp Web library built on [Baileys](https://github.com/WhiskeySockets/Baileys), with critical paths accelerated via a [Rust WASM bridge](https://www.npmjs.com/package/whatsapp-rust-bridge?activeTab=code).
|
|
4
|
-
|
|
5
|
-
<p align="center">
|
|
6
|
-
<img alt="package" src="https://img.shields.io/badge/package-%40badzz88%2Fbaileys-25D366?style=for-the-badge&logo=whatsapp&logoColor=white">
|
|
7
|
-
<img alt="version" src="https://img.shields.io/badge/version-1.1.8-blue?style=for-the-badge">
|
|
8
|
-
</p>
|
|
9
3
|
<p align="center">
|
|
10
|
-
<
|
|
11
|
-
<a href="https://github.com/Badzz88"><img alt="GitHub" src="https://img.shields.io/badge/GitHub-Badzz88-181717?style=for-the-badge&logo=github&logoColor=white"></a>
|
|
4
|
+
<img src="https://b.top4top.io/p_3816tx02l1.jpg" alt="Thumbnail" />
|
|
12
5
|
</p>
|
|
13
6
|
|
|
14
|
-
|
|
15
|
-
|---|---|
|
|
16
|
-
| 📦 **Package** | `@badzz88/baileys` |
|
|
17
|
-
| 🏷️ **Version** | `8.5.6` |
|
|
18
|
-
| 💬 **Telegram** | [t.me/FoxsSql](https://t.me/FoxsSql) |
|
|
19
|
-
| 🐙 **GitHub** | [github.com/Badzz88](https://github.com/Badzz88) |
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Index
|
|
24
|
-
|
|
25
|
-
- [What's Different](#whats-different)
|
|
26
|
-
- [Installation](#installation)
|
|
27
|
-
- [Running on Termux / Android](#running-on-termux--android)
|
|
28
|
-
- [Running on Pterodactyl](#running-on-pterodactyl)
|
|
29
|
-
- [Connecting Account](#connecting-account)
|
|
30
|
-
- [QR Code](#qr-code)
|
|
31
|
-
- [Pairing Code](#pairing-code)
|
|
32
|
-
- [Receive Full History](#receive-full-history)
|
|
33
|
-
- [Socket Config Notes](#socket-config-notes)
|
|
34
|
-
- [Saving & Restoring Sessions](#saving--restoring-sessions)
|
|
35
|
-
- [Handling Events](#handling-events)
|
|
36
|
-
- [Text Routing (onText / hears / command)](#text-routing-onText--hears--command)
|
|
37
|
-
- [Anti-Ban System](#anti-ban-system)
|
|
38
|
-
- [RateLimiter](#ratelimiter--throttle-outbound-messages)
|
|
39
|
-
- [WarmUp](#warmup--gradual-daily-limit-increase-for-new-numbers)
|
|
40
|
-
- [HealthMonitor](#healthmonitor--detect-ban-risk)
|
|
41
|
-
- [TimelockGuard](#timelockguard--handle-wa-463-reachout-blocks)
|
|
42
|
-
- [PresenceChoreographer](#presencechoreographer--human-like-typing-simulation)
|
|
43
|
-
- [wrapSocket](#wrapsocket--apply-all-anti-ban-layers-at-once)
|
|
44
|
-
- [Sending Messages](#sending-messages)
|
|
45
|
-
- [Text & Basic](#text--basic)
|
|
46
|
-
- [Buttons & Interactive](#buttons--interactive)
|
|
47
|
-
- [Media](#media)
|
|
48
|
-
- [Meta AI / Rich Responses](#meta-ai--rich-responses)
|
|
49
|
-
- [Status / Stories](#status--stories)
|
|
50
|
-
- [Modifying Messages](#modifying-messages)
|
|
51
|
-
- [Manipulating Media](#manipulating-media)
|
|
52
|
-
- [Groups](#groups)
|
|
53
|
-
- [Privacy](#privacy)
|
|
54
|
-
- [User Queries](#user-queries)
|
|
55
|
-
- [Change Profile](#change-profile)
|
|
56
|
-
- [Chat Modifiers](#chat-modifiers)
|
|
57
|
-
- [Writing Custom Functionality](#writing-custom-functionality)
|
|
58
|
-
- [Extra Utilities](#extra-utilities)
|
|
59
|
-
- [Sticker Maker](#sticker-maker)
|
|
60
|
-
- [Auto-Cache View-Once Media](#auto-cache-view-once-media)
|
|
61
|
-
- [Folder-Based Command Loader](#folder-based-command-loader)
|
|
62
|
-
- [Multi-Account Session Pool](#multi-account-session-pool)
|
|
63
|
-
- [Store Auto-Save, Message Limits & Encryption](#store-auto-save-message-limits--encryption)
|
|
64
|
-
- [Rust WASM Bridge](#rust-wasm-bridge)
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## What's Different
|
|
7
|
+
WhatsApp Baileys is an open-source library designed to help developers build automation solutions and integrations with WhatsApp efficiently and directly. Using websocket technology without the need for a browser, this library supports a wide range of features such as message management, chat handling, group administration, as well as interactive messages and action buttons for a more dynamic user experience.
|
|
69
8
|
|
|
70
|
-
|
|
9
|
+
Actively developed and maintained, baileys continuously receives updates to enhance stability and performance. One of the main focuses is to improve the pairing and authentication processes to be more stable and secure. Pairing features can be customized with your own codes, making the process more reliable and less prone to interruptions.
|
|
71
10
|
|
|
72
|
-
|
|
73
|
-
|---|---|---|
|
|
74
|
-
| Binary decode | JS | Rust WASM |
|
|
75
|
-
| Noise handshake | JS | Rust WASM |
|
|
76
|
-
| AES / HMAC / HKDF | JS (`crypto`) | Rust WASM |
|
|
77
|
-
| Signal protocol | `libsignal-node` | Rust WASM |
|
|
78
|
-
|
|
79
|
-
**Extra Features**
|
|
80
|
-
|
|
81
|
-
| Feature | Notes |
|
|
82
|
-
|---|---|
|
|
83
|
-
| Meta AI / msmsg decrypt | Full `messageSecret`-encrypted AI message decryption |
|
|
84
|
-
| Meta AI message handling | Receive and process Meta AI bot responses |
|
|
85
|
-
| Rich AI composer | Send tables, lists, code blocks, LaTeX via Meta AI format |
|
|
86
|
-
| Interactive buttons | List, reply, template, cards, product list, PIX/PAY |
|
|
87
|
-
| Interop (FB/IG) | Near-parity with mobile & web for cross-platform JIDs |
|
|
88
|
-
| Anti-ban measures | Connection fingerprinting aligned with official clients |
|
|
89
|
-
| Album messages | Send multiple media as an album |
|
|
90
|
-
| Sticker packs | Sticker pack message support |
|
|
91
|
-
| Newsletter messages | Follower invite messages |
|
|
92
|
-
| Top-level call signalling | Emits `call` for both `<call>`-wrapped and top-level `<offer>`/`<terminate>` stanzas (+ acks them) |
|
|
11
|
+
This library is highly suitable for building business bots, chat automation systems, customer service solutions, and various other communication automation applications that require high stability and comprehensive features. With a lightweight and modular design, baileys is easy to integrate into different systems and platforms.
|
|
93
12
|
|
|
94
13
|
---
|
|
95
14
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
npm install npm:@badzz88/baileys
|
|
100
|
-
# or
|
|
101
|
-
yarn add npm:@badzz88/baileys
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
**Requirements:** Node.js ≥ 20
|
|
105
|
-
|
|
106
|
-
**Optional peer dependencies:**
|
|
107
|
-
|
|
108
|
-
| Package | Purpose |
|
|
109
|
-
|---|---|
|
|
110
|
-
| `sharp` | Image processing / thumbnails |
|
|
111
|
-
| `jimp` | Fallback image processing |
|
|
112
|
-
| `audio-decode` | Voice message metadata |
|
|
113
|
-
| `link-preview-js` | Link preview generation |
|
|
114
|
-
|
|
115
|
-
### Running on Termux / Android
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
pkg install nodejs-lts
|
|
119
|
-
npm install npm:@badzz88/baileys
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
`whatsapp-rust-bridge` compiles to **WASM**, not a platform-specific native binary, and
|
|
123
|
-
ships a prebuilt `.wasm` artifact — so a normal `npm install` typically works on Termux
|
|
124
|
-
without installing a Rust toolchain at all (WASM bytecode runs the same on ARM, x86,
|
|
125
|
-
etc., unlike a native N-API `.node` addon). It's still marked as an **optional**
|
|
126
|
-
dependency as a safety net: on the rare setup where the prebuilt doesn't load (very old
|
|
127
|
-
CPUs lacking WASM SIMD, an unusual libc, etc.), `npm install` will **not** fail, and the
|
|
128
|
-
package still loads and works:
|
|
129
|
-
|
|
130
|
-
- MD5, SHA-256, HMAC-SHA256, AES-GCM/CTR/CBC, and HKDF transparently fall back to
|
|
131
|
-
Node's built-in `crypto` module — no functionality lost, no native module needed.
|
|
132
|
-
- WABinary node encoding/decoding fall back to a pure-JS implementation.
|
|
133
|
-
- **X25519 key exchange and XEdDSA signing** (used for identity/pre-key generation
|
|
134
|
-
and signing) also fall back to pure JS — X25519 itself via Node's own built-in
|
|
135
|
-
`crypto` (native, audited), and XEdDSA signing via a small hand-written
|
|
136
|
-
Edwards-curve implementation validated against the official RFC 8032 Ed25519 test
|
|
137
|
-
vectors and hundreds of randomized Montgomery↔Edwards interop checks (see
|
|
138
|
-
`Utils/curve25519-js.js`).
|
|
139
|
-
- **The Noise handshake and the Signal Double Ratchet session** genuinely need the
|
|
140
|
-
module (hand-rolling a full protocol session state machine from scratch is a much
|
|
141
|
-
larger correctness/security risk than a single curve operation, so there's no JS
|
|
142
|
-
fallback for these). Without the native module, connecting a WhatsApp session will
|
|
143
|
-
throw a clear error rather than silently failing — everything else (stickers, the
|
|
144
|
-
in-memory store, USync helpers, the command loader, session pool, key generation,
|
|
145
|
-
etc.) keeps working.
|
|
146
|
-
|
|
147
|
-
If you ever do need to build it from source (e.g. `WHATSAPP_RUST_BRIDGE_SKIP_PREBUILT=1`):
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
|
-
pkg install rust binutils
|
|
151
|
-
npm install npm:@badzz88/baileys
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
> **Note:** some published versions of the bridge ship a `package.json` whose
|
|
155
|
-
> `"exports"` map is missing a `.` entry, which makes a plain `require()` throw
|
|
156
|
-
> `ERR_PACKAGE_PATH_NOT_EXPORTED` even though the module itself works fine. This
|
|
157
|
-
> package works around that automatically (it locates the installed module's real
|
|
158
|
-
> entry file and requires it directly) — no action needed on your end.
|
|
159
|
-
|
|
160
|
-
Other Termux notes:
|
|
161
|
-
- `sharp` needs `pkg install libvips` to build; if that's not available, install
|
|
162
|
-
`jimp` instead (`npm install jimp`) — it's a pure-JS fallback used automatically.
|
|
163
|
-
- Animated stickers (`videoToWebpSticker`) need `ffmpeg` on PATH: `pkg install ffmpeg`.
|
|
164
|
-
|
|
165
|
-
### Running on Pterodactyl
|
|
15
|
+
### Main Features and Advantages
|
|
166
16
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
-
|
|
172
|
-
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
`sharp`, which installs normally.
|
|
176
|
-
- Persistent storage: point `useMultiFileAuthState`/the store's `writeToFile` at a path
|
|
177
|
-
under the server's data volume so sessions survive container restarts/reinstalls.
|
|
178
|
-
- If the egg's image is Alpine/musl-based rather than Debian/glibc-based, the
|
|
179
|
-
prebuilt WASM/`sharp` binaries are less likely to match — everything still installs
|
|
180
|
-
(thanks to the fallbacks above), but a live connection needs the native bridge to
|
|
181
|
-
work, so prefer a glibc-based Node image if you have the choice.
|
|
17
|
+
- Supports automatic and custom pairing processes
|
|
18
|
+
- Fixes previous pairing issues that often caused failures or disconnections
|
|
19
|
+
- Supports interactive messages, action buttons, and dynamic menus
|
|
20
|
+
- Efficient automatic session management for reliable operation
|
|
21
|
+
- Compatible with the latest multi-device features from WhatsApp
|
|
22
|
+
- Lightweight, stable, and easy to integrate into various systems
|
|
23
|
+
- Suitable for developing bots, automation, and complete communication solutions
|
|
24
|
+
- Comprehensive documentation and example codes to facilitate development
|
|
182
25
|
|
|
183
26
|
---
|
|
184
27
|
|
|
185
|
-
##
|
|
186
|
-
|
|
187
|
-
### QR Code
|
|
188
|
-
|
|
189
|
-
```js
|
|
190
|
-
const { makeWASocket, useMultiFileAuthState, DisconnectReason } = require('@badzz88/baileys')
|
|
191
|
-
const { Boom } = require('@hapi/boom')
|
|
192
|
-
|
|
193
|
-
const { state, saveCreds } = await useMultiFileAuthState('./auth')
|
|
194
|
-
|
|
195
|
-
const sock = makeWASocket({ auth: state, printQRInTerminal: true })
|
|
196
|
-
|
|
197
|
-
sock.ev.on('creds.update', saveCreds)
|
|
198
|
-
sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
|
|
199
|
-
if (connection === 'close') {
|
|
200
|
-
const shouldReconnect = new Boom(lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
201
|
-
if (shouldReconnect) connect()
|
|
202
|
-
}
|
|
203
|
-
})
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### Pairing Code
|
|
207
|
-
|
|
208
|
-
```js
|
|
209
|
-
const sock = makeWASocket({ auth: state, printQRInTerminal: false })
|
|
210
|
-
|
|
211
|
-
if (!state.creds.registered) {
|
|
212
|
-
const code = await sock.requestPairingCode('49123456789') // phone number without +
|
|
213
|
-
console.log('Pairing code:', code)
|
|
214
|
-
}
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### Receive Full History
|
|
28
|
+
## Getting Started
|
|
218
29
|
|
|
219
|
-
|
|
220
|
-
const sock = makeWASocket({
|
|
221
|
-
auth: state,
|
|
222
|
-
syncFullHistory: true
|
|
223
|
-
})
|
|
224
|
-
```
|
|
30
|
+
Begin by installing the library via your preferred package manager, then follow the provided configuration guide. You can also utilize the ready-made example codes to understand how the features work. Use session storage and interactive messaging features to build complete, stable solutions tailored to your business or project needs.
|
|
225
31
|
|
|
226
32
|
---
|
|
227
33
|
|
|
228
|
-
##
|
|
229
|
-
|
|
230
|
-
```js
|
|
231
|
-
const sock = makeWASocket({
|
|
232
|
-
auth: state,
|
|
34
|
+
## Add Function ( Simple code )
|
|
233
35
|
|
|
234
|
-
|
|
235
|
-
|
|
36
|
+
### Check ID Channel
|
|
37
|
+
Get ID channel
|
|
236
38
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
// Suppress notifications on the phone while connected
|
|
241
|
-
markOnlineOnConnect: false,
|
|
242
|
-
})
|
|
39
|
+
```javascript
|
|
40
|
+
await sock.newsletterId(url)
|
|
243
41
|
```
|
|
244
42
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
## Saving & Restoring Sessions
|
|
248
|
-
|
|
249
|
-
```js
|
|
250
|
-
const { useMultiFileAuthState } = require('@badzz88/baileys')
|
|
43
|
+
### Check banned number
|
|
44
|
+
You can see the status of blocked numbers here
|
|
251
45
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
sock.ev.on('creds.update', saveCreds)
|
|
46
|
+
```javascript
|
|
47
|
+
await sock.checkWhatsApp(target)
|
|
255
48
|
```
|
|
256
49
|
|
|
257
50
|
---
|
|
258
51
|
|
|
259
|
-
##
|
|
260
|
-
|
|
261
|
-
###
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
sock.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
All three (`onText`, `hears`, `command`) return an unsubscribe function:
|
|
326
|
-
|
|
327
|
-
```js
|
|
328
|
-
const stop = sock.onText(/^bye$/i, (msg) => { /* ... */ })
|
|
329
|
-
stop() // removes just this route
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
### Chats & Contacts
|
|
333
|
-
|
|
334
|
-
```js
|
|
335
|
-
sock.ev.on('chats.upsert', chats => { })
|
|
336
|
-
sock.ev.on('chats.update', chats => { })
|
|
337
|
-
sock.ev.on('chats.delete', ids => { })
|
|
338
|
-
sock.ev.on('chats.lock', ({ id, locked }) => { })
|
|
339
|
-
|
|
340
|
-
sock.ev.on('contacts.upsert', contacts => { })
|
|
341
|
-
sock.ev.on('contacts.update', contacts => { })
|
|
342
|
-
|
|
343
|
-
// Blocklist changed
|
|
344
|
-
sock.ev.on('blocklist.update', ({ blocklist, type }) => { })
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
### Groups
|
|
348
|
-
|
|
349
|
-
```js
|
|
350
|
-
sock.ev.on('groups.upsert', groups => { })
|
|
351
|
-
sock.ev.on('groups.update', updates => { })
|
|
352
|
-
sock.ev.on('group-participants.update', ({ id, participants, action }) => { })
|
|
353
|
-
|
|
354
|
-
// Someone requested to join
|
|
355
|
-
sock.ev.on('group.join-request', ({ id, participant, action }) => { })
|
|
356
|
-
|
|
357
|
-
// Member tag / mention update
|
|
358
|
-
sock.ev.on('group.member-tag.update', ({ id, participant }) => { })
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
### Newsletters
|
|
362
|
-
|
|
363
|
-
```js
|
|
364
|
-
sock.ev.on('newsletter-settings.update', update => { })
|
|
365
|
-
sock.ev.on('newsletter-participants.update', update => { })
|
|
366
|
-
sock.ev.on('newsletter.reaction', update => { })
|
|
367
|
-
sock.ev.on('newsletter.view', update => { })
|
|
368
|
-
sock.ev.on('newsletter.live-update', update => { })
|
|
369
|
-
sock.ev.on('newsletter.pin', update => { })
|
|
370
|
-
sock.ev.on('newsletter.invite', update => { })
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
### Connection & Auth
|
|
374
|
-
|
|
375
|
-
```js
|
|
376
|
-
sock.ev.on('connection.update', ({ connection, qr, lastDisconnect, isOnline, reachoutTimeLock }) => { })
|
|
377
|
-
sock.ev.on('creds.update', saveCreds)
|
|
378
|
-
|
|
379
|
-
// Security alert (e.g. linked device removed)
|
|
380
|
-
sock.ev.on('security.alert', data => { })
|
|
381
|
-
|
|
382
|
-
// Identity key change for a contact
|
|
383
|
-
sock.ev.on('identity.update', ({ jid }) => { })
|
|
384
|
-
|
|
385
|
-
// Server config received
|
|
386
|
-
sock.ev.on('server.config', config => { })
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
### Calls
|
|
390
|
-
|
|
391
|
-
```js
|
|
392
|
-
// `call` fires for both <call>-wrapped and top-level (<offer>/<terminate>) signalling
|
|
393
|
-
sock.ev.on('call', calls => { })
|
|
394
|
-
sock.ev.on('call.scheduled', ({ call }) => { })
|
|
395
|
-
sock.ev.on('call.schedule-cancelled', ({ call }) => { })
|
|
396
|
-
|
|
397
|
-
// Call links — create + toggle the link's waiting room
|
|
398
|
-
const token = await sock.createCallLink('audio')
|
|
399
|
-
await sock.toggleCallLinkWaitingRoom(token, true, 'audio')
|
|
400
|
-
|
|
401
|
-
// WA-Web coexistence (FB/IG) & business privacy-sync pushes
|
|
402
|
-
sock.ev.on('coexistence.update', u => { }) // { kind: 'onboarding' | 'offboarding', status?, productSurface? }
|
|
403
|
-
sock.ev.on('business.privacy-settings-sync', s => { })
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
### Labels
|
|
407
|
-
|
|
408
|
-
```js
|
|
409
|
-
sock.ev.on('labels.edit', ({ label }) => { })
|
|
410
|
-
sock.ev.on('labels.association', ({ association, type }) => { })
|
|
411
|
-
sock.ev.on('labels.reorder', ({ labelIds }) => { })
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
### Presence & Devices
|
|
415
|
-
|
|
416
|
-
```js
|
|
417
|
-
sock.ev.on('presence.update', ({ id, presences }) => { })
|
|
418
|
-
sock.ev.on('devices.update', ({ id, devices, isSelf }) => { })
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
### Bot / Meta AI
|
|
422
|
-
|
|
423
|
-
```js
|
|
424
|
-
sock.ev.on('bot.feedback', ({ message }) => { })
|
|
425
|
-
sock.ev.on('bot.stop-generation', ({ message }) => { })
|
|
426
|
-
sock.ev.on('bot.welcome-request', ({ message }) => { })
|
|
427
|
-
sock.ev.on('bot.psi-metadata', ({ message }) => { })
|
|
428
|
-
sock.ev.on('bot.query-fanout', ({ message }) => { })
|
|
429
|
-
sock.ev.on('bot.media-collection', ({ message }) => { })
|
|
430
|
-
sock.ev.on('bot.memu-onboarding', ({ message }) => { })
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
### Sync & Settings
|
|
434
|
-
|
|
435
|
-
```js
|
|
436
|
-
sock.ev.on('messaging-history.set', ({ chats, contacts, messages, isLatest }) => { })
|
|
437
|
-
sock.ev.on('messaging-history.status', ({ progress, hasMore }) => { })
|
|
438
|
-
sock.ev.on('settings.update', ({ setting, value }) => { })
|
|
439
|
-
sock.ev.on('lid-mapping.update', ({ lid, pn }) => { })
|
|
440
|
-
sock.ev.on('status.psa', ({ message }) => { })
|
|
441
|
-
sock.ev.on('status.mention', ({ message }) => { })
|
|
442
|
-
sock.ev.on('media.notify', ({ message }) => { })
|
|
443
|
-
sock.ev.on('reminder.update', ({ message }) => { })
|
|
444
|
-
sock.ev.on('payment.split', ({ message }) => { })
|
|
445
|
-
sock.ev.on('payment.reminder', ({ message }) => { })
|
|
446
|
-
sock.ev.on('cloud.thread.control', ({ message }) => { })
|
|
447
|
-
sock.ev.on('galaxy.flow.completed', ({ message }) => { })
|
|
52
|
+
## SendMessage Documentation
|
|
53
|
+
|
|
54
|
+
### Status Group Message V2
|
|
55
|
+
Send group status with version 2
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
await sock.sendMessage(target, {
|
|
59
|
+
groupStatusMessage: {
|
|
60
|
+
text: "#BADZZNE"
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Album Message (Multiple Images)
|
|
66
|
+
Send multiple images in a single album message:
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
await sock.sendMessage(target, {
|
|
70
|
+
albumMessage: [
|
|
71
|
+
{ image: cihuy, caption: "#BADZZNE" },
|
|
72
|
+
{ image: { url: "URL IMAGE" }, caption: "#BADZZNE" }
|
|
73
|
+
]
|
|
74
|
+
}, { quoted: m });
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Event Message
|
|
78
|
+
Create and send WhatsApp event invitations:
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
await sock.sendMessage(target, {
|
|
82
|
+
eventMessage: {
|
|
83
|
+
isCanceled: false,
|
|
84
|
+
name: "#BADZZNE",
|
|
85
|
+
description: "#BADZZNE",
|
|
86
|
+
location: {
|
|
87
|
+
degreesLatitude: 0,
|
|
88
|
+
degreesLongitude: 0,
|
|
89
|
+
name: "#BADZZNE"
|
|
90
|
+
},
|
|
91
|
+
joinLink: "https://call.whatsapp.com/video/badzzne2",
|
|
92
|
+
startTime: "1763019000",
|
|
93
|
+
endTime: "1763026200",
|
|
94
|
+
extraGuestsAllowed: false
|
|
95
|
+
}
|
|
96
|
+
}, { quoted: m });
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Poll Result Message
|
|
100
|
+
Display poll results with vote counts:
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
await sock.sendMessage(target, {
|
|
104
|
+
pollResultMessage: {
|
|
105
|
+
name: "#BADZZNE",
|
|
106
|
+
pollVotes: [
|
|
107
|
+
{
|
|
108
|
+
optionName: "#BADZZNE",
|
|
109
|
+
optionVoteCount: "112233"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
optionName: "#BADZZNE",
|
|
113
|
+
optionVoteCount: "1"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}, { quoted: m });
|
|
448
118
|
```
|
|
449
119
|
|
|
450
|
-
###
|
|
120
|
+
### Simple Interactive Message
|
|
121
|
+
Send basic interactive messages with copy button functionality:
|
|
451
122
|
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
123
|
+
```javascript
|
|
124
|
+
await sock.sendMessage(target, {
|
|
125
|
+
interactiveMessage: {
|
|
126
|
+
header: "#BADZZNE",
|
|
127
|
+
title: "#BADZZNE",
|
|
128
|
+
footer: "telegram: @badzzne2 ",
|
|
129
|
+
buttons: [
|
|
130
|
+
{
|
|
131
|
+
name: "cta_copy",
|
|
132
|
+
buttonParamsJson: JSON.stringify({
|
|
133
|
+
display_text: "#BADZZNE",
|
|
134
|
+
id: "123456789",
|
|
135
|
+
copy_code: "ABC123XYZ"
|
|
136
|
+
})
|
|
462
137
|
}
|
|
463
|
-
|
|
138
|
+
]
|
|
464
139
|
}
|
|
465
|
-
})
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
```
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
const wrappedSock = wrapSocket(sock, resolveConfig(PRESETS.SAFE))
|
|
569
|
-
// All outbound sendMessage calls are now automatically rate-limited,
|
|
570
|
-
// presence-simulated, and timelock-aware.
|
|
571
|
-
```
|
|
572
|
-
|
|
573
|
-
---
|
|
574
|
-
|
|
575
|
-
## Sending Messages
|
|
576
|
-
|
|
577
|
-
### Text & Basic
|
|
578
|
-
|
|
579
|
-
```js
|
|
580
|
-
// Text
|
|
581
|
-
await sock.sendMessage(jid, { text: 'Hello!' })
|
|
582
|
-
|
|
583
|
-
// Quote
|
|
584
|
-
await sock.sendMessage(jid, { text: 'Reply' }, { quoted: msg })
|
|
585
|
-
|
|
586
|
-
// Mention
|
|
587
|
-
await sock.sendMessage(jid, { text: '@49123456789', mentions: ['49123456789@s.whatsapp.net'] })
|
|
588
|
-
|
|
589
|
-
// Forward
|
|
590
|
-
await sock.sendMessage(jid, { forward: msg })
|
|
591
|
-
|
|
592
|
-
// Location
|
|
593
|
-
await sock.sendMessage(jid, { location: { degreesLatitude: 52.5, degreesLongitude: 13.4 } })
|
|
594
|
-
|
|
595
|
-
// Live Location
|
|
596
|
-
await sock.sendMessage(jid, {
|
|
597
|
-
liveLocation: { degreesLatitude: 52.5, degreesLongitude: 13.4 },
|
|
598
|
-
accuracyInMeters: 10,
|
|
599
|
-
speedInMps: 0,
|
|
600
|
-
degreesClockwisefromMagneticNorth: 0,
|
|
601
|
-
caption: 'Live',
|
|
602
|
-
sequenceNumber: 1
|
|
603
|
-
})
|
|
604
|
-
|
|
605
|
-
// Contact
|
|
606
|
-
await sock.sendMessage(jid, { contacts: { displayName: 'Name', contacts: [{ vcard: '...' }] } })
|
|
607
|
-
```
|
|
608
|
-
|
|
609
|
-
### Rich Response (table / code / latex / images)
|
|
610
|
-
|
|
611
|
-
Renders as WhatsApp's native AI-assistant-style rich card (the same UI Meta AI uses
|
|
612
|
-
for search results). `table` accepts either a plain 2D array (first row = header) or
|
|
613
|
-
`{ rows: [...] }`.
|
|
614
|
-
|
|
615
|
-
```js
|
|
616
|
-
await sock.sendMessage(jid, {
|
|
617
|
-
richResponse: {
|
|
618
|
-
text: 'Badzz88',
|
|
619
|
-
table: [
|
|
620
|
-
['header1', 'header2'],
|
|
621
|
-
['X1', 'X2']
|
|
622
|
-
],
|
|
623
|
-
// code: 'console.log("hi")', language: 'javascript',
|
|
624
|
-
// latex: 'x^2 + y^2 = z^2',
|
|
625
|
-
// imageUrl: 'https://...', // or imageUrls: ['https://...', ...]
|
|
626
|
-
// map: { latitude: 52.5, longitude: 13.4, zoom: 14, title: 'Berlin' }
|
|
140
|
+
}, { quoted: m });
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Interactive Message with Native Flow
|
|
144
|
+
Send interactive messages with buttons, copy actions, and native flow features:
|
|
145
|
+
|
|
146
|
+
```javascript
|
|
147
|
+
await sock.sendMessage(target, {
|
|
148
|
+
interactiveMessage: {
|
|
149
|
+
header: "#BADZZNE",
|
|
150
|
+
title: "#BADZZNE",
|
|
151
|
+
footer: "telegram: @badzzne2",
|
|
152
|
+
image: { url: "https://example.com/image.jpg" },
|
|
153
|
+
nativeFlowMessage: {
|
|
154
|
+
messageParamsJson: JSON.stringify({
|
|
155
|
+
limited_time_offer: {
|
|
156
|
+
text: "idk hummmm?",
|
|
157
|
+
url: "https://t.me/badzzne2",
|
|
158
|
+
copy_code: "#BADZZNE",
|
|
159
|
+
expiration_time: Date.now() * 999
|
|
160
|
+
},
|
|
161
|
+
bottom_sheet: {
|
|
162
|
+
in_thread_buttons_limit: 2,
|
|
163
|
+
divider_indices: [1, 2, 3, 4, 5, 999],
|
|
164
|
+
list_title: "#BADZZNE",
|
|
165
|
+
button_title: "#BADZZNE"
|
|
166
|
+
},
|
|
167
|
+
tap_target_configuration: {
|
|
168
|
+
title: " X ",
|
|
169
|
+
description: "bomboclard",
|
|
170
|
+
canonical_url: "https://t.me/badzzne2",
|
|
171
|
+
domain: "shop.example.com",
|
|
172
|
+
button_index: 0
|
|
173
|
+
}
|
|
174
|
+
}),
|
|
175
|
+
buttons: [
|
|
176
|
+
{
|
|
177
|
+
name: "single_select",
|
|
178
|
+
buttonParamsJson: JSON.stringify({
|
|
179
|
+
has_multiple_buttons: true
|
|
180
|
+
})
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "call_permission_request",
|
|
184
|
+
buttonParamsJson: JSON.stringify({
|
|
185
|
+
has_multiple_buttons: true
|
|
186
|
+
})
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "single_select",
|
|
190
|
+
buttonParamsJson: JSON.stringify({
|
|
191
|
+
title: "#BADZZNE",
|
|
192
|
+
sections: [
|
|
193
|
+
{
|
|
194
|
+
title: "title",
|
|
195
|
+
highlight_label: "label",
|
|
196
|
+
rows: [
|
|
197
|
+
{
|
|
198
|
+
title: "@badzzne2",
|
|
199
|
+
description: "love you",
|
|
200
|
+
id: "row_2"
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
has_multiple_buttons: true
|
|
206
|
+
})
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "cta_copy",
|
|
210
|
+
buttonParamsJson: JSON.stringify({
|
|
211
|
+
display_text: "copy code",
|
|
212
|
+
id: "123456789",
|
|
213
|
+
copy_code: "ABC123XYZ"
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}, { quoted: m });
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Interactive Message with Thumbnail
|
|
223
|
+
Send interactive messages with thumbnail image and copy button:
|
|
224
|
+
|
|
225
|
+
```javascript
|
|
226
|
+
await sock.sendMessage(target, {
|
|
227
|
+
interactiveMessage: {
|
|
228
|
+
header: "#BADZZNE",
|
|
229
|
+
title: "#BADZZNE",
|
|
230
|
+
footer: "telegram: @badzzne2",
|
|
231
|
+
image: { url: "https://example.com/image.jpg" },
|
|
232
|
+
buttons: [
|
|
233
|
+
{
|
|
234
|
+
name: "cta_copy",
|
|
235
|
+
buttonParamsJson: JSON.stringify({
|
|
236
|
+
display_text: "copy code",
|
|
237
|
+
id: "123456789",
|
|
238
|
+
copy_code: "ABC123XYZ"
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
]
|
|
627
242
|
}
|
|
628
|
-
}, {
|
|
629
|
-
```
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
243
|
+
}, { quoted: m });
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Product Message
|
|
247
|
+
Send product catalog messages with buttons and merchant information:
|
|
248
|
+
|
|
249
|
+
```javascript
|
|
250
|
+
await sock.sendMessage(target, {
|
|
251
|
+
productMessage: {
|
|
252
|
+
title: "Produk Contoh",
|
|
253
|
+
description: "Ini adalah deskripsi produk",
|
|
254
|
+
thumbnail: { url: "https://example.com/image.jpg" },
|
|
255
|
+
productId: "PROD001",
|
|
256
|
+
retailerId: "RETAIL001",
|
|
257
|
+
url: "https://example.com/product",
|
|
258
|
+
body: "Detail produk",
|
|
259
|
+
footer: "Harga spesial",
|
|
260
|
+
priceAmount1000: 50000,
|
|
261
|
+
currencyCode: "USD",
|
|
262
|
+
buttons: [
|
|
263
|
+
{
|
|
264
|
+
name: "cta_url",
|
|
265
|
+
buttonParamsJson: JSON.stringify({
|
|
266
|
+
display_text: "Beli Sekarang",
|
|
267
|
+
url: "https://example.com/buy"
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
}, { quoted: m });
|
|
645
273
|
```
|
|
646
274
|
|
|
647
|
-
###
|
|
275
|
+
### Interactive Message with Document Buffer
|
|
276
|
+
Send interactive messages with document from buffer (file system) - **Note: Documents only support buffer**:
|
|
648
277
|
|
|
649
|
-
```
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
278
|
+
```javascript
|
|
279
|
+
await sock.sendMessage(target, {
|
|
280
|
+
interactiveMessage: {
|
|
281
|
+
header: "#BADZZNE",
|
|
282
|
+
title: "#BADZZNE",
|
|
283
|
+
footer: "telegram: @badzzne2",
|
|
284
|
+
document: fs.readFileSync("./package.json"),
|
|
285
|
+
mimetype: "application/pdf",
|
|
286
|
+
fileName: "badzzne2.pdf",
|
|
287
|
+
jpegThumbnail: fs.readFileSync("./document.jpeg"),
|
|
288
|
+
contextInfo: {
|
|
289
|
+
mentionedJid: [target],
|
|
290
|
+
forwardingScore: 777,
|
|
291
|
+
isForwarded: false
|
|
292
|
+
},
|
|
293
|
+
externalAdReply: {
|
|
294
|
+
title: "#BADZZNE",
|
|
295
|
+
body: "#BADZZNE",
|
|
296
|
+
mediaType: 3,
|
|
297
|
+
thumbnailUrl: "https://example.com/image.jpg",
|
|
298
|
+
mediaUrl: " X ",
|
|
299
|
+
sourceUrl: "https://t.me/badzzne2",
|
|
300
|
+
showAdAttribution: true,
|
|
301
|
+
renderLargerThumbnail: false
|
|
302
|
+
},
|
|
654
303
|
buttons: [
|
|
655
|
-
{
|
|
656
|
-
|
|
304
|
+
{
|
|
305
|
+
name: "cta_url",
|
|
306
|
+
buttonParamsJson: JSON.stringify({
|
|
307
|
+
display_text: "Telegram",
|
|
308
|
+
url: "https://t.me/badzzne2",
|
|
309
|
+
merchant_url: "https://t.me/badzzne2"
|
|
310
|
+
})
|
|
311
|
+
}
|
|
657
312
|
]
|
|
658
313
|
}
|
|
659
|
-
})
|
|
660
|
-
|
|
661
|
-
// List message
|
|
662
|
-
await sock.sendMessage(jid, {
|
|
663
|
-
listMessage: {
|
|
664
|
-
title: 'Menu',
|
|
665
|
-
description: 'Pick one',
|
|
666
|
-
buttonText: 'Open',
|
|
667
|
-
listType: 1,
|
|
668
|
-
sections: [{
|
|
669
|
-
title: 'Section',
|
|
670
|
-
rows: [{ title: 'Item 1', rowId: 'item1' }]
|
|
671
|
-
}]
|
|
672
|
-
}
|
|
673
|
-
})
|
|
314
|
+
}, { quoted: m });
|
|
315
|
+
```
|
|
674
316
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
templateMessage: {
|
|
678
|
-
hydratedTemplate: {
|
|
679
|
-
hydratedContentText: 'Hello',
|
|
680
|
-
hydratedButtons: [
|
|
681
|
-
{ quickReplyButton: { displayText: 'Yes', id: 'yes' } },
|
|
682
|
-
{ urlButton: { displayText: 'Visit', url: 'https://example.com' } }
|
|
683
|
-
]
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
})
|
|
317
|
+
### Interactive Message with Document Buffer (Simple)
|
|
318
|
+
Send interactive messages with document from buffer (file system) without contextInfo and externalAdReply - **Note: Documents only support buffer**:
|
|
687
319
|
|
|
688
|
-
|
|
689
|
-
await sock.sendMessage(
|
|
320
|
+
```javascript
|
|
321
|
+
await sock.sendMessage(target, {
|
|
690
322
|
interactiveMessage: {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
323
|
+
header: "#BADZZNE",
|
|
324
|
+
title: "#BADZZNE",
|
|
325
|
+
footer: "telegram: @badzzne2",
|
|
326
|
+
document: fs.readFileSync("./package.json"),
|
|
327
|
+
mimetype: "application/pdf",
|
|
328
|
+
fileName: "badzzne2.pdf",
|
|
329
|
+
jpegThumbnail: fs.readFileSync("./document.jpeg"),
|
|
330
|
+
buttons: [
|
|
331
|
+
{
|
|
332
|
+
name: "cta_url",
|
|
333
|
+
buttonParamsJson: JSON.stringify({
|
|
334
|
+
display_text: "Telegram",
|
|
335
|
+
url: "https://t.me/badzzne2",
|
|
336
|
+
merchant_url: "https://t.me/badzzne2"
|
|
337
|
+
})
|
|
338
|
+
}
|
|
339
|
+
]
|
|
340
|
+
}
|
|
341
|
+
}, { quoted: m });
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### Request Payment Message
|
|
345
|
+
Send payment request messages with custom background and sticker:
|
|
346
|
+
|
|
347
|
+
```javascript
|
|
348
|
+
let quotedType = m.quoted?.mtype || '';
|
|
349
|
+
let quotedContent = JSON.stringify({ [quotedType]: m.quoted }, null, 2);
|
|
350
|
+
|
|
351
|
+
await sock.sendMessage(target, {
|
|
352
|
+
requestPaymentMessage: {
|
|
353
|
+
currency: "IDR",
|
|
354
|
+
amount: 10000000,
|
|
355
|
+
from: m.sender,
|
|
356
|
+
sticker: JSON.parse(quotedContent),
|
|
357
|
+
background: {
|
|
358
|
+
id: "100",
|
|
359
|
+
fileLength: "0",
|
|
360
|
+
width: 1000,
|
|
361
|
+
height: 1000,
|
|
362
|
+
mimetype: "image/webp",
|
|
363
|
+
placeholderArgb: 0xFF00FFFF,
|
|
364
|
+
textArgb: 0xFFFFFFFF,
|
|
365
|
+
subtextArgb: 0xFFAA00FF
|
|
695
366
|
}
|
|
696
367
|
}
|
|
697
|
-
})
|
|
698
|
-
```
|
|
699
|
-
|
|
700
|
-
### Media
|
|
701
|
-
|
|
702
|
-
```js
|
|
703
|
-
// Image
|
|
704
|
-
await sock.sendMessage(jid, { image: { url: './image.jpg' }, caption: 'Caption' })
|
|
705
|
-
|
|
706
|
-
// Video
|
|
707
|
-
await sock.sendMessage(jid, { video: { url: './video.mp4' }, caption: 'Video' })
|
|
708
|
-
|
|
709
|
-
// Audio
|
|
710
|
-
await sock.sendMessage(jid, { audio: { url: './audio.mp3' }, mimetype: 'audio/mp4' })
|
|
711
|
-
|
|
712
|
-
// Voice note (PTT)
|
|
713
|
-
await sock.sendMessage(jid, { audio: { url: './audio.ogg' }, mimetype: 'audio/ogg; codecs=opus', ptt: true })
|
|
714
|
-
|
|
715
|
-
// GIF
|
|
716
|
-
await sock.sendMessage(jid, { video: { url: './anim.mp4' }, gifPlayback: true })
|
|
717
|
-
|
|
718
|
-
// PTV (video note)
|
|
719
|
-
await sock.sendMessage(jid, { video: { url: './clip.mp4' }, ptv: true })
|
|
720
|
-
|
|
721
|
-
// View once
|
|
722
|
-
await sock.sendMessage(jid, { image: { url: './secret.jpg' }, viewOnce: true })
|
|
723
|
-
|
|
724
|
-
// Album
|
|
725
|
-
await sock.sendAlbumMessage(jid, [
|
|
726
|
-
{ image: { url: './1.jpg' } },
|
|
727
|
-
{ image: { url: './2.jpg' } },
|
|
728
|
-
{ video: { url: './3.mp4' } }
|
|
729
|
-
], { caption: 'Album' })
|
|
730
|
-
```
|
|
731
|
-
|
|
732
|
-
### Meta AI / Rich Responses
|
|
733
|
-
|
|
734
|
-
```js
|
|
735
|
-
// Rich AI response (table, list, code, LaTeX)
|
|
736
|
-
await sock.sendRichAIResponse(jid, {
|
|
737
|
-
table: { headers: ['Name', 'Value'], rows: [['Foo', '1'], ['Bar', '2']] }
|
|
738
|
-
})
|
|
739
|
-
|
|
740
|
-
await sock.sendRichAIResponse(jid, {
|
|
741
|
-
list: { items: ['Item 1', 'Item 2', 'Item 3'] }
|
|
742
|
-
})
|
|
743
|
-
|
|
744
|
-
await sock.sendRichAIResponse(jid, {
|
|
745
|
-
codeBlock: { language: 'js', code: 'console.log("hello")' }
|
|
746
|
-
})
|
|
747
|
-
|
|
748
|
-
await sock.sendRichAIResponse(jid, {
|
|
749
|
-
latex: 'E = mc^2'
|
|
750
|
-
})
|
|
751
|
-
|
|
752
|
-
// Capture & resend a Meta AI unified response
|
|
753
|
-
await sock.captureAndResendUnifiedResponse(jid, metaAiMsg)
|
|
754
|
-
```
|
|
755
|
-
|
|
756
|
-
### Status / Stories
|
|
757
|
-
|
|
758
|
-
```js
|
|
759
|
-
// Status with mentions
|
|
760
|
-
await sock.sendMessage('status@broadcast', {
|
|
761
|
-
text: 'Hello @49123',
|
|
762
|
-
mentions: ['49123@s.whatsapp.net'],
|
|
763
|
-
statusMentionedJids: ['49123@s.whatsapp.net']
|
|
764
|
-
})
|
|
765
|
-
|
|
766
|
-
// Status sticker interaction
|
|
767
|
-
await sock.sendMessage('status@broadcast', {
|
|
768
|
-
stickerInteraction: { sticker: { url: './sticker.webp' }, reactionKey: msg.key }
|
|
769
|
-
})
|
|
770
|
-
|
|
771
|
-
// Quote a status
|
|
772
|
-
await sock.sendMessage(jid, { text: 'Reply to status' }, { quoted: statusMsg })
|
|
773
|
-
```
|
|
774
|
-
|
|
775
|
-
---
|
|
776
|
-
|
|
777
|
-
## Modifying Messages
|
|
778
|
-
|
|
779
|
-
```js
|
|
780
|
-
// Delete for everyone
|
|
781
|
-
await sock.sendMessage(jid, { delete: msg.key })
|
|
782
|
-
|
|
783
|
-
// Edit
|
|
784
|
-
await sock.sendMessage(jid, { edit: msg.key, text: 'Updated text' })
|
|
785
|
-
```
|
|
786
|
-
|
|
787
|
-
---
|
|
788
|
-
|
|
789
|
-
## Manipulating Media
|
|
790
|
-
|
|
791
|
-
```js
|
|
792
|
-
const { downloadMediaMessage } = require('@badzz88/baileys')
|
|
793
|
-
|
|
794
|
-
// Download
|
|
795
|
-
const buffer = await downloadMediaMessage(msg, 'buffer', {})
|
|
796
|
-
|
|
797
|
-
// Re-upload to WhatsApp
|
|
798
|
-
const { url } = await sock.waUploadToServer(buffer, { mimetype: 'image/jpeg' })
|
|
368
|
+
}, { quoted: m });
|
|
799
369
|
```
|
|
800
370
|
|
|
801
371
|
---
|
|
802
372
|
|
|
803
|
-
##
|
|
804
|
-
|
|
805
|
-
```js
|
|
806
|
-
// Create
|
|
807
|
-
const group = await sock.groupCreate('Name', ['49123@s.whatsapp.net'])
|
|
808
|
-
|
|
809
|
-
// Add / Remove / Promote / Demote
|
|
810
|
-
await sock.groupParticipantsUpdate(jid, ['49123@s.whatsapp.net'], 'add') // add | remove | promote | demote
|
|
811
|
-
|
|
812
|
-
// Change name
|
|
813
|
-
await sock.groupUpdateSubject(jid, 'New Name')
|
|
814
|
-
|
|
815
|
-
// Change description
|
|
816
|
-
await sock.groupUpdateDescription(jid, 'Description')
|
|
817
|
-
|
|
818
|
-
// Change settings
|
|
819
|
-
await sock.groupSettingUpdate(jid, 'announcement') // announcement | not_announcement | locked | unlocked
|
|
820
|
-
|
|
821
|
-
// Leave
|
|
822
|
-
await sock.groupLeave(jid)
|
|
823
|
-
|
|
824
|
-
// Invite link
|
|
825
|
-
const code = await sock.groupInviteCode(jid)
|
|
826
|
-
await sock.groupRevokeInvite(jid)
|
|
827
|
-
await sock.groupAcceptInvite(code)
|
|
828
|
-
|
|
829
|
-
// Metadata (now also returns memberShareHistoryMode, memberLinkMode, limitSharing)
|
|
830
|
-
const meta = await sock.groupMetadata(jid)
|
|
831
|
-
|
|
832
|
-
// Join requests
|
|
833
|
-
const requests = await sock.groupRequestParticipantsList(jid)
|
|
834
|
-
await sock.groupRequestParticipantsUpdate(jid, ['49123@s.whatsapp.net'], 'approve') // approve | reject
|
|
373
|
+
## Why Choose WhatsApp Baileys?
|
|
835
374
|
|
|
836
|
-
|
|
837
|
-
const all = await sock.groupFetchAllParticipating()
|
|
838
|
-
|
|
839
|
-
// Ephemeral
|
|
840
|
-
await sock.groupToggleEphemeral(jid, 86400) // seconds, 0 = off
|
|
841
|
-
|
|
842
|
-
// Acknowledge a group
|
|
843
|
-
await sock.groupAcknowledge(jid)
|
|
844
|
-
|
|
845
|
-
// Communities — linked/sub-group participants, join a sub-group, batch profile pictures
|
|
846
|
-
const linkedParts = await sock.groupGetLinkedParticipants(communityJid)
|
|
847
|
-
await sock.groupJoinLinked(communityJid, subGroupJid)
|
|
848
|
-
const pics = await sock.getGroupProfilePictures([jid1, jid2], 'preview')
|
|
849
|
-
```
|
|
375
|
+
Because this library offers high stability, full features, and an actively improved pairing process. It is ideal for developers aiming to create professional and secure WhatsApp automation solutions. Support for the latest WhatsApp features ensures compatibility with platform updates.
|
|
850
376
|
|
|
851
377
|
---
|
|
852
378
|
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
```js
|
|
856
|
-
// Block / Unblock
|
|
857
|
-
await sock.updateBlockStatus(jid, 'block') // block | unblock
|
|
858
|
-
|
|
859
|
-
// Get settings
|
|
860
|
-
const privacy = await sock.fetchPrivacySettings()
|
|
861
|
-
// { last: 'all', online: 'all', profile: 'contacts', groupadd: 'all', calladd: 'all', ... }
|
|
862
|
-
|
|
863
|
-
// Force fresh fetch (bypass cache)
|
|
864
|
-
const fresh = await sock.fetchPrivacySettings(true)
|
|
865
|
-
|
|
866
|
-
// Get blocklist
|
|
867
|
-
const list = await sock.fetchBlocklist()
|
|
868
|
-
|
|
869
|
-
// Update individual settings (IQ-based, lowercase values, works on all accounts)
|
|
870
|
-
await sock.updateLastSeenPrivacy('contacts') // all | contacts | contact_blacklist | none
|
|
871
|
-
await sock.updateOnlinePrivacy('all')
|
|
872
|
-
await sock.updateProfilePicturePrivacy('contacts')
|
|
873
|
-
await sock.updateStatusPrivacy('contacts')
|
|
874
|
-
await sock.updateReadReceiptsPrivacy('all')
|
|
875
|
-
await sock.updateGroupsAddPrivacy('contacts')
|
|
876
|
-
await sock.updateCallPrivacy('all')
|
|
877
|
-
await sock.updateDefaultDisappearingMode(86400) // seconds, 0 = off
|
|
878
|
-
|
|
879
|
-
// Set via MEX GraphQL (UPPERCASE values required)
|
|
880
|
-
await sock.setPrivacySetting('LAST_SEEN', 'CONTACTS')
|
|
881
|
-
await sock.setPrivacySetting('GROUPS', 'CONTACT_BLACKLIST')
|
|
882
|
-
await sock.setPrivacySetting('CALLS', 'NONE')
|
|
883
|
-
|
|
884
|
-
// Manage contact lists for CONTACT_BLACKLIST / CONTACTS settings
|
|
885
|
-
await sock.updatePrivacyContactList('groupadd', 'contact_blacklist', [jid1, jid2])
|
|
886
|
-
const current = await sock.getPrivacyContactList('groupadd', 'contact_blacklist')
|
|
887
|
-
|
|
888
|
-
// "Block messages from unknown accounts" toggle (WA Web w:comms:chat)
|
|
889
|
-
const blockStatus = await sock.getChatBlockingStatus() // 'blocked' | 'unblocked'
|
|
890
|
-
await sock.updateChatBlockingStatus('block') // block | unblock
|
|
891
|
-
|
|
892
|
-
// Pending TOS disclosures · feature opt-out list · push config
|
|
893
|
-
const notices = await sock.getUserDisclosures()
|
|
894
|
-
const optOut = await sock.getOptOutList()
|
|
895
|
-
const push = await sock.getPushConfig()
|
|
896
|
-
```
|
|
897
|
-
|
|
898
|
-
---
|
|
899
|
-
|
|
900
|
-
## User Queries
|
|
901
|
-
|
|
902
|
-
```js
|
|
903
|
-
// Check if number exists on WA
|
|
904
|
-
const results = await sock.onWhatsApp('49123456789')
|
|
905
|
-
// results[0] === { jid: '49123456789@s.whatsapp.net', exists: true }
|
|
906
|
-
|
|
907
|
-
// Profile picture
|
|
908
|
-
const ppUrl = await sock.profilePictureUrl(jid, 'image')
|
|
909
|
-
|
|
910
|
-
// Status text (legacy)
|
|
911
|
-
const status = await sock.fetchStatus(jid)
|
|
912
|
-
|
|
913
|
-
// About text (MEX)
|
|
914
|
-
const abouts = await sock.getTextStatusList([jid])
|
|
915
|
-
// [{ jid, text: 'Hey there!', emoji: '👋', timestamp: 1234567890 }]
|
|
916
|
-
|
|
917
|
-
// Business profile
|
|
918
|
-
const biz = await sock.getBusinessProfile(jid)
|
|
919
|
-
|
|
920
|
-
// Presence (typing/online)
|
|
921
|
-
await sock.subscribePresence(jid)
|
|
922
|
-
sock.ev.on('presence.update', ({ id, presences }) => { })
|
|
923
|
-
|
|
924
|
-
// Chat history
|
|
925
|
-
await sock.fetchMessageHistory(50, oldestMsg.key, oldestMsg.messageTimestamp)
|
|
926
|
-
|
|
927
|
-
// Find user by @username
|
|
928
|
-
const user = await sock.findUserByUsername('someusername')
|
|
929
|
-
// { jid: '49123456789@s.whatsapp.net', contact: false } or null
|
|
930
|
-
|
|
931
|
-
// Verify a JID before opening a chat
|
|
932
|
-
const integrity = await sock.contactIntegrityQuery([jid])
|
|
933
|
-
```
|
|
934
|
-
|
|
935
|
-
---
|
|
936
|
-
|
|
937
|
-
## Change Profile
|
|
938
|
-
|
|
939
|
-
```js
|
|
940
|
-
// Status
|
|
941
|
-
await sock.updateProfileStatus('My status')
|
|
942
|
-
|
|
943
|
-
// Name
|
|
944
|
-
await sock.updateProfileName('New Name')
|
|
945
|
-
|
|
946
|
-
// Picture
|
|
947
|
-
await sock.updateProfilePicture(jid, { url: './photo.jpg' })
|
|
948
|
-
|
|
949
|
-
// Remove picture
|
|
950
|
-
await sock.removeProfilePicture(jid)
|
|
951
|
-
```
|
|
952
|
-
|
|
953
|
-
---
|
|
954
|
-
|
|
955
|
-
## Chat Modifiers
|
|
956
|
-
|
|
957
|
-
```js
|
|
958
|
-
// Archive
|
|
959
|
-
await sock.chatModify({ archive: true, lastMessages: [msg] }, jid)
|
|
960
|
-
|
|
961
|
-
// Mute (ms timestamp)
|
|
962
|
-
await sock.chatModify({ mute: Date.now() + 8 * 60 * 60 * 1000 }, jid)
|
|
963
|
-
|
|
964
|
-
// Mark read/unread
|
|
965
|
-
await sock.chatModify({ markRead: false, lastMessages: [msg] }, jid)
|
|
966
|
-
|
|
967
|
-
// Delete message for me
|
|
968
|
-
await sock.chatModify({ clear: { messages: [{ id: msg.key.id, fromMe: msg.key.fromMe }] } }, jid)
|
|
969
|
-
|
|
970
|
-
// Delete chat
|
|
971
|
-
await sock.chatModify({ delete: true, lastMessages: [msg] }, jid)
|
|
972
|
-
|
|
973
|
-
// Star / Unstar
|
|
974
|
-
await sock.chatModify({ star: { messages: [{ id: msg.key.id, fromMe: msg.key.fromMe }], star: true } }, jid)
|
|
975
|
-
|
|
976
|
-
// Disappearing messages
|
|
977
|
-
await sock.sendMessage(jid, { disappearingMessagesInChat: 86400 })
|
|
978
|
-
```
|
|
979
|
-
|
|
980
|
-
---
|
|
981
|
-
|
|
982
|
-
## Writing Custom Functionality
|
|
983
|
-
|
|
984
|
-
```js
|
|
985
|
-
// Enable debug logs
|
|
986
|
-
const sock = makeWASocket({ logger: pino({ level: 'debug' }) })
|
|
987
|
-
|
|
988
|
-
// Raw websocket events
|
|
989
|
-
sock.ws.on('CB:message', node => console.log(node))
|
|
990
|
-
|
|
991
|
-
// Register callback for specific WA nodes
|
|
992
|
-
sock.ws.on('CB:iq,,result', node => { })
|
|
993
|
-
```
|
|
994
|
-
|
|
995
|
-
---
|
|
996
|
-
|
|
997
|
-
## Extra Utilities
|
|
998
|
-
|
|
999
|
-
A handful of batteries-included helpers on top of stock Baileys, importable from the
|
|
1000
|
-
main package (`require('@badzz88/baileys')` / top-level `Utils` exports):
|
|
1001
|
-
|
|
1002
|
-
### Sticker Maker
|
|
1003
|
-
|
|
1004
|
-
```js
|
|
1005
|
-
const { imageToWebpSticker, videoToWebpSticker } = require('@badzz88/baileys')
|
|
1006
|
-
|
|
1007
|
-
const stickerBuf = await imageToWebpSticker(imageBuffer, {
|
|
1008
|
-
packName: 'My Pack',
|
|
1009
|
-
packPublisher: 'Me'
|
|
1010
|
-
})
|
|
1011
|
-
await sock.sendMessage(jid, { sticker: stickerBuf })
|
|
1012
|
-
|
|
1013
|
-
// animated stickers need ffmpeg on PATH
|
|
1014
|
-
const animatedBuf = await videoToWebpSticker(videoBuffer, { packName: 'My Pack', packPublisher: 'Me' })
|
|
1015
|
-
```
|
|
1016
|
-
|
|
1017
|
-
### Auto-Cache View-Once Media
|
|
1018
|
-
|
|
1019
|
-
Downloads and saves view-once photos/videos/voice notes to disk the moment they arrive,
|
|
1020
|
-
before the sender's app can mark them as opened.
|
|
1021
|
-
|
|
1022
|
-
```js
|
|
1023
|
-
const { autoCacheViewOnceMedia } = require('@badzz88/baileys')
|
|
1024
|
-
|
|
1025
|
-
const stop = autoCacheViewOnceMedia(sock, { cacheDir: './viewonce-cache' })
|
|
1026
|
-
// stop() to remove the listener later
|
|
1027
|
-
```
|
|
1028
|
-
|
|
1029
|
-
### Folder-Based Command Loader
|
|
1030
|
-
|
|
1031
|
-
```js
|
|
1032
|
-
const { createCommandHandler } = require('@badzz88/baileys')
|
|
1033
|
-
|
|
1034
|
-
createCommandHandler(sock, { commandsDir: './commands', prefix: '.' })
|
|
1035
|
-
```
|
|
1036
|
-
|
|
1037
|
-
```js
|
|
1038
|
-
// ./commands/ping.js
|
|
1039
|
-
module.exports = {
|
|
1040
|
-
name: 'ping',
|
|
1041
|
-
aliases: ['p'],
|
|
1042
|
-
async execute({ sock, jid }) {
|
|
1043
|
-
await sock.sendMessage(jid, { text: 'pong' })
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
```
|
|
1047
|
-
|
|
1048
|
-
### Multi-Account Session Pool
|
|
1049
|
-
|
|
1050
|
-
Runs several accounts side by side and auto-reconnects any that drop (except on
|
|
1051
|
-
logout) with exponential backoff + jitter, instead of hand-rolling a reconnect loop
|
|
1052
|
-
per project.
|
|
1053
|
-
|
|
1054
|
-
```js
|
|
1055
|
-
const { createSessionPool } = require('@badzz88/baileys')
|
|
1056
|
-
|
|
1057
|
-
const pool = createSessionPool({
|
|
1058
|
-
makeSocket: async sessionId => {
|
|
1059
|
-
const { state, saveCreds } = await useMultiFileAuthState(`./sessions/${sessionId}`)
|
|
1060
|
-
const sock = makeWASocket({ auth: state })
|
|
1061
|
-
sock.ev.on('creds.update', saveCreds)
|
|
1062
|
-
return sock
|
|
1063
|
-
},
|
|
1064
|
-
logger
|
|
1065
|
-
})
|
|
1066
|
-
|
|
1067
|
-
await pool.add('account-1')
|
|
1068
|
-
await pool.add('account-2')
|
|
1069
|
-
```
|
|
1070
|
-
|
|
1071
|
-
### Store Auto-Save, Message Limits & Encryption
|
|
1072
|
-
|
|
1073
|
-
`makeInMemoryStore` now persists **everything** (`chats`, `contacts`, `messages`,
|
|
1074
|
-
`labels`, `groupMetadata`, `presences`, `state`) instead of a subset, and supports:
|
|
1075
|
-
|
|
1076
|
-
```js
|
|
1077
|
-
const store = makeInMemoryStore({
|
|
1078
|
-
socket: sock,
|
|
1079
|
-
maxMessagesPerChat: 500, // cap memory usage per chat
|
|
1080
|
-
encryptionKey: process.env.STORE_KEY // optional, AES-256-GCM at rest
|
|
1081
|
-
})
|
|
1082
|
-
|
|
1083
|
-
store.readFromFile('./store.json')
|
|
1084
|
-
const stopAutoSave = store.startAutoSave('./store.json', 30_000) // every 30s + on socket close
|
|
1085
|
-
```
|
|
1086
|
-
|
|
1087
|
-
---
|
|
1088
|
-
|
|
1089
|
-
## Rust WASM Bridge
|
|
1090
|
-
|
|
1091
|
-
The native module lives at [7ucg/whatsapp-rust-bridge](https://github.com/7ucg/whatsapp-rust-bridge).
|
|
1092
|
-
Pre-built and bundled — **no Rust toolchain needed** to use this package.
|
|
1093
|
-
|
|
1094
|
-
Functions offloaded to Rust:
|
|
379
|
+
### Technical Notes
|
|
1095
380
|
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
| `aesEncrypt` / `aesDecrypt` | AES-256-CBC |
|
|
1104
|
-
| `aesEncryptGCM` / `aesDecryptGCM` | AES-256-GCM |
|
|
1105
|
-
| `aesEncryptCTR` / `aesDecryptCTR` | AES-256-CTR |
|
|
381
|
+
- Supports custom pairing codes that are stable and secure
|
|
382
|
+
- Fixes previous issues related to pairing and authentication
|
|
383
|
+
- Features interactive messages and action buttons for dynamic menu creation
|
|
384
|
+
- Automatic and efficient session management for long-term stability
|
|
385
|
+
- Compatible with the latest multi-device features from WhatsApp
|
|
386
|
+
- Easy to integrate and customize based on your needs
|
|
387
|
+
- Perfect for developing bots, customer service automation, and other communication applications
|
|
1106
388
|
|
|
1107
389
|
---
|
|
1108
390
|
|
|
1109
|
-
|
|
391
|
+
For complete documentation, installation guides, and implementation examples, please visit the official repository and community forums. We continually update and improve this library to meet the needs of developers and users of modern WhatsApp automation solutions.
|
|
1110
392
|
|
|
1111
|
-
|
|
393
|
+
**Thank you for choosing WhatsApp Baileys as your WhatsApp automation solution!**
|