supun-bailey-vip 0.0.0-stage → 1.0.3
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 +986 -2
- package/WAProto/fix-imports.js +85 -0
- package/WAProto/index.js +242946 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.js +138 -0
- package/lib/MessageBuilder/bot-signature.d.ts +22 -0
- package/lib/MessageBuilder/bot-signature.js +123 -0
- package/lib/MessageBuilder/extras.d.ts +449 -0
- package/lib/MessageBuilder/extras.js +1357 -0
- package/lib/MessageBuilder/index.d.ts +210 -0
- package/lib/MessageBuilder/index.js +3594 -0
- package/lib/MessageBuilder/metaai.d.ts +438 -0
- package/lib/MessageBuilder/metaai.js +891 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -0
- package/lib/Signal/Group/group-session-builder.js +30 -0
- package/lib/Signal/Group/group_cipher.js +93 -0
- package/lib/Signal/Group/index.js +12 -0
- package/lib/Signal/Group/keyhelper.js +18 -0
- package/lib/Signal/Group/queue-job.js +53 -0
- package/lib/Signal/Group/sender-chain-key.js +26 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
- package/lib/Signal/Group/sender-key-message.js +66 -0
- package/lib/Signal/Group/sender-key-name.js +48 -0
- package/lib/Signal/Group/sender-key-record.js +41 -0
- package/lib/Signal/Group/sender-key-state.js +84 -0
- package/lib/Signal/Group/sender-message-key.js +26 -0
- package/lib/Signal/libsignal.js +431 -0
- package/lib/Signal/lid-mapping.js +277 -0
- package/lib/Socket/Client/index.js +3 -0
- package/lib/Socket/Client/types.js +11 -0
- package/lib/Socket/Client/websocket.js +84 -0
- package/lib/Socket/ban-checker.js +265 -0
- package/lib/Socket/business.js +379 -0
- package/lib/Socket/chats.js +1193 -0
- package/lib/Socket/communities.js +431 -0
- package/lib/Socket/dugong.d.ts +130 -0
- package/lib/Socket/dugong.js +827 -0
- package/lib/Socket/groups.js +374 -0
- package/lib/Socket/index.js +18 -0
- package/lib/Socket/luxu.js +460 -0
- package/lib/Socket/messages-recv.js +1916 -0
- package/lib/Socket/messages-send.js +1704 -0
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.js +727 -0
- package/lib/Socket/socket.js +990 -0
- package/lib/Socket/username.js +234 -0
- package/lib/Store/index.js +10 -0
- package/lib/Store/keyed-db.js +108 -0
- package/lib/Store/make-cache-manager-store.js +85 -0
- package/lib/Store/make-in-memory-store.js +198 -0
- package/lib/Store/make-ordered-dictionary.js +75 -0
- package/lib/Store/object-repository.js +32 -0
- 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 +105 -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/lib/Utils/auth-store.d.ts +30 -0
- package/lib/Utils/auth-store.js +77 -0
- package/lib/Utils/auth-utils.js +302 -0
- package/lib/Utils/browser-utils.js +49 -0
- package/lib/Utils/business.js +231 -0
- package/lib/Utils/chat-utils.js +872 -0
- package/lib/Utils/classify-disconnect.js +126 -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 +401 -0
- package/lib/Utils/event-buffer.js +622 -0
- package/lib/Utils/generics.js +403 -0
- package/lib/Utils/group-metadata-cache.d.ts +5 -0
- package/lib/Utils/group-metadata-cache.js +26 -0
- package/lib/Utils/history.js +134 -0
- package/lib/Utils/html-app.d.ts +19 -0
- package/lib/Utils/html-app.js +97 -0
- package/lib/Utils/html-multiplayer.d.ts +10 -0
- package/lib/Utils/html-multiplayer.js +95 -0
- package/lib/Utils/identity-change-handler.js +50 -0
- package/lib/Utils/index.js +50 -0
- package/lib/Utils/link-preview-metadata.d.ts +47 -0
- package/lib/Utils/link-preview-metadata.js +89 -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/lib/Utils/make-mutex.js +33 -0
- package/lib/Utils/message-composer.js +273 -0
- package/lib/Utils/message-retry-manager.js +265 -0
- package/lib/Utils/messages-media.js +793 -0
- package/lib/Utils/messages.js +2037 -0
- package/lib/Utils/modern-messages.js +496 -0
- package/lib/Utils/native-flow.d.ts +11 -0
- package/lib/Utils/native-flow.js +136 -0
- package/lib/Utils/newsletter-status.js +651 -0
- package/lib/Utils/noise-handler.js +201 -0
- package/lib/Utils/offline-node-processor.js +34 -0
- package/lib/Utils/optional-media.d.ts +3 -0
- package/lib/Utils/optional-media.js +46 -0
- package/lib/Utils/payment-messages.d.ts +66 -0
- package/lib/Utils/payment-messages.js +161 -0
- package/lib/Utils/pre-key-manager.d.ts +26 -0
- package/lib/Utils/pre-key-manager.js +96 -0
- package/lib/Utils/process-message.js +630 -0
- package/lib/Utils/rate-limiter.js +228 -0
- package/lib/Utils/reporting-utils.js +258 -0
- package/lib/Utils/rich-message.js +720 -0
- package/lib/Utils/rich-messages.js +1144 -0
- package/lib/Utils/scheduled-message.d.ts +51 -0
- package/lib/Utils/scheduled-message.js +113 -0
- package/lib/Utils/sender-key-memory.d.ts +20 -0
- package/lib/Utils/sender-key-memory.js +52 -0
- package/lib/Utils/signal.js +201 -0
- package/lib/Utils/stanza-ack.js +38 -0
- package/lib/Utils/status-stickers.d.ts +127 -0
- package/lib/Utils/status-stickers.js +261 -0
- package/lib/Utils/sync-action-utils.d.ts +3 -0
- package/lib/Utils/sync-action-utils.js +45 -0
- package/lib/Utils/tc-token-utils.js +163 -0
- package/lib/Utils/ttl-cache.d.ts +29 -0
- package/lib/Utils/ttl-cache.js +121 -0
- package/lib/Utils/use-mongo-auth-state.d.ts +22 -0
- package/lib/Utils/use-mongo-auth-state.js +68 -0
- package/lib/Utils/use-multi-file-auth-state.js +121 -0
- package/lib/Utils/use-mysql-auth-state.d.ts +20 -0
- package/lib/Utils/use-mysql-auth-state.js +80 -0
- package/lib/Utils/use-postgres-auth-state.d.ts +20 -0
- package/lib/Utils/use-postgres-auth-state.js +80 -0
- package/lib/Utils/use-redis-auth-state.d.ts +20 -0
- package/lib/Utils/use-redis-auth-state.js +90 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-single-file-auth-state.js +109 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +13 -0
- package/lib/Utils/use-sqlite-auth-state.js +121 -0
- package/lib/Utils/useNekoDBAuth.d.ts +19 -0
- package/lib/Utils/useNekoDBAuth.js +111 -0
- package/lib/Utils/validate-connection.js +203 -0
- package/lib/Utils/voice-recognition.d.ts +53 -0
- package/lib/Utils/voice-recognition.js +219 -0
- package/lib/Voip/audio-feeder.d.ts +25 -0
- package/lib/Voip/audio-feeder.js +269 -0
- package/lib/Voip/index.d.ts +89 -0
- package/lib/Voip/index.js +937 -0
- package/lib/Voip/relay-transport.d.ts +6 -0
- package/lib/Voip/relay-transport.js +825 -0
- package/lib/Voip/signaling.d.ts +12 -0
- package/lib/Voip/signaling.js +1100 -0
- package/lib/Voip/types.d.ts +3 -0
- package/lib/Voip/types.js +13 -0
- package/lib/Voip/video-feeder.d.ts +25 -0
- package/lib/Voip/video-feeder.js +269 -0
- package/lib/Voip/wasm-engine.d.ts +27 -0
- package/lib/Voip/wasm-engine.js +1308 -0
- package/lib/Voip/worker-bootstrap.js +1024 -0
- package/lib/WABinary/constants.js +1301 -0
- package/lib/WABinary/decode.js +262 -0
- package/lib/WABinary/encode.js +220 -0
- 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/lib/WAM/BinaryInfo.js +10 -0
- package/lib/WAM/constants.js +22853 -0
- package/lib/WAM/encode.js +150 -0
- package/lib/WAM/index.js +4 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
- package/lib/WAUSync/Protocols/index.js +6 -0
- package/lib/WAUSync/USyncQuery.js +98 -0
- package/lib/WAUSync/USyncUser.js +31 -0
- package/lib/WAUSync/index.js +4 -0
- package/lib/assets/wasm/README.md +76 -0
- package/lib/assets/wasm/loader.js +5 -0
- package/lib/assets/wasm/whatsapp.wasm +0 -0
- package/lib/assets/wasm/worker-modules.js +273 -0
- package/lib/foundation/ai-rich.js +534 -0
- package/lib/foundation/license.js +122 -0
- package/lib/foundation/performance.js +385 -0
- package/lib/foundation/qrcode-terminal.js +273 -0
- package/lib/index.js +81 -0
- package/package.json +156 -5
package/README.md
CHANGED
|
@@ -1,3 +1,987 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://capsule-render.vercel.app/api?type=waving&height=220&color=0:ff6b6b,40:f06595,100:845ef7&text=supun-bailey-vip&fontAlignY=40&fontSize=44&fontColor=ffffff&desc=All-in-One%20Modern%20WhatsApp%20Web%20API%20for%20Production%20Bots&descAlignY=60&descSize=16" alt="Header Banner" />
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
<br/>
|
|
5
|
+
|
|
6
|
+
<a href="https://supunofc.site">
|
|
7
|
+
<kbd>
|
|
8
|
+
<img src="https://i.ibb.co/KjfHTDhN/file-00000000a86881f8801b23682cb9bf66.png" alt="WhatsApp Baileys 2026" width="720" />
|
|
9
|
+
</kbd>
|
|
10
|
+
</a>
|
|
11
|
+
|
|
12
|
+
<br/><br/>
|
|
13
|
+
|
|
14
|
+
# 🧑💻 supun-bailey-vip 🇱🇰
|
|
15
|
+
|
|
16
|
+
<p>
|
|
17
|
+
<img src="https://img.shields.io/badge/Node.js-%3E%3D20-339933?style=for-the-badge&logo=nodedotjs&logoColor=white" />
|
|
18
|
+
<img src="https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white" />
|
|
19
|
+
<img src="https://img.shields.io/badge/WebSocket-010101?style=for-the-badge&logo=socketdotio&logoColor=white" />
|
|
20
|
+
<img src="https://img.shields.io/badge/MessageBuilder-v4.7-7F5AF0?style=for-the-badge" />
|
|
21
|
+
<img src="https://img.shields.io/badge/VoIP-Audio%20%26%20Video-blue?style=for-the-badge" />
|
|
22
|
+
<img src="https://img.shields.io/badge/Open%20Source-FF4500?style=for-the-badge&logo=github&logoColor=white" />
|
|
23
|
+
<img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge" />
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
<p>
|
|
27
|
+
<img src="https://img.shields.io/npm/v/supun-bailey-vip?style=flat-square&color=25D366&label=npm" />
|
|
28
|
+
<img src="https://img.shields.io/badge/maintained%20by-Supun%20Fernando-black?style=flat-square" />
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
**Next-generation, all-in-one WhatsApp automation library — no browser required.**
|
|
32
|
+
High performance, enterprise-grade Baileys protocol engine featuring **Pairing Code & Terminal QR**, **MessageBuilder v4.7**, **VoIP Voice/Video Calls**, **Dugong Cloud Engine**, **Performance Latency Tuning**, **Multi-DB Auth**, and **Meta AI Rich Responses**.
|
|
33
|
+
|
|
34
|
+
<br/>
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 📑 Table of Contents
|
|
41
|
+
|
|
42
|
+
- [✨ Overview](#-overview)
|
|
43
|
+
- [📦 Installation](#-installation)
|
|
44
|
+
- [🔑 Authentication & Connection](#-authentication--connection)
|
|
45
|
+
- [1. Zero-Dependency Terminal QR](#1-zero-dependency-terminal-qr)
|
|
46
|
+
- [2. Pairing Code Authentication](#2-pairing-code-authentication-phone-number)
|
|
47
|
+
- [3. Connection Handling & Reconnection](#3-connection-handling--auto-reconnection)
|
|
48
|
+
- [🗄️ Multi-Database Auth States](#️-multi-database-auth-states)
|
|
49
|
+
- [⚙️ Configuration Options](#️-configuration-options)
|
|
50
|
+
- [📡 Event Handling](#-event-handling)
|
|
51
|
+
- [✉️ Sending Messages](#️-sending-messages)
|
|
52
|
+
- [Text & Mentions](#text--mentions)
|
|
53
|
+
- [Replying & Quoted Messages](#replying--quoted-messages)
|
|
54
|
+
- [Media (Image, Video, Audio, Document, Sticker)](#media-messages)
|
|
55
|
+
- [Downloading Received Media](#downloading-received-media)
|
|
56
|
+
- [Reactions](#message-reactions)
|
|
57
|
+
- [Editing & Deleting Messages](#editing--deleting-messages)
|
|
58
|
+
- [Pinning Messages](#pinning-messages)
|
|
59
|
+
- [Standard Polls & Photo Polls](#polls--photo-polls)
|
|
60
|
+
- [Location & Button Location](#location-messages)
|
|
61
|
+
- [Contacts / vCards](#contact-messages)
|
|
62
|
+
- [Rich Links & Songs with Album Art](#rich-links--music-cards)
|
|
63
|
+
- [🎨 MessageBuilder v4.7 (Buttons & Carousels)](#-messagebuilder-v47-buttons--carousels)
|
|
64
|
+
- [☁️ Dugong Cloud Engine (`sock.cloud`)](#️-dugong-cloud-engine-sockcloud)
|
|
65
|
+
- [📢 Status & Stories](#-status--stories)
|
|
66
|
+
- [👥 Group Management](#-group-management)
|
|
67
|
+
- [🏘️ Communities Management](#️-communities-management)
|
|
68
|
+
- [📰 Newsletters (Channels)](#-newsletters-channels)
|
|
69
|
+
- [🔒 Privacy & Profile Management](#-privacy--profile-management)
|
|
70
|
+
- [📞 VoIP Audio & Video Calls](#-voip-audio--video-calls)
|
|
71
|
+
- [🚫 4-Factor Ban Checker](#-4-factor-ban-checker)
|
|
72
|
+
- [🆔 WhatsApp MEX Username API](#-whatsapp-mex-username-api)
|
|
73
|
+
- [⚡ Performance Tuning & Modes](#-performance-tuning--modes)
|
|
74
|
+
- [💾 In-Memory Store](#-in-memory-store)
|
|
75
|
+
- [🌐 Community & Support](#-community--support)
|
|
76
|
+
- [📄 License](#-license)
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## ✨ Overview
|
|
81
|
+
|
|
82
|
+
**`supun-bailey-vip`** is a complete, standalone, modern WhatsApp Web WebSocket client designed for Node.js (ESM). It communicates directly with WhatsApp servers without any headless browser (like Puppeteer/Chromium), saving over 90% CPU and RAM.
|
|
83
|
+
|
|
84
|
+
### 🌟 Key Highlights:
|
|
85
|
+
- **Ultra-Lightweight & Fast**: Direct WebSocket communication with Noise protocol encryption.
|
|
86
|
+
- **Pairing Code & Built-in QR**: Connect via 8-digit OTP pairing code or zero-dependency terminal QR.
|
|
87
|
+
- **MessageBuilder v4.7**: Fluent chaining API for CTA buttons, carousels, cards, and flows.
|
|
88
|
+
- **Dugong Cloud Engine**: High-level dispatcher for albums, payments, products, interactive messages, and group stories.
|
|
89
|
+
- **VoIP Calling Engine**: Handle, accept, or reject WhatsApp voice and video calls.
|
|
90
|
+
- **Multi-DB Auth**: Ready-to-use adapters for MongoDB, Redis, PostgreSQL, MySQL, SQLite, Multi-file, and NekoDB.
|
|
91
|
+
- **4-Factor Ban Checker**: Check phone number status against WhatsApp infrastructure.
|
|
92
|
+
- **Username Support**: WhatsApp MEX GraphQL API for username query, registration, and lookup.
|
|
93
|
+
- **Performance Modes**: Configurable presets (`balanced`, `high`, `low-memory`, `ultra-low-latency`).
|
|
94
|
+
|
|
95
|
+
> ⚡ **Node.js ≥ 20 is required.** (Native ESM Module)
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 📦 Installation
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Using pnpm (Recommended)
|
|
103
|
+
pnpm add supun-bailey-vip
|
|
104
|
+
|
|
105
|
+
# Or using npm
|
|
106
|
+
npm install supun-bailey-vip
|
|
107
|
+
|
|
108
|
+
# Or using yarn
|
|
109
|
+
yarn add supun-bailey-vip
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 🔑 Authentication & Connection
|
|
115
|
+
|
|
116
|
+
### 1. Zero-Dependency Terminal QR
|
|
117
|
+
|
|
118
|
+
Scan the QR code printed straight to your terminal without installing external packages like `qrcode-terminal`:
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
import makeWASocket, { useMultiFileAuthState, generateQR } from 'supun-bailey-vip'
|
|
122
|
+
|
|
123
|
+
const { state, saveCreds } = await useMultiFileAuthState('./session')
|
|
124
|
+
|
|
125
|
+
const sock = makeWASocket({
|
|
126
|
+
auth: state,
|
|
127
|
+
key: 'YOUR_ACCESS_KEY', // VIP access key (Required)
|
|
128
|
+
performanceMode: 'high',
|
|
129
|
+
syncFullHistory: false
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
sock.ev.on('connection.update', ({ connection, qr, lastDisconnect }) => {
|
|
133
|
+
if (qr) {
|
|
134
|
+
// Render compact ASCII QR in terminal
|
|
135
|
+
generateQR(qr, { small: true })
|
|
136
|
+
}
|
|
137
|
+
if (connection === 'open') {
|
|
138
|
+
console.log('✅ Connected successfully!')
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
sock.ev.on('creds.update', saveCreds)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
### 2. Pairing Code Authentication (Phone Number)
|
|
148
|
+
|
|
149
|
+
Connect headless servers, VPS, or Termux without scanning QR codes:
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
import makeWASocket, { useMultiFileAuthState, delay } from 'supun-bailey-vip'
|
|
153
|
+
|
|
154
|
+
const { state, saveCreds } = await useMultiFileAuthState('./session')
|
|
155
|
+
|
|
156
|
+
const sock = makeWASocket({
|
|
157
|
+
auth: state,
|
|
158
|
+
printQRInTerminal: false,
|
|
159
|
+
syncFullHistory: false
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
// Check if credentials are not yet paired
|
|
163
|
+
if (!sock.authState.creds.registered) {
|
|
164
|
+
const phoneNumber = '94712345678' // Phone number with country code, no + or spaces
|
|
165
|
+
await delay(3000)
|
|
166
|
+
const code = await sock.requestPairingCode(phoneNumber)
|
|
167
|
+
console.log(`\n🔑 Your Pairing Code: ${code}\n`)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
sock.ev.on('creds.update', saveCreds)
|
|
171
|
+
|
|
172
|
+
sock.ev.on('connection.update', ({ connection }) => {
|
|
173
|
+
if (connection === 'open') {
|
|
174
|
+
console.log('✅ Connected via Pairing Code!')
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
### 3. Connection Handling & Auto-Reconnection
|
|
182
|
+
|
|
183
|
+
Handle connection states, network drops, and logout events gracefully:
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
import makeWASocket, {
|
|
187
|
+
useMultiFileAuthState,
|
|
188
|
+
DisconnectReason
|
|
189
|
+
} from 'supun-bailey-vip'
|
|
190
|
+
import { Boom } from '@hapi/boom'
|
|
191
|
+
|
|
192
|
+
async function connectToWhatsApp() {
|
|
193
|
+
const { state, saveCreds } = await useMultiFileAuthState('./session')
|
|
194
|
+
|
|
195
|
+
const sock = makeWASocket({
|
|
196
|
+
auth: state,
|
|
197
|
+
performanceMode: 'balanced',
|
|
198
|
+
syncFullHistory: false
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
sock.ev.on('connection.update', (update) => {
|
|
202
|
+
const { connection, lastDisconnect } = update
|
|
203
|
+
|
|
204
|
+
if (connection === 'close') {
|
|
205
|
+
const statusCode = (lastDisconnect?.error instanceof Boom)
|
|
206
|
+
? lastDisconnect.error.output.statusCode
|
|
207
|
+
: undefined
|
|
208
|
+
|
|
209
|
+
const shouldReconnect = statusCode !== DisconnectReason.loggedOut
|
|
210
|
+
|
|
211
|
+
console.log(`Connection closed due to: ${lastDisconnect?.error}, reconnecting: ${shouldReconnect}`)
|
|
212
|
+
|
|
213
|
+
if (shouldReconnect) {
|
|
214
|
+
connectToWhatsApp() // Auto-reconnect
|
|
215
|
+
} else {
|
|
216
|
+
console.log('❌ Logged out. Session deleted or invalid.')
|
|
217
|
+
}
|
|
218
|
+
} else if (connection === 'open') {
|
|
219
|
+
console.log('🎉 Successfully connected to WhatsApp!')
|
|
220
|
+
}
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
sock.ev.on('creds.update', saveCreds)
|
|
224
|
+
return sock
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
connectToWhatsApp()
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 🗄️ Multi-Database Auth States
|
|
233
|
+
|
|
234
|
+
Store your session data seamlessly across multiple database engines:
|
|
235
|
+
|
|
236
|
+
### Multi-File (Default)
|
|
237
|
+
```javascript
|
|
238
|
+
import { useMultiFileAuthState } from 'supun-bailey-vip'
|
|
239
|
+
const { state, saveCreds } = await useMultiFileAuthState('./auth_info')
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### MongoDB
|
|
243
|
+
```javascript
|
|
244
|
+
import { useMongoAuthState } from 'supun-bailey-vip'
|
|
245
|
+
import { MongoClient } from 'mongodb'
|
|
246
|
+
|
|
247
|
+
const client = new MongoClient('mongodb://localhost:27017')
|
|
248
|
+
await client.connect()
|
|
249
|
+
const collection = client.db('whatsapp').collection('auth')
|
|
250
|
+
|
|
251
|
+
const { state, saveCreds } = await useMongoAuthState(collection)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Redis
|
|
255
|
+
```javascript
|
|
256
|
+
import { useRedisAuthState } from 'supun-bailey-vip'
|
|
257
|
+
import { createClient } from 'redis'
|
|
258
|
+
|
|
259
|
+
const redis = createClient({ url: 'redis://localhost:6379' })
|
|
260
|
+
await redis.connect()
|
|
261
|
+
|
|
262
|
+
const { state, saveCreds } = await useRedisAuthState(redis, 'bot-session')
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### PostgreSQL
|
|
266
|
+
```javascript
|
|
267
|
+
import { usePostgresAuthState } from 'supun-bailey-vip'
|
|
268
|
+
import pg from 'pg'
|
|
269
|
+
|
|
270
|
+
const pool = new pg.Pool({ connectionString: 'postgres://user:pass@localhost:5432/db' })
|
|
271
|
+
const { state, saveCreds } = await usePostgresAuthState(pool, 'session_table')
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### MySQL
|
|
275
|
+
```javascript
|
|
276
|
+
import { useMySQLAuthState } from 'supun-bailey-vip'
|
|
277
|
+
import mysql from 'mysql2/promise'
|
|
278
|
+
|
|
279
|
+
const connection = await mysql.createConnection('mysql://user:pass@localhost:3306/db')
|
|
280
|
+
const { state, saveCreds } = await useMySQLAuthState(connection, 'sessions')
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### SQLite
|
|
284
|
+
```javascript
|
|
285
|
+
import { useSQLiteAuthState } from 'supun-bailey-vip'
|
|
286
|
+
const { state, saveCreds } = await useSQLiteAuthState('./session.sqlite')
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## ⚙️ Configuration Options
|
|
292
|
+
|
|
293
|
+
Full list of socket configuration parameters passed to `makeWASocket(config)`:
|
|
294
|
+
|
|
295
|
+
| Option | Type | Default | Description |
|
|
296
|
+
|---|---|---|---|
|
|
297
|
+
| `key` / `accessKey` | `string` | `process.env.SUPUN_KEY` | VIP License key (Required). Contact Supun Fernando to obtain. |
|
|
298
|
+
| `auth` | `AuthenticationState` | `undefined` | Auth credentials state & keys |
|
|
299
|
+
| `performanceMode` | `string` | `'balanced'` | `'balanced'` \| `'high'` \| `'low-memory'` \| `'ultra-low-latency'` |
|
|
300
|
+
| `syncFullHistory` | `boolean` | `true` | Download complete chat history upon startup |
|
|
301
|
+
| `aiLabel` | `boolean` | `true` | Mark outbound messages with AI bot label |
|
|
302
|
+
| `browser` | `[string, string, string]` | `Browsers.macOS('Chrome')` | Browser signature sent to WhatsApp |
|
|
303
|
+
| `printQRInTerminal` | `boolean` | `false` | Whether default QR prints in terminal |
|
|
304
|
+
| `logger` | `PinoLogger` | Internal logger | Custom Pino logger instance |
|
|
305
|
+
| `markOnlineOnConnect` | `boolean` | `true` | Set presence online when socket opens |
|
|
306
|
+
| `connectTimeoutMs` | `number` | `20000` | Socket connect timeout in ms |
|
|
307
|
+
| `keepAliveIntervalMs` | `number` | `30000` | Keepalive ping interval |
|
|
308
|
+
| `defaultQueryTimeoutMs`| `number` | `60000` | Default timeout for queries |
|
|
309
|
+
| `maxMsgRetryCount` | `number` | `5` | Retries for decrypting messages |
|
|
310
|
+
| `emitOwnEvents` | `boolean` | `true` | Emit messages sent by this client |
|
|
311
|
+
| `noSelfSync` | `boolean` | `false` | Skip syncing messages to companion devices |
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## 📡 Event Handling
|
|
316
|
+
|
|
317
|
+
Listen to WhatsApp updates using `sock.ev.on(...)` or batch process them via `sock.ev.process(...)`:
|
|
318
|
+
|
|
319
|
+
```javascript
|
|
320
|
+
// Incoming & outgoing messages
|
|
321
|
+
sock.ev.on('messages.upsert', async ({ messages, type }) => {
|
|
322
|
+
for (const msg of messages) {
|
|
323
|
+
if (!msg.message) continue
|
|
324
|
+
const from = msg.key.remoteJid
|
|
325
|
+
const isGroup = from.endsWith('@g.us')
|
|
326
|
+
const sender = isGroup ? msg.key.participant : from
|
|
327
|
+
const text = msg.message.conversation || msg.message.extendedTextMessage?.text
|
|
328
|
+
|
|
329
|
+
console.log(`Message from ${sender}: ${text}`)
|
|
330
|
+
|
|
331
|
+
// Simple echo response
|
|
332
|
+
if (text === '!ping') {
|
|
333
|
+
await sock.sendMessage(from, { text: 'Pong! 🏓' }, { quoted: msg })
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
// Message updates (read receipts, delivery status)
|
|
339
|
+
sock.ev.on('messages.update', (updates) => {
|
|
340
|
+
for (const update of updates) {
|
|
341
|
+
console.log(`Message ${update.key.id} status updated to: ${update.update.status}`)
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
// Reactions
|
|
346
|
+
sock.ev.on('messages.reaction', (reactions) => {
|
|
347
|
+
for (const { key, reaction } of reactions) {
|
|
348
|
+
console.log(`Reaction ${reaction.text} on message ${key.id}`)
|
|
349
|
+
}
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
// Group updates (members join/leave, promotes)
|
|
353
|
+
sock.ev.on('group-participants.update', async ({ id, participants, action }) => {
|
|
354
|
+
console.log(`Group: ${id} | Action: ${action} | Users: ${participants.join(', ')}`)
|
|
355
|
+
})
|
|
356
|
+
|
|
357
|
+
// Incoming Voice & Video Calls
|
|
358
|
+
sock.ev.on('call', async (calls) => {
|
|
359
|
+
for (const call of calls) {
|
|
360
|
+
console.log(`Call from ${call.from} | Status: ${call.status} | Video: ${call.isVideo}`)
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## ✉️ Sending Messages
|
|
368
|
+
|
|
369
|
+
### Text & Mentions
|
|
370
|
+
|
|
371
|
+
```javascript
|
|
372
|
+
// Simple Text
|
|
373
|
+
await sock.sendMessage(jid, { text: 'Hello, World!' })
|
|
374
|
+
|
|
375
|
+
// Text with Mentions
|
|
376
|
+
await sock.sendMessage(jid, {
|
|
377
|
+
text: 'Hello @94712345678 and @94787654321!',
|
|
378
|
+
mentions: ['94712345678@s.whatsapp.net', '94787654321@s.whatsapp.net']
|
|
379
|
+
})
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Replying & Quoted Messages
|
|
383
|
+
|
|
384
|
+
```javascript
|
|
385
|
+
// Quote a message received from messages.upsert
|
|
386
|
+
await sock.sendMessage(jid, { text: 'This is a reply!' }, { quoted: msg })
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Media Messages
|
|
390
|
+
|
|
391
|
+
```javascript
|
|
392
|
+
import fs from 'fs'
|
|
393
|
+
|
|
394
|
+
// 1. Image
|
|
395
|
+
await sock.sendMessage(jid, {
|
|
396
|
+
image: fs.readFileSync('./photo.jpg'), // or { url: 'https://example.com/photo.jpg' }
|
|
397
|
+
caption: '🖼️ Beautiful picture!'
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
// 2. Video & GIF
|
|
401
|
+
await sock.sendMessage(jid, {
|
|
402
|
+
video: fs.readFileSync('./video.mp4'),
|
|
403
|
+
caption: '🎥 Sample Video',
|
|
404
|
+
gifPlayback: false // set true to loop as GIF
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
// 3. Audio & Voice Note (PTT)
|
|
408
|
+
await sock.sendMessage(jid, {
|
|
409
|
+
audio: fs.readFileSync('./audio.mp3'),
|
|
410
|
+
mimetype: 'audio/mp4',
|
|
411
|
+
ptt: true // set true to send as Voice Recording
|
|
412
|
+
})
|
|
413
|
+
|
|
414
|
+
// 4. Document
|
|
415
|
+
await sock.sendMessage(jid, {
|
|
416
|
+
document: fs.readFileSync('./manual.pdf'),
|
|
417
|
+
mimetype: 'application/pdf',
|
|
418
|
+
fileName: 'UserManual.pdf'
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
// 5. Sticker
|
|
422
|
+
await sock.sendMessage(jid, {
|
|
423
|
+
sticker: fs.readFileSync('./sticker.webp')
|
|
424
|
+
})
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Downloading Received Media
|
|
428
|
+
|
|
429
|
+
```javascript
|
|
430
|
+
import { downloadMediaMessage } from 'supun-bailey-vip'
|
|
431
|
+
import fs from 'fs'
|
|
432
|
+
|
|
433
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
434
|
+
const m = messages[0]
|
|
435
|
+
const messageType = Object.keys(m.message || {})[0]
|
|
436
|
+
|
|
437
|
+
if (['imageMessage', 'videoMessage', 'audioMessage', 'documentMessage', 'stickerMessage'].includes(messageType)) {
|
|
438
|
+
// Download directly to Buffer
|
|
439
|
+
const buffer = await downloadMediaMessage(
|
|
440
|
+
m,
|
|
441
|
+
'buffer',
|
|
442
|
+
{},
|
|
443
|
+
{ logger: console, reuploadRequest: sock.updateMediaMessage }
|
|
444
|
+
)
|
|
445
|
+
fs.writeFileSync('./downloaded_file', buffer)
|
|
446
|
+
console.log('✅ Media downloaded successfully!')
|
|
447
|
+
}
|
|
448
|
+
})
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### Message Reactions
|
|
452
|
+
|
|
453
|
+
```javascript
|
|
454
|
+
// Add Reaction
|
|
455
|
+
await sock.sendMessage(jid, {
|
|
456
|
+
react: {
|
|
457
|
+
text: '🔥',
|
|
458
|
+
key: msg.key
|
|
459
|
+
}
|
|
460
|
+
})
|
|
461
|
+
|
|
462
|
+
// Remove Reaction
|
|
463
|
+
await sock.sendMessage(jid, {
|
|
464
|
+
react: {
|
|
465
|
+
text: '',
|
|
466
|
+
key: msg.key
|
|
467
|
+
}
|
|
468
|
+
})
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Editing & Deleting Messages
|
|
472
|
+
|
|
473
|
+
```javascript
|
|
474
|
+
// Edit a previously sent message
|
|
475
|
+
await sock.sendMessage(jid, {
|
|
476
|
+
text: 'Updated text content',
|
|
477
|
+
edit: sentMessage.key
|
|
478
|
+
})
|
|
479
|
+
|
|
480
|
+
// Delete for everyone (Your message)
|
|
481
|
+
await sock.sendMessage(jid, { delete: sentMessage.key })
|
|
482
|
+
|
|
483
|
+
// Admin delete someone else's message in group
|
|
484
|
+
await sock.sendMessage(groupJid, {
|
|
485
|
+
delete: {
|
|
486
|
+
remoteJid: groupJid,
|
|
487
|
+
fromMe: false,
|
|
488
|
+
id: targetMessage.key.id,
|
|
489
|
+
participant: targetMessage.key.participant
|
|
490
|
+
}
|
|
491
|
+
})
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### Pinning Messages
|
|
495
|
+
|
|
496
|
+
```javascript
|
|
497
|
+
import { proto } from 'supun-bailey-vip'
|
|
498
|
+
|
|
499
|
+
// Pin for 24 Hours, 7 Days, or 30 Days
|
|
500
|
+
await sock.sendMessage(jid, {
|
|
501
|
+
pin: msg.key,
|
|
502
|
+
type: proto.PinInChat.Type.PIN_FOR_24H // or PIN_FOR_7D / PIN_FOR_30D / UNPIN
|
|
503
|
+
})
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### Polls & Photo Polls
|
|
507
|
+
|
|
508
|
+
```javascript
|
|
509
|
+
// 1. Standard Poll
|
|
510
|
+
await sock.sendMessage(jid, {
|
|
511
|
+
poll: {
|
|
512
|
+
name: 'What is your favorite color?',
|
|
513
|
+
values: ['Blue', 'Red', 'Green'],
|
|
514
|
+
selectableCount: 1
|
|
515
|
+
}
|
|
516
|
+
})
|
|
517
|
+
|
|
518
|
+
// 2. Photo Poll (Options with images!)
|
|
519
|
+
await sock.sendMessage(jid, {
|
|
520
|
+
photoPoll: {
|
|
521
|
+
name: 'Choose the best logo design:',
|
|
522
|
+
values: [
|
|
523
|
+
{ name: 'Concept 1', image: fs.readFileSync('./logo1.png') },
|
|
524
|
+
{ name: 'Concept 2', image: fs.readFileSync('./logo2.png') }
|
|
525
|
+
],
|
|
526
|
+
selectableCount: 1
|
|
527
|
+
}
|
|
528
|
+
})
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Location Messages
|
|
532
|
+
|
|
533
|
+
```javascript
|
|
534
|
+
// Standard Location
|
|
535
|
+
await sock.sendMessage(jid, {
|
|
536
|
+
location: {
|
|
537
|
+
degreesLatitude: 6.9271,
|
|
538
|
+
degreesLongitude: 79.8612,
|
|
539
|
+
name: 'Colombo, Sri Lanka'
|
|
540
|
+
}
|
|
541
|
+
})
|
|
542
|
+
|
|
543
|
+
// Button Location (Interactive Location Card)
|
|
544
|
+
await sock.sendMessage(jid, {
|
|
545
|
+
buttonLocation: {
|
|
546
|
+
latitude: 6.9271,
|
|
547
|
+
longitude: 79.8612,
|
|
548
|
+
title: 'Main Headquarters',
|
|
549
|
+
text: 'Visit us for more details',
|
|
550
|
+
footer: 'Colombo, SL',
|
|
551
|
+
thumbnail: fs.readFileSync('./office.jpg'),
|
|
552
|
+
buttons: [
|
|
553
|
+
{ id: 'dir_btn', text: 'Get Directions' }
|
|
554
|
+
]
|
|
555
|
+
}
|
|
556
|
+
})
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
### Contact Messages
|
|
560
|
+
|
|
561
|
+
```javascript
|
|
562
|
+
const vcard = 'BEGIN:VCARD\n'
|
|
563
|
+
+ 'VERSION:3.0\n'
|
|
564
|
+
+ 'FN:Supun Fernando\n'
|
|
565
|
+
+ 'ORG:Supun MD;\n'
|
|
566
|
+
+ 'TEL;type=CELL;type=VOICE;waid=94712345678:+94 71 234 5678\n'
|
|
567
|
+
+ 'END:VCARD'
|
|
568
|
+
|
|
569
|
+
await sock.sendMessage(jid, {
|
|
570
|
+
contacts: {
|
|
571
|
+
displayName: 'Supun Fernando',
|
|
572
|
+
contacts: [{ vcard }]
|
|
573
|
+
}
|
|
574
|
+
})
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### Rich Links & Music Cards
|
|
578
|
+
|
|
579
|
+
```javascript
|
|
580
|
+
// 1. Rich Link Preview Card
|
|
581
|
+
await sock.sendMessage(jid, {
|
|
582
|
+
richLink: {
|
|
583
|
+
text: 'Explore supun-bailey-vip documentation!',
|
|
584
|
+
url: 'https://supunofc.site',
|
|
585
|
+
title: 'supun-bailey-vip — The Ultimate Baileys Stack',
|
|
586
|
+
description: 'Complete documentation, examples, and guides.',
|
|
587
|
+
image: fs.readFileSync('./banner.jpg'),
|
|
588
|
+
large: true
|
|
589
|
+
}
|
|
590
|
+
})
|
|
591
|
+
|
|
592
|
+
// 2. Song with Album Art
|
|
593
|
+
await sock.sendMessage(jid, {
|
|
594
|
+
song: {
|
|
595
|
+
audio: fs.readFileSync('./track.mp3'),
|
|
596
|
+
title: 'Cyberpulse Track',
|
|
597
|
+
author: 'Supun Fernando',
|
|
598
|
+
artwork: fs.readFileSync('./cover.jpg'),
|
|
599
|
+
url: 'https://supunofc.site'
|
|
600
|
+
}
|
|
601
|
+
})
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
---
|
|
605
|
+
|
|
606
|
+
## 🎨 MessageBuilder v4.7 (Buttons & Carousels)
|
|
607
|
+
|
|
608
|
+
Easily construct modern WhatsApp interactive messages using fluent chainable builders:
|
|
609
|
+
|
|
610
|
+
```javascript
|
|
611
|
+
import { Button, Carousel, AIRich } from 'supun-bailey-vip'
|
|
612
|
+
|
|
613
|
+
// 1. Interactive CTA Buttons
|
|
614
|
+
const buttonMsg = new Button()
|
|
615
|
+
.setTitle('Welcome to Supun-MD')
|
|
616
|
+
.setBody('Please select an option from the menu:')
|
|
617
|
+
.setFooter('Powered by supun-bailey-vip')
|
|
618
|
+
.addReply('Quick Reply', 'btn_1')
|
|
619
|
+
.addUrl('Visit Website', 'https://supunofc.site')
|
|
620
|
+
.addCall('Call Support', '+94712345678')
|
|
621
|
+
.addCopy('Copy Promo Code', 'SUPUN2026')
|
|
622
|
+
.run()
|
|
623
|
+
|
|
624
|
+
await sock.sendMessage(jid, buttonMsg)
|
|
625
|
+
|
|
626
|
+
// 2. Multi-Card Interactive Carousel
|
|
627
|
+
const carousel = new Carousel()
|
|
628
|
+
.setTitle('Featured Products')
|
|
629
|
+
.setBody('Browse our top selections:')
|
|
630
|
+
.setFooter('Swipe cards to explore')
|
|
631
|
+
|
|
632
|
+
carousel.addCard({
|
|
633
|
+
image: { url: 'https://example.com/product1.jpg' },
|
|
634
|
+
title: 'Smart Watch Series 9',
|
|
635
|
+
caption: 'Water-resistant, AMOLED display, 5-day battery.',
|
|
636
|
+
nativeFlow: [
|
|
637
|
+
{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Buy Now', id: 'buy_1' }) },
|
|
638
|
+
{ name: 'cta_url', buttonParamsJson: JSON.stringify({ display_text: 'Specs', url: 'https://supunofc.site' }) }
|
|
639
|
+
]
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
carousel.addCard({
|
|
643
|
+
image: { url: 'https://example.com/product2.jpg' },
|
|
644
|
+
title: 'Wireless Earbuds Pro',
|
|
645
|
+
caption: 'Active Noise Cancellation and 30-hour playback.',
|
|
646
|
+
nativeFlow: [
|
|
647
|
+
{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Buy Now', id: 'buy_2' }) }
|
|
648
|
+
]
|
|
649
|
+
})
|
|
650
|
+
|
|
651
|
+
await sock.sendMessage(jid, carousel.run())
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
---
|
|
655
|
+
|
|
656
|
+
## ☁️ Dugong Cloud Engine (`sock.cloud`)
|
|
657
|
+
|
|
658
|
+
Access Dugong high-level interactive handlers directly:
|
|
659
|
+
|
|
660
|
+
```javascript
|
|
661
|
+
// 1. Native Interactive Buttons via Dugong
|
|
662
|
+
await sock.cloud.handleInteractiveButtons({
|
|
663
|
+
title: 'Bot Dashboard',
|
|
664
|
+
text: 'Choose your desired service below:',
|
|
665
|
+
footer: 'supun-bailey-vip system',
|
|
666
|
+
buttons: [
|
|
667
|
+
{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Status Check', id: 'st_1' }) },
|
|
668
|
+
{ name: 'cta_url', buttonParamsJson: JSON.stringify({ display_text: 'Documentation', url: 'https://supunofc.site' }) }
|
|
669
|
+
]
|
|
670
|
+
}, jid, quoted)
|
|
671
|
+
|
|
672
|
+
// 2. Album Messages (Group multiple photos/videos into one album card)
|
|
673
|
+
await sock.cloud.handleAlbum([
|
|
674
|
+
{ image: fs.readFileSync('./img1.jpg'), caption: 'Photo 1' },
|
|
675
|
+
{ image: fs.readFileSync('./img2.jpg'), caption: 'Photo 2' }
|
|
676
|
+
], jid, quoted)
|
|
677
|
+
|
|
678
|
+
// 3. Payment Request
|
|
679
|
+
await sock.cloud.handlePayment({
|
|
680
|
+
amount1000: 2500000, // 2500.00
|
|
681
|
+
currencyCode: 'USD',
|
|
682
|
+
note: 'Invoice #1042'
|
|
683
|
+
}, quoted)
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
---
|
|
687
|
+
|
|
688
|
+
## 📢 Status & Stories
|
|
689
|
+
|
|
690
|
+
Share updates to WhatsApp Status (`status@broadcast`):
|
|
691
|
+
|
|
692
|
+
```javascript
|
|
693
|
+
// 1. Text Status
|
|
694
|
+
await sock.sendMessage('status@broadcast', {
|
|
695
|
+
text: '🚀 Testing supun-bailey-vip status feature!'
|
|
696
|
+
}, {
|
|
697
|
+
backgroundColor: '#3b82f6',
|
|
698
|
+
font: 2
|
|
699
|
+
})
|
|
700
|
+
|
|
701
|
+
// 2. Image / Video Status
|
|
702
|
+
await sock.sendMessage('status@broadcast', {
|
|
703
|
+
image: fs.readFileSync('./status.jpg'),
|
|
704
|
+
caption: 'Good morning everyone! ☀️'
|
|
705
|
+
})
|
|
706
|
+
|
|
707
|
+
// 3. Private Status with Mentions (Visible only to target JIDs)
|
|
708
|
+
await sock.sendStatusMention({
|
|
709
|
+
image: { url: 'https://example.com/banner.jpg' },
|
|
710
|
+
caption: 'Exclusive update for VIP members!'
|
|
711
|
+
}, ['94712345678@s.whatsapp.net', '94787654321@s.whatsapp.net'])
|
|
712
|
+
|
|
713
|
+
// 4. Group Status Story (swgc)
|
|
714
|
+
await sock.swgc(groupJid, {
|
|
715
|
+
image: fs.readFileSync('./announcement.jpg'),
|
|
716
|
+
caption: 'Official group announcement!'
|
|
717
|
+
})
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
---
|
|
721
|
+
|
|
722
|
+
## 👥 Group Management
|
|
723
|
+
|
|
724
|
+
Comprehensive controls for WhatsApp Groups:
|
|
725
|
+
|
|
726
|
+
```javascript
|
|
727
|
+
// Create Group
|
|
728
|
+
const group = await sock.groupCreate('My VIP Group', [
|
|
729
|
+
'94712345678@s.whatsapp.net',
|
|
730
|
+
'94787654321@s.whatsapp.net'
|
|
731
|
+
])
|
|
732
|
+
|
|
733
|
+
// Get Group Details
|
|
734
|
+
const metadata = await sock.groupMetadata(groupJid)
|
|
735
|
+
console.log(`Group Name: ${metadata.subject}, Members: ${metadata.participants.length}`)
|
|
736
|
+
|
|
737
|
+
// Manage Participants ('add' | 'remove' | 'promote' | 'demote')
|
|
738
|
+
await sock.groupParticipantsUpdate(groupJid, ['94712345678@s.whatsapp.net'], 'promote')
|
|
739
|
+
await sock.groupParticipantsUpdate(groupJid, ['94712345678@s.whatsapp.net'], 'remove')
|
|
740
|
+
|
|
741
|
+
// Change Group Name & Description
|
|
742
|
+
await sock.groupUpdateSubject(groupJid, 'New Group Name')
|
|
743
|
+
await sock.groupUpdateDescription(groupJid, 'Updated rules and info')
|
|
744
|
+
|
|
745
|
+
// Settings: Lock info editing & announcement mode
|
|
746
|
+
await sock.groupSettingUpdate(groupJid, 'locked') // only admins edit info
|
|
747
|
+
await sock.groupSettingUpdate(groupJid, 'announcement') // only admins send messages
|
|
748
|
+
|
|
749
|
+
// Invite Links
|
|
750
|
+
const code = await sock.groupInviteCode(groupJid)
|
|
751
|
+
console.log(`Invite link: https://chat.whatsapp.com/${code}`)
|
|
752
|
+
await sock.groupRevokeInvite(groupJid) // Revoke link
|
|
753
|
+
|
|
754
|
+
// Join via Code & Leave Group
|
|
755
|
+
await sock.groupAcceptInvite('ABCD1234efgh')
|
|
756
|
+
await sock.groupLeave(groupJid)
|
|
757
|
+
|
|
758
|
+
// Bulk Send to Group Members (with safety delay)
|
|
759
|
+
await sock.sendMessageMembers(groupJid, { text: 'Notification to all members!' }, {
|
|
760
|
+
delayMs: 2000,
|
|
761
|
+
onlyMember: true // sends only to group members/admins
|
|
762
|
+
})
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
---
|
|
766
|
+
|
|
767
|
+
## 🏘️ Communities Management
|
|
768
|
+
|
|
769
|
+
Create and configure WhatsApp Communities:
|
|
770
|
+
|
|
771
|
+
```javascript
|
|
772
|
+
// Create Community
|
|
773
|
+
const community = await sock.communityCreate('Developers Community', 'Community for developers')
|
|
774
|
+
|
|
775
|
+
// Link Subgroup to Community
|
|
776
|
+
await sock.communityLinkGroup(community.id, subGroupJid)
|
|
777
|
+
|
|
778
|
+
// Unlink Group from Community
|
|
779
|
+
await sock.communityUnlinkGroup(community.id, subGroupJid)
|
|
780
|
+
|
|
781
|
+
// Fetch Subgroups in Community
|
|
782
|
+
const groups = await sock.communityFetchGroups(community.id)
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
---
|
|
786
|
+
|
|
787
|
+
## 📰 Newsletters (Channels)
|
|
788
|
+
|
|
789
|
+
Create and interact with WhatsApp Channels (Newsletters):
|
|
790
|
+
|
|
791
|
+
```javascript
|
|
792
|
+
// Create Channel
|
|
793
|
+
const newsletter = await sock.newsletterCreate('Tech Updates', 'Latest technology news')
|
|
794
|
+
|
|
795
|
+
// Follow & Unfollow
|
|
796
|
+
await sock.newsletterFollow(newsletterJid)
|
|
797
|
+
await sock.newsletterUnfollow(newsletterJid)
|
|
798
|
+
|
|
799
|
+
// Mute & Unmute
|
|
800
|
+
await sock.newsletterMute(newsletterJid)
|
|
801
|
+
await sock.newsletterUnmute(newsletterJid)
|
|
802
|
+
|
|
803
|
+
// Post to Channel
|
|
804
|
+
await sock.sendMessage(newsletterJid, {
|
|
805
|
+
text: '🔥 Major new update released today!'
|
|
806
|
+
})
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
---
|
|
810
|
+
|
|
811
|
+
## 🔒 Privacy & Profile Management
|
|
812
|
+
|
|
813
|
+
```javascript
|
|
814
|
+
// Update Profile Details
|
|
815
|
+
await sock.updateProfileName('Supun MD')
|
|
816
|
+
await sock.updateProfileStatus('Available on supun-bailey-vip')
|
|
817
|
+
await sock.updateProfilePicture(sock.user.id, fs.readFileSync('./avatar.jpg'))
|
|
818
|
+
await sock.removeProfilePicture(sock.user.id)
|
|
819
|
+
|
|
820
|
+
// Online Presence
|
|
821
|
+
await sock.sendPresenceUpdate('available') // 'available' | 'unavailable' | 'composing' | 'recording' | 'paused'
|
|
822
|
+
|
|
823
|
+
// Mark Messages as Read
|
|
824
|
+
await sock.readMessages([msg.key])
|
|
825
|
+
|
|
826
|
+
// Privacy Settings
|
|
827
|
+
await sock.updateLastSeenPrivacy('contacts') // 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
|
828
|
+
await sock.updateOnlinePrivacy('all') // 'all' | 'match_last_seen'
|
|
829
|
+
await sock.updateProfilePicturePrivacy('all')
|
|
830
|
+
await sock.updateReadReceiptsPrivacy('all') // 'all' | 'none'
|
|
831
|
+
|
|
832
|
+
// Block & Unblock Users
|
|
833
|
+
await sock.updateBlockStatus('94712345678@s.whatsapp.net', 'block')
|
|
834
|
+
await sock.updateBlockStatus('94712345678@s.whatsapp.net', 'unblock')
|
|
835
|
+
const blocklist = await sock.fetchBlocklist()
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
---
|
|
839
|
+
|
|
840
|
+
## 📞 VoIP Audio & Video Calls
|
|
841
|
+
|
|
842
|
+
Full VoIP calling support powered by native WhatsApp WebAssembly and WebRTC signaling engine:
|
|
843
|
+
|
|
844
|
+
```javascript
|
|
845
|
+
import { makeWASocket } from 'supun-bailey-vip'
|
|
846
|
+
import { VoipClient, CallMediaType } from 'supun-bailey-vip/voip'
|
|
847
|
+
|
|
848
|
+
// Listen for incoming call offers
|
|
849
|
+
sock.ev.on('call', async (calls) => {
|
|
850
|
+
for (const call of calls) {
|
|
851
|
+
console.log(`Incoming ${call.isVideo ? 'video' : 'audio'} call from ${call.from}`)
|
|
852
|
+
|
|
853
|
+
// Automatically reject calls if desired
|
|
854
|
+
if (call.status === 'offer') {
|
|
855
|
+
await sock.rejectCall(call.id, call.from)
|
|
856
|
+
await sock.sendMessage(call.from, {
|
|
857
|
+
text: '⚠️ Automated message: Voice and video calls are not accepted.'
|
|
858
|
+
})
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
})
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
---
|
|
865
|
+
|
|
866
|
+
## 🚫 4-Factor Ban Checker
|
|
867
|
+
|
|
868
|
+
Verify any phone number against WhatsApp's official infrastructure using 4-factor non-invasive probing:
|
|
869
|
+
|
|
870
|
+
```javascript
|
|
871
|
+
const result = await sock.checkBanStatus('94712345678')
|
|
872
|
+
|
|
873
|
+
console.log(result)
|
|
874
|
+
/*
|
|
875
|
+
{
|
|
876
|
+
status: 'ACTIVE' | 'PROFILE_HIDDEN' | 'LIKELY_ACTIVE' | 'BANNED' | 'OFF_WHATSAPP' | 'UNKNOWN',
|
|
877
|
+
emoji: '🟢' | '🟡' | '🔴' | '❓',
|
|
878
|
+
confidence: 0.95,
|
|
879
|
+
deviceCount: 2,
|
|
880
|
+
registryExists: true,
|
|
881
|
+
pageVisible: true,
|
|
882
|
+
profileName: 'Supun Fernando'
|
|
883
|
+
}
|
|
884
|
+
*/
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
---
|
|
888
|
+
|
|
889
|
+
## 🆔 WhatsApp MEX Username API
|
|
890
|
+
|
|
891
|
+
Interact with WhatsApp Web's `@username` system via MEX GraphQL:
|
|
892
|
+
|
|
893
|
+
```javascript
|
|
894
|
+
// 1. Check Username Availability
|
|
895
|
+
const res = await sock.checkUsername('supunmd')
|
|
896
|
+
|
|
897
|
+
// 2. Set or Update Username
|
|
898
|
+
await sock.setUsername('supunmd')
|
|
899
|
+
|
|
900
|
+
// 3. Delete Username
|
|
901
|
+
await sock.deleteUsername()
|
|
902
|
+
|
|
903
|
+
// 4. Find User by Username
|
|
904
|
+
const user = await sock.findUserByUsername('targetuser')
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
---
|
|
908
|
+
|
|
909
|
+
## ⚡ Performance Tuning & Modes
|
|
910
|
+
|
|
911
|
+
Configure cache TTLs, pipeline coalescing, and RAM footprint per instance:
|
|
912
|
+
|
|
913
|
+
```javascript
|
|
914
|
+
const sock = makeWASocket({
|
|
915
|
+
auth: state,
|
|
916
|
+
performanceMode: 'high', // 'balanced' | 'high' | 'low-memory' | 'ultra-low-latency'
|
|
917
|
+
})
|
|
918
|
+
```
|
|
919
|
+
|
|
920
|
+
| Mode | Target | Description |
|
|
921
|
+
|---|---|---|
|
|
922
|
+
| `balanced` | Default | Safe, backward-compatible caching. Balanced memory and CPU usage. |
|
|
923
|
+
| `high` | High Traffic Bots | Aggressive group/contact caching and promise coalescing for low latency. |
|
|
924
|
+
| `low-memory` | Termux / VPS | Small caches with rapid eviction; ideal for 512MB RAM environments. |
|
|
925
|
+
| `ultra-low-latency` | Real-time Systems | Maximum throughput with in-flight deduplication. |
|
|
926
|
+
|
|
927
|
+
---
|
|
928
|
+
|
|
929
|
+
## 💾 In-Memory Store
|
|
930
|
+
|
|
931
|
+
Cache chats, messages, and contacts in memory and persist them to disk:
|
|
932
|
+
|
|
933
|
+
```javascript
|
|
934
|
+
import { makeInMemoryStore } from 'supun-bailey-vip'
|
|
935
|
+
|
|
936
|
+
const store = makeInMemoryStore({})
|
|
937
|
+
store.readFromFile('./store.json')
|
|
938
|
+
|
|
939
|
+
// Save store to disk every 10 seconds
|
|
940
|
+
setInterval(() => {
|
|
941
|
+
store.writeToFile('./store.json')
|
|
942
|
+
}, 10000)
|
|
943
|
+
|
|
944
|
+
// Bind store to socket event emitter
|
|
945
|
+
store.bind(sock.ev)
|
|
946
|
+
|
|
947
|
+
// Fetch saved messages
|
|
948
|
+
const chatMessages = store.messages[jid]
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
---
|
|
952
|
+
|
|
953
|
+
## 🌐 Community & Support
|
|
954
|
+
|
|
955
|
+
<div align="center">
|
|
956
|
+
|
|
957
|
+
<table>
|
|
958
|
+
<tr>
|
|
959
|
+
<td align="center">
|
|
960
|
+
<a href="https://supunofc.site">
|
|
961
|
+
🌐<br/><b>Website</b><br/>supunofc.site
|
|
962
|
+
</a>
|
|
963
|
+
</td>
|
|
964
|
+
<td align="center">
|
|
965
|
+
<a href="https://whatsapp.com/channel/0029Vb55cv41nozBTTIw1y07">
|
|
966
|
+
💬<br/><b>WhatsApp Channel</b><br/>Join Channel
|
|
967
|
+
</a>
|
|
968
|
+
</td>
|
|
969
|
+
<td align="center">
|
|
970
|
+
<a href="https://www.youtube.com/@darkshadow_zap">
|
|
971
|
+
▶️<br/><b>YouTube</b><br/>@darkshadow_zap
|
|
972
|
+
</a>
|
|
973
|
+
</td>
|
|
974
|
+
</tr>
|
|
975
|
+
</table>
|
|
976
|
+
|
|
977
|
+
**Developer:** Supun Fernando
|
|
978
|
+
Made with ❤️ in Sri Lanka 🇱🇰
|
|
979
|
+
|
|
980
|
+
</div>
|
|
981
|
+
|
|
982
|
+
---
|
|
983
|
+
|
|
984
|
+
## 📄 License
|
|
985
|
+
|
|
986
|
+
This project is licensed under the **MIT License**.
|
|
987
|
+
Copyright © 2026 Supun Fernando. All rights reserved.
|