@qadeer-xtech/stablebail 1.1.3 → 1.2.0
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/CHANGELOG.md +6 -0
- package/README.md +243 -419
- package/WAProto/index.d.ts +111 -1
- package/WAProto/index.js +770 -0
- package/lib/Socket/business.d.ts +8 -2
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/communities.d.ts +8 -2
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/index.d.ts +8 -2
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/messages-recv.d.ts +8 -2
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-recv.js +1 -1
- package/lib/Socket/messages-recv.js.map +1 -1
- package/lib/Socket/messages-send.d.ts +10 -2
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/messages-send.js +97 -14
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Types/Message.d.ts +14 -0
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Utils/banner.d.ts.map +1 -1
- package/lib/Utils/banner.js +1 -2
- package/lib/Utils/banner.js.map +1 -1
- package/lib/Utils/decode-wa-message.js +1 -1
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +4 -0
- package/lib/Utils/messages.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,524 +1,348 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
**STABLEBAIL — POWERED BY TEAM QADEER**
|
|
5
|
-
</p>
|
|
3
|
+
# @qadeer-xtech/stablebail
|
|
6
4
|
|
|
7
|
-
A
|
|
5
|
+
**A stable, fixed WhatsApp Web API for Node.js — with interactive buttons, lists and carousels built right into `sendMessage`.**
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
[](https://npmjs.com/package/@qadeer-xtech/stablebail)
|
|
8
|
+
[](https://npmjs.com/package/@qadeer-xtech/stablebail)
|
|
9
|
+
[](https://npmjs.com/package/@qadeer-xtech/stablebail)
|
|
10
|
+
[](https://nodejs.org)
|
|
11
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
12
|
|
|
11
|
-
[
|
|
13
|
+
[Install](#-install) · [Quick Start](#-quick-start) · [Messages](#-messages) · [Interactive](#-interactive-messages) · [Themes](#-chat-themes) · [Newsletter](#-newsletter--channels) · [Disconnect reasons](#-disconnect-reasons) · [Credits](#-credits)
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
</div>
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
WhatsApp. It changes what WhatsApp sends your bot, so pick carefully —
|
|
17
|
-
nothing else in your bot code changes, and your existing session keeps
|
|
18
|
-
working; the identity simply applies on the next connect.
|
|
17
|
+
---
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
## ✨ Highlights
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
empty stubs** with no media inside. If your bot needs view-once,
|
|
32
|
-
use setup 2 or 3.
|
|
33
|
-
|
|
34
|
-
**2. Android phone identity** — the bot presents itself as an Android
|
|
35
|
-
phone.
|
|
36
|
-
|
|
37
|
-
```js
|
|
38
|
-
browser: Browsers.androidPhone('Chrome')
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
- **Who it is for:** bots that need full media, above all view-once.
|
|
42
|
-
- **What changes in the bot after this setup:** WhatsApp treats the
|
|
43
|
-
bot as a phone-class device, so **view-once media actually arrives**
|
|
44
|
-
instead of empty stubs. One side effect: on Android sessions,
|
|
45
|
-
channel data can arrive in a compact **binary format** instead of
|
|
46
|
-
JSON — StableBail decodes that format fully, so your channel
|
|
47
|
-
features (name, followers, description, picture) keep working.
|
|
21
|
+
| | |
|
|
22
|
+
|---|---|
|
|
23
|
+
| 🛡️ **Stable base** | Faithful Baileys **7.0.0-rc14** core — same API you already know, plus reviewed fixes upstream has not released yet |
|
|
24
|
+
| 🎛️ **Interactive built-in** | Buttons, lists and carousels with plain `sendMessage` — **no** `relayMessage` hacks, no extra helper library |
|
|
25
|
+
| 🔧 **Real fixes** | Media re-upload on 403/404/410, pairing-code 515 failures, stream drops, retry double-encryption — all fixed |
|
|
26
|
+
| 💾 **Safe sessions** | Atomic `creds.json` writes — a crash mid-write can no longer corrupt your login |
|
|
27
|
+
| 📢 **Newsletters** | Channel media paths fixed — posts and media show up the way they should |
|
|
28
|
+
| 👁️ **View once** | Works out of the box, including on Android companion devices |
|
|
29
|
+
| 🔢 **Custom pairing codes** | Link with your own 8-character code (e.g. `TEAMQD11`) |
|
|
48
30
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
```js
|
|
52
|
-
const getBrowserIdentity = (registered) =>
|
|
53
|
-
registered ? Browsers.androidPhone('Chrome') : Browsers.macOS('Safari')
|
|
54
|
-
|
|
55
|
-
// inside makeWASocket:
|
|
56
|
-
browser: getBrowserIdentity(state.creds.registered)
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
- **Who it is for:** most bots — this is the setup we recommend.
|
|
60
|
-
- **How it works:** while the session is fresh (not yet registered),
|
|
61
|
-
the Safari/Mac identity pairs the fastest and most reliably. As
|
|
62
|
-
soon as the session is registered, the identity switches to the
|
|
63
|
-
Android phone identity by itself on the next connect — **no
|
|
64
|
-
re-pairing, no code change** — and the bot gets the full Android
|
|
65
|
-
behaviour from setup 2, including view-once media.
|
|
66
|
-
|
|
67
|
-
**In short:** Ubuntu = simple web bot, no view-once. Android =
|
|
68
|
-
phone-class bot, view-once works. Dynamic = easy pairing first,
|
|
69
|
-
Android powers after — the best of both.
|
|
70
|
-
|
|
71
|
-
## View-once — the fix, and the bot code for it
|
|
72
|
-
|
|
73
|
-
**The problem:** on browser/web identities, WhatsApp delivers
|
|
74
|
-
view-once photos and videos to companion devices as *empty stubs* —
|
|
75
|
-
the message arrives, but there is no media inside it. No bot code can
|
|
76
|
-
recover media that never arrived.
|
|
77
|
-
|
|
78
|
-
**The fix in StableBail:** when the bot runs on the Android phone
|
|
79
|
-
identity, StableBail presents a real Android device in the connection
|
|
80
|
-
user-agent (device = `Android`, not `Desktop`). WhatsApp then treats
|
|
81
|
-
the bot as a phone-class device and delivers view-once media
|
|
82
|
-
normally — it works out of the box, nothing to configure in the
|
|
83
|
-
library.
|
|
84
|
-
|
|
85
|
-
**The code you add in your bot (`index.js`):** just run the bot on
|
|
86
|
-
the Android identity — or use the dynamic setup so pairing stays
|
|
87
|
-
easy and Android takes over right after:
|
|
88
|
-
|
|
89
|
-
```js
|
|
90
|
-
const {
|
|
91
|
-
default: makeWASocket,
|
|
92
|
-
Browsers,
|
|
93
|
-
useMultiFileAuthState
|
|
94
|
-
} = require('@whiskeysockets/baileys')
|
|
95
|
-
|
|
96
|
-
const getBrowserIdentity = (registered) =>
|
|
97
|
-
registered ? Browsers.androidPhone('Chrome') : Browsers.macOS('Safari')
|
|
98
|
-
|
|
99
|
-
const { state, saveCreds } = await useMultiFileAuthState('auth')
|
|
100
|
-
|
|
101
|
-
const sock = makeWASocket({
|
|
102
|
-
auth: state,
|
|
103
|
-
browser: getBrowserIdentity(state.creds.registered)
|
|
104
|
-
})
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
That is all. Pair once (Safari identity), and from the next connect
|
|
108
|
-
onward the bot runs as Android and view-once media arrives — your
|
|
109
|
-
view-once commands can then download the quoted message as usual.
|
|
110
|
-
|
|
111
|
-
## Why StableBail instead of stock Baileys?
|
|
112
|
-
|
|
113
|
-
Same API — StableBail is Baileys 7.0.0-rc14 plus reviewed fixes that
|
|
114
|
-
upstream has not released yet:
|
|
115
|
-
|
|
116
|
-
| Area | Stock rc14 | StableBail |
|
|
117
|
-
|---|---|---|
|
|
118
|
-
| Media reupload on 403/404/410 | broken | fixed (1.0.3) |
|
|
119
|
-
| Stream drops ~50 min (status ack) | broken | fixed (1.0.7) |
|
|
120
|
-
| Pairing code 515 failures | broken | fixed (1.0.7) |
|
|
121
|
-
| creds.json corruption on crash | possible | atomic writes (1.0.7) |
|
|
122
|
-
| Channel (newsletter) media | often invisible | fixed paths (1.0.2 + 1.0.7) |
|
|
123
|
-
| Status mentions | not available | `sendStatusMention` (1.0.5) |
|
|
124
|
-
| Retry double-encryption | present | fixed (1.0.7) |
|
|
125
|
-
| View-once on Android companions | unavailable stubs | works out of the box (1.0.12) |
|
|
126
|
-
| Ban / number status checker | not available | `checkStatusWA` (1.0.12) |
|
|
127
|
-
|
|
128
|
-
Full per-version list: [CHANGELOG.md](CHANGELOG.md) · Plans: [ROADMAP.md](ROADMAP.md) · Runnable samples: [examples/](examples/)
|
|
129
|
-
|
|
130
|
-
## Switching from official Baileys (1 minute)
|
|
131
|
-
|
|
132
|
-
Change only the dependency line — your code stays the same:
|
|
133
|
-
|
|
134
|
-
```json
|
|
135
|
-
"@whiskeysockets/baileys": "npm:@qadeer-xtech/stablebail@latest"
|
|
136
|
-
```
|
|
31
|
+
Made by **Team Qadeer** · Package: [npmjs.com/package/@qadeer-xtech/stablebail](https://npmjs.com/package/@qadeer-xtech/stablebail) · Source: [github.com/Qadeer-Xtech/stablebail](https://github.com/Qadeer-Xtech/stablebail)
|
|
137
32
|
|
|
138
|
-
|
|
33
|
+
> **Why StableBail instead of stock Baileys?** Stock rc14 breaks in places every serious bot hits: media re-uploads fail, pairing dies on 515, streams drop, creds corrupt on crash. StableBail keeps the exact same API and fixes those — verified by a full test suite (**437/437 passing**) and by production bots running on it every day.
|
|
139
34
|
|
|
140
|
-
|
|
35
|
+
---
|
|
141
36
|
|
|
142
|
-
|
|
143
|
-
[`src/`](src/). It is **build-verified**: compiling it with the
|
|
144
|
-
included tsconfig reproduces the shipped `lib/` JavaScript
|
|
145
|
-
exactly — what you read here is what runs. (The published
|
|
146
|
-
tarball omits the build's sourcemap files, and a few type
|
|
147
|
-
declarations were completed so the types match the shipped JS.)
|
|
37
|
+
## 📥 Install
|
|
148
38
|
|
|
149
|
-
|
|
39
|
+
Requires **Node.js 18+**.
|
|
150
40
|
|
|
151
41
|
```bash
|
|
152
42
|
npm install @qadeer-xtech/stablebail
|
|
153
43
|
```
|
|
154
44
|
|
|
155
|
-
## Use as Official Baileys Replacement
|
|
156
|
-
|
|
157
|
-
To use StableBail without changing your existing import paths, add this alias to your "package.json":
|
|
158
|
-
|
|
159
45
|
```json
|
|
160
46
|
{
|
|
161
47
|
"dependencies": {
|
|
162
|
-
"@
|
|
48
|
+
"@qadeer-xtech/stablebail": "^1.1.3"
|
|
163
49
|
}
|
|
164
50
|
}
|
|
165
51
|
```
|
|
166
52
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
## ✅ Recommended Settings for Bot Projects
|
|
53
|
+
---
|
|
170
54
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
```json
|
|
174
|
-
{
|
|
175
|
-
"dependencies": {
|
|
176
|
-
"@whiskeysockets/baileys": "npm:@qadeer-xtech/stablebail@1.0.13",
|
|
177
|
-
"sharp": "0.35.5",
|
|
178
|
-
"wa-sticker-formatter": "4.4.4"
|
|
179
|
-
},
|
|
180
|
-
"overrides": {
|
|
181
|
-
"sharp": "$sharp"
|
|
182
|
-
},
|
|
183
|
-
"engines": {
|
|
184
|
-
"node": "20.x"
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
```
|
|
55
|
+
## 🚀 Quick Start
|
|
188
56
|
|
|
189
|
-
|
|
57
|
+
A complete bot that links by QR or pairing code and answers `!ping`.
|
|
190
58
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
- Status Mentions — Mention contacts and groups in WhatsApp status updates.
|
|
197
|
-
- CSToken / NCT Support — Additional token handling for LID-addressed messaging.
|
|
198
|
-
- Connection Banner — Optional branded startup banner.
|
|
199
|
-
- Improved Stability — Additional fixes for connection handling and media operations.
|
|
59
|
+
```javascript
|
|
60
|
+
import makeWASocket, {
|
|
61
|
+
useMultiFileAuthState,
|
|
62
|
+
DisconnectReason
|
|
63
|
+
} from '@qadeer-xtech/stablebail'
|
|
200
64
|
|
|
201
|
-
|
|
65
|
+
const PHONE_NUMBER = '' // e.g. '923001234567' to use a pairing code
|
|
66
|
+
const PAIR_CODE = '' // optional custom 8-character code
|
|
202
67
|
|
|
203
|
-
|
|
68
|
+
const start = async () => {
|
|
69
|
+
const { state, saveCreds } = await useMultiFileAuthState('./session')
|
|
204
70
|
|
|
205
|
-
|
|
71
|
+
const sock = makeWASocket({
|
|
72
|
+
auth: state,
|
|
73
|
+
printQRInTerminal: !PHONE_NUMBER,
|
|
74
|
+
syncFullHistory: false
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
sock.ev.on('creds.update', saveCreds)
|
|
78
|
+
|
|
79
|
+
let pairingRequested = false
|
|
80
|
+
sock.ev.on('connection.update', async ({ connection, lastDisconnect, qr }) => {
|
|
81
|
+
if (qr && PHONE_NUMBER && !pairingRequested) {
|
|
82
|
+
pairingRequested = true
|
|
83
|
+
try {
|
|
84
|
+
console.log('Pairing code:', await sock.requestPairingCode(PHONE_NUMBER, PAIR_CODE || undefined))
|
|
85
|
+
} catch (err) {
|
|
86
|
+
console.error('Could not request a pairing code:', err.message)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
206
89
|
|
|
207
|
-
|
|
90
|
+
if (connection === 'open') console.log('Connected as', sock.user?.id)
|
|
208
91
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
92
|
+
if (connection === 'close') {
|
|
93
|
+
const code = lastDisconnect?.error?.output?.statusCode
|
|
94
|
+
if (code === DisconnectReason.loggedOut) {
|
|
95
|
+
return console.log('Logged out. Delete ./session and run again to link a new device.')
|
|
96
|
+
}
|
|
97
|
+
console.log(`Connection closed (${code}), reconnecting...`)
|
|
98
|
+
setTimeout(start, 1000)
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
sock.ev.on('messages.upsert', async ({ messages, type }) => {
|
|
103
|
+
if (type !== 'notify') return
|
|
104
|
+
for (const m of messages) {
|
|
105
|
+
if (m.key.fromMe || !m.message) continue
|
|
106
|
+
const text = m.message.conversation || m.message.extendedTextMessage?.text
|
|
107
|
+
if (text === '!ping') {
|
|
108
|
+
await sock.sendMessage(m.key.remoteJid, { text: 'pong' }, { quoted: m }).catch(console.error)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
}
|
|
220
113
|
|
|
221
|
-
|
|
114
|
+
start()
|
|
115
|
+
```
|
|
222
116
|
|
|
223
|
-
|
|
224
|
-
- Improved channel message decoding.
|
|
225
|
-
- Better thumbnail handling.
|
|
226
|
-
- Protection against missing channel profile pictures.
|
|
227
|
-
- Support for legacy message-fetching arguments.
|
|
117
|
+
**How to link**
|
|
228
118
|
|
|
229
|
-
|
|
119
|
+
| Method | Steps |
|
|
120
|
+
|---|---|
|
|
121
|
+
| QR code | Leave `PHONE_NUMBER` empty, then scan from *Linked devices → Link a device* |
|
|
122
|
+
| Pairing code | Set `PHONE_NUMBER`, choose *Link with phone number instead*, enter the code |
|
|
123
|
+
| Custom code | Set `PAIR_CODE` to any 8 characters (empty = random) |
|
|
230
124
|
|
|
231
|
-
|
|
125
|
+
> Your login is stored in `./session`. Keep it private and out of git.
|
|
232
126
|
|
|
233
|
-
|
|
234
|
-
- Prevents downloads from remaining stuck after stream failures.
|
|
235
|
-
- Improved recovery for expired media links.
|
|
236
|
-
- Handles CDN "403", "404", and "410" responses.
|
|
237
|
-
- Improved phone-based media reupload handling.
|
|
238
|
-
- Automatically converts Base64 media keys into usable byte data when required.
|
|
127
|
+
### ⚙️ Socket options
|
|
239
128
|
|
|
240
|
-
|
|
129
|
+
| Option | Default | What it does |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| `auth` | – | **Required.** The `state` from an auth helper |
|
|
132
|
+
| `browser` | — | Device name shown in *Linked devices* |
|
|
133
|
+
| `printQRInTerminal` | `false` | Print each QR in the terminal (`qr` is always emitted on `connection.update`) |
|
|
134
|
+
| `syncFullHistory` | `true` | Set `false` for lighter bots |
|
|
135
|
+
| `markOnlineOnConnect` | `true` | Set `false` to keep notifications on your phone |
|
|
136
|
+
| `connectTimeoutMs` | `60000` | Opening handshake timeout |
|
|
137
|
+
| `keepAliveIntervalMs` | `25000` | Ping interval |
|
|
138
|
+
| `defaultQueryTimeoutMs` | `60000` | Server request timeout |
|
|
139
|
+
| `getMessage` | `undefined` | Return a stored message by key so retries and poll votes can be decrypted |
|
|
140
|
+
| `logger` | built-in | Any pino-style logger |
|
|
241
141
|
|
|
242
|
-
|
|
243
|
-
- Updated default WhatsApp Web version configuration.
|
|
244
|
-
- Improved LID address handling in "onWhatsApp()".
|
|
245
|
-
- Returns LID information alongside standard WhatsApp lookup results when available.
|
|
142
|
+
---
|
|
246
143
|
|
|
247
|
-
|
|
144
|
+
## 💬 Messages
|
|
248
145
|
|
|
249
|
-
|
|
250
|
-
{
|
|
251
|
-
jid,
|
|
252
|
-
exists,
|
|
253
|
-
lid
|
|
254
|
-
}
|
|
255
|
-
```
|
|
146
|
+
Everything from Baileys works as documented upstream — text, mentions, reactions, media, stickers, locations, polls and more:
|
|
256
147
|
|
|
257
|
-
|
|
148
|
+
```javascript
|
|
149
|
+
// Text with mention
|
|
150
|
+
await sock.sendMessage(jid, { text: 'Hello @923001234567', mentions: ['923001234567@s.whatsapp.net'] })
|
|
258
151
|
|
|
259
|
-
|
|
152
|
+
// Image with caption
|
|
153
|
+
await sock.sendMessage(jid, { image: { url: 'https://example.com/pic.jpg' }, caption: 'Look at this' })
|
|
260
154
|
|
|
261
|
-
|
|
155
|
+
// Reaction
|
|
156
|
+
await sock.sendMessage(jid, { react: { text: '🔥', key: msg.key } })
|
|
262
157
|
|
|
263
|
-
|
|
264
|
-
await sock.
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
'923009876543@s.whatsapp.net'
|
|
268
|
-
],
|
|
269
|
-
{
|
|
270
|
-
text: 'Eid Mubarak! 🌙'
|
|
271
|
-
}
|
|
272
|
-
)
|
|
158
|
+
// Poll
|
|
159
|
+
await sock.sendMessage(jid, {
|
|
160
|
+
poll: { name: 'Best language?', values: ['JavaScript', 'Python', 'Go'], selectableCount: 1 }
|
|
161
|
+
})
|
|
273
162
|
```
|
|
274
163
|
|
|
275
|
-
|
|
164
|
+
### Status & stories
|
|
276
165
|
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
{
|
|
281
|
-
image: {
|
|
282
|
-
url: 'https://example.com/pic.jpg'
|
|
283
|
-
},
|
|
284
|
-
caption: 'Team Qadeer'
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
delayMs: 1500
|
|
288
|
-
}
|
|
289
|
-
)
|
|
166
|
+
```javascript
|
|
167
|
+
// Status with mentions — sendStatusMention
|
|
168
|
+
await sock.sendStatusMention({ text: 'New post!' }, [jid1, jid2])
|
|
290
169
|
```
|
|
291
170
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
### 5. CSToken / NCT Support
|
|
295
|
-
|
|
296
|
-
Additional support for WhatsApp's NCT and contact token handling.
|
|
171
|
+
### Check a number
|
|
297
172
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
- Computes CSToken using HMAC-SHA256 when a required token is unavailable.
|
|
302
|
-
- Prioritizes existing TCToken data when available.
|
|
303
|
-
- Adds additional token handling for LID-addressed messaging.
|
|
304
|
-
|
|
305
|
-
The library also exposes existing reach-out timelock information through:
|
|
306
|
-
|
|
307
|
-
```js
|
|
308
|
-
sock.fetchAccountReachoutTimelock()
|
|
173
|
+
```javascript
|
|
174
|
+
// Is this number banned / on WhatsApp?
|
|
175
|
+
const status = await sock.checkStatusWA('923001234567')
|
|
309
176
|
```
|
|
310
177
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
### 6. Custom Connection Banner
|
|
178
|
+
---
|
|
314
179
|
|
|
315
|
-
|
|
180
|
+
## 🎛️ Interactive Messages
|
|
316
181
|
|
|
317
|
-
|
|
318
|
-
╭───────────────────────────╮
|
|
319
|
-
│ ✦ Q A D E E R ✦ │
|
|
320
|
-
│ stablebail • Qadeer-Xtech │
|
|
321
|
-
╰───────────────────────────╯
|
|
322
|
-
```
|
|
182
|
+
This is where StableBail goes beyond stock Baileys: **buttons, lists and carousels are part of `sendMessage` itself.** No manual proto building, no `relayMessage`, no external button library.
|
|
323
183
|
|
|
324
|
-
|
|
184
|
+
### Buttons
|
|
325
185
|
|
|
326
|
-
|
|
186
|
+
Add a `buttons` array to any message. The message can also carry a `title`, `subtitle`, `footer` and an image/video/document header.
|
|
327
187
|
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
188
|
+
```javascript
|
|
189
|
+
await sock.sendMessage(jid, {
|
|
190
|
+
title: 'QADEER AI',
|
|
191
|
+
text: 'Choose an option:',
|
|
192
|
+
footer: 'Powered by My Bot',
|
|
193
|
+
buttons: [
|
|
194
|
+
{ type: 'reply', displayText: '📋 Menu', id: '.menu' },
|
|
195
|
+
{ type: 'url', displayText: '🌐 Website', url: 'https://example.com' },
|
|
196
|
+
{ type: 'copy', displayText: '📑 Copy JID', copyCode: jid }
|
|
197
|
+
]
|
|
333
198
|
})
|
|
334
199
|
```
|
|
335
200
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
Buttons and lists are built into the library — no extra helper
|
|
339
|
-
files or packages. Just pass `buttons` to `sendMessage`:
|
|
201
|
+
**Button types**
|
|
340
202
|
|
|
341
|
-
|
|
203
|
+
| Type | Fields | What it does |
|
|
204
|
+
|---|---|---|
|
|
205
|
+
| `reply` | `displayText`, `id` | Quick-reply button — tapping sends `id` back as a message |
|
|
206
|
+
| `url` | `displayText`, `url` | Opens a link |
|
|
207
|
+
| `call` | `displayText`, `phoneNumber` | Starts a call to the number |
|
|
208
|
+
| `copy` | `displayText`, `copyCode` | Copies the code/text to the clipboard |
|
|
209
|
+
| `list` | `title`, `sections` | Opens a selection list (see below) |
|
|
210
|
+
| `reminder` | `displayText`, `id` | Creates a reminder |
|
|
211
|
+
| `cancelReminder` | `displayText`, `id` | Cancels a reminder |
|
|
212
|
+
| `address` | `displayText`, `id` | Address message button |
|
|
213
|
+
| `location` | — | Asks for / sends location |
|
|
214
|
+
|
|
215
|
+
### Lists
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
342
218
|
await sock.sendMessage(jid, {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
219
|
+
text: 'Pick a category',
|
|
220
|
+
footer: 'Tap below',
|
|
221
|
+
buttons: [
|
|
222
|
+
{
|
|
223
|
+
type: 'list',
|
|
224
|
+
title: 'Open menu',
|
|
225
|
+
sections: [
|
|
350
226
|
{
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
rows: [{ title: 'First item', description: 'Details', id: 'item_1' }]
|
|
357
|
-
}
|
|
358
|
-
]
|
|
227
|
+
title: 'Main',
|
|
228
|
+
rows: [
|
|
229
|
+
{ title: 'Downloads', description: 'Songs, videos, apps', id: '.menu download' },
|
|
230
|
+
{ title: 'Games', description: 'Play in chat', id: '.menu games' }
|
|
231
|
+
]
|
|
359
232
|
}
|
|
360
|
-
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
]
|
|
361
236
|
})
|
|
362
237
|
```
|
|
363
238
|
|
|
364
|
-
|
|
365
|
-
(`carousel: { cards: [...] }`), legacy buttons (`legacyButtons`),
|
|
366
|
-
reminder buttons, and raw native-flow passthrough.
|
|
367
|
-
|
|
368
|
-
## 🚀 Basic Usage
|
|
369
|
-
|
|
370
|
-
```js
|
|
371
|
-
const makeWASocket =
|
|
372
|
-
require('@qadeer-xtech/stablebail').default
|
|
373
|
-
|
|
374
|
-
const {
|
|
375
|
-
useMultiFileAuthState,
|
|
376
|
-
DisconnectReason
|
|
377
|
-
} = require('@qadeer-xtech/stablebail')
|
|
378
|
-
|
|
379
|
-
async function startBot() {
|
|
380
|
-
const { state, saveCreds } =
|
|
381
|
-
await useMultiFileAuthState('auth_info')
|
|
382
|
-
|
|
383
|
-
const sock = makeWASocket({
|
|
384
|
-
auth: state,
|
|
385
|
-
printQRInTerminal: true
|
|
386
|
-
})
|
|
239
|
+
### Carousel
|
|
387
240
|
|
|
388
|
-
|
|
241
|
+
Swipeable cards, each with its own media, text and buttons:
|
|
389
242
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
243
|
+
```javascript
|
|
244
|
+
await sock.sendMessage(jid, {
|
|
245
|
+
text: 'Featured',
|
|
246
|
+
footer: 'Swipe →',
|
|
247
|
+
carousel: {
|
|
248
|
+
cards: [
|
|
249
|
+
{
|
|
250
|
+
title: 'Card One',
|
|
251
|
+
text: 'First card body',
|
|
252
|
+
footer: 'My Bot',
|
|
253
|
+
image: { url: 'https://example.com/one.jpg' },
|
|
254
|
+
buttons: [{ type: 'reply', displayText: 'Open', id: '.open 1' }]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
title: 'Card Two',
|
|
258
|
+
text: 'Second card body',
|
|
259
|
+
footer: 'My Bot',
|
|
260
|
+
image: { url: 'https://example.com/two.jpg' },
|
|
261
|
+
buttons: [{ type: 'url', displayText: 'Visit', url: 'https://example.com' }]
|
|
262
|
+
}
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
})
|
|
394
266
|
```
|
|
395
267
|
|
|
396
|
-
|
|
268
|
+
### Legacy buttons
|
|
397
269
|
|
|
398
|
-
|
|
270
|
+
Old-style template buttons are still available as `legacyButtons` if you need them.
|
|
399
271
|
|
|
400
|
-
```js
|
|
401
|
-
const channel = await sock.newsletterFromUrl(
|
|
402
|
-
'https://whatsapp.com/channel/CHANNEL_ID'
|
|
403
|
-
)
|
|
404
272
|
|
|
405
|
-
|
|
406
|
-
channel.id,
|
|
407
|
-
channel.name,
|
|
408
|
-
channel.subscribers
|
|
409
|
-
)
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
Follow / Unfollow
|
|
413
|
-
|
|
414
|
-
```js
|
|
415
|
-
await sock.newsletterFollow(channel.id)
|
|
416
|
-
|
|
417
|
-
await sock.newsletterUnfollow(channel.id)
|
|
418
|
-
```
|
|
273
|
+
---
|
|
419
274
|
|
|
420
|
-
|
|
275
|
+
## 🎨 Chat Themes
|
|
421
276
|
|
|
422
|
-
|
|
423
|
-
const channels = await sock.newsletterSubscribed()
|
|
277
|
+
Set the official WhatsApp chat theme for any chat or group — preset colour schemes or your own solid colour. This uses WhatsApp's own `CHAT_THEME_SETTING` protocol message.
|
|
424
278
|
|
|
425
|
-
|
|
426
|
-
|
|
279
|
+
```javascript
|
|
280
|
+
import { CHAT_THEMES } from '@qadeer-xtech/stablebail'
|
|
427
281
|
|
|
428
|
-
|
|
282
|
+
// Preset themes: 'Default-Blue@Minimal', 'Emerald@Minimal', 'Pink@Minimal',
|
|
283
|
+
// 'Red@Minimal', 'Royal-Blue@Minimal', 'Tyrian-Purple@Minimal', 'WhatsApp-Green@Minimal', ...
|
|
284
|
+
await sock.setChatTheme(jid, 'Emerald@Minimal')
|
|
429
285
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
channel.id,
|
|
433
|
-
20
|
|
434
|
-
)
|
|
286
|
+
// ...or through sendMessage
|
|
287
|
+
await sock.sendMessage(jid, { chatTheme: 'Pink@Minimal' })
|
|
435
288
|
|
|
436
|
-
|
|
289
|
+
// Custom solid colour (ARGB hex strings), with optional doodle background
|
|
290
|
+
await sock.setChatThemeColor(jid, { colorLight: 'FFFF0000', colorDark: 'FF7A0000', isDoodleEnabled: true })
|
|
437
291
|
```
|
|
438
292
|
|
|
439
|
-
|
|
293
|
+
---
|
|
440
294
|
|
|
441
|
-
|
|
442
|
-
const updates = await sock.newsletterFetchUpdates(
|
|
443
|
-
channel.id,
|
|
444
|
-
20
|
|
445
|
-
)
|
|
295
|
+
## 🥷 Stealth Device Targeting
|
|
446
296
|
|
|
447
|
-
|
|
448
|
-
updates[0].server_id,
|
|
449
|
-
updates[0].views,
|
|
450
|
-
updates[0].reactions
|
|
451
|
-
)
|
|
452
|
-
```
|
|
297
|
+
Control exactly **which devices** a direct message is delivered to. Pass these options to `relayMessage` (they apply to 1-to-1 chats only — not groups or status):
|
|
453
298
|
|
|
454
|
-
|
|
299
|
+
```javascript
|
|
300
|
+
// participant (no count): recipient-only — skips your own linked devices
|
|
301
|
+
await sock.relayMessage(jid, message, { participant: { jid } })
|
|
455
302
|
|
|
456
|
-
|
|
457
|
-
await sock.
|
|
458
|
-
text: 'Assalam o Alaikum! 👋'
|
|
459
|
-
})
|
|
460
|
-
```
|
|
303
|
+
// isSecret: only the recipient's primary phone — no web/desktop companions
|
|
304
|
+
await sock.relayMessage(jid, message, { isSecret: true })
|
|
461
305
|
|
|
462
|
-
|
|
306
|
+
// protected: everywhere EXCEPT the recipient's linked/companion devices
|
|
307
|
+
await sock.relayMessage(jid, message, { protected: true })
|
|
463
308
|
|
|
464
|
-
|
|
465
|
-
await sock.
|
|
466
|
-
image: {
|
|
467
|
-
url: 'https://example.com/pic.jpg'
|
|
468
|
-
},
|
|
469
|
-
caption: 'New Channel Update'
|
|
470
|
-
})
|
|
309
|
+
// me: only your own devices
|
|
310
|
+
await sock.relayMessage(jid, message, { me: true })
|
|
471
311
|
```
|
|
472
312
|
|
|
473
|
-
|
|
313
|
+
---
|
|
474
314
|
|
|
475
|
-
|
|
476
|
-
await sock.newsletterReactMessage(
|
|
477
|
-
channel.id,
|
|
478
|
-
updates[0].server_id,
|
|
479
|
-
'❤️'
|
|
480
|
-
)
|
|
481
|
-
```
|
|
315
|
+
## 📢 Newsletter / Channels
|
|
482
316
|
|
|
483
|
-
|
|
317
|
+
- Channel (newsletter) media paths are fixed — media posts render correctly for followers.
|
|
318
|
+
- Follow, unfollow, react and manage newsletters with the standard socket methods.
|
|
484
319
|
|
|
485
|
-
|
|
486
|
-
- Baileys-compatible socket workflow
|
|
487
|
-
- Existing Baileys-based bot projects
|
|
488
|
-
- Multi-file authentication
|
|
489
|
-
- WhatsApp Web connection workflows
|
|
320
|
+
---
|
|
490
321
|
|
|
491
|
-
|
|
322
|
+
## 🔌 Disconnect reasons
|
|
492
323
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
324
|
+
| Code | Meaning | What to do |
|
|
325
|
+
|---|---|---|
|
|
326
|
+
| `401` | Logged out | Session is dead — delete it and pair again |
|
|
327
|
+
| `403` | Forbidden | Number/account restricted by WhatsApp |
|
|
328
|
+
| `408` | Timed out | Reconnect |
|
|
329
|
+
| `428` | Connection closed | Reconnect |
|
|
330
|
+
| `440` | Connection replaced | The same session opened somewhere else — do not fight it, find the other instance |
|
|
331
|
+
| `500` | Bad session | Reconnect; if it repeats, re-pair |
|
|
332
|
+
| `515` | Restart required | Normal right after pairing — just reconnect |
|
|
502
333
|
|
|
503
|
-
|
|
504
|
-
is under MIT: the upstream Baileys code (© Rajeh Taher /
|
|
505
|
-
WhiskeySockets) and Team Qadeer's fixes, extensions and branding
|
|
506
|
-
(© Team Qadeer / Qadeer-Xtech) alike. The [NOTICE](NOTICE) file
|
|
507
|
-
ships with the package and carries a (non-binding) credit request.
|
|
334
|
+
---
|
|
508
335
|
|
|
509
|
-
##
|
|
336
|
+
## 🗄️ Session storage
|
|
510
337
|
|
|
511
|
-
|
|
512
|
-
scope, with code **byte-identical** to upstream (proof in each
|
|
513
|
-
repo's DIFF.md):
|
|
338
|
+
`useMultiFileAuthState('./session')` stores credentials and keys as files in a folder. Back the folder up if the session matters — on hosts with ephemeral disks (Heroku, containers), persist it to a database or external storage on `creds.update` and on a timer, and restore it before starting the socket.
|
|
514
339
|
|
|
515
|
-
|
|
516
|
-
- [@qadeer-xtech/whatsapp-rust-bridge](https://github.com/Qadeer-Xtech/whatsapp-rust-bridge) — of official whatsapp-rust-bridge 0.5.4
|
|
340
|
+
---
|
|
517
341
|
|
|
518
|
-
##
|
|
342
|
+
## 🙏 Credits
|
|
519
343
|
|
|
520
|
-
|
|
344
|
+
Built on [**@whiskeysockets/baileys**](https://github.com/WhiskeySockets/Baileys) 7.0.0-rc14 (MIT). Full upstream attribution is kept in [NOTICE](https://github.com/Qadeer-Xtech/stablebail/blob/main/NOTICE).
|
|
521
345
|
|
|
522
|
-
|
|
346
|
+
## 📄 License
|
|
523
347
|
|
|
524
|
-
|
|
348
|
+
MIT — see [LICENSE](https://github.com/Qadeer-Xtech/stablebail/blob/main/LICENSE).
|