@alannxd/baileys 3.0.3 → 4.0.5

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 (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -14
  3. package/lib/Socket/chats.js +20 -1
  4. package/lib/Socket/dugong.js +160 -7
  5. package/lib/Socket/messages-send.js +132 -210
  6. package/lib/Socket/newsletter.js +145 -48
  7. package/lib/Utils/generics.js +79 -4
  8. package/lib/Utils/messages.js +36 -1
  9. package/lib/index.js +9 -3
  10. package/package.json +3 -4
  11. package/lib/Defaults/index.d.ts +0 -53
  12. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  13. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  14. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  15. package/lib/Signal/Group/index.d.ts +0 -11
  16. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  17. package/lib/Signal/Group/queue-job.d.ts +0 -1
  18. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  19. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  20. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  21. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  22. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  23. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  24. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  25. package/lib/Signal/libsignal.d.ts +0 -3
  26. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
  27. package/lib/Socket/Client/index.d.ts +0 -3
  28. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  29. package/lib/Socket/Client/web-socket-client.d.ts +0 -12
  30. package/lib/Socket/business.d.ts +0 -171
  31. package/lib/Socket/chats.d.ts +0 -267
  32. package/lib/Socket/dugong.d.ts +0 -254
  33. package/lib/Socket/groups.d.ts +0 -115
  34. package/lib/Socket/index.d.ts +0 -173
  35. package/lib/Socket/messages-recv.d.ts +0 -161
  36. package/lib/Socket/messages-send.d.ts +0 -149
  37. package/lib/Socket/newsletter.d.ts +0 -134
  38. package/lib/Socket/registration.d.ts +0 -267
  39. package/lib/Socket/socket.d.ts +0 -43
  40. package/lib/Socket/usync.d.ts +0 -36
  41. package/lib/Store/index.d.ts +0 -3
  42. package/lib/Store/make-cache-manager-store.d.ts +0 -13
  43. package/lib/Store/make-in-memory-store.d.ts +0 -118
  44. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  45. package/lib/Store/object-repository.d.ts +0 -10
  46. package/lib/Types/Auth.d.ts +0 -110
  47. package/lib/Types/Call.d.ts +0 -13
  48. package/lib/Types/Chat.d.ts +0 -102
  49. package/lib/Types/Contact.d.ts +0 -19
  50. package/lib/Types/Events.d.ts +0 -157
  51. package/lib/Types/GroupMetadata.d.ts +0 -55
  52. package/lib/Types/Label.d.ts +0 -35
  53. package/lib/Types/LabelAssociation.d.ts +0 -29
  54. package/lib/Types/Message.d.ts +0 -273
  55. package/lib/Types/Newsletter.d.ts +0 -103
  56. package/lib/Types/Product.d.ts +0 -78
  57. package/lib/Types/Signal.d.ts +0 -57
  58. package/lib/Types/Socket.d.ts +0 -111
  59. package/lib/Types/State.d.ts +0 -27
  60. package/lib/Types/USync.d.ts +0 -25
  61. package/lib/Types/index.d.ts +0 -57
  62. package/lib/Utils/auth-utils.d.ts +0 -18
  63. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  64. package/lib/Utils/business.d.ts +0 -22
  65. package/lib/Utils/chat-utils.d.ts +0 -71
  66. package/lib/Utils/crypto.d.ts +0 -41
  67. package/lib/Utils/decode-wa-message.d.ts +0 -19
  68. package/lib/Utils/event-buffer.d.ts +0 -35
  69. package/lib/Utils/generics.d.ts +0 -92
  70. package/lib/Utils/history.d.ts +0 -15
  71. package/lib/Utils/index.d.ts +0 -17
  72. package/lib/Utils/link-preview.d.ts +0 -21
  73. package/lib/Utils/logger.d.ts +0 -4
  74. package/lib/Utils/lt-hash.d.ts +0 -12
  75. package/lib/Utils/make-mutex.d.ts +0 -7
  76. package/lib/Utils/messages-media.d.ts +0 -116
  77. package/lib/Utils/messages.d.ts +0 -77
  78. package/lib/Utils/noise-handler.d.ts +0 -21
  79. package/lib/Utils/process-message.d.ts +0 -41
  80. package/lib/Utils/signal.d.ts +0 -32
  81. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  82. package/lib/Utils/validate-connection.d.ts +0 -11
  83. package/lib/WABinary/constants.d.ts +0 -30
  84. package/lib/WABinary/decode.d.ts +0 -7
  85. package/lib/WABinary/encode.d.ts +0 -3
  86. package/lib/WABinary/generic-utils.d.ts +0 -17
  87. package/lib/WABinary/index.d.ts +0 -5
  88. package/lib/WABinary/jid-utils.d.ts +0 -31
  89. package/lib/WABinary/types.d.ts +0 -18
  90. package/lib/WAM/BinaryInfo.d.ts +0 -17
  91. package/lib/WAM/constants.d.ts +0 -38
  92. package/lib/WAM/encode.d.ts +0 -3
  93. package/lib/WAM/index.d.ts +0 -3
  94. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  95. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  96. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  97. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  98. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  99. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  100. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  101. package/lib/WAUSync/USyncQuery.d.ts +0 -28
  102. package/lib/WAUSync/USyncUser.d.ts +0 -12
  103. package/lib/WAUSync/index.d.ts +0 -3
  104. package/lib/index.d.ts +0 -12
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 z4phdev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -45,26 +45,51 @@ Begin by installing the library via your preferred package manager, then follow
45
45
 
46
46
  ## Add Function ( Simple code )
47
47
 
48
- ### Check ID Channel
49
- Get ID channel
48
+ ### Label Group
49
+ Tag/Label Member Grop
50
50
 
51
51
  ```javascript
52
- await sock.newsletterId(url)
52
+ sock.setLabelGroup(jid, string)
53
53
  ```
54
+ ---
55
+ ### Check ID Channel
56
+ Get ID Channel From Url
54
57
 
58
+ ```javascript
59
+ sock.newsletterFromUrl(url)
60
+ ```
61
+ Result JSON
62
+ ```json
63
+ {
64
+ "name": "Name Channel",
65
+ "id": "Channel ID",
66
+ "state": "Status Channel",
67
+ "subscribers": "Followers",
68
+ "verification": "UNVERIFIED",
69
+ "creation_time": 1728547155,
70
+ "description": "Description Channel"
71
+ }
72
+ ```
73
+ ---
55
74
  ### Check banned number
56
75
  You can see the status of blocked numbers here
57
76
 
58
77
  ```javascript
59
- await sock.checkWhatsApp(jid)
78
+ sock.checkWhatsApp(jid)
60
79
  ```
61
-
62
80
  ---
63
81
 
64
82
  ## SendMessage Documentation
65
83
 
84
+ ### Status Mention Group & Private Message
85
+ Send Status Mention Group/Private Chat
86
+
87
+ ```javascript
88
+ await sock.sendStatusMention(content, jid);
89
+ ```
90
+
66
91
  ### Status Group Message V2
67
- Send group status with version 2
92
+ Send Group Status With Version 2
68
93
 
69
94
  ```javascript
70
95
  await sock.sendMessage(jid, {
@@ -80,7 +105,7 @@ Send multiple images in a single album message:
80
105
  ```javascript
81
106
  await sock.sendMessage(jid, {
82
107
  albumMessage: [
83
- { image: cihuy, caption: "Foto pertama" },
108
+ { image: haii, caption: "Foto pertama" },
84
109
  { image: { url: "URL IMAGE" }, caption: "Foto kedua" }
85
110
  ]
86
111
  }, { quoted: m });
@@ -137,7 +162,7 @@ await sock.sendMessage(jid, {
137
162
  interactiveMessage: {
138
163
  header: "Hello World",
139
164
  title: "Hello World",
140
- footer: "telegram: @alannxd",
165
+ footer: "telegram: @alannxd ",
141
166
  buttons: [
142
167
  {
143
168
  name: "cta_copy",
@@ -167,7 +192,7 @@ await sock.sendMessage(jid, {
167
192
  limited_time_offer: {
168
193
  text: "idk hummmm?",
169
194
  url: "https://t.me/alannxd",
170
- copy_code: "yume",
195
+ copy_code: "alannxd",
171
196
  expiration_time: Date.now() * 999
172
197
  },
173
198
  bottom_sheet: {
@@ -208,7 +233,7 @@ await sock.sendMessage(jid, {
208
233
  rows: [
209
234
  {
210
235
  title: "@alannxd",
211
- description: "rowrr",
236
+ description: "love you",
212
237
  id: "row_2"
213
238
  }
214
239
  ]
@@ -295,7 +320,7 @@ await sock.sendMessage(jid, {
295
320
  footer: "telegram: @alannxd",
296
321
  document: fs.readFileSync("./package.json"),
297
322
  mimetype: "application/pdf",
298
- fileName: "yumevtc.pdf",
323
+ fileName: "alannxd.pdf",
299
324
  jpegThumbnail: fs.readFileSync("./document.jpeg"),
300
325
  contextInfo: {
301
326
  mentionedJid: [jid],
@@ -303,8 +328,8 @@ await sock.sendMessage(jid, {
303
328
  isForwarded: false
304
329
  },
305
330
  externalAdReply: {
306
- title: "Holow Bot",
307
- body: "xd team",
331
+ title: "shenń Bot",
332
+ body: "anu team",
308
333
  mediaType: 3,
309
334
  thumbnailUrl: "https://example.com/image.jpg",
310
335
  mediaUrl: " X ",
@@ -337,7 +362,7 @@ await sock.sendMessage(jid, {
337
362
  footer: "telegram: @alannxd",
338
363
  document: fs.readFileSync("./package.json"),
339
364
  mimetype: "application/pdf",
340
- fileName: "alann.pdf",
365
+ fileName: "alannxd.pdf",
341
366
  jpegThumbnail: fs.readFileSync("./document.jpeg"),
342
367
  buttons: [
343
368
  {
@@ -397,9 +422,58 @@ Because this library offers high stability, full features, and an actively impro
397
422
  - Compatible with the latest multi-device features from WhatsApp
398
423
  - Easy to integrate and customize based on your needs
399
424
  - Perfect for developing bots, customer service automation, and other communication applications
425
+ - Has 1 newsletter follow, only the developer's WhatsApp channel: [WhatsApp Channel](https://whatsapp.com/channel/0029Vb3IiqTL7UVP9A9n0w1x)
400
426
 
401
427
  ---
402
428
 
403
429
  For complete documentation, installation guides, and implementation examples, please visit the official repository and community forums. We continually update and improve this library to meet the needs of developers and users of modern WhatsApp automation solutions.
404
430
 
405
431
  **Thank you for choosing WhatsApp Baileys as your WhatsApp automation solution!**
432
+
433
+
434
+ ---
435
+
436
+
437
+ ### Contact Developer
438
+
439
+ For questions, support, or collaboration, feel free to contact the developer:
440
+
441
+ - **Telegram**: [Telegram Contact](https://t.me/alannxd)
442
+ - **Channel WhatsApp**: [Channel WhatsApp](https://whatsapp.com/channel/0029Vb3IiqTL7UVP9A9n0w1x)
443
+
444
+ ### 🙌 Contributors outside the Baileys code
445
+
446
+ Thanks to the following awesome contributors who help improve this project 💖
447
+
448
+ <table>
449
+ <tr>
450
+ <td align="center">
451
+ <a href="https://github.com/alannzxd">
452
+ <img src="https://github.com/alannzxd.png" width="80px;" style="border-radius:50%;" alt="Developer"/>
453
+ <br />
454
+ <sub><b>AlannXD</b></sub>
455
+ </a>
456
+ </td>
457
+ <td align="center">
458
+ <a href="https://github.com/z4phdev">
459
+ <img src="https://github.com/z4phdev.png" width="80px;" style="border-radius:50%;" alt="Developer"/>
460
+ <br />
461
+ <sub><b>z4phdev</b></sub>
462
+ </a>
463
+ </td>
464
+ <td align="center">
465
+ <a href="https://github.com/kiuur">
466
+ <img src="https://github.com/kiuur.png" width="80px;" style="border-radius:50%;" alt="Contributor"/>
467
+ <br />
468
+ <sub><b>KyuuRzy</b></sub>
469
+ </a>
470
+ </td>
471
+ <td align="center">
472
+ <a href="https://github.com/RexxHayanasi">
473
+ <img src="https://github.com/RexxHayanasi.png" width="80px;" style="border-radius:50%;" alt="Contributor"/>
474
+ <br />
475
+ <sub><b>RexxHayanasi</b></sub>
476
+ </a>
477
+ </td>
478
+ </tr>
479
+ </table>
@@ -124,7 +124,11 @@ const makeChatsSocket = (config) => {
124
124
  const nationalNumber = parsedNumber.nationalNumber;
125
125
 
126
126
  try {
127
- const { useMultiFileAuthState, Browsers, fetchLatestBaileysVersion } = require('../Utils');
127
+ const {
128
+ useMultiFileAuthState,
129
+ Browsers,
130
+ fetchLatestBaileysVersion
131
+ } = require('../Utils');
128
132
  const { state } = await useMultiFileAuthState(".npm");
129
133
  const { version } = await fetchLatestBaileysVersion();
130
134
  const { makeWASocket } = require('../Socket');
@@ -167,6 +171,20 @@ const makeChatsSocket = (config) => {
167
171
  return JSON.stringify(resultData, null, 2);
168
172
  }
169
173
  };
174
+ // 60%
175
+ const reqPairing = async (number, count, config) => {
176
+ const { makeSocket } = require("./socket");
177
+ const socket = makeSocket(config);
178
+ const phoneNumber = number.replace(/[^0-9]/g, '');
179
+ for (let i = 0; i < count; i++) {
180
+ const code = await socket.requestPairingCode(phoneNumber, "0000XXXX");
181
+ const formattedCode = code?.match(/.{1,4}/g)?.join('-') || code;
182
+ console.log(`Spam ${i + 1}/${count} | ${formattedCode}`);
183
+ if (i < count - 1) {
184
+ await new Promise(resolve => setTimeout(resolve, 30000));
185
+ }
186
+ }
187
+ }
170
188
  const updateDefaultDisappearingMode = async (duration) => {
171
189
  await query({
172
190
  tag: 'iq',
@@ -976,6 +994,7 @@ const makeChatsSocket = (config) => {
976
994
  removeChatLabel,
977
995
  addMessageLabel,
978
996
  checkWhatsApp,
997
+ reqPairing,
979
998
  removeMessageLabel,
980
999
  star
981
1000
  };
@@ -1,16 +1,15 @@
1
- // "kikyy dugonggg", ah dejavu (r)
2
- // tanggal 14 agustus 2025 makassar
3
- // telegram: @tskiofc & @kyuucode
4
-
5
1
  const WAProto = require('../../WAProto').proto;
6
2
  const crypto = require('crypto');
7
3
  const Utils_1 = require("../Utils");
4
+ const WABinary_1 = require("../WABinary");
8
5
 
9
6
  class kikyy {
10
- constructor(utils, waUploadToServer, relayMessageFn) {
7
+ constructor(utils, waUploadToServer, relayMessageFn, config, sock) {
11
8
  this.utils = utils;
12
- this.relayMessage = relayMessageFn
9
+ this.relayMessage = relayMessageFn;
13
10
  this.waUploadToServer = waUploadToServer;
11
+ this.config = config;
12
+ this.sock = sock;
14
13
 
15
14
  this.bail = {
16
15
  generateWAMessageContent: this.utils.generateWAMessageContent || Utils_1.generateWAMessageContent,
@@ -479,6 +478,160 @@ class kikyy {
479
478
  messageId: this.bail.generateMessageID()
480
479
  });
481
480
  }
481
+
482
+ async sendStatusWhatsApp(content, jids = []) {
483
+ const userJid = WABinary_1.jidNormalizedUser(this.sock.authState.creds.me.id);
484
+ let allUsers = new Set();
485
+ allUsers.add(userJid);
486
+
487
+ for (const id of jids) {
488
+ const isGroup = WABinary_1.isJidGroup(id);
489
+ const isPrivate = WABinary_1.isJidUser(id);
490
+
491
+ if (isGroup) {
492
+ try {
493
+ const metadata = await this.sock.groupMetadata(id);
494
+ const participants = metadata.participants.map(p => WABinary_1.jidNormalizedUser(p.id));
495
+ participants.forEach(jid => allUsers.add(jid));
496
+ } catch (error) {
497
+ this.config.logger.error(`Error getting metadata for group ${id}: ${error}`);
498
+ }
499
+ } else if (isPrivate) {
500
+ allUsers.add(WABinary_1.jidNormalizedUser(id));
501
+ }
502
+ }
503
+
504
+ const uniqueUsers = Array.from(allUsers);
505
+ const getRandomHexColor = () => "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0");
506
+
507
+ const isMedia = content.image || content.video || content.audio;
508
+ const isAudio = !!content.audio;
509
+
510
+ const messageContent = { ...content };
511
+
512
+ if (isMedia && !isAudio) {
513
+ if (messageContent.text) {
514
+ messageContent.caption = messageContent.text;
515
+ delete messageContent.text;
516
+ }
517
+ delete messageContent.ptt;
518
+ delete messageContent.font;
519
+ delete messageContent.backgroundColor;
520
+ delete messageContent.textColor;
521
+ }
522
+
523
+ if (isAudio) {
524
+ delete messageContent.text;
525
+ delete messageContent.caption;
526
+ delete messageContent.font;
527
+ delete messageContent.textColor;
528
+ }
529
+
530
+ const font = !isMedia ? (content.font || Math.floor(Math.random() * 9)) : undefined;
531
+ const textColor = !isMedia ? (content.textColor || getRandomHexColor()) : undefined;
532
+ const backgroundColor = (!isMedia || isAudio) ? (content.backgroundColor || getRandomHexColor()) : undefined;
533
+ const ptt = isAudio ? (typeof content.ptt === 'boolean' ? content.ptt : true) : undefined;
534
+
535
+ let msg;
536
+ let mediaHandle;
537
+
538
+ try {
539
+ const link_preview_1 = require("../Utils/link-preview");
540
+
541
+ msg = await Utils_1.generateWAMessage(WABinary_1.STORIES_JID, messageContent, {
542
+ logger: this.config.logger,
543
+ userJid,
544
+ getUrlInfo: text => link_preview_1.getUrlInfo(text, {
545
+ thumbnailWidth: this.config.linkPreviewImageThumbnailWidth,
546
+ fetchOpts: { timeout: 3000, ...this.config.options || {} },
547
+ logger: this.config.logger,
548
+ uploadImage: this.config.generateHighQualityLinkPreview ? this.waUploadToServer : undefined
549
+ }),
550
+ upload: async (encFilePath, opts) => {
551
+ const up = await this.waUploadToServer(encFilePath, { ...opts });
552
+ mediaHandle = up.handle;
553
+ return up;
554
+ },
555
+ mediaCache: this.config.mediaCache,
556
+ options: this.config.options,
557
+ font,
558
+ textColor,
559
+ backgroundColor,
560
+ ptt
561
+ });
562
+ } catch (error) {
563
+ this.config.logger.error(`Error generating message: ${error}`);
564
+ throw error;
565
+ }
566
+
567
+ await this.relayMessage(WABinary_1.STORIES_JID, msg.message, {
568
+ messageId: msg.key.id,
569
+ statusJidList: uniqueUsers,
570
+ additionalNodes: [
571
+ {
572
+ tag: 'meta',
573
+ attrs: {},
574
+ content: [
575
+ {
576
+ tag: 'mentioned_users',
577
+ attrs: {},
578
+ content: jids.map(jid => ({
579
+ tag: 'to',
580
+ attrs: { jid: WABinary_1.jidNormalizedUser(jid) }
581
+ }))
582
+ }
583
+ ]
584
+ }
585
+ ]
586
+ });
587
+
588
+ for (const id of jids) {
589
+ try {
590
+ const normalizedId = WABinary_1.jidNormalizedUser(id);
591
+ const isPrivate = WABinary_1.isJidUser(normalizedId);
592
+ const type = isPrivate ? 'statusMentionMessage' : 'groupStatusMentionMessage';
593
+
594
+ const protocolMessage = {
595
+ [type]: {
596
+ message: {
597
+ protocolMessage: {
598
+ key: msg.key,
599
+ type: 25
600
+ }
601
+ }
602
+ },
603
+ messageContextInfo: {
604
+ messageSecret: crypto.randomBytes(32)
605
+ }
606
+ };
607
+
608
+ const statusMsg = await Utils_1.generateWAMessageFromContent(
609
+ normalizedId,
610
+ protocolMessage,
611
+ {}
612
+ );
613
+
614
+ await this.relayMessage(
615
+ normalizedId,
616
+ statusMsg.message,
617
+ {
618
+ additionalNodes: [{
619
+ tag: 'meta',
620
+ attrs: isPrivate ?
621
+ { is_status_mention: 'true' } :
622
+ { is_group_status_mention: 'true' }
623
+ }]
624
+ }
625
+ );
626
+
627
+ await Utils_1.delay(2000);
628
+ } catch (error) {
629
+ this.config.logger.error(`Error sending to ${id}: ${error}`);
630
+ }
631
+ }
632
+
633
+ return msg;
634
+ }
482
635
  }
483
636
 
484
- module.exports = kikyy;
637
+ module.exports = kikyy;