ishumdz-bail 1.0.8 → 1.0.9

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.
Files changed (2) hide show
  1. package/README.md +396 -764
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,135 +1,300 @@
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=ishumdz-bail&fontAlignY=40&fontSize=44&fontColor=ffffff&desc=Stable%20WhatsApp%20Web%20API%20Fork%20for%20Production%20Bots&descAlignY=60&descSize=16" alt="Header Banner" />
3
2
 
4
- <br/>
5
-
6
- <!-- Rounded + border image -->
7
- <a href="https://ishanx-pro.site.je">
8
- <kbd>
9
- <img src="https://i.postimg.cc/9Q6q2Pv6/IMG-20260925-WA4965.jpg" alt="WhatsApp Baileys 2026" width="720" />
10
- </kbd>
11
- </a>
12
-
13
- <br/><br/>
14
-
15
-
16
- # 🧑‍💻 ishumdz-bail
3
+ ```
4
+ ╔═══════════════════════════════════════════════════════════════════╗
5
+ ║ ║
6
+ ║ ██╗ ██╗██████╗ █████╗ ███████╗████████╗ ║
7
+ ║ ██║ ██║██╔══██╗██╔══██╗██╔════╝╚══██╔══╝ ║
8
+ ║ ███████║██████╔╝███████║███████╗ ██║ ║
9
+ ║ ██╔══██║██╔══██╗██╔══██║╚════██║ ██║ ║
10
+ ║ ██║ ██║██████╔╝██║ ██║███████║ ██║ ║
11
+ ║ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ║
12
+ ║ ║
13
+ ║ ██████╗ ██╗ ██╗██╗███████╗ ║
14
+ ║ ██╔══██╗██║ ██║██║╚══███╔╝ ║
15
+ ║ ██║ ██║██║ ██║██║ ███╔╝ ║
16
+ ║ ██║ ██║██║ ██║██║ ███╔╝ ║
17
+ ║ ██████╔╝╚██████╔╝██║███████╗ ║
18
+ ║ ╚═════╝ ╚═════╝ ╚═╝╚══════╝ ║
19
+ ║ ║
20
+ ║ WhatsApp Web API Fork for Bots ║
21
+ ║ By Lovely ❤️ ║
22
+ ║ ║
23
+ ╚═══════════════════════════════════════════════════════════════════╝
24
+ ```
25
+
26
+ <img src="https://i.postimg.cc/9Q6q2Pv6/IMG-20260925-WA4965.jpg" alt="ishumdz-bail" width="700" />
17
27
 
18
- <p>
19
- <img src="https://img.shields.io/badge/Node.js-%3E%3D20-339933?style=for-the-badge&logo=nodedotjs&logoColor=white" />
20
- <img src="https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white" />
21
- <img src="https://img.shields.io/badge/WebSocket-010101?style=for-the-badge&logo=socketdotio&logoColor=white" />
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>
28
+ <br/>
25
29
 
26
- <p>
27
- <img src="https://img.shields.io/npm/v/ishumdz-bail?style=flat-square&color=25D366&label=npm" />
28
- <img src="https://img.shields.io/badge/maintained%20by-Lovely-black?style=flat-square" />
29
- </p>
30
+ [![npm](https://img.shields.io/badge/npm-ishumdz--bail-25D366?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/ishumdz-bail)
31
+ [![GitHub](https://img.shields.io/badge/GitHub-lovelyofficial/ishumdz--bail-FF4500?style=for-the-badge&logo=github&logoColor=white)](https://github.com/lovelyofficial/ishumdz-bail)
32
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D20-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org)
33
+ [![License](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)](LICENSE)
34
+ [![WhatsApp](https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white)](https://whatsapp.com)
30
35
 
31
36
  **Open-source WhatsApp automation library — no browser required.**
32
37
  Built on WebSocket for speed, stability, and full multi-device support.
33
38
 
34
- <br/>
39
+ </div>
35
40
 
36
- [Installation](#-getting-started) • [Features](#-main-features) • [Stability](#-stability--disconnect-handling) • [Website](https://ishanx-pro.site.je) • [WhatsApp Channel](https://shyracore.indevs.in)
41
+ ---
37
42
 
38
- </div>
43
+ ## 📋 Table of Contents
44
+
45
+ - [✨ What is ishumdz-bail?](#-what-is-ishumdz-bail)
46
+ - [🚀 Installation](#-installation)
47
+ - [⚡ Quick Start](#-quick-start)
48
+ - [🎯 Features Overview](#-features-overview)
49
+ - [🎮 Games](#-games)
50
+ - [📞 VoIP Caller](#-voip-caller)
51
+ - [⚡ Pro Methods](#-pro-methods)
52
+ - [📊 Polls](#-polls)
53
+ - [📢 Newsletter/Channels](#-newsletterchannels)
54
+ - [🟢 Status/Stories](#-statusstories)
55
+ - [💬 Chat Actions](#-chat-actions)
56
+ - [👥 Group Management](#-group-management)
57
+ - [👤 Profile Management](#-profile-management)
58
+ - [📰 Newsletter Media](#-newsletter-media)
59
+ - [🔌 API Reference](#-api-reference)
60
+ - [📝 Examples](#-examples)
39
61
 
40
62
  ---
41
63
 
42
64
  ## ✨ What is ishumdz-bail?
43
65
 
44
- **ishumdz-bail** (`ishumdz-bail`) is a powerful, open-source WhatsApp Web library built on top of the Baileys protocol stack — extended with features not found in any other public fork. It connects directly to WhatsApp's multi-device WebSocket protocol. No Selenium, no Puppeteer, no browser overhead.
66
+ **ishumdz-bail** is a powerful, open-source WhatsApp Web library built on top of the Baileys protocol stack — extended with features not found in any other public fork.
45
67
 
46
- > ⚡ **Node.js ≥ 20 required.**
68
+ **Why choose ishumdz-bail?**
69
+
70
+ ```
71
+ ┌─────────────────────────────────────────────────────────────────┐
72
+ │ ✅ No Browser Required │ ✅ Multi-Device Support │
73
+ │ ✅ WebSocket Based │ ✅ Full API Coverage │
74
+ │ ✅ Built-in Games (8) │ ✅ VoIP Call Answer │
75
+ │ ✅ Pro Methods (34) │ ✅ Newsletter/Channel Support │
76
+ │ ✅ Active Maintenance │ ✅ MIT Licensed │
77
+ └─────────────────────────────────────────────────────────────────┘
78
+ ```
47
79
 
48
80
  ---
49
81
 
50
- ## 🚀 Getting Started
82
+ ## 🚀 Installation
51
83
 
52
84
  ```bash
53
85
  npm install ishumdz-bail
54
86
  ```
55
87
 
88
+ **Requirements:**
89
+ - Node.js ≥ 20
90
+ - npm or yarn
91
+
92
+ ---
93
+
94
+ ## ⚡ Quick Start
95
+
56
96
  ```javascript
57
- import { makeWASocket, useMultiFileAuthState } from 'ishumdz-bail'
97
+ const { makeWASocket, useMultiFileAuthState, attachProMethods } = require('ishumdz-bail');
98
+
99
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info');
58
100
 
59
- const { state, saveCreds } = await useMultiFileAuthState('auth_info')
60
101
  const sock = makeWASocket({
61
102
  auth: state,
62
- syncFullHistory: false, // skip history sync — bot works immediately
63
- aiLabel: true, // stamp messages with AI bot marker (default: true)
64
- })
103
+ syncFullHistory: false,
104
+ aiLabel: true,
105
+ autoAnswer: false,
106
+ });
107
+
108
+ sock.ev.on('creds.update', saveCreds);
65
109
 
66
- sock.ev.on('creds.update', saveCreds)
110
+ sock.ev.on('connection.update', ({ connection }) => {
111
+ if (connection === 'open') {
112
+ console.log('✅ Connected to WhatsApp!');
113
+
114
+ // Attach Pro methods
115
+ attachProMethods(sock);
116
+ }
117
+ });
67
118
  ```
68
119
 
69
120
  ---
70
121
 
71
- ## 🧩 Main Features
72
-
73
- | Feature | Description |
74
- |---|---|
75
- | 💬 **Rich Response (GenAI Bubble)** | Send Meta AI-style messages: markdown, code blocks, tables, LaTeX, maps, inline images, HTML — rendered natively as GenAI bubble in WA client |
76
- | 🚫 **4-Factor Ban Checker** | Detect ban status via 4 independent signals: live registry, public send-page, identity-key probe, device-count signature |
77
- | 🆔 **Username Socket (w:mex)** | Full WA username API: check availability, set, delete, pin, find by username, fetch recommendations — via WhatsApp's internal Pando/MEX GraphQL protocol |
78
- | 🏘️ **Communities Socket** | Full community management: create, link/unlink groups, manage participants, invite codes, ephemeral toggle, approval mode |
79
- | 🔕 **noSelfSync** | Skip syncing outgoing messages to your own other devices — reduces noise and bandwidth. Includes silent-drop guard (throws 421 instead of pretending the send succeeded) |
80
- | ⚙️ **Rust-powered Crypto** | `md5`, `hkdf`, LT-Hash anti-tampering offloaded to `whatsapp-rust-bridge` native module for raw speed |
81
- | 🗂️ **LID Mapping Store** | Persistent LID ↔ phone-number bi-directional cache with LRU eviction and in-flight dedup — prevents duplicate USync lookups |
82
- | 🔐 **Pre-Key Manager** | Concurrency-safe Signal pre-key operations via per-key-type PQueue — no race conditions on key updates/deletions |
83
- | 🔄 **Classify Disconnect** | Maps every WA disconnect code to `{ category, shouldReconnect, backoffMs }` — properly handles code 515 (restartRequired) as recoverable, not fatal |
84
- | ⏱️ **Rate Limiter** | Anti-spam pacing calculator: enforces per-minute/hour/day caps, burst allowance, new-chat delays, identical-message dedup |
85
- | 🖼️ **Album Message** | Send multiple images/videos as a single WA album/grid, with per-item or top-level caption and `gifPlayback` support |
86
- | 🤖 **AI Label Config** | `aiLabel: true/false` in socket config — controls whether outgoing messages carry the `biz_bot` attribute that WA uses to render the AI icon |
87
- | 🔎 **USync Username Protocol** | Username resolution baked into USync queries — resolve WA usernames alongside contacts in a single round-trip |
88
- | 📥 **Offline Node Processor** | Batch-processes pending stanzas received while offline, preventing message loss on reconnect |
89
- | 🔑 **Identity Change Handler** | Dedicated handler for Signal identity key changes — prevents session corruption when a contact re-registers |
90
- | 📣 **Newsletter/Channel Media Upload** | Full support for uploading images, videos, audio, stickers to channels using correct `/newsletter/newsletter-*` paths |
91
- | 😀 **Newsletter Reactions** | React to channel messages with emojis, track votes, and manage newsletter engagement |
92
- | 📊 **Poll Voting** | Create polls, track encrypted votes, display results, and support multiple selection polls |
93
- | 🎮 **Built-in Games** | 8 games: Blackjack, Slots, Dice, Coin Flip, Roulette, Mines, Trivia, Rock Paper Scissors |
94
- | 📞 **VoIP Caller** | Answer incoming calls with audio playback using WASM VoIP engine |
95
- | ⚡ **Pro Methods** | 34 convenience methods: Polls, Newsletter, Status, Chat, Groups, Profile |
122
+ ## 🎯 Features Overview
123
+
124
+ ```
125
+ ┌─────────────────────────────────────────────────────────────────────────┐
126
+ │ ISHUMDZ-BAIL FEATURES │
127
+ ├─────────────────────────────────────────────────────────────────────────┤
128
+ │ │
129
+ │ 🎮 GAMES (8) │ 📞 VOIP (3) │ ⚡ PRO METHODS (34) │
130
+ │ ├─ Blackjack │ ├─ VoipClient │ ├─ sendPoll │
131
+ │ ├─ Slots │ ├─ ActiveCall │ ├─ sendPollVote │
132
+ │ ├─ Dice │ └─ AudioFeeder │ ├─ editMessage │
133
+ │ ├─ Coin Flip │ │ ├─ deleteMessage │
134
+ │ ├─ Roulette │ 📊 POLLS (3) │ ├─ pinMessage │
135
+ │ ├─ Mines │ ├─ sendPoll │ ├─ reactMessage │
136
+ │ ├─ Trivia │ ├─ sendPollVote │ ├─ sendStatusText │
137
+ │ └─ Rock Paper │ └─ getAggregate │ ├─ checkNumber │
138
+ │ Scissors │ Votes │ └─ ... and more! │
139
+ │ │
140
+ │ 📢 NEWSLETTER (6) │ 🟢 STATUS (4) │ 💬 CHAT (8) │
141
+ │ ├─ channelVote │ ├─ sendStatusText │ ├─ editMessage │
142
+ │ ├─ newsletterReact │ ├─ sendStatusMedia │ ├─ deleteMessage │
143
+ │ ├─ newsletterGet │ ├─ readStatus │ ├─ pinMessage │
144
+ │ │ Messages │ └─ reactStatus │ ├─ unpinMessage │
145
+ │ ├─ newsletterSearch │ │ ├─ starMessage │
146
+ │ └─ newsletterList │ 👥 GROUPS (7) │ ├─ sendPresence │
147
+ │ │ ├─ groupGetInvite │ └─ reply │
148
+ │ 👤 PROFILE (6) │ ├─ groupJoinVia │ │
149
+ │ ├─ checkNumber │ │ Invite │ │
150
+ │ ├─ setBio │ ├─ groupSet │ │
151
+ │ ├─ updateProfileName │ │ Announcement │ │
152
+ │ ├─ setProfilePicture │ ├─ groupSetLocked │ │
153
+ │ ├─ removeProfile │ ├─ groupRequest │ │
154
+ │ │ Picture │ │ Participants │ │
155
+ │ └─ rejectCall │ ├─ groupApprove │ │
156
+ │ │ │ Participants │ │
157
+ │ │ └─ groupReject │ │
158
+ │ │ Participants │ │
159
+ │ │
160
+ └─────────────────────────────────────────────────────────────────────────┘
161
+ ```
96
162
 
97
163
  ---
98
164
 
99
- ## 📞 VoIP Caller (Call Answer + Audio)
165
+ ## 🎮 Games
166
+
167
+ 8 built-in games for your WhatsApp bot:
168
+
169
+ ```javascript
170
+ const { blackjack, slotMachine, diceGame, coinFlip, roulette, rps, trivia, createMines } = require('ishumdz-bail');
171
+ ```
172
+
173
+ ### 🃏 Blackjack
174
+
175
+ ```javascript
176
+ // Start a game
177
+ const game = blackjack('start', [], [], 100);
178
+ console.log(game.playerHand); // [{suit:'♠️',value:'A'}, {suit:'♥️',value:'K'}]
179
+ console.log(game.dealerHand); // [{suit:'♦️',value:'5'}, {suit:'♣️',value:'?'}]
180
+ console.log(game.status); // 'playing'
181
+
182
+ // Hit (draw card)
183
+ const hit = blackjack('hit', game.playerHand, game.dealerHand, 100);
100
184
 
101
- Answer incoming WhatsApp calls and play audio automatically:
185
+ // Stand (end turn)
186
+ const stand = blackjack('stand', game.playerHand, game.dealerHand, 100);
187
+ console.log(stand.status); // 'win', 'lose', or 'push'
188
+ ```
189
+
190
+ ### 🎰 Slots
102
191
 
103
192
  ```javascript
104
- const { makeWASocket, enableCallAutoAnswer } = require('ishumdz-bail');
193
+ const slots = slotMachine(100);
194
+ console.log(slots.reels); // ['🍒', '🍋', '🍊']
195
+ console.log(slots.payout); // 0-500 (multiplier)
196
+ ```
197
+
198
+ ### 🎲 Dice
199
+
200
+ ```javascript
201
+ const dice = diceGame(100, 'high'); // 'high', 'low', or specific number
202
+ console.log(dice.dice1); // 1-6
203
+ console.log(dice.dice2); // 1-6
204
+ console.log(dice.total); // 2-12
205
+ console.log(dice.win); // true/false
206
+ ```
207
+
208
+ ### 🪙 Coin Flip
209
+
210
+ ```javascript
211
+ const flip = coinFlip(100, 'heads'); // 'heads' or 'tails'
212
+ console.log(flip.result); // 'heads' or 'tails'
213
+ console.log(flip.payout); // 0 or 200
214
+ ```
215
+
216
+ ### 🎡 Roulette
217
+
218
+ ```javascript
219
+ const spin = roulette(100, 'red'); // 'red', 'black', 'green', or number
220
+ console.log(spin.number); // 0-36
221
+ console.log(spin.color); // 'red', 'black', or 'green'
222
+ console.log(spin.payout); // 0-3600
223
+ ```
224
+
225
+ ### ✊ Rock Paper Scissors
226
+
227
+ ```javascript
228
+ const game = rps('rock'); // 'rock', 'paper', or 'scissors'
229
+ console.log(game.playerChoice); // 'rock'
230
+ console.log(game.botChoice); // 'paper'
231
+ console.log(game.result); // 'win', 'lose', or 'draw'
232
+ ```
233
+
234
+ ### 🧠 Trivia
235
+
236
+ ```javascript
237
+ const question = trivia(100);
238
+ console.log(question.question); // 'What is the capital of France?'
239
+ console.log(question.options); // ['A) Paris', 'B) London', ...]
240
+ console.log(question.answer); // 'A'
241
+ ```
242
+
243
+ ### 💣 Mines
244
+
245
+ ```javascript
246
+ // Create a 5x5 grid with 5 mines
247
+ const game = createMines(5, 5, 5);
248
+ console.log(game.totalSafe); // 20
249
+
250
+ // Reveal a tile
251
+ const tile = revealTile(game, 0, 0);
252
+ console.log(tile.safe); // true (diamond) or false (mine)
253
+ console.log(tile.mine); // true or false
254
+
255
+ // Cash out
256
+ const cashout = cashoutMines(game, 100);
257
+ console.log(cashout.payout); // based on revealed tiles
258
+ ```
259
+
260
+ ---
261
+
262
+ ## 📞 VoIP Caller
263
+
264
+ Answer incoming WhatsApp calls with audio playback:
265
+
266
+ ```javascript
267
+ const { makeWASocket, enableCallAutoAnswer, getActiveVoipClient } = require('ishumdz-bail');
105
268
 
106
269
  const sock = makeWASocket({ auth: state });
107
270
 
108
- // Enable auto-answer with audio playback
271
+ // Enable auto-answer
109
272
  sock.enableCallAutoAnswer({
110
- audio: './welcome.wav', // Audio file to play (MP3/WAV)
111
- autoAnswer: true, // Auto-answer incoming calls
112
- answerDelayMs: 200, // Delay before answering
113
- durationMs: 60000, // Max call duration (60s)
114
- loop: true, // Loop audio
115
- onCall: (call) => {}, // Callback on incoming call
116
- onAnswer: (call) => {}, // Callback when answered
117
- onEnd: (call, reason) => {} // Callback when ended
273
+ audio: './welcome.wav', // Audio file (MP3/WAV)
274
+ autoAnswer: true, // Auto-answer calls
275
+ answerDelayMs: 200, // Delay before answer
276
+ durationMs: 60000, // Max duration (60s)
277
+ loop: true, // Loop audio
278
+ onCall: (call) => {}, // Incoming call callback
279
+ onAnswer: (call) => {}, // Answered callback
280
+ onEnd: (call, reason) => {} // Ended callback
118
281
  });
119
282
  ```
120
283
 
121
- **Manual call handling:**
284
+ ### Manual Call Handling
285
+
122
286
  ```javascript
123
287
  sock.ev.on('call', async ([call]) => {
124
288
  if (call.status === 'offer') {
289
+ console.log(`📞 Incoming ${call.isVideo ? 'video' : 'voice'} call from ${call.from}`);
290
+
125
291
  // Reject call
126
292
  await sock.rejectCall(call.id, call.from);
127
293
 
128
294
  // Or accept with VoIP client
129
295
  const voipClient = getActiveVoipClient();
130
- if (voipClient) {
131
- const activeCall = voipClient.activeCall;
132
- activeCall.accept('./audio.wav');
296
+ if (voipClient?.activeCall) {
297
+ voipClient.activeCall.accept('./audio.wav');
133
298
  }
134
299
  }
135
300
  });
@@ -139,7 +304,7 @@ sock.ev.on('call', async ([call]) => {
139
304
 
140
305
  ## ⚡ Pro Methods
141
306
 
142
- 34 convenience methods attached to socket via `attachProMethods()`:
307
+ 34 convenience methods for easier development:
143
308
 
144
309
  ```javascript
145
310
  const { makeWASocket, attachProMethods } = require('ishumdz-bail');
@@ -148,7 +313,9 @@ const sock = makeWASocket({ auth: state });
148
313
  attachProMethods(sock); // Attach all Pro methods
149
314
  ```
150
315
 
151
- ### 📊 Polls Pro
316
+ ---
317
+
318
+ ## 📊 Polls
152
319
 
153
320
  ```javascript
154
321
  // Create a poll
@@ -165,10 +332,12 @@ await sock.sendPollVote(jid, pollMessage, ['Red']);
165
332
  const votes = sock.getAggregatePollVotes(pollMessage);
166
333
  ```
167
334
 
168
- ### 📢 Newsletter/Channel Pro
335
+ ---
336
+
337
+ ## 📢 Newsletter/Channels
169
338
 
170
339
  ```javascript
171
- // Smart channel poll vote (auto-resolves links, IDs)
340
+ // Smart channel poll vote (auto-resolves links)
172
341
  await sock.channelVote('https://whatsapp.com/channel/xxx/123', 1);
173
342
 
174
343
  // React to channel post
@@ -184,7 +353,9 @@ const results = await sock.newsletterSearch('technology');
184
353
  const channels = await sock.newsletterList();
185
354
  ```
186
355
 
187
- ### 🟢 Status/Stories Pro
356
+ ---
357
+
358
+ ## 🟢 Status/Stories
188
359
 
189
360
  ```javascript
190
361
  // Send text status
@@ -203,7 +374,9 @@ await sock.sendStatusMedia('./photo.jpg', {
203
374
  await sock.reactStatus(statusKey, '❤️');
204
375
  ```
205
376
 
206
- ### 💬 Chat Pro
377
+ ---
378
+
379
+ ## 💬 Chat Actions
207
380
 
208
381
  ```javascript
209
382
  // Edit a message
@@ -212,8 +385,11 @@ await sock.editMessage(jid, messageKey, 'Updated text!');
212
385
  // Delete a message
213
386
  await sock.deleteMessage(jid, messageKey);
214
387
 
215
- // Pin a message (24h, 7d, or 30d)
216
- await sock.pinMessage(jid, messageKey, 86400); // 24 hours
388
+ // Pin a message (86400 = 24h, 604800 = 7d, 2592000 = 30d)
389
+ await sock.pinMessage(jid, messageKey, 86400);
390
+
391
+ // Unpin a message
392
+ await sock.unpinMessage(jid, messageKey);
217
393
 
218
394
  // Star/unstar a message
219
395
  await sock.starMessage(jid, messageKey, true);
@@ -228,7 +404,9 @@ await sock.sendPresence(jid, 'composing');
228
404
  await sock.reply(jid, 'This is a reply!', quotedMessage);
229
405
  ```
230
406
 
231
- ### 👥 Groups Pro
407
+ ---
408
+
409
+ ## 👥 Group Management
232
410
 
233
411
  ```javascript
234
412
  // Get group info from invite link
@@ -249,7 +427,9 @@ await sock.groupApproveParticipants(groupJid, [participant1, participant2]);
249
427
  await sock.groupRejectParticipants(groupJid, [participant3]);
250
428
  ```
251
429
 
252
- ### 👤 Profile Pro
430
+ ---
431
+
432
+ ## 👤 Profile Management
253
433
 
254
434
  ```javascript
255
435
  // Check if number exists on WhatsApp
@@ -271,722 +451,174 @@ await sock.removeProfilePicture(jid);
271
451
 
272
452
  ---
273
453
 
274
- ## 🎮 Built-in Games
454
+ ## 📰 Newsletter Media
275
455
 
276
- 8 fun games for your WhatsApp bot:
456
+ Upload media to channels with correct paths:
277
457
 
278
458
  ```javascript
279
- const { blackjack, slotMachine, diceGame, coinFlip, roulette, rps, trivia, createMines } = require('ishumdz-bail');
280
-
281
- // Blackjack
282
- const game = blackjack('start', [], [], 100); // Start with 100 bet
283
- // game.playerHand, game.dealerHand, game.status
284
-
285
- // Slots
286
- const slots = slotMachine(100);
287
- // slots.reels, slots.payout
288
-
289
- // Dice
290
- const dice = diceGame(100, 'high'); // Bet on high (7-12)
291
- // dice.total, dice.dice1, dice.dice2
292
-
293
- // Coin Flip
294
- const flip = coinFlip(100, 'heads');
295
- // flip.result, flip.payout
296
-
297
- // Roulette
298
- const spin = roulette(100, 'red');
299
- // spin.number, spin.color, spin.payout
300
-
301
- // Rock Paper Scissors
302
- const game = rps('rock');
303
- // game.playerChoice, game.botChoice, game.result
304
-
305
- // Trivia
306
- const question = trivia(100);
307
- // question.question, question.options, question.answer
308
-
309
- // Mines
310
- const mines = createMines(5, 5, 5); // 5x5 grid, 5 mines
311
- const tile = revealTile(mines, 0, 0); // Reveal tile at (0,0)
312
- // tile.safe, tile.mine
313
- const cashout = cashoutMines(mines, 100); // Cash out
314
- // cashout.payout
315
- ```
316
-
317
- ## 💬 Rich Response (GenAI Bubble)
318
-
319
- Send messages that render as Meta AI-style bubbles inside WhatsApp. Supports multiple primitives in a single message:
320
-
321
- ```javascript
322
- // Markdown text
323
- await sock.sendMessage(jid, {
324
- richResponse: {
325
- text: '**Hello** from *ishumdz-bail*',
326
- responseId: 'optional-uuid'
327
- }
328
- })
329
-
330
- // Code block
331
- await sock.sendMessage(jid, {
332
- richResponse: {
333
- code: 'console.log("hello")',
334
- language: 'javascript'
335
- }
336
- })
337
-
338
- // Table
339
- await sock.sendMessage(jid, {
340
- richResponse: {
341
- table: {
342
- rows: [
343
- ['Name', 'Age'],
344
- ['Alice', '25'],
345
- ['Bob', '30']
346
- ]
347
- }
348
- }
349
- })
350
-
351
- // HTML (raw HTML rendered in client)
352
- await sock.sendMessage(jid, {
353
- richResponse: {
354
- text: 'fallback',
355
- html: '<b>bold</b> <a href="https://example.com">link</a>'
356
- }
357
- })
358
-
359
- // LaTeX
360
- await sock.sendMessage(jid, {
361
- richResponse: {
362
- latex: 'E = mc^2'
363
- }
364
- })
365
-
366
- // Map / location
367
- await sock.sendMessage(jid, {
368
- richResponse: {
369
- map: {
370
- latitude: -6.2,
371
- longitude: 106.8,
372
- zoom: 15,
373
- title: 'Jakarta',
374
- annotations: []
375
- }
376
- }
377
- })
378
-
379
- // Inline image
380
- await sock.sendMessage(jid, {
381
- richResponse: {
382
- imageUrl: 'https://example.com/photo.jpg'
383
- }
384
- })
385
- ```
459
+ const { NEWSLETTER_MEDIA_PATH_MAP } = require('ishumdz-bail');
386
460
 
387
- **Shortcut methods** (all accept `quoted` and `options`):
388
-
389
- ```javascript
390
- await sock.sendTable(jid, 'Title', ['H1','H2'], [['A','B']], quoted)
391
- await sock.sendList(jid, 'Title', ['item1','item2'], quoted)
392
- await sock.sendCodeBlock(jid, 'print("hello")', quoted, { language: 'python' })
393
- await sock.sendLatex(jid, quoted, { latex: 'x^2 + y^2 = z^2' })
394
- await sock.sendRichMessage(jid, submessages, quoted)
395
- ```
396
-
397
- ---
398
-
399
- ## 🖼️ Album Message
400
-
401
- Send multiple images/videos grouped into a single WA album:
402
-
403
- ```javascript
404
- await sock.sendMessage(jid, {
405
- album: [
406
- { image: { url: 'https://example.com/a.jpg' } },
407
- { image: { url: 'https://example.com/b.jpg' }, caption: 'caption foto kedua' },
408
- { video: { url: 'https://example.com/c.mp4' }, gifPlayback: false }
409
- ],
410
- caption: 'caption ini otomatis ke item pertama'
411
- })
412
- ```
413
-
414
- ---
415
-
416
- ## 🚫 Ban Checker
417
-
418
- 4-factor ban detection against WhatsApp's own servers — no third-party API:
419
-
420
- ```javascript
421
- const result = await sock.checkBanStatus('628123456789')
422
- // or: sock.checkBanStatus('628123456789@s.whatsapp.net')
423
-
424
- console.log(result)
461
+ console.log(NEWSLETTER_MEDIA_PATH_MAP);
425
462
  // {
426
- // status: 'ACTIVE' | 'PROFILE_HIDDEN' | 'LIKELY_ACTIVE' | 'BANNED' | 'OFF_WHATSAPP' | 'UNKNOWN',
427
- // emoji: '🟢' | '🟡' | '🔴' | '❓',
428
- // confidence: 0..1,
429
- // deviceCount: number | null,
430
- // registryExists: boolean | null,
431
- // pageVisible: boolean | null,
432
- // profileName: string | null
463
+ // image: '/newsletter/newsletter-image',
464
+ // video: '/newsletter/newsletter-video',
465
+ // document: '/newsletter/newsletter-document',
466
+ // audio: '/newsletter/newsletter-audio',
467
+ // sticker: '/newsletter/newsletter-image',
468
+ // gif: '/newsletter/newsletter-gif',
469
+ // ptt: '/newsletter/newsletter-ptt',
470
+ // ptv: '/newsletter/newsletter-ptv'
433
471
  // }
434
472
  ```
435
473
 
436
- **Four factors checked:**
437
- - **Factor A** — Live registry (`sock.onWhatsApp`)
438
- - **Factor B** — Public send-page title/image probe (`api.whatsapp.com`)
439
- - **Factor C** — Identity-key device probe via USync (strongest: banned numbers have their keys destroyed)
440
- - **Factor D** — Device-count signature (2+ = ACTIVE, 1 generic = likely BANNED, 0 = BANNED/OFF_WA)
441
-
442
- ---
443
-
444
- ## 🆔 Username Socket (w:mex)
445
-
446
- Full WA `@username` API via WhatsApp's internal Pando/MEX GraphQL protocol, query IDs sourced from Java decompile of WA 2.26.17.2:
447
-
448
- ```javascript
449
- // Check availability
450
- const res = await sock.checkUsername('myusername')
451
- // { available: true, username } or { available: false, suggestions: [...] }
452
-
453
- // Set username
454
- await sock.setUsername('myusername')
455
-
456
- // Delete username
457
- await sock.deleteUsername()
458
-
459
- // Get your own username
460
- const mine = await sock.getMyUsername()
461
-
462
- // Pin/unpin username
463
- await sock.setUsernamePin(true)
464
-
465
- // Find user by username
466
- const user = await sock.findUserByUsername('someuser', pin)
467
-
468
- // Fetch usernames of your contacts in batch
469
- const usernames = await sock.fetchContactUsernames('94xxxx@s.whatsapp.net', '628yyy@s.whatsapp.net')
470
-
471
- // Get username suggestions
472
- const suggestions = await sock.getUsernameRecommendations()
473
- ```
474
-
475
474
  ---
476
475
 
477
- ## 🏘️ Communities Socket
478
-
479
- ```javascript
480
- // Create community
481
- const community = await sock.communityCreate('Community Name', 'Description')
482
-
483
- // Create group inside community
484
- await sock.communityCreateGroup('Group Name', [jid1, jid2], communityJid)
485
-
486
- // Link/unlink existing group
487
- await sock.communityLinkGroup(groupJid, communityJid)
488
- await sock.communityUnlinkGroup(groupJid, communityJid)
489
-
490
- // Fetch linked groups
491
- const groups = await sock.communityFetchLinkedGroups(communityJid)
492
-
493
- // Manage participants
494
- await sock.communityParticipantsUpdate(communityJid, [jid1], 'add') // 'add' | 'remove' | 'promote' | 'demote'
495
-
496
- // Invite code
497
- const code = await sock.communityInviteCode(communityJid)
498
- await sock.communityRevokeInvite(communityJid)
499
- await sock.communityAcceptInvite(code)
500
-
501
- // Settings
502
- await sock.communityToggleEphemeral(communityJid, 86400) // seconds
503
- await sock.communityMemberAddMode(communityJid, 'admin_add')
504
- await sock.communityJoinApprovalMode(communityJid, 'on')
505
- await sock.communityUpdateSubject(communityJid, 'New Name')
506
- await sock.communityUpdateDescription(communityJid, 'New Desc')
507
- await sock.communityLeave(communityJid)
508
- ```
476
+ ## 🔌 API Reference
477
+
478
+ ### Core Functions
479
+
480
+ | Function | Description |
481
+ |----------|-------------|
482
+ | `makeWASocket(config)` | Create WhatsApp socket |
483
+ | `useMultiFileAuthState(dir)` | Multi-file auth state |
484
+ | `attachProMethods(sock)` | Attach Pro methods |
485
+ | `enableCallAutoAnswer(sock, opts)` | Enable VoIP auto-answer |
486
+ | `getActiveVoipClient()` | Get active VoIP client |
487
+ | `delay(ms)` | Delay execution |
488
+
489
+ ### Games
490
+
491
+ | Function | Description |
492
+ |----------|-------------|
493
+ | `blackjack(action, player, dealer, bet)` | Play blackjack |
494
+ | `slotMachine(bet)` | Play slots |
495
+ | `diceGame(bet, prediction)` | Play dice |
496
+ | `coinFlip(bet, choice)` | Flip coin |
497
+ | `roulette(bet, choice)` | Play roulette |
498
+ | `rps(choice)` | Rock Paper Scissors |
499
+ | `trivia(bet)` | Play trivia |
500
+ | `createMines(rows, cols, mines)` | Create mines game |
501
+ | `revealTile(game, row, col)` | Reveal tile |
502
+ | `cashoutMines(game, bet)` | Cash out |
503
+
504
+ ### Pro Methods
505
+
506
+ | Function | Description |
507
+ |----------|-------------|
508
+ | `sendPoll(jid, data)` | Create poll |
509
+ | `sendPollVote(jid, key, options)` | Vote on poll |
510
+ | `editMessage(jid, key, text)` | Edit message |
511
+ | `deleteMessage(jid, key)` | Delete message |
512
+ | `pinMessage(jid, key, duration)` | Pin message |
513
+ | `unpinMessage(jid, key)` | Unpin message |
514
+ | `starMessage(jid, key, star)` | Star message |
515
+ | `reactMessage(jid, key, emoji)` | React to message |
516
+ | `sendPresence(jid, presence)` | Send presence |
517
+ | `reply(jid, text, quoted)` | Reply with quote |
518
+ | `checkNumber(phone)` | Check WhatsApp number |
519
+ | `setBio(text)` | Update bio |
520
+ | `updateProfileName(name)` | Update name |
521
+ | `setProfilePicture(jid, content)` | Set profile pic |
522
+ | `removeProfilePicture(jid)` | Remove profile pic |
523
+ | `sendStatusText(text, options)` | Send text status |
524
+ | `sendStatusMedia(media, options)` | Send media status |
525
+ | `readStatus(key)` | Mark status as read |
526
+ | `reactStatus(key, emoji)` | React to status |
527
+ | `channelVote(target, option)` | Smart channel vote |
528
+ | `newsletterReact(jid, id, reaction)` | React to channel |
529
+ | `newsletterGetMessages(jid, count)` | Get channel messages |
530
+ | `newsletterSearch(query)` | Search channels |
531
+ | `newsletterList()` | List followed channels |
532
+ | `groupGetInviteInfo(code)` | Get group info |
533
+ | `groupJoinViaInvite(code)` | Join via invite |
534
+ | `groupSetAnnouncement(jid, bool)` | Admin-only messages |
535
+ | `groupSetLocked(jid, bool)` | Admin-only edit |
536
+ | `groupRequestParticipantsList(jid)` | Pending requests |
537
+ | `groupApproveParticipants(jid, list)` | Approve requests |
538
+ | `groupRejectParticipants(jid, list)` | Reject requests |
539
+ | `rejectCall(callId, from)` | Reject call |
509
540
 
510
541
  ---
511
542
 
512
- ## 🔕 noSelfSync
543
+ ## 📝 Examples
513
544
 
514
- Skip syncing outgoing messages to your own linked devices. Useful for high-volume bots where sync traffic is unnecessary:
545
+ ### Basic Bot
515
546
 
516
547
  ```javascript
517
- await sock.sendMessage(jid, { text: 'hello' }, { noSelfSync: true })
518
-
519
- // Also supported in all shortcut methods:
520
- await sock.sendTable(jid, title, headers, rows, quoted, { noSelfSync: true })
521
- await sock.sendCodeBlock(jid, code, quoted, { noSelfSync: true })
522
- ```
523
-
524
- > **Safe by design:** if `noSelfSync` would accidentally drop all recipients (e.g. messaging yourself), the guard kicks in and delivers normally. If the other party has zero resolved devices, it throws `Boom 421` instead of silently pretending the message was sent.
525
-
526
- ---
548
+ const { makeWASocket, useMultiFileAuthState, attachProMethods } = require('ishumdz-bail');
527
549
 
528
- ## 🔄 Stability & Disconnect Handling
529
-
530
- ishumdz-bail ships `classifyDisconnect()` — maps every WA status code into an actionable result:
531
-
532
- ```javascript
533
- import { classifyDisconnect } from 'ishumdz-bail'
534
-
535
- sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
536
- if (connection === 'close') {
537
- const code = lastDisconnect?.error?.output?.statusCode
538
- const info = classifyDisconnect(code)
539
-
540
- console.log(info)
541
- // {
542
- // category: 'fatal' | 'recoverable' | 'rate-limited' | 'unknown',
543
- // shouldReconnect: boolean,
544
- // backoffMs: number, // ms to wait before reconnecting
545
- // message: string,
546
- // code: number
547
- // }
548
-
549
- if (info.shouldReconnect) {
550
- setTimeout(() => reconnect(), info.backoffMs)
551
- }
552
- }
553
- })
554
- ```
555
-
556
- **Code map:**
557
-
558
- | Code | Category | Reconnect | Backoff |
559
- |---|---|---|---|
560
- | 401, 440 | fatal | ❌ | — |
561
- | 515 | recoverable | ✅ | 0 ms (immediate) |
562
- | 405 | fatal | ❌ | — |
563
- | 408 | recoverable | ✅ | 30 s |
564
- | 503 | recoverable | ✅ | 5 min |
565
- | 429 | rate-limited | ✅ | 60 s |
566
- | 500 | recoverable | ✅ | 5 s |
567
- | 503 | recoverable | ✅ | 10 s |
568
- | Graceful close | recoverable | ✅ | 2 s |
569
- | Unknown | unknown | ✅ | 15 s |
570
-
571
- > **Important:** Code 515 (`restartRequired`) is WhatsApp's normal post-pairing signal. ishumdz-bail correctly treats it as recoverable with 0 ms backoff — other forks incorrectly mark it as fatal, causing bots to stop after first pair.
572
-
573
- ---
574
-
575
- ## ⏱️ Rate Limiter
576
-
577
- Anti-ban pacing calculator — wire into your send path before each `sendMessage`:
578
-
579
- ```javascript
580
- import { RateLimiter } from 'ishumdz-bail'
581
-
582
- const limiter = new RateLimiter({
583
- maxPerMinute: 8,
584
- maxPerHour: 200,
585
- maxPerDay: 1500,
586
- minDelayMs: 1500,
587
- maxDelayMs: 5000,
588
- newChatDelayMs: 3000,
589
- maxIdenticalMessages: 3,
590
- burstAllowance: 3
591
- })
592
-
593
- async function safeSend(jid, content) {
594
- const delay = await limiter.getDelay(jid, content)
595
- if (delay === -1) throw new Error('Rate limit exceeded — blocked')
596
- if (delay > 0) await new Promise(r => setTimeout(r, delay))
597
- await sock.sendMessage(jid, content)
598
- limiter.record(jid, content)
599
- }
600
- ```
601
-
602
- ---
603
-
604
- ## 📦 Supported Message Types
605
-
606
- Every WhatsApp message type is covered:
607
-
608
- - Text, image, video, audio, document, sticker, GIF/video note (PTV)
609
- - Location & live location
610
- - Contact / vCard
611
- - Poll (create, vote, add option, poll result)
612
- - Button, list, template, interactive (native flow)
613
- - Album (multiple media in one message)
614
- - Event & event invite
615
- - Group invite, group status, group mention
616
- - Spoiler (blurred) messages
617
- - Reaction & edited message
618
- - View-once media
619
- - Status/story mention & reply
620
- - Newsletter / channel messages
621
- - Payment & payment invite
622
- - All WhatsApp Business types: product, catalog, order, invoice, business profile
623
-
624
- <details>
625
- <summary><b>Example: Album</b></summary>
626
-
627
- ```javascript
628
- await sock.sendMessage(jid, {
629
- album: [
630
- { image: { url: 'https://example.com/1.jpg' } },
631
- { video: { url: 'https://example.com/2.mp4' } }
632
- ],
633
- caption: 'Album caption'
634
- })
635
- ```
636
- </details>
637
-
638
- <details>
639
- <summary><b>Example: Poll</b></summary>
640
-
641
- ```javascript
642
- await sock.sendMessage(jid, {
643
- poll: {
644
- name: 'Poll Title',
645
- values: ['Option A', 'Option B'],
646
- selectableCount: 1
647
- }
648
- })
649
- ```
650
- </details>
651
-
652
- <details>
653
- <summary><b>Example: Spoiler</b></summary>
654
-
655
- ```javascript
656
- await sock.sendMessage(jid, {
657
- text: 'Spoiler content',
658
- spoiler: true
659
- })
660
- ```
661
- </details>
662
-
663
- <details>
664
- <summary><b>Example: Event</b></summary>
665
-
666
- ```javascript
667
- await sock.sendMessage(jid, {
668
- eventMessage: {
669
- name: 'Meeting',
670
- description: 'Weekly sync',
671
- location: { degreesLatitude: -6.2, degreesLongitude: 106.8 },
672
- startTime: Math.floor(Date.now() / 1000) + 3600
673
- }
674
- })
675
- ```
676
- </details>
677
-
678
- ---
679
-
680
- ## 🛠️ Additional Methods
681
-
682
- ```javascript
683
- // Parse incoming extended/special messages
684
- sock.ev.on('messages.upsert', ({ messages }) => {
685
- const extended = sock.parseExtendedMessageContent(messages[0].message)
686
- if (extended) console.log(extended.type, extended.data)
687
- })
688
-
689
- // Business profile
690
- const profile = await sock.getBusinessProfile(jid)
691
- await sock.updateBusinessProfile({ description: 'Open 9-5', email: 'hi@example.com', category: 'Retail' })
692
-
693
- // Get newsletter/channel JID from URL
694
- await sock.newsletterId('https://whatsapp.com/channel/...')
695
-
696
- // Refresh media URL for expired messages
697
- await sock.updateMediaMessage(message)
698
- ```
699
-
700
- ---
701
-
702
- ## 🎮 Games
703
-
704
- Built-in games for your WhatsApp bot! Import from `ishumdz-bail`:
705
-
706
- ```javascript
707
- import {
708
- blackjack, slotMachine, diceGame,
709
- coinFlip, roulette, rps, trivia,
710
- createMines, revealTile, cashoutMines
711
- } from 'ishumdz-bail'
712
- ```
713
-
714
- ### 🃏 Blackjack
715
-
716
- ```javascript
717
- // Start game
718
- const game = blackjack('start', [], [], 1000)
719
- await sock.sendMessage(jid, { text: game.message })
720
-
721
- // Hit (after start)
722
- const hit = blackjack('hit', game.playerHand, game.dealerHand, 1000)
723
-
724
- // Stand
725
- const stand = blackjack('stand', game)
726
-
727
- // Double
728
- const dbl = blackjack('double', game)
729
- ```
730
-
731
- ### 🎰 Slot Machine
732
-
733
- ```javascript
734
- const slot = slotMachine(100)
735
- await sock.sendMessage(jid, { text: slot.message })
736
- // 🎰 [🍒] [🍋] [💎] - NO MATCH
737
- ```
738
-
739
- ### 🎲 Dice
740
-
741
- ```javascript
742
- const dice = diceGame(100, 'high') // high, low, or seven
743
- await sock.sendMessage(jid, { text: dice.message })
744
- ```
745
-
746
- ### 🪙 Coin Flip
747
-
748
- ```javascript
749
- const coin = coinFlip(100, 'heads') // heads or tails
750
- await sock.sendMessage(jid, { text: coin.message })
751
- ```
752
-
753
- ### 🎰 Roulette
754
-
755
- ```javascript
756
- const rou = roulette(100, 'red') // red, black, odd, even, low, high
757
- await sock.sendMessage(jid, { text: rou.message })
758
- ```
759
-
760
- ### ✊ Rock Paper Scissors
761
-
762
- ```javascript
763
- const r = rps('rock') // rock, paper, scissors
764
- await sock.sendMessage(jid, { text: r.message })
765
- ```
766
-
767
- ### 💣 Mines
768
-
769
- ```javascript
770
- // Create game
771
- const game = createMines(5, 5, 5) // rows, cols, mines
772
-
773
- // Reveal tile
774
- const result = revealTile(game, 0, 0) // row, col
775
- await sock.sendMessage(jid, { text: result.message })
776
-
777
- // Cashout
778
- const cashout = cashoutMines(game, 100)
779
- await sock.sendMessage(jid, { text: cashout.message })
780
- ```
781
-
782
- ### 🧠 Trivia
783
-
784
- ```javascript
785
- const quiz = trivia(100)
786
- await sock.sendMessage(jid, { text: quiz.message })
787
-
788
- // Check answer (A, B, C, or D)
789
- const answer = checkTriviaAnswer('B', quiz.answer, 100)
790
- await sock.sendMessage(jid, { text: answer.message })
791
- ```
792
-
793
- ### 📱 Bot Command Example
794
-
795
- ```javascript
796
- sock.ev.on('messages.upsert', async ({ messages }) => {
797
- const msg = messages[0]
798
- const text = msg.message?.conversation || ''
550
+ async function startBot() {
551
+ const { state, saveCreds } = await useMultiFileAuthState('auth');
799
552
 
800
- if (text === '.rps rock' || text === '.rps paper' || text === '.rps scissors') {
801
- const choice = text.split(' ')[1]
802
- const result = rps(choice)
803
- await sock.sendMessage(msg.key.remoteJid, { text: result.message })
804
- }
553
+ const sock = makeWASocket({
554
+ auth: state,
555
+ printQRInTerminal: true
556
+ });
805
557
 
806
- if (text.startsWith('.slot')) {
807
- const bet = parseInt(text.split(' ')[1]) || 100
808
- const result = slotMachine(bet)
809
- await sock.sendMessage(msg.key.remoteJid, { text: result.message })
810
- }
558
+ attachProMethods(sock);
811
559
 
812
- if (text.startsWith('.coinflip')) {
813
- const choice = text.split(' ')[1] || 'heads'
814
- const bet = parseInt(text.split(' ')[2]) || 100
815
- const result = coinFlip(bet, choice)
816
- await sock.sendMessage(msg.key.remoteJid, { text: result.message })
817
- }
818
- })
819
- ```
820
-
821
- ---
822
-
823
- ## 📊 Poll Voting
824
-
825
- Create polls, track votes, and display results.
826
-
827
- ### 🗳️ Create Poll
828
-
829
- ```javascript
830
- await sock.sendMessage(jid, {
831
- poll: {
832
- name: 'Best programming language?',
833
- values: ['JavaScript', 'Python', 'Java', 'Go', 'Rust'],
834
- selectableCount: 1
835
- }
836
- })
837
- ```
838
-
839
- ### 📊 Poll with Multiple Selections
840
-
841
- ```javascript
842
- await sock.sendMessage(jid, {
843
- poll: {
844
- name: 'Which features do you want?',
845
- values: ['Games', 'AI', 'Stickers', 'Download'],
846
- selectableCount: 3 // Users can select up to 3 options
847
- }
848
- })
849
- ```
850
-
851
- ### 📢 Announcement Group Poll (Admin Only Voting)
852
-
853
- ```javascript
854
- await sock.sendMessage(groupJid, {
855
- poll: {
856
- name: 'Admin Poll',
857
- values: ['Option 1', 'Option 2'],
858
- selectableCount: 1,
859
- toAnnouncementGroup: true
860
- }
861
- })
862
- ```
863
-
864
- ### 🏆 Poll Result (Fake Results)
865
-
866
- ```javascript
867
- await sock.sendMessage(jid, {
868
- pollResult: {
869
- name: 'Best framework?',
870
- votes: [['React', 150], ['Vue', 120], ['Angular', 80]]
871
- }
872
- })
873
- ```
874
-
875
- ### 📈 Track Poll Votes
876
-
877
- ```javascript
878
- import { getAggregateVotesInPollMessage } from 'ishumdz-bail'
879
-
880
- // Store messages
881
- const messageStore = new Map()
882
-
883
- sock.ev.on('messages.upsert', async ({ messages }) => {
884
- for (const msg of messages) {
885
- const id = msg.key.remoteJid + ':' + msg.key.id
886
- messageStore.set(id, msg)
887
- }
888
- })
889
-
890
- // Listen for poll votes
891
- sock.ev.on('messages.update', async (events) => {
892
- for (const { key, update } of events) {
893
- if (update.pollUpdates) {
894
- const id = key.remoteJid + ':' + key.id
895
- const pollCreation = messageStore.get(id)
560
+ sock.ev.on('creds.update', saveCreds);
561
+
562
+ sock.ev.on('messages.upsert', async ({ messages }) => {
563
+ const msg = messages[0];
564
+ if (!msg.key.fromMe && msg.message?.conversation) {
565
+ const text = msg.message.conversation.toLowerCase();
896
566
 
897
- if (pollCreation) {
898
- const votes = getAggregateVotesInPollMessage({
899
- message: pollCreation,
900
- pollUpdates: update.pollUpdates
901
- })
902
-
903
- console.log('Poll votes:', votes)
904
- // [{ name: 'Option 1', voters: ['123@s.whatsapp.net'] }, ...]
567
+ if (text === '!ping') {
568
+ await sock.reply(msg.key.remoteJid, 'Pong! 🏓', msg);
569
+ }
570
+
571
+ if (text === '!slots') {
572
+ const slots = slotMachine(100);
573
+ await sock.reply(msg.key.remoteJid,
574
+ `🎰 Slots: ${slots.reels.join(' | ')}\nPayout: ${slots.payout}`, msg);
905
575
  }
906
576
  }
907
- }
908
- })
577
+ });
578
+ }
579
+
580
+ startBot();
909
581
  ```
910
582
 
911
- ### 📱 Poll Bot Command Example
583
+ ### Call Auto-Answer Bot
912
584
 
913
585
  ```javascript
914
- sock.ev.on('messages.upsert', async ({ messages }) => {
915
- const msg = messages[0]
916
- const text = msg.message?.conversation || ''
586
+ const { makeWASocket, useMultiFileAuthState, enableCallAutoAnswer } = require('ishumdz-bail');
587
+
588
+ async function startCallBot() {
589
+ const { state, saveCreds } = await useMultiFileAuthState('auth');
917
590
 
918
- // .poll Question | Option1 | Option2 | Option3
919
- if (text.startsWith('.poll')) {
920
- const args = text.slice(5).split('|').map(s => s.trim())
921
- const question = args[0]
922
- const options = args.slice(1)
923
-
924
- if (question && options.length >= 2) {
925
- await sock.sendMessage(msg.key.remoteJid, {
926
- poll: {
927
- name: question,
928
- values: options,
929
- selectableCount: 1
930
- }
931
- })
932
- }
933
- }
591
+ const sock = makeWASocket({ auth: state });
592
+
593
+ sock.ev.on('creds.update', saveCreds);
934
594
 
935
- // .pollresult React | 150 | Vue | 120
936
- if (text.startsWith('.pollresult')) {
937
- const args = text.slice(12).split('|').map(s => s.trim())
938
- const votes = []
939
- for (let i = 0; i < args.length; i += 2) {
940
- votes.push([args[i], parseInt(args[i + 1]) || 0])
595
+ sock.ev.on('connection.update', ({ connection }) => {
596
+ if (connection === 'open') {
597
+ sock.enableCallAutoAnswer({
598
+ audio: './welcome.wav',
599
+ autoAnswer: true
600
+ });
601
+ console.log('📞 Call bot ready!');
941
602
  }
942
-
943
- await sock.sendMessage(msg.key.remoteJid, {
944
- pollResult: {
945
- name: 'Poll Results',
946
- votes
947
- }
948
- })
949
- }
950
- })
603
+ });
604
+ }
605
+
606
+ startCallBot();
951
607
  ```
952
608
 
953
609
  ---
954
610
 
955
- ## 🌐 Community & Support
956
-
957
- <div align="center">
958
-
959
- <table>
960
- <tr>
961
- <td align="center">
962
- <a href="https://ishanx-pro.site.je">
963
- 🌐<br/><b>Website</b><br/>ishanx-pro.site.je
964
- </a>
965
- </td>
966
- <td align="center">
967
- <a href="https://shyracore.indevs.in">
968
- 💬<br/><b>WhatsApp Channel</b><br/>shyracore.indevs.in
969
- </a>
970
- </td>
971
- </tr>
972
- </table>
973
-
974
- **Developer:** Lovely
611
+ ## 📄 License
975
612
 
976
- </div>
613
+ MIT License - See [LICENSE](LICENSE) for details.
977
614
 
978
615
  ---
979
616
 
980
617
  <div align="center">
981
618
 
982
- ### ⭐ If this project helped you, consider giving it a star!
619
+ **Made with ❤️ by Lovely**
983
620
 
984
- Made with ❤️ by **Lovely**
621
+ [![npm](https://img.shields.io/badge/npm-ishumdz--bail-25D366?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/ishumdz-bail)
622
+ [![GitHub](https://img.shields.io/badge/GitHub-lovelyofficial-FF4500?style=for-the-badge&logo=github&logoColor=white)](https://github.com/lovelyofficial/ishumdz-bail)
985
623
 
986
624
  </div>
987
-
988
- ---
989
-
990
- ## 📄 License
991
-
992
- MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ishumdz-bail",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "WhatsApp API Modification By Lovely",
5
5
  "keywords": [
6
6
  "whatsapp",