@qadeer-xtech/stablebail 1.1.2 → 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 +249 -393
- 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 +115 -14
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Types/Message.d.ts +124 -1
- 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 +6 -1
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +171 -1
- 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,492 +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.
|
|
48
|
-
|
|
49
|
-
**3. Dynamic identity (recommended)** — pair easily, run as Android.
|
|
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:
|
|
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`) |
|
|
133
30
|
|
|
134
|
-
|
|
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
|
-
|
|
53
|
+
---
|
|
168
54
|
|
|
169
|
-
##
|
|
55
|
+
## 🚀 Quick Start
|
|
170
56
|
|
|
171
|
-
|
|
57
|
+
A complete bot that links by QR or pairing code and answers `!ping`.
|
|
172
58
|
|
|
173
|
-
```
|
|
174
|
-
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
"wa-sticker-formatter": "4.4.4"
|
|
179
|
-
},
|
|
180
|
-
"overrides": {
|
|
181
|
-
"sharp": "$sharp"
|
|
182
|
-
},
|
|
183
|
-
"engines": {
|
|
184
|
-
"node": "20.x"
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
```
|
|
59
|
+
```javascript
|
|
60
|
+
import makeWASocket, {
|
|
61
|
+
useMultiFileAuthState,
|
|
62
|
+
DisconnectReason
|
|
63
|
+
} from '@qadeer-xtech/stablebail'
|
|
188
64
|
|
|
189
|
-
|
|
65
|
+
const PHONE_NUMBER = '' // e.g. '923001234567' to use a pairing code
|
|
66
|
+
const PAIR_CODE = '' // optional custom 8-character code
|
|
190
67
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
- Media Stream Fixes — Improved download error handling, media retries, and expired-link recovery.
|
|
194
|
-
- Windows Hybrid Support — Updated device identification for modern WhatsApp connections.
|
|
195
|
-
- LID Compatibility — Improved "onWhatsApp()" support for LID-based addresses.
|
|
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.
|
|
68
|
+
const start = async () => {
|
|
69
|
+
const { state, saveCreds } = await useMultiFileAuthState('./session')
|
|
200
70
|
|
|
201
|
-
|
|
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
|
+
}
|
|
202
89
|
|
|
203
|
-
|
|
90
|
+
if (connection === 'open') console.log('Connected as', sock.user?.id)
|
|
204
91
|
|
|
205
|
-
|
|
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
|
+
}
|
|
206
113
|
|
|
207
|
-
|
|
114
|
+
start()
|
|
115
|
+
```
|
|
208
116
|
|
|
209
|
-
|
|
210
|
-
| --- | --- |
|
|
211
|
-
| "newsletterFromUrl()" | Fetch channel information from an invite link |
|
|
212
|
-
| "newsletterSubscribed()" | Get subscribed channels |
|
|
213
|
-
| "newsletterFetchAllSubscribe()" | Fetch all subscribed channels |
|
|
214
|
-
| "newsletterFetchMessages()" | Retrieve channel messages |
|
|
215
|
-
| "newsletterFetchUpdates()" | Fetch views and reactions |
|
|
216
|
-
| "newsletterReactionMode()" | Change channel reaction settings |
|
|
217
|
-
| "newsletterFollow()" | Follow a channel |
|
|
218
|
-
| "newsletterUnfollow()" | Unfollow a channel |
|
|
219
|
-
| "newsletterReactMessage()" | React to channel messages |
|
|
117
|
+
**How to link**
|
|
220
118
|
|
|
221
|
-
|
|
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) |
|
|
222
124
|
|
|
223
|
-
|
|
224
|
-
- Improved channel message decoding.
|
|
225
|
-
- Better thumbnail handling.
|
|
226
|
-
- Protection against missing channel profile pictures.
|
|
227
|
-
- Support for legacy message-fetching arguments.
|
|
125
|
+
> Your login is stored in `./session`. Keep it private and out of git.
|
|
228
126
|
|
|
229
|
-
###
|
|
127
|
+
### ⚙️ Socket options
|
|
230
128
|
|
|
231
|
-
|
|
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 |
|
|
232
141
|
|
|
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.
|
|
142
|
+
---
|
|
239
143
|
|
|
240
|
-
|
|
144
|
+
## 💬 Messages
|
|
241
145
|
|
|
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.
|
|
146
|
+
Everything from Baileys works as documented upstream — text, mentions, reactions, media, stickers, locations, polls and more:
|
|
246
147
|
|
|
247
|
-
|
|
148
|
+
```javascript
|
|
149
|
+
// Text with mention
|
|
150
|
+
await sock.sendMessage(jid, { text: 'Hello @923001234567', mentions: ['923001234567@s.whatsapp.net'] })
|
|
248
151
|
|
|
249
|
-
|
|
250
|
-
{
|
|
251
|
-
jid,
|
|
252
|
-
exists,
|
|
253
|
-
lid
|
|
254
|
-
}
|
|
255
|
-
```
|
|
152
|
+
// Image with caption
|
|
153
|
+
await sock.sendMessage(jid, { image: { url: 'https://example.com/pic.jpg' }, caption: 'Look at this' })
|
|
256
154
|
|
|
257
|
-
|
|
155
|
+
// Reaction
|
|
156
|
+
await sock.sendMessage(jid, { react: { text: '🔥', key: msg.key } })
|
|
258
157
|
|
|
259
|
-
|
|
158
|
+
// Poll
|
|
159
|
+
await sock.sendMessage(jid, {
|
|
160
|
+
poll: { name: 'Best language?', values: ['JavaScript', 'Python', 'Go'], selectableCount: 1 }
|
|
161
|
+
})
|
|
162
|
+
```
|
|
260
163
|
|
|
261
|
-
|
|
164
|
+
### Status & stories
|
|
262
165
|
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
'923001234567@s.whatsapp.net',
|
|
267
|
-
'923009876543@s.whatsapp.net'
|
|
268
|
-
],
|
|
269
|
-
{
|
|
270
|
-
text: 'Eid Mubarak! 🌙'
|
|
271
|
-
}
|
|
272
|
-
)
|
|
166
|
+
```javascript
|
|
167
|
+
// Status with mentions — sendStatusMention
|
|
168
|
+
await sock.sendStatusMention({ text: 'New post!' }, [jid1, jid2])
|
|
273
169
|
```
|
|
274
170
|
|
|
275
|
-
|
|
171
|
+
### Check a number
|
|
276
172
|
|
|
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
|
-
)
|
|
173
|
+
```javascript
|
|
174
|
+
// Is this number banned / on WhatsApp?
|
|
175
|
+
const status = await sock.checkStatusWA('923001234567')
|
|
290
176
|
```
|
|
291
177
|
|
|
292
|
-
|
|
178
|
+
---
|
|
293
179
|
|
|
294
|
-
|
|
180
|
+
## 🎛️ Interactive Messages
|
|
295
181
|
|
|
296
|
-
|
|
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.
|
|
297
183
|
|
|
298
|
-
|
|
299
|
-
- Stores available NCT salt in authentication credentials.
|
|
300
|
-
- Supports regular-high synchronization when history synchronization is disabled.
|
|
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.
|
|
184
|
+
### Buttons
|
|
304
185
|
|
|
305
|
-
The
|
|
186
|
+
Add a `buttons` array to any message. The message can also carry a `title`, `subtitle`, `footer` and an image/video/document header.
|
|
306
187
|
|
|
307
|
-
```
|
|
308
|
-
sock.
|
|
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
|
+
]
|
|
198
|
+
})
|
|
309
199
|
```
|
|
310
200
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
### 6. Custom Connection Banner
|
|
314
|
-
|
|
315
|
-
StableBail includes an optional branded connection banner.
|
|
201
|
+
**Button types**
|
|
316
202
|
|
|
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
|
|
218
|
+
await sock.sendMessage(jid, {
|
|
219
|
+
text: 'Pick a category',
|
|
220
|
+
footer: 'Tap below',
|
|
221
|
+
buttons: [
|
|
222
|
+
{
|
|
223
|
+
type: 'list',
|
|
224
|
+
title: 'Open menu',
|
|
225
|
+
sections: [
|
|
226
|
+
{
|
|
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
|
+
]
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
]
|
|
236
|
+
})
|
|
317
237
|
```
|
|
318
|
-
╭───────────────────────────╮
|
|
319
|
-
│ ✦ Q A D E E R ✦ │
|
|
320
|
-
│ stablebail • Qadeer-Xtech │
|
|
321
|
-
╰───────────────────────────╯
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
The banner is displayed once when the connection opens.
|
|
325
|
-
|
|
326
|
-
To disable it:
|
|
327
238
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
239
|
+
### Carousel
|
|
240
|
+
|
|
241
|
+
Swipeable cards, each with its own media, text and buttons:
|
|
242
|
+
|
|
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
|
+
}
|
|
333
265
|
})
|
|
334
266
|
```
|
|
335
267
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
```js
|
|
339
|
-
const makeWASocket =
|
|
340
|
-
require('@qadeer-xtech/stablebail').default
|
|
268
|
+
### Legacy buttons
|
|
341
269
|
|
|
342
|
-
|
|
343
|
-
useMultiFileAuthState,
|
|
344
|
-
DisconnectReason
|
|
345
|
-
} = require('@qadeer-xtech/stablebail')
|
|
270
|
+
Old-style template buttons are still available as `legacyButtons` if you need them.
|
|
346
271
|
|
|
347
|
-
async function startBot() {
|
|
348
|
-
const { state, saveCreds } =
|
|
349
|
-
await useMultiFileAuthState('auth_info')
|
|
350
272
|
|
|
351
|
-
|
|
352
|
-
auth: state,
|
|
353
|
-
printQRInTerminal: true
|
|
354
|
-
})
|
|
273
|
+
---
|
|
355
274
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return sock
|
|
359
|
-
}
|
|
275
|
+
## 🎨 Chat Themes
|
|
360
276
|
|
|
361
|
-
|
|
362
|
-
```
|
|
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.
|
|
363
278
|
|
|
364
|
-
|
|
279
|
+
```javascript
|
|
280
|
+
import { CHAT_THEMES } from '@qadeer-xtech/stablebail'
|
|
365
281
|
|
|
366
|
-
|
|
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')
|
|
367
285
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
'https://whatsapp.com/channel/CHANNEL_ID'
|
|
371
|
-
)
|
|
286
|
+
// ...or through sendMessage
|
|
287
|
+
await sock.sendMessage(jid, { chatTheme: 'Pink@Minimal' })
|
|
372
288
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
channel.name,
|
|
376
|
-
channel.subscribers
|
|
377
|
-
)
|
|
289
|
+
// Custom solid colour (ARGB hex strings), with optional doodle background
|
|
290
|
+
await sock.setChatThemeColor(jid, { colorLight: 'FFFF0000', colorDark: 'FF7A0000', isDoodleEnabled: true })
|
|
378
291
|
```
|
|
379
292
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
```js
|
|
383
|
-
await sock.newsletterFollow(channel.id)
|
|
384
|
-
|
|
385
|
-
await sock.newsletterUnfollow(channel.id)
|
|
386
|
-
```
|
|
293
|
+
---
|
|
387
294
|
|
|
388
|
-
|
|
295
|
+
## 🥷 Stealth Device Targeting
|
|
389
296
|
|
|
390
|
-
|
|
391
|
-
const channels = await sock.newsletterSubscribed()
|
|
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):
|
|
392
298
|
|
|
393
|
-
|
|
394
|
-
|
|
299
|
+
```javascript
|
|
300
|
+
// participant (no count): recipient-only — skips your own linked devices
|
|
301
|
+
await sock.relayMessage(jid, message, { participant: { jid } })
|
|
395
302
|
|
|
396
|
-
|
|
303
|
+
// isSecret: only the recipient's primary phone — no web/desktop companions
|
|
304
|
+
await sock.relayMessage(jid, message, { isSecret: true })
|
|
397
305
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
channel.id,
|
|
401
|
-
20
|
|
402
|
-
)
|
|
306
|
+
// protected: everywhere EXCEPT the recipient's linked/companion devices
|
|
307
|
+
await sock.relayMessage(jid, message, { protected: true })
|
|
403
308
|
|
|
404
|
-
|
|
309
|
+
// me: only your own devices
|
|
310
|
+
await sock.relayMessage(jid, message, { me: true })
|
|
405
311
|
```
|
|
406
312
|
|
|
407
|
-
|
|
313
|
+
---
|
|
408
314
|
|
|
409
|
-
|
|
410
|
-
const updates = await sock.newsletterFetchUpdates(
|
|
411
|
-
channel.id,
|
|
412
|
-
20
|
|
413
|
-
)
|
|
315
|
+
## 📢 Newsletter / Channels
|
|
414
316
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
updates[0].views,
|
|
418
|
-
updates[0].reactions
|
|
419
|
-
)
|
|
420
|
-
```
|
|
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.
|
|
421
319
|
|
|
422
|
-
|
|
320
|
+
---
|
|
423
321
|
|
|
424
|
-
|
|
425
|
-
await sock.sendMessage(channel.id, {
|
|
426
|
-
text: 'Assalam o Alaikum! 👋'
|
|
427
|
-
})
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
Send Channel Image
|
|
322
|
+
## 🔌 Disconnect reasons
|
|
431
323
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
React to Channel Message
|
|
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 |
|
|
442
333
|
|
|
443
|
-
|
|
444
|
-
await sock.newsletterReactMessage(
|
|
445
|
-
channel.id,
|
|
446
|
-
updates[0].server_id,
|
|
447
|
-
'❤️'
|
|
448
|
-
)
|
|
449
|
-
```
|
|
334
|
+
---
|
|
450
335
|
|
|
451
|
-
##
|
|
336
|
+
## 🗄️ Session storage
|
|
452
337
|
|
|
453
|
-
|
|
454
|
-
- Baileys-compatible socket workflow
|
|
455
|
-
- Existing Baileys-based bot projects
|
|
456
|
-
- Multi-file authentication
|
|
457
|
-
- WhatsApp Web connection workflows
|
|
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.
|
|
458
339
|
|
|
459
|
-
|
|
340
|
+
---
|
|
460
341
|
|
|
461
|
-
##
|
|
342
|
+
## 🙏 Credits
|
|
462
343
|
|
|
463
|
-
-
|
|
464
|
-
- Status mention functionality should be tested with a dedicated account before production use.
|
|
465
|
-
- WhatsApp may change its internal protocols without notice.
|
|
466
|
-
- Connection restrictions, account-level limitations, and server-side errors cannot always be resolved through library-side changes.
|
|
467
|
-
- Always keep your authentication credentials private.
|
|
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).
|
|
468
345
|
|
|
469
346
|
## 📄 License
|
|
470
347
|
|
|
471
|
-
MIT
|
|
472
|
-
is under MIT: the upstream Baileys code (© Rajeh Taher /
|
|
473
|
-
WhiskeySockets) and Team Qadeer's fixes, extensions and branding
|
|
474
|
-
(© Team Qadeer / Qadeer-Xtech) alike. The [NOTICE](NOTICE) file
|
|
475
|
-
ships with the package and carries a (non-binding) credit request.
|
|
476
|
-
|
|
477
|
-
## Dependencies
|
|
478
|
-
|
|
479
|
-
The two core dependencies are faithful republishes under the same
|
|
480
|
-
scope, with code **byte-identical** to upstream (proof in each
|
|
481
|
-
repo's DIFF.md):
|
|
482
|
-
|
|
483
|
-
- [@qadeer-xtech/libsignal](https://github.com/Qadeer-Xtech/libsignal) — of official libsignal 6.0.0
|
|
484
|
-
- [@qadeer-xtech/whatsapp-rust-bridge](https://github.com/Qadeer-Xtech/whatsapp-rust-bridge) — of official whatsapp-rust-bridge 0.5.4
|
|
485
|
-
|
|
486
|
-
## 🖤 Credits
|
|
487
|
-
|
|
488
|
-
Developed and maintained by Team Qadeer.
|
|
489
|
-
|
|
490
|
-
STABLEBAIL — Built for developers. Enhanced for performance.
|
|
491
|
-
|
|
492
|
-
"Powered by Team Qadeer"
|
|
348
|
+
MIT — see [LICENSE](https://github.com/Qadeer-Xtech/stablebail/blob/main/LICENSE).
|