@jkt48connect-corp/baileys 7.2.6 → 7.2.8

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 (102) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +838 -94
  3. package/WAProto/WAProto.proto +969 -88
  4. package/WAProto/index.d.ts +13199 -1260
  5. package/WAProto/index.js +124901 -74525
  6. package/lib/Defaults/baileys-version.json +1 -1
  7. package/lib/Defaults/index.d.ts +7 -8
  8. package/lib/Defaults/index.js +5 -3
  9. package/lib/Defaults/phonenumber-mcc.json +221 -221
  10. package/lib/Signal/libsignal.js +18 -9
  11. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -2
  12. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -1
  13. package/lib/Socket/business.d.ts +40 -40
  14. package/lib/Socket/chats.d.ts +13 -14
  15. package/lib/Socket/groups.d.ts +20 -21
  16. package/lib/Socket/groups.js +1 -1
  17. package/lib/Socket/index.d.ts +49 -49
  18. package/lib/Socket/messages-recv.d.ts +39 -39
  19. package/lib/Socket/messages-recv.js +310 -151
  20. package/lib/Socket/messages-send.d.ts +33 -31
  21. package/lib/Socket/messages-send.js +269 -36
  22. package/lib/Socket/newsletter.d.ts +24 -25
  23. package/lib/Socket/newsletter.js +3 -3
  24. package/lib/Socket/registration.d.ts +49 -52
  25. package/lib/Socket/registration.js +7 -7
  26. package/lib/Socket/socket.d.ts +6 -7
  27. package/lib/Socket/socket.js +7 -3
  28. package/lib/Store/make-cache-manager-store.d.ts +1 -0
  29. package/lib/Store/make-in-memory-store.d.ts +3 -4
  30. package/lib/Store/make-in-memory-store.js +13 -11
  31. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  32. package/lib/Types/Auth.d.ts +0 -1
  33. package/lib/Types/Call.d.ts +1 -1
  34. package/lib/Types/Chat.d.ts +12 -7
  35. package/lib/Types/Events.d.ts +17 -2
  36. package/lib/Types/GroupMetadata.d.ts +3 -1
  37. package/lib/Types/Label.d.ts +11 -0
  38. package/lib/Types/Label.js +1 -1
  39. package/lib/Types/LabelAssociation.js +1 -1
  40. package/lib/Types/Message.d.ts +164 -13
  41. package/lib/Types/Newsletter.js +3 -3
  42. package/lib/Types/Socket.d.ts +7 -2
  43. package/lib/Types/index.d.ts +9 -0
  44. package/lib/Types/index.js +1 -1
  45. package/lib/Utils/auth-utils.js +3 -3
  46. package/lib/Utils/business.d.ts +1 -1
  47. package/lib/Utils/business.js +2 -2
  48. package/lib/Utils/chat-utils.d.ts +11 -12
  49. package/lib/Utils/chat-utils.js +41 -20
  50. package/lib/Utils/crypto.d.ts +15 -16
  51. package/lib/Utils/crypto.js +35 -23
  52. package/lib/Utils/decode-wa-message.d.ts +17 -0
  53. package/lib/Utils/decode-wa-message.js +43 -15
  54. package/lib/Utils/generics.d.ts +10 -19
  55. package/lib/Utils/generics.js +32 -16
  56. package/lib/Utils/history.d.ts +6 -2
  57. package/lib/Utils/history.js +3 -0
  58. package/lib/Utils/index.d.ts +0 -1
  59. package/lib/Utils/index.js +0 -1
  60. package/lib/Utils/logger.d.ts +1 -3
  61. package/lib/Utils/make-mutex.d.ts +2 -2
  62. package/lib/Utils/messages-media.d.ts +25 -28
  63. package/lib/Utils/messages-media.js +38 -47
  64. package/lib/Utils/messages.d.ts +5 -8
  65. package/lib/Utils/messages.js +430 -12
  66. package/lib/Utils/noise-handler.d.ts +4 -5
  67. package/lib/Utils/process-message.js +2 -2
  68. package/lib/Utils/use-multi-file-auth-state.js +17 -3
  69. package/lib/Utils/validate-connection.d.ts +2 -2
  70. package/lib/Utils/validate-connection.js +12 -23
  71. package/lib/WABinary/decode.d.ts +1 -2
  72. package/lib/WABinary/decode.js +17 -7
  73. package/lib/WABinary/encode.d.ts +1 -2
  74. package/lib/WABinary/encode.js +33 -17
  75. package/lib/WABinary/generic-utils.d.ts +2 -3
  76. package/lib/WABinary/generic-utils.js +2 -2
  77. package/lib/WABinary/jid-utils.d.ts +1 -1
  78. package/lib/WAM/BinaryInfo.d.ts +2 -11
  79. package/lib/WAM/encode.d.ts +1 -2
  80. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  81. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  82. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  83. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  84. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  85. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  86. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  87. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  88. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  89. package/lib/WAUSync/Protocols/index.js +20 -0
  90. package/lib/WAUSync/USyncQuery.d.ts +26 -0
  91. package/lib/WAUSync/USyncQuery.js +79 -0
  92. package/lib/WAUSync/USyncUser.d.ts +10 -0
  93. package/lib/WAUSync/USyncUser.js +22 -0
  94. package/lib/WAUSync/index.d.ts +3 -0
  95. package/lib/WAUSync/index.js +19 -0
  96. package/lib/index.js +4 -1
  97. package/package.json +15 -10
  98. package/lib/Socket/community.d.ts +0 -219
  99. package/lib/Socket/community.js +0 -354
  100. package/lib/Utils/use-single-file-auth-statev2.d.ts +0 -12
  101. package/lib/Utils/use-single-file-auth-statev2.js +0 -75
  102. package/lib/index.d.ts +0 -11
package/README.md CHANGED
@@ -1,34 +1,711 @@
1
- # Baileys - Typescript/Javascript WhatsApp Web API
1
+ # @jkt48connect-corp/baileys - Typescript/Javascript WhatsApp Web API
2
2
 
3
- ### Warning
4
- This baileys has been re-modified by @Indraazy don't use it for illegal things!!
3
+ ### INFORMATION !!
4
+ This Baileys has been modified by @jkt48connect-corp. Don't use it for illegal activities or to harm other people.
5
5
 
6
6
  ### Important Note
7
7
 
8
- This library was originally a project for **CS-2362 at Ashoka University** and is in no way affiliated with or endorsed by WhatsApp. Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
8
+ This library was originally a project of *@adiwajshing/baileys* and is in no way affiliated with or endorsed by WhatsApp. Use at your own discretion. Don't spam others with this. We do not encourage the use of stalking, mass or automated messaging.
9
9
 
10
10
  #### Liability and License Notice
11
- Baileys and its maintainers cannot be held liable for misuse of this application, as stated in the [MIT license](https://github.com/WhiskeySockets/Baileys/blob/master/LICENSE).
12
- The maintainers of Baileys do not in any way condone the use of this application in practices that violate the Terms of Service of WhatsApp. The maintainers of this application call upon the personal responsibility of its users to use this application in a fair way, as it is intended to be used.
11
+ Indraazy and its managers are not responsible for misuse of this application, as stated in the MIT license. Indraazy management in no way condones the use of this application in practices that violate the WhatsApp Terms of Service. The manager of this application holds its users personally responsible for using this application in a fair manner, as it is intended to be used.
13
12
  ##
14
13
 
15
- Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**.
16
- Not running Selenium or Chromimum saves you like **half a gig** of ram :/
17
- Baileys supports interacting with the multi-device & web versions of WhatsApp.
18
- Thank you to [@pokearaujo](https://github.com/pokearaujo/multidevice) for writing his observations on the workings of WhatsApp Multi-Device. Also, thank you to [@Sigalor](https://github.com/sigalor/whatsapp-web-reveng) for writing his observations on the workings of WhatsApp Web and thanks to [@Rhymen](https://github.com/Rhymen/go-whatsapp/) for the __go__ implementation.
19
-
14
+ BaileysPro doesn't require Selenium or any other browser to interact with WhatsApp Web, it does it directly using WebSocket. Not running Selenium or Chromimum saves half a gig of ram :/ BaileysPro supports interaction with multi-device & web versions of WhatsApp.
15
+
20
16
  ## Please Read
21
17
 
22
- The original repository had to be removed by the original author - we now continue development in this repository here.
23
- This is the only official repository and is maintained by the community.
24
- **Join the Discord [here](https://discord.gg/WeJM5FP9GG)**
18
+ The original repository had to be removed by the original author - we are now continuing development of this repository here. This is one of the modification repositories and is maintained by Indraazy.
19
+ ___
20
+
21
+ ## Shop Message:
22
+ ```
23
+ client.sendMessage(
24
+ jid,
25
+ {
26
+ text: "YOUR TEXT",
27
+ title: "YOUR TITLE",
28
+ subtitle: "YOUR SUBTITLE",
29
+ footer: "FOOTER",
30
+ viewOnce: true,
31
+ shop: 3,
32
+ id: "199872865193",
33
+ },
34
+ {
35
+ quoted : m
36
+ }
37
+ )
38
+ ```
39
+
40
+ #### Poll Result From Newsletter Message
41
+ ```ts
42
+ await client.sendMessage(
43
+ jid,
44
+ {
45
+ pollResult: {
46
+ name: "Text poll",
47
+ votes: [["Options 1", 10], ["Options 2", 10]], // 10 For Fake Polling Count Results
48
+ }
49
+ }, { quoted : message }
50
+ )
51
+ ```
52
+
53
+
54
+ #### Status Mentions
55
+ ```ts
56
+ await sock.StatusMentions(
57
+ {
58
+ text: "Hello", // or image / video / audio ( url or buffer )
59
+ },
60
+ [
61
+ "123456789123456789@g.us",
62
+ "123456789@s.whatsapp.net",
63
+ // Enter jid chat here
64
+ ] // If the Jid Group and Jid Private Chat are included in the JID list, try to make the JID group first starting from the Jid Private Chat or Jid Private Chat in the middle between the group Jid
65
+ )
66
+ ```
67
+
68
+
69
+ ##### Cards Message
70
+ ```ts
71
+ await client.sendMessage(
72
+ jid,
73
+ {
74
+ text: "Hello",
75
+ footer: "Footer Message",
76
+ cards: [
77
+ {
78
+ image: { url: 'https://example.jpg' }, // or buffer,
79
+ title: 'Title Cards',
80
+ caption: 'Caption Cards',
81
+ footer: 'Footer Cards',
82
+ buttons: [
83
+ {
84
+ name: "quick_reply",
85
+ buttonParamsJson: JSON.stringify({
86
+ display_text: "Display Button",
87
+ id: "ID"
88
+ })
89
+ },
90
+ {
91
+ name: "cta_url",
92
+ buttonParamsJson: JSON.stringify({
93
+ display_text: "Display Button",
94
+ url: "https://www.example.com"
95
+ })
96
+ }
97
+ ]
98
+ },
99
+ {
100
+ video: { url: 'https://example.mp4' }, // or buffer,
101
+ title: 'Title Cards',
102
+ caption: 'Caption Cards',
103
+ footer: 'Footer Cards',
104
+ buttons: [
105
+ {
106
+ name: "quick_reply",
107
+ buttonParamsJson: JSON.stringify({
108
+ display_text: "Display Button",
109
+ id: "ID"
110
+ })
111
+ },
112
+ {
113
+ name: "cta_url",
114
+ buttonParamsJson: JSON.stringify({
115
+ display_text: "Display Button",
116
+ url: "https://www.example.com"
117
+ })
118
+ }
119
+ ]
120
+ }
121
+ ]
122
+ },
123
+ { quoted : message }
124
+ )
125
+ ```
126
+
127
+
128
+ #### Album Message
129
+ ```ts
130
+ await sock.AlbumMessage(
131
+ jid,
132
+ [
133
+ {
134
+ image: { url: "https://example.jpg" }, // or buffer
135
+ caption: "Hello World",
136
+ },
137
+ {
138
+ video: { url: "https://example.mp4" }, // or buffer
139
+ caption: "Hello World",
140
+ },
141
+ ],
142
+ {
143
+ quoted : message,
144
+ delay : 2000 // number in seconds
145
+ }
146
+ )
147
+ ```
148
+
149
+
150
+ #### Interactive Response Message
151
+ ```ts
152
+ await client.sendMessage(
153
+ jid,
154
+ {
155
+ buttonReply: {
156
+ text: 'Text',
157
+ nativeFlow: {
158
+ version: 3,
159
+ },
160
+ },
161
+ type: 'interactive',
162
+ ephemeral: true,
163
+ }
164
+ )
165
+ ```
166
+
167
+
168
+ #### Keep Message
169
+ - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object
170
+
171
+ - Time can be:
172
+
173
+ | Time | Seconds |
174
+ |-------|----------------|
175
+ | 24h | 86.400 |
176
+ | 7d | 604.800 |
177
+ | 30d | 2.592.000 |
178
+
179
+ ```ts
180
+ await client.sendMessage(
181
+ jid,
182
+ {
183
+ keep: message.key,
184
+ type: 1, // 2 to unpin
185
+ time: 86400
186
+ }
187
+ )
188
+ ```
189
+
190
+
191
+ #### Pin Message
192
+ - You need to pass the key of message, you can retrieve from [store](#implementing-a-data-store) or use a [key](https://baileys.whiskeysockets.io/types/WAMessageKey.html) object
193
+
194
+ - Time can be:
195
+
196
+ | Time | Seconds |
197
+ |-------|----------------|
198
+ | 24h | 86.400 |
199
+ | 7d | 604.800 |
200
+ | 30d | 2.592.000 |
201
+
202
+ ```ts
203
+ await client.sendMessage(
204
+ jid,
205
+ {
206
+ pin: message.key
207
+ type: 1, // 2 to unpin
208
+ time: 86400
209
+ }
210
+ )
211
+ ```
212
+
213
+
214
+ #### Group Invite Message With Thumbnail According to Jid
215
+ ```ts
216
+ await client.sendMessage(
217
+ jid,
218
+ {
219
+ groupInvite: {
220
+ subject: "Your Group Name", // Group name
221
+ jid: "1234@g.us", // Group ID
222
+ text: "WhatsApp Group Invitation", // Additional information
223
+ inviteCode: "CODE INVITATION", // Group invitation code
224
+ inviteExpiration: 86400 * 3, // Expiration time in seconds (example: 86400 for 24 hours)
225
+ }
226
+ },
227
+ {
228
+ quoted: message,
229
+ getProfilePicUrl: sock.profilePictureUrl
230
+ }
231
+ )
232
+ ```
233
+
234
+
235
+ #### Group Invite Message With Thumbnail Custom
236
+ ```ts
237
+ const thumbnail = "https://example.jpg" // or buffer
238
+ // The image is used under 300 so that the thumbnail can be displayed
239
+ let Jimp = require("jimp");
240
+ // import Jimp from "jimp"; => for type esm
241
+ let img = await Jimp.read(thumbnail);
242
+ let newWidth = img.bitmap.width;
243
+ let newHeight = img.bitmap.height;
244
+ if (newWidth > 300 || newHeight > 300) {
245
+ const aspectRatio = newWidth / newHeight;
246
+ if (aspectRatio > 1) {
247
+ newWidth = 300;
248
+ newHeight = Math.round(newWidth / aspectRatio);
249
+ } else {
250
+ newHeight = 300;
251
+ newWidth = Math.round(newHeight * aspectRatio);
252
+ }
253
+ }
254
+ let buff = await img
255
+ .resize(newWidth, newHeight)
256
+ .getBufferAsync(Jimp.MIME_JPEG);
257
+
258
+ await client.sendMessage(
259
+ jid,
260
+ {
261
+ groupInvite: {
262
+ subject: "Your Group Name", // Group name
263
+ jid: "1234@g.us", // Group ID
264
+ text: "WhatsApp Group Invitation", // Additional information
265
+ inviteCode: "CODE INVITATION", // Group invitation code
266
+ inviteExpiration: number, // Expiration time in seconds (example: 86400 for 24 hours),
267
+ thumbnail: buff || null // if result not found or error
268
+ }
269
+ },
270
+ { quoted: message }
271
+ )
272
+ ```
273
+
274
+
275
+ #### Request Payment Message Available To Quote Message
276
+ ```ts
277
+ // Example non media sticker
278
+ await client.sendMessage(
279
+ jid,
280
+ {
281
+ requestPayment: {
282
+ currency: "IDR",
283
+ amount: "10000000",
284
+ from: "123456@s.whatsapp.net",
285
+ note: "Hai Guys",
286
+ background: { ...background of the message }
287
+ }
288
+ },
289
+ { quoted : message }
290
+ )
291
+
292
+
293
+ // with media sticker buffer
294
+ await client.sendMessage(
295
+ jid,
296
+ {
297
+ requestPayment: {
298
+ currency: "IDR",
299
+ amount: "10000000",
300
+ from: "123456@s.whatsapp.net",
301
+ sticker: Buffer,
302
+ background: { ...background of the message }
303
+ }
304
+ },
305
+ { quoted : message }
306
+ )
307
+
308
+
309
+ // with media sticker url
310
+ await client.sendMessage(
311
+ jid,
312
+ {
313
+ requestPayment: {
314
+ currency: "IDR",
315
+ amount: "10000000",
316
+ from: "123456@s.whatsapp.net",
317
+ sticker: { url: Sticker Url },
318
+ background: { ...background of the message }
319
+ }
320
+ },
321
+ { quoted : message }
322
+ )
323
+ ```
324
+
325
+
326
+ #### Event Message
327
+ ```ts
328
+ await client.sendMessage(
329
+ jid,
330
+ {
331
+ event: {
332
+ isCanceled: false, // or true for cancel event
333
+ name: "Name Event",
334
+ description: "Description Event",
335
+ location: {
336
+ degressLatitude: -0,
337
+ degressLongitude: - 0
338
+ },
339
+ link: Call Link,
340
+ startTime: m.messageTimestamp.low,
341
+ endTime: m.messageTimestamp.low + 86400, // 86400 is day in seconds
342
+ extraGuestsAllowed: true // or false
343
+ }
344
+ },
345
+ { quoted : message }
346
+ )
347
+ ```
348
+
349
+
350
+ #### Poll Message
351
+ ```ts
352
+ await client.sendMessage(
353
+ jid,
354
+ {
355
+ poll: {
356
+ name: 'My Poll',
357
+ values: ['Option 1', 'Option 2', ...],
358
+ selectableCount: 1,
359
+ toAnnouncementGroup: false // or true
360
+ }
361
+ },
362
+ { quoted : message }
363
+ )
364
+ ```
365
+
366
+
367
+ #### Interactive Message
368
+ ```ts
369
+ // Example non header media
370
+ await client.sendMessage(
371
+ jid,
372
+ {
373
+ text: "Description Of Messages", //Additional information
374
+ title: "Title Of Messages",
375
+ subtitle: "Subtitle Message",
376
+ footer: "Footer Messages",
377
+ interactiveButtons: [
378
+ {
379
+ name: "quick_reply",
380
+ buttonParamsJson: JSON.stringify({
381
+ display_text: "Display Button",
382
+ id: "ID"
383
+ })
384
+ },
385
+ {
386
+ name: "cta_url",
387
+ buttonParamsJson: JSON.stringify({
388
+ display_text: "Display Button",
389
+ url: "https://www.example.com"
390
+ })
391
+ }
392
+ ]
393
+ },
394
+ {
395
+ quoted : message
396
+ }
397
+ )
398
+
399
+ // Example with media
400
+ await client.sendMessage(
401
+ jid,
402
+ {
403
+ image: { url : "https://example.jpg" }, // Can buffer
404
+ caption: "Description Of Messages", //Additional information
405
+ title: "Title Of Messages",
406
+ subtitle: "Subtile Message",
407
+ footer: "Footer Messages",
408
+ media: true,
409
+ interactiveButtons: [
410
+ {
411
+ name: "quick_reply",
412
+ buttonParamsJson: JSON.stringify({
413
+ display_text: "Display Button",
414
+ id: "ID"
415
+ })
416
+ },
417
+ {
418
+ name: "cta_url",
419
+ buttonParamsJson: JSON.stringify({
420
+ display_text: "Display Button",
421
+ url: "https://www.example.com"
422
+ })
423
+ }
424
+ ]
425
+ },
426
+ {
427
+ quoted : message
428
+ }
429
+ )
430
+
431
+ // Example with header product
432
+ await client.sendMessage(
433
+ jid,
434
+ {
435
+ product: {
436
+ productImage: { url: "https://example.jpg }, //or buffer
437
+ productImageCount: 1,
438
+ title: "Title Product",
439
+ description: "Description Product",
440
+ priceAmount1000: 20000 * 1000,
441
+ currencyCode: "IDR",
442
+ retailerId: "Retail",
443
+ url: "https://example.com",
444
+ },
445
+ businessOwnerJid: "1234@s.whatsapp.net",
446
+ caption: "Description Of Messages", //Additional information
447
+ title: "Title Of Messages",
448
+ footer: "Footer Messages",
449
+ media: true,
450
+ interactiveButtons: [
451
+ {
452
+ name: "quick_reply",
453
+ buttonParamsJson: JSON.stringify({
454
+ display_text: "Display Button",
455
+ id: "ID"
456
+ })
457
+ },
458
+ {
459
+ name: "cta_url",
460
+ buttonParamsJson: JSON.stringify({
461
+ display_text: "Display Button",
462
+ url: "https://www.example.com"
463
+ })
464
+ }
465
+ ]
466
+ },
467
+ {
468
+ quoted : message
469
+ }
470
+ )
471
+ ```
472
+
473
+ ## Buttons Message:
474
+ ```
475
+ // send old a buttons
476
+ client.sendMessage(m.chat, {
477
+ text: "Hello World !",
478
+ footer: "Indraazy - 2025",
479
+ buttons: [
480
+ { buttonId: `🚀`,
481
+ buttonText: {
482
+ displayText: '🗿'
483
+ }, type: 1 }
484
+ ],
485
+ headerType: 1,
486
+ viewOnce: true
487
+ },{ quoted: null })
488
+ ```
489
+
490
+ ## send location buttons:
491
+ ```
492
+ client.sendMessage(m.chat, {
493
+ location: {
494
+ degreesLatitude: -6.2088, // Ganti dengan latitude lokasi
495
+ degreesLongitude: 106.8456, // Ganti dengan longitude lokasi
496
+ },
497
+ caption: "Ini adalah lokasi yang dikirim.",
498
+ footer: "© dcodeindraa",
499
+ buttons: [
500
+ { buttonId: `🚀`,
501
+ buttonText: {
502
+ displayText: '🗿'
503
+ },
504
+ type: 1 }
505
+ ], // isi buttons nya
506
+ headerType: 6,
507
+ viewOnce: true
508
+ }, { quoted: m });
509
+ ```
510
+
511
+
512
+ ## send image buttons:
513
+ ```
514
+ client.sendMessage(m.chat, {
515
+ image: { url: "LINK YOUR IMAGE" },
516
+ caption: "Ini pesan gambar Buttons",
517
+ footer: "© Indraazy Dev",
518
+ buttons: [
519
+ {
520
+ buttonId: '.owner',
521
+ buttonText: {
522
+ displayText: 'Dev bot'
523
+ },
524
+ type: 1
525
+ },
526
+ ],
527
+ headerType: 1,
528
+ viewOnce: true
529
+ }, { quoted: m })
530
+ ```
25
531
 
532
+ ## send document buttons:
533
+ ```
534
+ let buttonMessage = {
535
+ document: { url: "https://www.youtube.com/" },
536
+ mimetype: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
537
+ fileName: "「 dcodeindraa 」",
538
+ fileLength: 999,
539
+ pageCount: 999,
540
+ contextInfo: {
541
+ forwardingScore: 555,
542
+ isForwarded: true,
543
+ externalAdReply: {
544
+ mediaUrl: "https://www.youtube.com/",
545
+ mediaType: 2,
546
+ previewType: "pdf",
547
+ title: "kamu mana punya",
548
+ body: "ini",
549
+ thumbnail: fs.readFileSync("./path/to/image"),
550
+ sourceUrl: "https://www.youtube.com/",
551
+ },
552
+ },
553
+ caption: "tes",
554
+ footer: "2020",
555
+ buttons: [
556
+ {
557
+ buttonId: "ID MU",
558
+ buttonText: {
559
+ displayText: 'Display text'
560
+ }
561
+ }, {
562
+ buttonId: "ID MU",
563
+ buttonText: {
564
+ displayText: "DISPLAY TEXT"
565
+ }
566
+ }
567
+ ],
568
+ viewOnce: true,
569
+ headerType: 6,
570
+ };
571
+
572
+ return await client.sendMessage(m.chat, buttonMessage, { quoted: null });
573
+ ```
574
+
575
+ ## send all buttons interactive:
576
+ ```
577
+ const { generateWAMessageFromContent, proto } = require("@indraazy/baileys")
578
+ let msg = generateWAMessageFromContent(m.chat, {
579
+ viewOnceMessage: {
580
+ message: {
581
+ "messageContextInfo": {
582
+ "deviceListMetadata": {},
583
+ "deviceListMetadataVersion": 2
584
+ },
585
+ interactiveMessage: proto.Message.InteractiveMessage.create({
586
+ body: proto.Message.InteractiveMessage.Body.create({
587
+ text: "Indraazy Dev"
588
+ }),
589
+ footer: proto.Message.InteractiveMessage.Footer.create({
590
+ text: "Bot"
591
+ }),
592
+ header: proto.Message.InteractiveMessage.Header.create({
593
+ title: "Igna",
594
+ subtitle: "test",
595
+ hasMediaAttachment: false
596
+ }),
597
+ nativeFlowMessage: proto.Message.InteractiveMessage.NativeFlowMessage.create({
598
+ buttons: [
599
+ {
600
+ "name": "single_select",
601
+ "buttonParamsJson": "{\"title\":\"title\",\"sections\":[{\".menu\":\".play dj webito\",\"highlight_label\":\"label\",\"rows\":[{\"header\":\"header\",\"title\":\"title\",\"description\":\"description\",\"id\":\"id\"},{\"header\":\"header\",\"title\":\"title\",\"description\":\"description\",\"id\":\"id\"}]}]}"
602
+ },
603
+ {
604
+ "name": "cta_reply",
605
+ "buttonParamsJson": "{\"display_text\":\"quick_reply\",\"id\":\"message\"}"
606
+ },
607
+ {
608
+ "name": "cta_url",
609
+ "buttonParamsJson": "{\"display_text\":\"url\",\"url\":\"https://www.google.com\",\"merchant_url\":\"https://www.google.com\"}"
610
+ },
611
+ {
612
+ "name": "cta_call",
613
+ "buttonParamsJson": "{\"display_text\":\"call\",\"id\":\"message\"}"
614
+ },
615
+ {
616
+ "name": "cta_copy",
617
+ "buttonParamsJson": "{\"display_text\":\"copy\",\"id\":\"123456789\",\"copy_code\":\"message\"}"
618
+ },
619
+ {
620
+ "name": "cta_reminder",
621
+ "buttonParamsJson": "{\"display_text\":\"Recordatorio\",\"id\":\"message\"}"
622
+ },
623
+ {
624
+ "name": "cta_cancel_reminder",
625
+ "buttonParamsJson": "{\"display_text\":\"cta_cancel_reminder\",\"id\":\"message\"}"
626
+ },
627
+ {
628
+ "name": "address_message",
629
+ "buttonParamsJson": "{\"display_text\":\"address_message\",\"id\":\"message\"}"
630
+ },
631
+ {
632
+ "name": "send_location",
633
+ "buttonParamsJson": ""
634
+ }
635
+ ],
636
+ })
637
+ })
638
+ }
639
+ }
640
+ }, {})
641
+
642
+ return client.relayMessage(msg.key.remoteJid, msg.message, { messageId: msg.key.id })
643
+ ```
644
+
645
+ ## buttons double:
646
+ ```
647
+ client.sendMessage(m.key.remoteJid, {
648
+ text: "Hello Wolrd !;",
649
+ footer: "© Indraazy Dev",
650
+ buttons: [
651
+ {
652
+ buttonId: '.tes',
653
+ buttonText: {
654
+ displayText: 'TESTING BOT'
655
+ },
656
+ type: 1,
657
+ },
658
+ {
659
+ buttonId: ' ',
660
+ buttonText: {
661
+ displayText: 'PRIVATE SCRIPT'
662
+ },
663
+ type: 1,
664
+ },
665
+ {
666
+ buttonId: 'action',
667
+ buttonText: {
668
+ displayText: 'ini pesan interactiveMeta'
669
+ },
670
+ type: 4,
671
+ nativeFlowInfo: {
672
+ name: 'single_select',
673
+ paramsJson: JSON.stringify({
674
+ title: 'message',
675
+ sections: [
676
+ {
677
+ title: 'IndraazyDev - 2025',
678
+ highlight_label: '😜',
679
+ rows: [
680
+ {
681
+ header: 'HEADER',
682
+ title: 'TITLE',
683
+ description: 'DESCRIPTION',
684
+ id: 'YOUR ID',
685
+ },
686
+ {
687
+ header: 'HEADER',
688
+ title: 'TITLE',
689
+ description: 'DESCRIPTION',
690
+ id: 'YOUR ID',
691
+ },
692
+ ],
693
+ },
694
+ ],
695
+ }),
696
+ },
697
+ },
698
+ ],
699
+ headerType: 1,
700
+ viewOnce: true
701
+ }, { quoted: m });
702
+ ```
26
703
  ## Example
27
704
 
28
705
  Do check out & run [example.ts](Example/example.ts) to see an example usage of the library.
29
706
  The script covers most common use cases.
30
707
  To run the example script, download or clone the repo and then type the following in a terminal:
31
- 1. ``` cd path/to/Baileys ```
708
+ 1. ``` cd path/to/BaileysPro ```
32
709
  2. ``` yarn ```
33
710
  3. ``` yarn example ```
34
711
 
@@ -36,17 +713,17 @@ To run the example script, download or clone the repo and then type the followin
36
713
 
37
714
  Use the stable version:
38
715
  ```
39
- yarn add @whiskeysockets/baileys
716
+ yarn add @indraazy/baileys
40
717
  ```
41
718
 
42
719
  Use the edge version (no guarantee of stability, but latest fixes + features)
43
720
  ```
44
- yarn add github:WhiskeySockets/Baileys
721
+ yarn add github:IndraazyDev/BaileysV2
45
722
  ```
46
723
 
47
724
  Then import your code using:
48
725
  ``` ts
49
- import makeWASocket from '@whiskeysockets/baileys'
726
+ import makeWASocket from '@indraazy/baileys'
50
727
  ```
51
728
 
52
729
  ## Unit Tests
@@ -55,10 +732,10 @@ TODO
55
732
 
56
733
  ## Connecting multi device (recommended)
57
734
 
58
- WhatsApp provides a multi-device API that allows Baileys to be authenticated as a second WhatsApp client by scanning a QR code with WhatsApp on your phone.
735
+ WhatsApp provides a multi-device API that allows BaileysPro to be authenticated as a second WhatsApp client by scanning a QR code with WhatsApp on your phone.
59
736
 
60
737
  ``` ts
61
- import makeWASocket, { DisconnectReason } from '@whiskeysockets/baileys'
738
+ import makeWASocket, { DisconnectReason } from '@indraazy/baileys'
62
739
  import { Boom } from '@hapi/boom'
63
740
 
64
741
  async function connectToWhatsApp () {
@@ -83,7 +760,7 @@ async function connectToWhatsApp () {
83
760
  console.log(JSON.stringify(m, undefined, 2))
84
761
 
85
762
  console.log('replying to', m.messages[0].key.remoteJid)
86
- await sock.sendMessage(m.messages[0].key.remoteJid!, { text: 'Hello there!' })
763
+ await client.sendMessage(m.messages[0].key.remoteJid!, { text: 'Hello there!' })
87
764
  })
88
765
  }
89
766
  // run in main file
@@ -92,6 +769,16 @@ connectToWhatsApp()
92
769
 
93
770
  If the connection is successful, you will see a QR code printed on your terminal screen, scan it with WhatsApp on your phone and you'll be logged in!
94
771
 
772
+ **Note:** install `qrcode-terminal` using `yarn add qrcode-terminal` to auto-print the QR to the terminal.
773
+
774
+ **Note:** the code to support the legacy version of WA Web (pre multi-device) has been removed in v5. Only the standard multi-device connection is now supported. This is done as WA seems to have completely dropped support for the legacy version.
775
+
776
+ ## Connecting native mobile api
777
+
778
+ BaileysPro also supports the native mobile API, which allows users to authenticate as a standalone WhatsApp client using their phone number.
779
+
780
+ Run the [example](Example/example.ts) file with ``--mobile`` cli flag to use the native mobile API.
781
+
95
782
  ## Configuring the Connection
96
783
 
97
784
  You can configure the connection by passing a `SocketConfig` object.
@@ -102,21 +789,21 @@ type SocketConfig = {
102
789
  /** the WS url to connect to WA */
103
790
  waWebSocketUrl: string | URL
104
791
  /** Fails the connection if the socket times out in this interval */
105
- connectTimeoutMs: number
792
+ connectTimeoutMs: number
106
793
  /** Default timeout for queries, undefined for no timeout */
107
794
  defaultQueryTimeoutMs: number | undefined
108
795
  /** ping-pong interval for WS connection */
109
796
  keepAliveIntervalMs: number
110
797
  /** proxy agent */
111
- agent?: Agent
798
+ agent?: Agent
112
799
  /** pino logger */
113
- logger: Logger
800
+ logger: Logger
114
801
  /** version to connect with */
115
802
  version: WAVersion
116
803
  /** override browser config */
117
- browser: WABrowserDescription
118
- /** agent used for fetch requests -- uploading/downloading media */
119
- fetchAgent?: Agent
804
+ browser: WABrowserDescription
805
+ /** agent used for fetch requests -- uploading/downloading media */
806
+ fetchAgent?: Agent
120
807
  /** should the QR be printed in the terminal */
121
808
  printQRInTerminal: boolean
122
809
  /** should events be emitted for actions done by this socket connection */
@@ -147,9 +834,9 @@ type SocketConfig = {
147
834
  msgRetryCounterMap?: MessageRetryMap
148
835
  /** width for link preview images */
149
836
  linkPreviewImageThumbnailWidth: number
150
- /** Should Baileys ask the phone for full history, will be received async */
837
+ /** Should BaileysPro ask the phone for full history, will be received async */
151
838
  syncFullHistory: boolean
152
- /** Should baileys fire init queries automatically, default true */
839
+ /** Should BaileysPro fire init queries automatically, default true */
153
840
  fireInitQueries: boolean
154
841
  /**
155
842
  * generate a high quality link preview,
@@ -169,7 +856,7 @@ type SocketConfig = {
169
856
 
170
857
  ### Emulating the Desktop app instead of the web
171
858
 
172
- 1. Baileys, by default, emulates a chrome web session
859
+ 1. BaileysPro, by default, emulates a chrome web session
173
860
  2. If you'd like to emulate a desktop connection (and receive more message history), add this to your Socket config:
174
861
  ``` ts
175
862
  const conn = makeWASocket({
@@ -186,12 +873,12 @@ You obviously don't want to keep scanning the QR code every time you want to con
186
873
 
187
874
  So, you can load the credentials to log back in:
188
875
  ``` ts
189
- import makeWASocket, { BufferJSON, useMultiFileAuthState } from '@whiskeysockets/baileys'
876
+ import makeWASocket, { BufferJSON, useMultiFileAuthState } from '@indraazy/baileys'
190
877
  import * as fs from 'fs'
191
878
 
192
879
  // utility function to help save the auth state in a single folder
193
880
  // this function serves as a good guide to help write auth & key states for SQL/no-SQL databases, which I would recommend in any production grade system
194
- const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
881
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_BaileysPro')
195
882
  // will use the given state to connect
196
883
  // so if valid credentials are available -- it'll connect without QR
197
884
  const conn = makeWASocket({ auth: state })
@@ -203,22 +890,22 @@ conn.ev.on ('creds.update', saveCreds)
203
890
 
204
891
  ## Listening to Connection Updates
205
892
 
206
- Baileys now fires the `connection.update` event to let you know something has updated in the connection. This data has the following structure:
893
+ BaileysPro now fires the `connection.update` event to let you know something has updated in the connection. This data has the following structure:
207
894
  ``` ts
208
895
  type ConnectionState = {
209
- /** connection is now open, connecting or closed */
210
- connection: WAConnectionState
211
- /** the error that caused the connection to close */
212
- lastDisconnect?: {
213
- error: Error
214
- date: Date
215
- }
216
- /** is this a new login */
217
- isNewLogin?: boolean
218
- /** the current QR code */
219
- qr?: string
220
- /** has the device received all pending notifications while it was offline */
221
- receivedPendingNotifications?: boolean
896
+ /** connection is now open, connecting or closed */
897
+ connection: WAConnectionState
898
+ /** the error that caused the connection to close */
899
+ lastDisconnect?: {
900
+ error: Error
901
+ date: Date
902
+ }
903
+ /** is this a new login */
904
+ isNewLogin?: boolean
905
+ /** the current QR code */
906
+ qr?: string
907
+ /** has the device received all pending notifications while it was offline */
908
+ receivedPendingNotifications?: boolean
222
909
  }
223
910
  ```
224
911
 
@@ -226,16 +913,16 @@ type ConnectionState = {
226
913
 
227
914
  ## Handling Events
228
915
 
229
- Baileys uses the EventEmitter syntax for events.
916
+ BaileysPro uses the EventEmitter syntax for events.
230
917
  They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
231
918
 
232
919
  The events are typed as mentioned here:
233
920
 
234
921
  ``` ts
235
922
 
236
- export type BaileysEventMap = {
923
+ export type BaileysProEventMap = {
237
924
  /** connection state has been updated -- WS closed, opened, connecting etc. */
238
- 'connection.update': Partial<ConnectionState>
925
+ 'connection.update': Partial<ConnectionState>
239
926
  /** credentials updated -- some metadata, keys or something */
240
927
  'creds.update': Partial<AuthenticationCreds>
241
928
  /** history sync, everything is reverse chronologically sorted */
@@ -296,20 +983,20 @@ sock.ev.on('messages.upsert', ({ messages }) => {
296
983
 
297
984
  ## Implementing a Data Store
298
985
 
299
- Baileys does not come with a defacto storage for chats, contacts, or messages. However, a simple in-memory implementation has been provided. The store listens for chat updates, new messages, message updates, etc., to always have an up-to-date version of the data.
986
+ BaileysPro does not come with a defacto storage for chats, contacts, or messages. However, a simple in-memory implementation has been provided. The store listens for chat updates, new messages, message updates, etc., to always have an up-to-date version of the data.
300
987
 
301
988
  It can be used as follows:
302
989
 
303
990
  ``` ts
304
- import makeWASocket, { makeInMemoryStore } from '@whiskeysockets/baileys'
991
+ import makeWASocket, { makeInMemoryStore } from '@indraazy/baileys'
305
992
  // the store maintains the data of the WA connection in memory
306
993
  // can be written out to a file & read from it
307
994
  const store = makeInMemoryStore({ })
308
995
  // can be read from a file
309
- store.readFromFile('./baileys_store.json')
996
+ store.readFromFile('./BaileysPro_store.json')
310
997
  // saves the state to a file every 10s
311
998
  setInterval(() => {
312
- store.writeToFile('./baileys_store.json')
999
+ store.writeToFile('./BaileysPro_store.json')
313
1000
  }, 10_000)
314
1001
 
315
1002
  const sock = makeWASocket({ })
@@ -317,13 +1004,13 @@ const sock = makeWASocket({ })
317
1004
  // the store can listen from a new socket once the current socket outlives its lifetime
318
1005
  store.bind(sock.ev)
319
1006
 
320
- sock.ev.on('chats.upsert', () => {
1007
+ sock.ev.on('chats.set', () => {
321
1008
  // can use "store.chats" however you want, even after the socket dies out
322
1009
  // "chats" => a KeyedDB instance
323
1010
  console.log('got chats', store.chats.all())
324
1011
  })
325
1012
 
326
- sock.ev.on('contacts.upsert', () => {
1013
+ sock.ev.on('contacts.set', () => {
327
1014
  console.log('got contacts', Object.values(store.contacts))
328
1015
  })
329
1016
 
@@ -340,17 +1027,17 @@ The store also provides some simple functions such as `loadMessages` that utiliz
340
1027
  ### Non-Media Messages
341
1028
 
342
1029
  ``` ts
343
- import { MessageType, MessageOptions, Mimetype } from '@whiskeysockets/baileys'
1030
+ import { MessageType, MessageOptions, Mimetype } from '@indraazy/baileys'
344
1031
 
345
1032
  const id = 'abcd@s.whatsapp.net' // the WhatsApp ID
346
1033
  // send a simple text!
347
- const sentMsg = await sock.sendMessage(id, { text: 'oh hello there' })
1034
+ const sentMsg = await client.sendMessage(id, { text: 'oh hello there' })
348
1035
  // send a reply messagge
349
- const sentMsg = await sock.sendMessage(id, { text: 'oh hello there' }, { quoted: message })
1036
+ const sentMsg = await client.sendMessage(id, { text: 'oh hello there' }, { quoted: message })
350
1037
  // send a mentions message
351
- const sentMsg = await sock.sendMessage(id, { text: '@12345678901', mentions: ['12345678901@s.whatsapp.net'] })
1038
+ const sentMsg = await client.sendMessage(id, { text: '@12345678901', mentions: ['12345678901@s.whatsapp.net'] })
352
1039
  // send a location!
353
- const sentMsg = await sock.sendMessage(
1040
+ const sentMsg = await client.sendMessage(
354
1041
  id,
355
1042
  { location: { degreesLatitude: 24.121231, degreesLongitude: 55.1121221 } }
356
1043
  )
@@ -361,7 +1048,7 @@ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
361
1048
  + 'ORG:Ashoka Uni;\n' // the organization of the contact
362
1049
  + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
363
1050
  + 'END:VCARD'
364
- const sentMsg = await sock.sendMessage(
1051
+ const sentMsg = await client.sendMessage(
365
1052
  id,
366
1053
  {
367
1054
  contacts: {
@@ -378,30 +1065,30 @@ const reactionMessage = {
378
1065
  }
379
1066
  }
380
1067
 
381
- const sendMsg = await sock.sendMessage(id, reactionMessage)
1068
+ const sendMsg = await client.sendMessage(id, reactionMessage)
382
1069
  ```
383
1070
 
384
1071
  ### Sending messages with link previews
385
1072
 
386
1073
  1. By default, WA MD does not have link generation when sent from the web
387
- 2. Baileys has a function to generate the content for these link previews
1074
+ 2. BaileysPro has a function to generate the content for these link previews
388
1075
  3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
389
1076
  4. Send a link:
390
1077
  ``` ts
391
1078
  // send a link
392
- const sentMsg = await sock.sendMessage(id, { text: 'Hi, this was sent using https://github.com/adiwajshing/baileys' })
1079
+ const sentMsg = await client.sendMessage(id, { text: 'Hi, this was sent using https://github.com/adiwajshing/BaileysPro' })
393
1080
  ```
394
1081
 
395
1082
  ### Media Messages
396
1083
 
397
1084
  Sending media (video, stickers, images) is easier & more efficient than ever.
398
1085
  - You can specify a buffer, a local url or even a remote url.
399
- - When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
1086
+ - When specifying a media url, BaileysPro never loads the entire buffer into memory; it even encrypts the media as a readable stream.
400
1087
 
401
1088
  ``` ts
402
- import { MessageType, MessageOptions, Mimetype } from '@whiskeysockets/baileys'
1089
+ import { MessageType, MessageOptions, Mimetype } from '@indraazy/baileys'
403
1090
  // Sending gifs
404
- await sock.sendMessage(
1091
+ await client.sendMessage(
405
1092
  id,
406
1093
  {
407
1094
  video: fs.readFileSync("Media/ma_gif.mp4"),
@@ -410,18 +1097,17 @@ await sock.sendMessage(
410
1097
  }
411
1098
  )
412
1099
 
413
- await sock.sendMessage(
1100
+ await client.sendMessage(
414
1101
  id,
415
1102
  {
416
1103
  video: "./Media/ma_gif.mp4",
417
1104
  caption: "hello!",
418
- gifPlayback: true,
419
- ptv: false // if set to true, will send as a `video note`
1105
+ gifPlayback: true
420
1106
  }
421
1107
  )
422
1108
 
423
1109
  // send an audio file
424
- await sock.sendMessage(
1110
+ await client.sendMessage(
425
1111
  id,
426
1112
  { audio: { url: "./Media/audio.mp3" }, mimetype: 'audio/mp4' }
427
1113
  { url: "Media/audio.mp3" }, // can send mp3, mp4, & ogg
@@ -432,8 +1118,8 @@ await sock.sendMessage(
432
1118
 
433
1119
  - `id` is the WhatsApp ID of the person or group you're sending the message to.
434
1120
  - It must be in the format ```[country code][phone number]@s.whatsapp.net```
435
- - Example for people: ```+19999999999@s.whatsapp.net```.
436
- - For groups, it must be in the format ``` 123456789-123345@g.us ```.
1121
+ - Example for people: ```+19999999999@s.whatsapp.net```.
1122
+ - For groups, it must be in the format ``` 123456789-123345@g.us ```.
437
1123
  - For broadcast lists, it's `[timestamp of creation]@broadcast`.
438
1124
  - For stories, the ID is `status@broadcast`.
439
1125
  - For media messages, the thumbnail can be generated automatically for images & stickers provided you add `jimp` or `sharp` as a dependency in your project using `yarn add jimp` or `yarn add sharp`. Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.
@@ -449,7 +1135,7 @@ await sock.sendMessage(
449
1135
  Do not enter this field if you want to automatically generate a thumb
450
1136
  */
451
1137
  mimetype: Mimetype.pdf, /* (for media messages) specify the type of media (optional for all media types except documents),
452
- import {Mimetype} from '@whiskeysockets/baileys'
1138
+ import {Mimetype} from '@indraazy/baileys'
453
1139
  */
454
1140
  fileName: 'somefile.pdf', // (for media messages) file name for the media
455
1141
  /* will send audio messages as voice notes, if set to true */
@@ -463,13 +1149,13 @@ await sock.sendMessage(
463
1149
 
464
1150
  ``` ts
465
1151
  const msg = getMessageFromStore('455@s.whatsapp.net', 'HSJHJWH7323HSJSJ') // implement this on your end
466
- await sock.sendMessage('1234@s.whatsapp.net', { forward: msg }) // WA forward the message!
1152
+ await client.sendMessage('1234@s.whatsapp.net', { forward: msg }) // WA forward the message!
467
1153
  ```
468
1154
 
469
1155
  ## Reading Messages
470
1156
 
471
1157
  A set of message keys must be explicitly marked read now.
472
- In multi-device, you cannot mark an entire "chat" read as it were with Baileys Web.
1158
+ In multi-device, you cannot mark an entire "chat" read as it were with BaileysPro Web.
473
1159
  This means you have to keep track of unread messages.
474
1160
 
475
1161
  ``` ts
@@ -501,14 +1187,14 @@ type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'pau
501
1187
 
502
1188
  The presence expires after about 10 seconds.
503
1189
 
504
- **Note:** In the multi-device version of WhatsApp -- if a desktop client is active, WA doesn't send push notifications to the device. If you would like to receive said notifications -- mark your Baileys client offline using `sock.sendPresenceUpdate('unavailable')`
1190
+ **Note:** In the multi-device version of WhatsApp -- if a desktop client is active, WA doesn't send push notifications to the device. If you would like to receive said notifications -- mark your BaileysPro client offline using `sock.sendPresenceUpdate('unavailable')`
505
1191
 
506
1192
  ## Downloading Media Messages
507
1193
 
508
1194
  If you want to save the media you received
509
1195
  ``` ts
510
1196
  import { writeFile } from 'fs/promises'
511
- import { downloadMediaMessage } from '@whiskeysockets/baileys'
1197
+ import { downloadMediaMessage } from '@indraazy/baileys'
512
1198
 
513
1199
  sock.ev.on('messages.upsert', async ({ messages }) => {
514
1200
  const m = messages[0]
@@ -524,7 +1210,7 @@ sock.ev.on('messages.upsert', async ({ messages }) => {
524
1210
  { },
525
1211
  {
526
1212
  logger,
527
- // pass this so that baileys can request a reupload of media
1213
+ // pass this so that BaileysPro can request a reupload of media
528
1214
  // that has been deleted
529
1215
  reuploadRequest: sock.updateMediaMessage
530
1216
  }
@@ -544,10 +1230,10 @@ const updatedMediaMsg = await sock.updateMediaMessage(msg)
544
1230
 
545
1231
  ``` ts
546
1232
  const jid = '1234@s.whatsapp.net' // can also be a group
547
- const response = await sock.sendMessage(jid, { text: 'hello!' }) // send a message
1233
+ const response = await client.sendMessage(jid, { text: 'hello!' }) // send a message
548
1234
  // sends a message to delete the given message
549
1235
  // this deletes the message for everyone
550
- await sock.sendMessage(jid, { delete: response.key })
1236
+ await client.sendMessage(jid, { delete: response.key })
551
1237
  ```
552
1238
 
553
1239
  **Note:** deleting for oneself is supported via `chatModify` (next section)
@@ -557,7 +1243,7 @@ await sock.sendMessage(jid, { delete: response.key })
557
1243
  ``` ts
558
1244
  const jid = '1234@s.whatsapp.net'
559
1245
 
560
- await sock.sendMessage(jid, {
1246
+ await client.sendMessage(jid, {
561
1247
  text: 'updated text goes here',
562
1248
  edit: response.key,
563
1249
  });
@@ -613,13 +1299,13 @@ WA uses an encrypted form of communication to send chat/app updates. This has be
613
1299
  },
614
1300
  '123456@s.whatsapp.net')
615
1301
  ```
616
-
1302
+
617
1303
  - Star/unstar a message
618
1304
  ``` ts
619
1305
  await sock.chatModify({
620
1306
  star: {
621
- messages: [{ id: 'messageID', fromMe: true // or `false` }],
622
- star: true // - true: Star Message; false: Unstar Message
1307
+ messages: [{ id: 'messageID', fromMe: true // or `false` }],
1308
+ star: true // - true: Star Message; false: Unstar Message
623
1309
  }},'123456@s.whatsapp.net');
624
1310
  ```
625
1311
 
@@ -630,15 +1316,15 @@ WA uses an encrypted form of communication to send chat/app updates. This has be
630
1316
  ``` ts
631
1317
  const jid = '1234@s.whatsapp.net' // can also be a group
632
1318
  // turn on disappearing messages
633
- await sock.sendMessage(
1319
+ await client.sendMessage(
634
1320
  jid,
635
1321
  // this is 1 week in seconds -- how long you want messages to appear for
636
1322
  { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
637
1323
  )
638
1324
  // will send as a disappearing message
639
- await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
1325
+ await client.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
640
1326
  // turn off disappearing messages
641
- await sock.sendMessage(
1327
+ await client.sendMessage(
642
1328
  jid,
643
1329
  { disappearingMessagesInChat: false }
644
1330
  )
@@ -707,13 +1393,71 @@ await sock.sendMessage(
707
1393
  ```
708
1394
  Of course, replace ``` xyz ``` with an actual ID.
709
1395
 
1396
+ ## Newsletter
1397
+ - To get info newsletter
1398
+ ``` ts
1399
+ const metadata = await sock.newsletterMetadata("invite", "xxxxx")
1400
+ // or
1401
+ const metadata = await sock.newsletterMetadata("jid", "abcd@newsletter")
1402
+ console.log(metadata)
1403
+ ```
1404
+ - To update the description of a newsletter
1405
+ ``` ts
1406
+ await sock.newsletterUpdateDescription("abcd@newsletter", "New Description")
1407
+ ```
1408
+ - To update the name of a newsletter
1409
+ ``` ts
1410
+ await sock.newsletterUpdateName("abcd@newsletter", "New Name")
1411
+ ```
1412
+ - To update the profile picture of a newsletter.
1413
+ ``` ts
1414
+ await sock.newsletterUpdatePicture("abcd@newsletter", buffer)
1415
+ ```
1416
+ - To remove the profile picture of a newsletter
1417
+ ``` ts
1418
+ await sock.newsletterRemovePicture("abcd@newsletter")
1419
+ ```
1420
+ - To mute notifications for a newsletter.
1421
+ ``` ts
1422
+ await sock.newsletterUnmute("abcd@newsletter")
1423
+ ```
1424
+ - To mute notifications for a newsletter.
1425
+ ``` ts
1426
+ await sock.newsletterMute("abcd@newsletter")
1427
+ ```
1428
+ - To create a newsletter
1429
+ ``` ts
1430
+ const metadata = await sock.newsletterCreate("Newsletter Name", "Newsletter Description")
1431
+ console.log(metadata)
1432
+ ```
1433
+ - To delete a newsletter.
1434
+ ``` ts
1435
+ await sock.newsletterDelete("abcd@newsletter")
1436
+ ```
1437
+ - To follow a newsletter
1438
+ ``` ts
1439
+ await sock.newsletterFollow("abcd@newsletter")
1440
+ ```
1441
+ - To unfollow a newsletter
1442
+ ``` ts
1443
+ await sock.newsletterUnfollow("abcd@newsletter")
1444
+ ```
1445
+ - To send reaction
1446
+ ``` ts
1447
+ // jid, id message & emoticon
1448
+ // way to get the ID is to copy the message url from channel
1449
+ // Example: [ https://whatsapp.com/channel/xxxxx/175 ]
1450
+ // The last number of the URL is the ID
1451
+ const id = "175"
1452
+ await sock.newsletterReactMessage("abcd@newsletter", id, "🥳")
1453
+ ```
710
1454
  ## Groups
711
1455
  - To create a group
712
1456
  ``` ts
713
1457
  // title & participants
714
1458
  const group = await sock.groupCreate("My Fab Group", ["1234@s.whatsapp.net", "4564@s.whatsapp.net"])
715
1459
  console.log ("created group with id: " + group.gid)
716
- sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
1460
+ client.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
717
1461
  ```
718
1462
  - To add/remove people to a group or demote/promote people
719
1463
  ``` ts
@@ -828,7 +1572,7 @@ Of course, replace ``` xyz ``` with an actual ID.
828
1572
  ```
829
1573
  - To update the Groups Add privacy
830
1574
  ``` ts
831
- const value = 'all' // 'contacts' | 'contact_blacklist'
1575
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
832
1576
  await sock.updateGroupsAddPrivacy(value)
833
1577
  ```
834
1578
  - To update the Default Disappearing Mode
@@ -841,7 +1585,7 @@ Of course, replace ``` xyz ``` with an actual ID.
841
1585
  Messages can be sent to broadcasts & stories.
842
1586
  you need to add the following message options in sendMessage, like this:
843
1587
  ```ts
844
- sock.sendMessage(jid, {image: {url: url}, caption: caption}, {backgroundColor : backgroundColor, font : font, statusJidList: statusJidList, broadcast : true})
1588
+ client.sendMessage(jid, {image: {url: url}, caption: caption}, {backgroundColor : backgroundColor, font : font, statusJidList: statusJidList, broadcast : true})
845
1589
  ```
846
1590
  - the message body can be a extendedTextMessage or imageMessage or videoMessage or voiceMessage
847
1591
  - You can add backgroundColor and other options in the message options
@@ -858,7 +1602,7 @@ sock.sendMessage(jid, {image: {url: url}, caption: caption}, {backgroundColor :
858
1602
  ```
859
1603
 
860
1604
  ## Writing Custom Functionality
861
- Baileys is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.
1605
+ BaileysPro is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.
862
1606
 
863
1607
  First, enable the logging of unhandled messages from WhatsApp by setting:
864
1608
  ``` ts
@@ -873,7 +1617,7 @@ Some examples:
873
1617
  1. Functionality to track the battery percentage of your phone.
874
1618
  You enable logging and you'll see a message about your battery pop up in the console:
875
1619
  ```{"level":10,"fromMe":false,"frame":{"tag":"ib","attrs":{"from":"@s.whatsapp.net"},"content":[{"tag":"edge_routing","attrs":{},"content":[{"tag":"routing_info","attrs":{},"content":{"type":"Buffer","data":[8,2,8,5]}}]}]},"msg":"communication"} ```
876
-
1620
+
877
1621
  The "frame" is what the message received is, it has three components:
878
1622
  - `tag` -- what this frame is about (eg. message will have "message")
879
1623
  - `attrs` -- a string key-value pair with some metadata (contains ID of the message usually)
@@ -889,4 +1633,4 @@ Some examples:
889
1633
  // for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
890
1634
  sock.ws.on(`CB:edge_routing,id:abcd,routing_info`, (node: BinaryNode) => { })
891
1635
  ```
892
- Also, this repo is now licenced under GPL 3 since it uses [libsignal-node](https://git.questbook.io/backend/service-coderunner/-/merge_requests/1)
1636
+ Also, this repo is now licenced under GPL 3 since it uses [libsignal-node](https://git.questbook.io/backend/service-coderunner/-/merge_requests/1)