hunter-baileys 2.1.1

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 (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +783 -0
  3. package/WAProto/GenerateStatics.sh +2 -0
  4. package/WAProto/WAProto.proto +4633 -0
  5. package/WAProto/index.js +165059 -0
  6. package/WAProto/obed +1 -0
  7. package/lib/Defaults/baileys-version.json +3 -0
  8. package/lib/Defaults/index.js +105 -0
  9. package/lib/Defaults/obed +1 -0
  10. package/lib/Signal/Group/ciphertext-message.js +15 -0
  11. package/lib/Signal/Group/group-session-builder.js +64 -0
  12. package/lib/Signal/Group/group_cipher.js +96 -0
  13. package/lib/Signal/Group/index.js +57 -0
  14. package/lib/Signal/Group/keyhelper.js +55 -0
  15. package/lib/Signal/Group/obed +1 -0
  16. package/lib/Signal/Group/queue-job.js +57 -0
  17. package/lib/Signal/Group/sender-chain-key.js +34 -0
  18. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  19. package/lib/Signal/Group/sender-key-message.js +69 -0
  20. package/lib/Signal/Group/sender-key-name.js +51 -0
  21. package/lib/Signal/Group/sender-key-record.js +53 -0
  22. package/lib/Signal/Group/sender-key-state.js +99 -0
  23. package/lib/Signal/Group/sender-message-key.js +29 -0
  24. package/lib/Signal/libsignal.js +174 -0
  25. package/lib/Socket/Client/index.js +18 -0
  26. package/lib/Socket/Client/obed +1 -0
  27. package/lib/Socket/Client/types.js +13 -0
  28. package/lib/Socket/Client/websocket.js +62 -0
  29. package/lib/Socket/business.js +260 -0
  30. package/lib/Socket/chats.js +880 -0
  31. package/lib/Socket/gcstatus.js +237 -0
  32. package/lib/Socket/groups.js +340 -0
  33. package/lib/Socket/index.js +10 -0
  34. package/lib/Socket/messages-recv.js +1079 -0
  35. package/lib/Socket/messages-send.js +1057 -0
  36. package/lib/Socket/mex.js +46 -0
  37. package/lib/Socket/newsletter.js +233 -0
  38. package/lib/Socket/socket.js +617 -0
  39. package/lib/Socket/usync.js +65 -0
  40. package/lib/Types/Auth.js +2 -0
  41. package/lib/Types/Call.js +2 -0
  42. package/lib/Types/Chat.js +10 -0
  43. package/lib/Types/Contact.js +2 -0
  44. package/lib/Types/Events.js +2 -0
  45. package/lib/Types/GroupMetadata.js +2 -0
  46. package/lib/Types/Label.js +27 -0
  47. package/lib/Types/LabelAssociation.js +9 -0
  48. package/lib/Types/Message.js +7 -0
  49. package/lib/Types/Newsletter.js +33 -0
  50. package/lib/Types/Product.js +2 -0
  51. package/lib/Types/Signal.js +2 -0
  52. package/lib/Types/Socket.js +2 -0
  53. package/lib/Types/State.js +2 -0
  54. package/lib/Types/USync.js +2 -0
  55. package/lib/Types/index.js +42 -0
  56. package/lib/Types/obed +1 -0
  57. package/lib/Utils/auth-utils.js +199 -0
  58. package/lib/Utils/baileys-event-stream.js +63 -0
  59. package/lib/Utils/business.js +240 -0
  60. package/lib/Utils/chat-utils.js +741 -0
  61. package/lib/Utils/crypto.js +187 -0
  62. package/lib/Utils/decode-wa-message.js +284 -0
  63. package/lib/Utils/event-buffer.js +516 -0
  64. package/lib/Utils/generics.js +400 -0
  65. package/lib/Utils/history.js +100 -0
  66. package/lib/Utils/index.js +34 -0
  67. package/lib/Utils/lid-mapping.js +88 -0
  68. package/lib/Utils/link-preview.js +122 -0
  69. package/lib/Utils/logger.js +7 -0
  70. package/lib/Utils/lt-hash.js +51 -0
  71. package/lib/Utils/make-mutex.js +44 -0
  72. package/lib/Utils/messages-media.js +706 -0
  73. package/lib/Utils/messages.js +797 -0
  74. package/lib/Utils/noise-handler.js +150 -0
  75. package/lib/Utils/obed +1 -0
  76. package/lib/Utils/process-message.js +381 -0
  77. package/lib/Utils/signal.js +155 -0
  78. package/lib/Utils/use-multi-file-auth-state.js +124 -0
  79. package/lib/Utils/validate-connection.js +170 -0
  80. package/lib/WABinary/constants.js +1303 -0
  81. package/lib/WABinary/decode.js +266 -0
  82. package/lib/WABinary/encode.js +252 -0
  83. package/lib/WABinary/generic-utils.js +110 -0
  84. package/lib/WABinary/index.js +21 -0
  85. package/lib/WABinary/jid-utils.js +66 -0
  86. package/lib/WABinary/obed +1 -0
  87. package/lib/WABinary/types.js +2 -0
  88. package/lib/WAM/BinaryInfo.js +13 -0
  89. package/lib/WAM/constants.js +15243 -0
  90. package/lib/WAM/encode.js +153 -0
  91. package/lib/WAM/index.js +19 -0
  92. package/lib/WAM/obed +1 -0
  93. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  94. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  95. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  96. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  97. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  98. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  99. package/lib/WAUSync/Protocols/index.js +20 -0
  100. package/lib/WAUSync/Protocols/obed +1 -0
  101. package/lib/WAUSync/USyncQuery.js +93 -0
  102. package/lib/WAUSync/USyncUser.js +26 -0
  103. package/lib/WAUSync/index.js +19 -0
  104. package/lib/index.js +30 -0
  105. package/package.json +55 -0
package/README.md ADDED
@@ -0,0 +1,783 @@
1
+ <div align="center">
2
+
3
+ <img src="https://readme-typing-svg.demolab.com?font=Fira+Code&size=32&pause=1000&color=25D366&center=true&vCenter=true&width=600&lines=Hunter-Baileys+v2.1.1;WhatsApp+Web+API+Library;Powered+by+OBED+TECH" alt="Hunter-Baileys" />
4
+
5
+ <h3>A powerful, full-featured WhatsApp Web API library for Node.js</h3>
6
+
7
+ [![NPM Version](https://img.shields.io/npm/v/hunter-baileys?color=25D366&label=npm&logo=npm)](https://www.npmjs.com/package/hunter-baileys)
8
+ [![NPM Downloads](https://img.shields.io/npm/dm/hunter-baileys?color=25D366&logo=npm)](https://www.npmjs.com/package/hunter-baileys)
9
+ [![License](https://img.shields.io/github/license/Obedweb3/hunter-baileys?color=25D366)](LICENSE)
10
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-25D366?logo=node.js)](https://nodejs.org)
11
+ [![GitHub Stars](https://img.shields.io/github/stars/Obedweb3/hunter-baileys?color=25D366&logo=github)](https://github.com/Obedweb3/hunter-baileys/stargazers)
12
+
13
+ **Maintained by [OBED TECH](https://github.com/Obedweb3)**
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ ## ⚠️ Disclaimer
20
+
21
+ > This project is **not affiliated, associated, authorized, endorsed by, or in any way officially connected** with WhatsApp or Meta Platforms Inc.
22
+ > Use at your own discretion. Do **not** spam people with this library. We strongly discourage stalkerware, bulk or automated unsolicited messaging.
23
+
24
+ ---
25
+
26
+ ## 📋 Table of Contents
27
+
28
+ - [Features](#-features)
29
+ - [Requirements](#-requirements)
30
+ - [Installation](#-installation)
31
+ - [Quick Start](#-quick-start)
32
+ - [Authentication](#-authentication)
33
+ - [QR Code](#method-1--qr-code)
34
+ - [Pairing Code](#method-2--pairing-code-no-qr)
35
+ - [Sending Messages](#-sending-messages)
36
+ - [Text](#1-text-message)
37
+ - [Image](#2-image-message)
38
+ - [Video](#3-video-message)
39
+ - [Audio / Voice Note](#4-audio--voice-note)
40
+ - [Document](#5-document--file)
41
+ - [Sticker](#6-sticker)
42
+ - [Location](#7-location)
43
+ - [Contact Card](#8-contact-card)
44
+ - [Poll](#9-poll)
45
+ - [Reaction](#10-reaction-emoji)
46
+ - [Reply / Quote](#11-reply--quote-a-message)
47
+ - [Forward](#12-forward-a-message)
48
+ - [Receiving Messages](#-receiving-messages)
49
+ - [Group Management](#-group-management)
50
+ - [Privacy Settings](#-privacy-settings)
51
+ - [Profile Management](#-profile-management)
52
+ - [WhatsApp Channels](#-whatsapp-channels-newsletter)
53
+ - [Presence & Typing](#-presence--typing-indicator)
54
+ - [Utilities](#-utilities)
55
+ - [Events Reference](#-events-reference)
56
+ - [License](#-license)
57
+
58
+ ---
59
+
60
+ ## ✨ Features
61
+
62
+ | Feature | Status |
63
+ |---------|--------|
64
+ | ✅ Multi-device support | Fully supported |
65
+ | ✅ QR Code authentication | Fully supported |
66
+ | ✅ Pairing Code (no QR) | Fully supported |
67
+ | ✅ Send/receive all message types | Fully supported |
68
+ | ✅ Group management (create, add, remove, promote) | Fully supported |
69
+ | ✅ Group status/story sending | Exclusive feature |
70
+ | ✅ WhatsApp Channels (Newsletter) | Fully supported |
71
+ | ✅ Privacy settings control | Fully supported |
72
+ | ✅ Profile picture & name management | Fully supported |
73
+ | ✅ Poll messages & vote decryption | Fully supported |
74
+ | ✅ LID addressing (personal & groups) | Fully supported |
75
+ | ✅ Media download & upload | Fully supported |
76
+ | ✅ Link preview generation | Fully supported |
77
+ | ✅ Disappearing messages | Fully supported |
78
+ | ✅ Block / unblock contacts | Fully supported |
79
+
80
+ ---
81
+
82
+ ## 📦 Requirements
83
+
84
+ - **Node.js** v18.0.0 or higher
85
+ - **npm** v9.0.0 or higher
86
+ - **Git** (required for installing dependencies)
87
+
88
+ ---
89
+
90
+ ## 💾 Installation
91
+
92
+ ```bash
93
+ npm install hunter-baileys
94
+ ```
95
+
96
+ Or using yarn:
97
+ ```bash
98
+ yarn add hunter-baileys
99
+ ```
100
+
101
+ **Import in your project:**
102
+ ```javascript
103
+ // CommonJS (recommended)
104
+ const { default: makeWASocket, useMultiFileAuthState, Browsers, DisconnectReason } = require('hunter-baileys')
105
+
106
+ // ES Modules / TypeScript
107
+ import pkg from 'hunter-baileys'
108
+ const { default: makeWASocket, useMultiFileAuthState, Browsers, DisconnectReason } = pkg
109
+ ```
110
+
111
+ ---
112
+
113
+ ## 🚀 Quick Start
114
+
115
+ Here is the simplest possible bot — connects to WhatsApp and replies to `!ping`:
116
+
117
+ ```javascript
118
+ const { default: makeWASocket, useMultiFileAuthState, DisconnectReason, Browsers } = require('hunter-baileys')
119
+ const { Boom } = require('@hapi/boom')
120
+
121
+ async function startBot() {
122
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info')
123
+
124
+ const sock = makeWASocket({
125
+ auth: state,
126
+ browser: Browsers.ubuntu('MyBot'),
127
+ printQRInTerminal: true,
128
+ })
129
+
130
+ // Save credentials whenever they update
131
+ sock.ev.on('creds.update', saveCreds)
132
+
133
+ // Handle connection
134
+ sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
135
+ if (connection === 'close') {
136
+ const shouldReconnect = (lastDisconnect?.error instanceof Boom)
137
+ ? lastDisconnect.error.output?.statusCode !== DisconnectReason.loggedOut
138
+ : true
139
+ if (shouldReconnect) startBot()
140
+ } else if (connection === 'open') {
141
+ console.log('✅ Bot connected!')
142
+ }
143
+ })
144
+
145
+ // Handle messages
146
+ sock.ev.on('messages.upsert', async ({ messages }) => {
147
+ const msg = messages[0]
148
+ if (!msg.message || msg.key.fromMe) return
149
+
150
+ const from = msg.key.remoteJid
151
+ const text = msg.message?.conversation || msg.message?.extendedTextMessage?.text || ''
152
+
153
+ if (text === '!ping') {
154
+ await sock.sendMessage(from, { text: '🏓 Pong!' })
155
+ }
156
+ })
157
+ }
158
+
159
+ startBot()
160
+ ```
161
+
162
+ ---
163
+
164
+ ## 🔐 Authentication
165
+
166
+ ### Method 1 — QR Code
167
+
168
+ Scan the QR code that appears in your terminal with WhatsApp.
169
+
170
+ ```javascript
171
+ const { default: makeWASocket, useMultiFileAuthState } = require('hunter-baileys')
172
+ const qrcode = require('qrcode-terminal')
173
+
174
+ async function connect() {
175
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info')
176
+
177
+ const sock = makeWASocket({
178
+ auth: state,
179
+ printQRInTerminal: false, // we handle QR ourselves
180
+ })
181
+
182
+ sock.ev.on('creds.update', saveCreds)
183
+
184
+ sock.ev.on('connection.update', ({ qr, connection }) => {
185
+ if (qr) {
186
+ console.log('Scan this QR code:\n')
187
+ qrcode.generate(qr, { small: true })
188
+ }
189
+ if (connection === 'open') console.log('✅ Connected!')
190
+ })
191
+ }
192
+
193
+ connect()
194
+ ```
195
+
196
+ ### Method 2 — Pairing Code (no QR)
197
+
198
+ Link your WhatsApp using a 8-digit code — no need to scan anything.
199
+
200
+ ```javascript
201
+ const { default: makeWASocket, useMultiFileAuthState } = require('hunter-baileys')
202
+
203
+ async function connectWithPairingCode(phoneNumber) {
204
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info')
205
+
206
+ const sock = makeWASocket({
207
+ auth: state,
208
+ printQRInTerminal: false,
209
+ })
210
+
211
+ sock.ev.on('creds.update', saveCreds)
212
+
213
+ sock.ev.on('connection.update', async ({ connection }) => {
214
+ if (connection === 'open') console.log('✅ Connected!')
215
+ })
216
+
217
+ // Request pairing code after a short delay
218
+ if (!sock.authState.creds.registered) {
219
+ await new Promise(r => setTimeout(r, 3000))
220
+ // Phone number with country code, no + or spaces
221
+ const code = await sock.requestPairingCode(phoneNumber)
222
+ console.log(`Your pairing code: ${code}`)
223
+ // Enter this code in WhatsApp > Linked Devices > Link with phone number
224
+ }
225
+ }
226
+
227
+ connectWithPairingCode('254712345678')
228
+ ```
229
+
230
+ ---
231
+
232
+ ## 💬 Sending Messages
233
+
234
+ ### 1. Text message
235
+
236
+ ```javascript
237
+ await sock.sendMessage(jid, { text: 'Hello from hunter-baileys! 👋' })
238
+ ```
239
+
240
+ ### 2. Image message
241
+
242
+ ```javascript
243
+ const fs = require('fs')
244
+
245
+ // From a file
246
+ await sock.sendMessage(jid, {
247
+ image: fs.readFileSync('./image.jpg'),
248
+ caption: 'Check out this image! 🖼️'
249
+ })
250
+
251
+ // From a URL
252
+ await sock.sendMessage(jid, {
253
+ image: { url: 'https://example.com/image.jpg' },
254
+ caption: 'Image from URL'
255
+ })
256
+ ```
257
+
258
+ ### 3. Video message
259
+
260
+ ```javascript
261
+ await sock.sendMessage(jid, {
262
+ video: fs.readFileSync('./video.mp4'),
263
+ caption: 'Watch this! 🎬',
264
+ gifPlayback: false // set true to send as GIF
265
+ })
266
+ ```
267
+
268
+ ### 4. Audio / Voice note
269
+
270
+ ```javascript
271
+ // Regular audio file
272
+ await sock.sendMessage(jid, {
273
+ audio: fs.readFileSync('./audio.mp3'),
274
+ mimetype: 'audio/mp4'
275
+ })
276
+
277
+ // Voice note (shows as microphone bubble)
278
+ await sock.sendMessage(jid, {
279
+ audio: fs.readFileSync('./voice.ogg'),
280
+ mimetype: 'audio/ogg; codecs=opus',
281
+ ptt: true // ptt = push to talk = voice note
282
+ })
283
+ ```
284
+
285
+ ### 5. Document / File
286
+
287
+ ```javascript
288
+ await sock.sendMessage(jid, {
289
+ document: fs.readFileSync('./file.pdf'),
290
+ mimetype: 'application/pdf',
291
+ fileName: 'my-document.pdf',
292
+ caption: 'Here is your file 📄'
293
+ })
294
+ ```
295
+
296
+ ### 6. Sticker
297
+
298
+ ```javascript
299
+ await sock.sendMessage(jid, {
300
+ sticker: fs.readFileSync('./sticker.webp')
301
+ })
302
+ ```
303
+
304
+ ### 7. Location
305
+
306
+ ```javascript
307
+ await sock.sendMessage(jid, {
308
+ location: {
309
+ degreesLatitude: -1.2921, // Nairobi, Kenya
310
+ degreesLongitude: 36.8219,
311
+ name: 'Nairobi City',
312
+ address: 'Nairobi, Kenya'
313
+ }
314
+ })
315
+ ```
316
+
317
+ ### 8. Contact card
318
+
319
+ ```javascript
320
+ const vcard = `BEGIN:VCARD\nVERSION:3.0\nFN:Obed Tech\nTEL;type=CELL;waid=254712345678:+254 712 345 678\nEND:VCARD`
321
+
322
+ await sock.sendMessage(jid, {
323
+ contacts: {
324
+ displayName: 'Obed Tech',
325
+ contacts: [{ vcard }]
326
+ }
327
+ })
328
+ ```
329
+
330
+ ### 9. Poll
331
+
332
+ ```javascript
333
+ await sock.sendMessage(jid, {
334
+ poll: {
335
+ name: 'What is your favourite feature?',
336
+ values: ['Pairing Code', 'Group Management', 'Media Support', 'Privacy Control'],
337
+ selectableCount: 1 // how many options user can select
338
+ }
339
+ })
340
+ ```
341
+
342
+ ### 10. Reaction (emoji)
343
+
344
+ ```javascript
345
+ await sock.sendMessage(jid, {
346
+ react: {
347
+ text: '❤️', // the emoji to react with — use '' to remove reaction
348
+ key: msg.key // the key of the message to react to
349
+ }
350
+ })
351
+ ```
352
+
353
+ ### 11. Reply / Quote a message
354
+
355
+ ```javascript
356
+ // The second argument is the quoted message
357
+ await sock.sendMessage(
358
+ jid,
359
+ { text: 'This is my reply!' },
360
+ { quoted: msg } // pass the original message here
361
+ )
362
+ ```
363
+
364
+ ### 12. Forward a message
365
+
366
+ ```javascript
367
+ const { generateForwardMessageContent, generateWAMessageFromContent } = require('hunter-baileys')
368
+
369
+ const forwardContent = generateForwardMessageContent(msg, false)
370
+ const forwardMsg = generateWAMessageFromContent(jid, forwardContent, {
371
+ userJid: sock.user.id
372
+ })
373
+ await sock.relayMessage(jid, forwardMsg.message, { messageId: forwardMsg.key.id })
374
+ ```
375
+
376
+ ---
377
+
378
+ ## 📥 Receiving Messages
379
+
380
+ ```javascript
381
+ sock.ev.on('messages.upsert', async ({ messages, type }) => {
382
+ for (const msg of messages) {
383
+ if (!msg.message) continue // ignore empty messages
384
+ if (msg.key.fromMe) continue // ignore messages sent by the bot itself
385
+
386
+ const from = msg.key.remoteJid // who sent it / which chat
387
+ const isGroup = from.endsWith('@g.us') // is it a group?
388
+ const sender = msg.key.participant || from // actual sender in groups
389
+ const pushName = msg.pushName || 'Unknown' // contact display name
390
+
391
+ // Get message text — handles all message types
392
+ const body = msg.message?.conversation
393
+ || msg.message?.extendedTextMessage?.text
394
+ || msg.message?.imageMessage?.caption
395
+ || msg.message?.videoMessage?.caption
396
+ || msg.message?.documentMessage?.caption
397
+ || ''
398
+
399
+ console.log(`📩 From: ${pushName} (${from})`)
400
+ console.log(`💬 Text: ${body}`)
401
+
402
+ // Get message type
403
+ const { getContentType } = require('hunter-baileys')
404
+ const msgType = getContentType(msg.message)
405
+ console.log(`📎 Type: ${msgType}`)
406
+
407
+ // --- Example commands ---
408
+ if (body === '!ping') {
409
+ await sock.sendMessage(from, { text: '🏓 Pong!' }, { quoted: msg })
410
+ }
411
+
412
+ if (body === '!info') {
413
+ await sock.sendMessage(from, {
414
+ text: `*Hunter-Baileys Bot*\n\nVersion: v2.1.1\nOwner: OBED TECH\nLibrary: hunter-baileys`
415
+ })
416
+ }
417
+
418
+ if (body === '!groups') {
419
+ const groups = await sock.groupFetchAllParticipating()
420
+ const list = Object.values(groups).map(g => `• ${g.subject}`).join('\n')
421
+ await sock.sendMessage(from, { text: `*Groups I am in:*\n\n${list}` })
422
+ }
423
+ }
424
+ })
425
+ ```
426
+
427
+ ---
428
+
429
+ ## 👥 Group Management
430
+
431
+ ```javascript
432
+ // Create a new group
433
+ const group = await sock.groupCreate('My Group', [
434
+ '254712345678@s.whatsapp.net',
435
+ '254700000000@s.whatsapp.net'
436
+ ])
437
+ console.log('Created group:', group.id)
438
+
439
+ // Add participants
440
+ await sock.groupParticipantsUpdate(groupJid, ['254712345678@s.whatsapp.net'], 'add')
441
+
442
+ // Remove participants
443
+ await sock.groupParticipantsUpdate(groupJid, ['254712345678@s.whatsapp.net'], 'remove')
444
+
445
+ // Promote to admin
446
+ await sock.groupParticipantsUpdate(groupJid, ['254712345678@s.whatsapp.net'], 'promote')
447
+
448
+ // Demote from admin
449
+ await sock.groupParticipantsUpdate(groupJid, ['254712345678@s.whatsapp.net'], 'demote')
450
+
451
+ // Change group name
452
+ await sock.groupUpdateSubject(groupJid, 'New Group Name')
453
+
454
+ // Change group description
455
+ await sock.groupUpdateDescription(groupJid, 'This is our group description')
456
+
457
+ // Lock group — only admins can send messages
458
+ await sock.groupSettingUpdate(groupJid, 'announcement')
459
+
460
+ // Unlock group — everyone can send messages
461
+ await sock.groupSettingUpdate(groupJid, 'not_announcement')
462
+
463
+ // Get group info
464
+ const metadata = await sock.groupMetadata(groupJid)
465
+ console.log('Group name:', metadata.subject)
466
+ console.log('Participants:', metadata.participants.length)
467
+
468
+ // Get group invite link
469
+ const code = await sock.groupInviteCode(groupJid)
470
+ console.log('Invite link: https://chat.whatsapp.com/' + code)
471
+
472
+ // Revoke invite link (creates a new one)
473
+ await sock.groupRevokeInvite(groupJid)
474
+
475
+ // Leave group
476
+ await sock.groupLeave(groupJid)
477
+
478
+ // Get all groups the bot is in
479
+ const allGroups = await sock.groupFetchAllParticipating()
480
+ console.log('Total groups:', Object.keys(allGroups).length)
481
+
482
+ // Enable disappearing messages (86400 = 24h, 604800 = 7 days, 7776000 = 90 days)
483
+ await sock.groupToggleEphemeral(groupJid, 86400)
484
+
485
+ // Send status/story to group (EXCLUSIVE hunter-baileys feature!)
486
+ await sock.giftedStatus(groupJid, {
487
+ text: '🔥 Hello everyone! This is a group status!'
488
+ })
489
+ ```
490
+
491
+ ---
492
+
493
+ ## 🔒 Privacy Settings
494
+
495
+ ```javascript
496
+ // Last seen — 'all' | 'contacts' | 'contact_blacklist' | 'none'
497
+ await sock.updateLastSeenPrivacy('contacts')
498
+
499
+ // Online status visibility
500
+ await sock.updateOnlinePrivacy('match_last_seen')
501
+
502
+ // Profile picture — 'all' | 'contacts' | 'contact_blacklist' | 'none'
503
+ await sock.updateProfilePicturePrivacy('contacts')
504
+
505
+ // Status/Stories — 'all' | 'contacts' | 'contact_blacklist' | 'none'
506
+ await sock.updateStatusPrivacy('contacts')
507
+
508
+ // Read receipts (blue ticks) — 'all' | 'none'
509
+ await sock.updateReadReceiptsPrivacy('all')
510
+
511
+ // Who can add you to groups — 'all' | 'contacts' | 'contact_blacklist'
512
+ await sock.updateGroupsAddPrivacy('contacts')
513
+
514
+ // Who can call you — 'all' | 'contacts' | 'contact_blacklist' | 'none'
515
+ await sock.updateCallPrivacy('contacts')
516
+
517
+ // Default disappearing messages timer for new chats
518
+ await sock.updateDefaultDisappearingMode(86400) // 24 hours
519
+
520
+ // Block a contact
521
+ await sock.updateBlockStatus('254712345678@s.whatsapp.net', 'block')
522
+
523
+ // Unblock a contact
524
+ await sock.updateBlockStatus('254712345678@s.whatsapp.net', 'unblock')
525
+
526
+ // Get full blocklist
527
+ const blocklist = await sock.fetchBlocklist()
528
+ console.log('Blocked contacts:', blocklist)
529
+
530
+ // Get all privacy settings
531
+ const privacy = await sock.fetchPrivacySettings(true)
532
+ console.log(privacy)
533
+ ```
534
+
535
+ ---
536
+
537
+ ## 👤 Profile Management
538
+
539
+ ```javascript
540
+ const fs = require('fs')
541
+
542
+ // Change bot display name
543
+ await sock.updateProfileName('Hunter Bot 🤖')
544
+
545
+ // Change About/bio text
546
+ await sock.updateProfileStatus('Powered by OBED TECH 🚀')
547
+
548
+ // Change profile picture
549
+ const img = await sharp(fs.readFileSync('./photo.jpg'))
550
+ .resize(640, 640)
551
+ .toBuffer()
552
+ await sock.updateProfilePicture(sock.user.id, img)
553
+
554
+ // Remove profile picture
555
+ await sock.removeProfilePicture(sock.user.id)
556
+
557
+ // Get profile picture URL of any contact
558
+ const ppUrl = await sock.profilePictureUrl('254712345678@s.whatsapp.net', 'image')
559
+ console.log('Profile pic URL:', ppUrl)
560
+
561
+ // Get status/About of any contact
562
+ const status = await sock.fetchStatus('254712345678@s.whatsapp.net')
563
+ console.log('About:', status?.status)
564
+
565
+ // Check if a number is on WhatsApp
566
+ const [result] = await sock.onWhatsApp('254712345678')
567
+ console.log('On WhatsApp:', result?.exists)
568
+ console.log('JID:', result?.jid)
569
+ ```
570
+
571
+ ---
572
+
573
+ ## 📰 WhatsApp Channels (Newsletter)
574
+
575
+ ```javascript
576
+ // Create a new channel
577
+ const channel = await sock.newsletterCreate({
578
+ name: 'OBED TECH Updates',
579
+ description: 'Latest news and updates from OBED TECH'
580
+ })
581
+ console.log('Channel ID:', channel.id)
582
+
583
+ // Get channel metadata
584
+ const meta = await sock.newsletterMetadata('invite', 'channelInviteCode')
585
+ console.log('Subscribers:', meta.subscribers)
586
+
587
+ // Follow a channel
588
+ await sock.newsletterFollow(channelId)
589
+
590
+ // Unfollow a channel
591
+ await sock.newsletterUnfollow(channelId)
592
+
593
+ // Mute a channel
594
+ await sock.newsletterMute(channelId)
595
+
596
+ // Update channel name
597
+ await sock.newsletterUpdateName(channelId, 'New Channel Name')
598
+
599
+ // Update channel description
600
+ await sock.newsletterUpdateDescription(channelId, 'New description here')
601
+
602
+ // Fetch channel messages/posts
603
+ const messages = await sock.newsletterFetchMessages('updates', channelId, null, 20)
604
+
605
+ // React to a channel post
606
+ await sock.newsletterReactMessage(channelId, serverId, '🔥')
607
+
608
+ // Get subscriber count
609
+ const count = await sock.newsletterSubscribers(channelId)
610
+ console.log('Subscribers:', count)
611
+
612
+ // Delete channel
613
+ await sock.newsletterDelete(channelId)
614
+ ```
615
+
616
+ ---
617
+
618
+ ## 🟢 Presence & Typing Indicator
619
+
620
+ ```javascript
621
+ // Show "typing..." indicator
622
+ await sock.sendPresenceUpdate('composing', jid)
623
+
624
+ // Show "recording audio..." indicator
625
+ await sock.sendPresenceUpdate('recording', jid)
626
+
627
+ // Show as online
628
+ await sock.sendPresenceUpdate('available', jid)
629
+
630
+ // Show as offline
631
+ await sock.sendPresenceUpdate('unavailable', jid)
632
+
633
+ // Subscribe to presence updates of a contact
634
+ await sock.presenceSubscribe(jid)
635
+
636
+ // Listen for presence changes
637
+ sock.ev.on('presence.update', ({ id, presences }) => {
638
+ console.log(`${id} is now:`, presences)
639
+ })
640
+
641
+ // Example: show typing before sending a message
642
+ async function sendWithTyping(jid, text) {
643
+ await sock.sendPresenceUpdate('composing', jid)
644
+ await new Promise(r => setTimeout(r, 1500)) // wait 1.5s
645
+ await sock.sendPresenceUpdate('paused', jid)
646
+ await sock.sendMessage(jid, { text })
647
+ }
648
+ ```
649
+
650
+ ---
651
+
652
+ ## 🛠 Utilities
653
+
654
+ ```javascript
655
+ const {
656
+ isJidGroup,
657
+ isJidUser,
658
+ isJidNewsletter,
659
+ jidNormalizedUser,
660
+ getContentType,
661
+ extractMessageContent,
662
+ downloadMediaMessage,
663
+ generateMessageID
664
+ } = require('hunter-baileys')
665
+
666
+ // Check if a JID is a group
667
+ if (isJidGroup(jid)) console.log('This is a group')
668
+
669
+ // Check if a JID is a regular user
670
+ if (isJidUser(jid)) console.log('This is a user')
671
+
672
+ // Check if a JID is a WhatsApp Channel
673
+ if (isJidNewsletter(jid)) console.log('This is a channel')
674
+
675
+ // Normalize a JID
676
+ const normalized = jidNormalizedUser('254712345678@s.whatsapp.net')
677
+
678
+ // Get the type of a message
679
+ const type = getContentType(msg.message)
680
+ // Returns: 'conversation' | 'imageMessage' | 'videoMessage' | 'audioMessage' | etc.
681
+
682
+ // Download media from any message
683
+ const buffer = await downloadMediaMessage(msg, 'buffer', {})
684
+ fs.writeFileSync('./downloaded.' + type, buffer)
685
+
686
+ // Generate a unique message ID
687
+ const id = generateMessageID()
688
+
689
+ // Mark messages as read (blue ticks)
690
+ await sock.readMessages([msg.key])
691
+
692
+ // Star a message
693
+ await sock.star(jid, [msg.key], true)
694
+
695
+ // Unstar a message
696
+ await sock.star(jid, [msg.key], false)
697
+
698
+ // Reject an incoming call
699
+ sock.ev.on('call', async (calls) => {
700
+ for (const call of calls) {
701
+ await sock.rejectCall(call.id, call.from)
702
+ }
703
+ })
704
+ ```
705
+
706
+ ---
707
+
708
+ ## 📡 Events Reference
709
+
710
+ | Event | Fires when... |
711
+ |-------|--------------|
712
+ | `connection.update` | Connection status changes — QR, connected, disconnected |
713
+ | `creds.update` | Session credentials are updated — always call `saveCreds()` |
714
+ | `messages.upsert` | New messages arrive |
715
+ | `messages.update` | A message is edited, deleted, or its status changes |
716
+ | `messages.reaction` | Someone reacts to a message |
717
+ | `message-receipt.update` | Delivery/read receipts update (ticks) |
718
+ | `groups.update` | Group info changes (name, description, settings) |
719
+ | `group-participants.update` | Someone joins, leaves, is added or removed |
720
+ | `presence.update` | A contact's online/typing status changes |
721
+ | `chats.update` | Chat metadata changes |
722
+ | `contacts.update` | Contact info changes |
723
+ | `call` | Incoming voice or video call |
724
+ | `labels.association` | Label added or removed from a chat |
725
+ | `blocklist.update` | Block list changes |
726
+
727
+ ---
728
+
729
+ ## 📁 Project Structure
730
+
731
+ ```
732
+ hunter-baileys/
733
+ ├── lib/
734
+ │ ├── Socket/
735
+ │ │ ├── socket.js # Core WebSocket connection
736
+ │ │ ├── messages-send.js # All message sending functions
737
+ │ │ ├── messages-recv.js # Message receiving & decoding
738
+ │ │ ├── groups.js # Group management
739
+ │ │ ├── chats.js # Chat management
740
+ │ │ ├── business.js # Business account features
741
+ │ │ ├── newsletter.js # WhatsApp Channels
742
+ │ │ └── gcstatus.js # Group status sending (exclusive)
743
+ │ ├── Utils/
744
+ │ │ ├── use-multi-file-auth-state.js # Session management
745
+ │ │ ├── messages-media.js # Media handling
746
+ │ │ ├── crypto.js # Encryption utilities
747
+ │ │ └── ...
748
+ │ ├── Types/ # TypeScript type definitions
749
+ │ └── Defaults/ # Default configurations
750
+ ├── WAProto/ # WhatsApp protobuf definitions
751
+ ├── package.json
752
+ └── README.md
753
+ ```
754
+
755
+ ---
756
+
757
+ ## 🤝 Contributing
758
+
759
+ Contributions are welcome! Feel free to:
760
+
761
+ 1. Fork the repository
762
+ 2. Create a new branch (`git checkout -b feature/my-feature`)
763
+ 3. Commit your changes (`git commit -m 'Add my feature'`)
764
+ 4. Push to the branch (`git push origin feature/my-feature`)
765
+ 5. Open a Pull Request
766
+
767
+ ---
768
+
769
+ ## 📄 License
770
+
771
+ This project is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
772
+
773
+ ---
774
+
775
+ <div align="center">
776
+
777
+ Made with ❤️ by **OBED TECH**
778
+
779
+ [![GitHub](https://img.shields.io/badge/GitHub-Obedweb3-25D366?logo=github)](https://github.com/Obedweb3)
780
+
781
+ ⭐ If this library helped you, please give it a star on GitHub!
782
+
783
+ </div>