@zeronexcode/baileys 7.0.0-zeronex.1 → 7.0.0-zeronex.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,13 +8,30 @@
8
8
  A ZeroneXCode-maintained fork of Baileys, a WebSocket-based TypeScript library for interacting with WhatsApp Web.
9
9
  </div>
10
10
 
11
+ > [!IMPORTANT]
12
+ > ZeroneXCode Baileys is based on the open-source Baileys project maintained by WhiskeySockets.
13
+ >
14
+ > Most Baileys documentation and examples can be used directly by replacing:
15
+ >
16
+ > ```ts
17
+ > '@whiskeysockets/baileys'
18
+ > ```
19
+ >
20
+ > with:
21
+ >
22
+ > ```ts
23
+ > '@zeronexcode/baileys'
24
+ > ```
25
+
11
26
  ## Package
12
27
 
28
+ Using npm:
29
+
13
30
  ```bash
14
31
  npm install @zeronexcode/baileys
15
32
  ```
16
33
 
17
- or:
34
+ Using Yarn:
18
35
 
19
36
  ```bash
20
37
  yarn add @zeronexcode/baileys
@@ -28,26 +45,408 @@ npm install github:XzeroOffc/baileys
28
45
 
29
46
  Requires **Node.js 20 or newer**.
30
47
 
31
- ## Basic Usage
48
+ ---
49
+
50
+ ## Import
51
+
52
+ Basic import:
53
+
54
+ ```ts
55
+ import makeWASocket from '@zeronexcode/baileys'
56
+ ```
57
+
58
+ Import with helpers:
32
59
 
33
60
  ```ts
34
61
  import makeWASocket, {
35
62
  Browsers,
63
+ DisconnectReason,
64
+ useMultiFileAuthState
65
+ } from '@zeronexcode/baileys'
66
+ ```
67
+
68
+ If an original Baileys example uses:
69
+
70
+ ```ts
71
+ import makeWASocket from '@whiskeysockets/baileys'
72
+ ```
73
+
74
+ change it to:
75
+
76
+ ```ts
77
+ import makeWASocket from '@zeronexcode/baileys'
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Basic Usage
83
+
84
+ ```ts
85
+ import makeWASocket, {
86
+ useMultiFileAuthState
87
+ } from '@zeronexcode/baileys'
88
+
89
+ const { state, saveCreds } = await useMultiFileAuthState('./session')
90
+
91
+ const sock = makeWASocket({
92
+ auth: state,
93
+ printQRInTerminal: false,
94
+ markOnlineOnConnect: false
95
+ })
96
+
97
+ sock.ev.on('creds.update', saveCreds)
98
+
99
+ sock.ev.on('connection.update', update => {
100
+ const { connection } = update
101
+
102
+ if (connection === 'open') {
103
+ console.log('WhatsApp connected')
104
+ }
105
+
106
+ if (connection === 'close') {
107
+ console.log('WhatsApp disconnected')
108
+ }
109
+ })
110
+ ```
111
+
112
+ ---
113
+
114
+ # Connecting Account
115
+
116
+ Baileys connects your account as a WhatsApp Web companion device.
117
+
118
+ You can connect using:
119
+
120
+ - QR Code
121
+ - Pairing Code
122
+
123
+ ---
124
+
125
+ ## Starting Socket with QR Code
126
+
127
+ ```ts
128
+ import makeWASocket, {
129
+ Browsers
130
+ } from '@zeronexcode/baileys'
131
+
132
+ const sock = makeWASocket({
133
+ browser: Browsers.ubuntu('My App'),
134
+ printQRInTerminal: true
135
+ })
136
+ ```
137
+
138
+ Scan the generated QR code using:
139
+
140
+ **WhatsApp → Linked Devices → Link a Device**
141
+
142
+ ---
143
+
144
+ ## Starting Socket with Pairing Code
145
+
146
+ Pairing Code allows you to connect WhatsApp Web without scanning a QR code.
147
+
148
+ The phone number must:
149
+
150
+ - include the country code
151
+ - contain numbers only
152
+ - not contain `+`
153
+ - not contain spaces
154
+ - not contain `()`
155
+ - not contain `-`
156
+
157
+ Example:
158
+
159
+ ```ts
160
+ import makeWASocket from '@zeronexcode/baileys'
161
+
162
+ const sock = makeWASocket({
163
+ printQRInTerminal: false
164
+ })
165
+
166
+ if (!sock.authState.creds.registered) {
167
+ const number = '6281234567890'
168
+ const code = await sock.requestPairingCode(number)
169
+ console.log(code)
170
+ }
171
+ ```
172
+
173
+ Example Indonesian number:
174
+
175
+ ```text
176
+ 6281234567890
177
+ ```
178
+
179
+ Not:
180
+
181
+ ```text
182
+ +6281234567890
183
+ 081234567890
184
+ 62 812 3456 7890
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Saving & Restoring Sessions
190
+
191
+ Baileys provides `useMultiFileAuthState` for simple session storage.
192
+
193
+ ```ts
194
+ import makeWASocket, {
36
195
  useMultiFileAuthState
37
196
  } from '@zeronexcode/baileys'
38
197
 
39
- const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
198
+ const { state, saveCreds } = await useMultiFileAuthState('./session')
40
199
 
41
200
  const sock = makeWASocket({
42
201
  auth: state,
43
- browser: Browsers.ubuntu('ZeroneXCode')
202
+ printQRInTerminal: false
44
203
  })
45
204
 
46
205
  sock.ev.on('creds.update', saveCreds)
47
206
  ```
48
207
 
49
- For the complete Baileys API and usage guide, see the upstream documentation:
50
- https://baileys.wiki/docs/intro/
208
+ For production environments, using a database-backed auth state is recommended instead of relying only on filesystem sessions.
209
+
210
+ ---
211
+
212
+ # Handling Messages
213
+
214
+ Listen for incoming messages:
215
+
216
+ ```ts
217
+ sock.ev.on('messages.upsert', async ({ messages, type }) => {
218
+ const msg = messages[0]
219
+
220
+ if (!msg?.message) return
221
+
222
+ console.log(type)
223
+ console.log(msg)
224
+ })
225
+ ```
226
+
227
+ Get message text:
228
+
229
+ ```ts
230
+ const text =
231
+ msg.message?.conversation ||
232
+ msg.message?.extendedTextMessage?.text ||
233
+ ''
234
+ ```
235
+
236
+ ---
237
+
238
+ # Sending Messages
239
+
240
+ ## Text Message
241
+
242
+ ```ts
243
+ await sock.sendMessage(
244
+ '6281234567890@s.whatsapp.net',
245
+ {
246
+ text: 'Hello from ZeroneXCode Baileys'
247
+ }
248
+ )
249
+ ```
250
+
251
+ ## Reply Message
252
+
253
+ ```ts
254
+ await sock.sendMessage(
255
+ msg.key.remoteJid,
256
+ {
257
+ text: 'Hello!'
258
+ },
259
+ {
260
+ quoted: msg
261
+ }
262
+ )
263
+ ```
264
+
265
+ ## Image
266
+
267
+ ```ts
268
+ await sock.sendMessage(jid, {
269
+ image: {
270
+ url: './image.jpg'
271
+ },
272
+ caption: 'Hello from ZeroneXCode'
273
+ })
274
+ ```
275
+
276
+ ## Video
277
+
278
+ ```ts
279
+ await sock.sendMessage(jid, {
280
+ video: {
281
+ url: './video.mp4'
282
+ },
283
+ caption: 'Video'
284
+ })
285
+ ```
286
+
287
+ ## Audio
288
+
289
+ ```ts
290
+ await sock.sendMessage(jid, {
291
+ audio: {
292
+ url: './audio.mp3'
293
+ },
294
+ mimetype: 'audio/mpeg'
295
+ })
296
+ ```
297
+
298
+ ## Reaction
299
+
300
+ ```ts
301
+ await sock.sendMessage(jid, {
302
+ react: {
303
+ text: '🔥',
304
+ key: msg.key
305
+ }
306
+ })
307
+ ```
308
+
309
+ ---
310
+
311
+ # Presence
312
+
313
+ ```ts
314
+ await sock.sendPresenceUpdate('available')
315
+ await sock.sendPresenceUpdate('composing', jid)
316
+ await sock.sendPresenceUpdate('paused', jid)
317
+ ```
318
+
319
+ If you want WhatsApp mobile notifications to continue normally:
320
+
321
+ ```ts
322
+ const sock = makeWASocket({
323
+ markOnlineOnConnect: false
324
+ })
325
+ ```
326
+
327
+ ---
328
+
329
+ # Groups
330
+
331
+ ## Create Group
332
+
333
+ ```ts
334
+ const group = await sock.groupCreate(
335
+ 'My Group',
336
+ [
337
+ '6281111111111@s.whatsapp.net',
338
+ '6282222222222@s.whatsapp.net'
339
+ ]
340
+ )
341
+ ```
342
+
343
+ ## Group Metadata
344
+
345
+ ```ts
346
+ const metadata = await sock.groupMetadata(jid)
347
+ console.log(metadata)
348
+ ```
349
+
350
+ ## Add / Remove / Promote / Demote Participant
351
+
352
+ ```ts
353
+ await sock.groupParticipantsUpdate(jid, ['6281234567890@s.whatsapp.net'], 'add')
354
+ await sock.groupParticipantsUpdate(jid, ['6281234567890@s.whatsapp.net'], 'remove')
355
+ await sock.groupParticipantsUpdate(jid, ['6281234567890@s.whatsapp.net'], 'promote')
356
+ await sock.groupParticipantsUpdate(jid, ['6281234567890@s.whatsapp.net'], 'demote')
357
+ ```
358
+
359
+ ## Leave Group
360
+
361
+ ```ts
362
+ await sock.groupLeave(jid)
363
+ ```
364
+
365
+ ---
366
+
367
+ # Profile
368
+
369
+ ```ts
370
+ await sock.updateProfileName('ZeroneXCode Bot')
371
+ await sock.updateProfileStatus('Using ZeroneXCode Baileys')
372
+ await sock.updateProfilePicture(jid, { url: './profile.jpg' })
373
+ ```
374
+
375
+ ---
376
+
377
+ # Privacy
378
+
379
+ ```ts
380
+ const settings = await sock.fetchPrivacySettings(true)
381
+ console.log(settings)
382
+
383
+ const blocklist = await sock.fetchBlocklist()
384
+ console.log(blocklist)
385
+
386
+ await sock.updateBlockStatus(jid, 'block')
387
+ await sock.updateBlockStatus(jid, 'unblock')
388
+ ```
389
+
390
+ ---
391
+
392
+ # Full Baileys Documentation
393
+
394
+ This fork follows the upstream Baileys API.
395
+
396
+ For advanced usage and the complete API reference:
397
+
398
+ - Upstream Docs: https://baileys.wiki/docs/intro/
399
+ - Upstream Repository: https://github.com/WhiskeySockets/Baileys
400
+ - ZeroneXCode Repository: https://github.com/XzeroOffc/baileys
401
+ - ZeroneXCode npm package: `@zeronexcode/baileys`
402
+
403
+ When reading upstream documentation, simply replace:
404
+
405
+ ```ts
406
+ import makeWASocket from '@whiskeysockets/baileys'
407
+ ```
408
+
409
+ with:
410
+
411
+ ```ts
412
+ import makeWASocket from '@zeronexcode/baileys'
413
+ ```
414
+
415
+ The same applies to other imports:
416
+
417
+ ```ts
418
+ import {
419
+ useMultiFileAuthState,
420
+ Browsers,
421
+ DisconnectReason
422
+ } from '@zeronexcode/baileys'
423
+ ```
424
+
425
+ ---
426
+
427
+ ## ZeroneXCode
428
+
429
+ **Baileys modified by ZeroneXCode**
430
+
431
+ Telegram:
432
+
433
+ ```text
434
+ @ZerBackup
435
+ ```
436
+
437
+ Package:
438
+
439
+ ```text
440
+ @zeronexcode/baileys
441
+ ```
442
+
443
+ Repository:
444
+
445
+ ```text
446
+ https://github.com/XzeroOffc/baileys
447
+ ```
448
+
449
+ ---
51
450
 
52
451
  ## Repository
53
452
 
@@ -55,16 +454,21 @@ https://baileys.wiki/docs/intro/
55
454
  - Upstream project: https://github.com/WhiskeySockets/Baileys
56
455
  - npm package: `@zeronexcode/baileys`
57
456
 
457
+ ---
458
+
58
459
  ## Upstream Attribution
59
460
 
60
461
  This project is derived from the open-source **Baileys** project maintained by
61
462
  **WhiskeySockets** and its contributors.
62
463
 
63
464
  ZeroneXCode does not claim authorship of the original Baileys codebase.
465
+
64
466
  Original copyright notices and the MIT License are preserved.
65
467
 
66
468
  Changes made in this fork include package branding, distribution configuration,
67
- release workflow changes, and future ZeroneXCode-specific maintenance.
469
+ release workflow changes, documentation improvements, and ZeroneXCode-specific maintenance.
470
+
471
+ ---
68
472
 
69
473
  ## Disclaimer
70
474
 
@@ -72,8 +476,11 @@ This project is not affiliated with, authorized by, endorsed by, or officially
72
476
  connected with WhatsApp or Meta.
73
477
 
74
478
  Use this library responsibly and in accordance with applicable terms, policies,
75
- and laws. Do not use it for spam, stalkerware, abusive automation, or other
76
- harmful activity.
479
+ and laws.
480
+
481
+ Do not use it for spam, stalkerware, abusive automation, or other harmful activity.
482
+
483
+ ---
77
484
 
78
485
  ## License
79
486
 
@@ -93,8 +500,9 @@ copies or substantial portions of the Software.
93
500
 
94
501
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
95
502
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
96
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
97
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
98
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
99
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
100
- SOFTWARE.
503
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
504
+
505
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
506
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
507
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
508
+ OR OTHER DEALINGS IN THE SOFTWARE.
package/lib/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import makeWASocket from './Socket/index.js';
2
+ declare global {
3
+ var __ZERONEX_BAILEYS_BRANDING__: boolean | undefined;
4
+ }
2
5
  export * from '../WAProto/index.js';
3
6
  export * from './Utils/index.js';
4
7
  export * from './Types/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAEzC,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAE/B,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,CAAA;AACvB,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAEzC,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,4BAA4B,EAAE,OAAO,GAAG,SAAS,CAAA;CACtD;AA4BD,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAE/B,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,CAAA;AACvB,eAAe,YAAY,CAAA"}
package/lib/index.js CHANGED
@@ -1,4 +1,27 @@
1
1
  import makeWASocket from './Socket/index.js';
2
+ const c = {
3
+ reset: '\x1b[0m',
4
+ bold: '\x1b[1m',
5
+ cyan: '\x1b[36m',
6
+ green: '\x1b[32m',
7
+ magenta: '\x1b[35m',
8
+ gray: '\x1b[90m'
9
+ };
10
+ if (!globalThis.__ZERONEX_BAILEYS_BRANDING__) {
11
+ globalThis.__ZERONEX_BAILEYS_BRANDING__ = true;
12
+ console.log('');
13
+ console.log(`${c.cyan}${c.bold}███████╗██╗ ██╗${c.reset}`);
14
+ console.log(`${c.cyan}${c.bold}╚══███╔╝╚██╗██╔╝${c.reset}`);
15
+ console.log(`${c.cyan}${c.bold} ███╔╝ ╚███╔╝ ${c.reset}`);
16
+ console.log(`${c.cyan}${c.bold} ███╔╝ ██╔██╗ ${c.reset}`);
17
+ console.log(`${c.cyan}${c.bold}███████╗██╔╝ ██╗${c.reset}`);
18
+ console.log(`${c.cyan}${c.bold}╚══════╝╚═╝ ╚═╝${c.reset}`);
19
+ console.log('');
20
+ console.log(`${c.green}${c.bold}Baileys modified by ZeroneXCode${c.reset}`);
21
+ console.log(`${c.magenta}Tele: @ZerBackup${c.reset}`);
22
+ console.log(`${c.gray}Package: @zeronexcode/baileys${c.reset}`);
23
+ console.log('');
24
+ }
2
25
  export * from '../WAProto/index.js';
3
26
  export * from './Utils/index.js';
4
27
  export * from './Types/index.js';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAEzC,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAA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AAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;IAC3D,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACf,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,kCAAkC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;IAC3E,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,mBAAmB,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;IACrD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,gCAAgC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;IAC/D,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACjB,CAAC;AAED,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAG/B,OAAO,EAAE,YAAY,EAAE,CAAA;AACvB,eAAe,YAAY,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zeronexcode/baileys",
3
3
  "type": "module",
4
- "version": "7.0.0-zeronex.1",
4
+ "version": "7.0.0-zeronex.3",
5
5
  "description": "ZeroneXCode fork of Baileys, a WebSockets library for interacting with WhatsApp Web",
6
6
  "keywords": [
7
7
  "whatsapp",