@itsliaaa/baileys 0.1.32 β 0.2.0
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 +328 -74
- package/WAProto/index.js +22 -18
- package/lib/Defaults/index.js +2 -0
- package/lib/Socket/chats.js +223 -57
- package/lib/Socket/groups.js +6 -0
- package/lib/Socket/messages-recv.js +230 -53
- package/lib/Socket/messages-send.js +78 -7
- package/lib/Utils/chat-utils.js +34 -7
- package/lib/Utils/decode-wa-message.js +14 -0
- package/lib/Utils/event-buffer.js +2 -0
- package/lib/Utils/generics.js +9 -0
- package/lib/Utils/history.js +11 -9
- package/lib/Utils/identity-change-handler.js +1 -0
- package/lib/Utils/messages-media.js +1 -1
- package/lib/Utils/messages.js +21 -6
- package/lib/Utils/process-message.js +53 -1
- package/lib/Utils/rich-message-utils.js +40 -35
- package/lib/Utils/sync-action-utils.js +1 -0
- package/lib/Utils/tc-token-utils.js +151 -5
- package/lib/Utils/use-single-file-auth-state.js +19 -26
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +26 -3
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +22 -0
- package/lib/WAUSync/Protocols/index.js +2 -1
- package/lib/WAUSync/USyncQuery.js +5 -1
- package/lib/WAUSync/USyncUser.js +8 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,30 +34,8 @@ This fork designed for production use with a focus on clarity and safety:
|
|
|
34
34
|
- π« No obfuscation. Easy to read and audit.
|
|
35
35
|
- π« No auto-follow channel (newsletter) behavior.
|
|
36
36
|
|
|
37
|
-
> [!IMPORTANT]
|
|
38
|
-
Hi everyone,
|
|
39
|
-
>
|
|
40
|
-
> I want to share something thatβs been weighing on me a bit.
|
|
41
|
-
>
|
|
42
|
-
> Recently, I found a few packages published on npm that are essentially just **renamed** versions of a fork I personally worked on:
|
|
43
|
-
>
|
|
44
|
-
> - ~[RESOLVED]~
|
|
45
|
-
> - ~[RESOLVED]~
|
|
46
|
-
> - ~[RESOLVED]~
|
|
47
|
-
> - [@zackmans](https://www.npmjs.com/package/@zackmans/baileys) **[STEALER]**
|
|
48
|
-
> - [@dnuzi](https://www.npmjs.com/package/@dnuzi/baileys) **[STEALER]**
|
|
49
|
-
> - ["Update rich.js"](https://github.com/gcamerator/mbaileys/commits/main/) **[STEALER]**
|
|
50
|
-
>
|
|
51
|
-
> To be clear, Iβm **not** the original maintainer of Baileys all respect goes to the amazing work behind [@whiskeysockets/baileys](https://github.com/WhiskeySockets/Baileys). I only created and maintained my own fork ([@itsliaaa/baileys](https://www.npmjs.com/package/@itsliaaa/baileys)) where I spent a **lot** of time improving and adapting things on my own.
|
|
52
|
-
>
|
|
53
|
-
> **Itβs honestly a bit disheartening to see my fork being republished under different names without any acknowledgment or credit.** I put a lot of late nights and personal effort into it, so seeing it circulate like this feelsβ¦ quietly painful.
|
|
54
|
-
>
|
|
55
|
-
> If you come across these packages, Iβd really appreciate it if you could take a closer look and, if appropriate, **help report them to npm.** More than anything, I just hope for a bit of fairness and proper recognition for the work that people put in.
|
|
56
|
-
>
|
|
57
|
-
> Thank you for taking the time to read this π€
|
|
58
|
-
|
|
59
37
|
> [!NOTE]
|
|
60
|
-
π This project is maintained with limited scope and is not intended to replace upstream Baileys.
|
|
38
|
+
> π This project is maintained with limited scope and is not intended to replace upstream Baileys.
|
|
61
39
|
>
|
|
62
40
|
> π And, really sorry for my bad english.
|
|
63
41
|
|
|
@@ -90,10 +68,15 @@ Hi everyone,
|
|
|
90
68
|
- π [`secureMetaServiceLabel`](#6%EF%B8%8Fβ£-secure-meta-service-label) - Secure meta service label on message **[NEW]**
|
|
91
69
|
- π [`raw`](#5%EF%B8%8Fβ£-raw) - Build your message manually **(DO NOT USE FOR EXPLOITATION)**
|
|
92
70
|
|
|
93
|
-
### π
|
|
71
|
+
### π Table of Contents
|
|
72
|
+
- [β¨ Highlights](#-highlights)
|
|
73
|
+
- [π οΈ Internal Adjustments](#%EF%B8%8F-internal-adjustments)
|
|
74
|
+
- [π¨ Messages Handling & Compatibility](#-highlights)
|
|
75
|
+
- [π§© Additional Message Options](#-additional-message-options)
|
|
94
76
|
- [π₯ Installation](#-installation)
|
|
95
77
|
- [π§© Import (ESM & CJS)](#-import-esm--cjs)
|
|
96
78
|
- [π Connect to WhatsApp (Quick Step)](#-connect-to-whatsapp-quick-step)
|
|
79
|
+
- [π Auth State](#-auth-state)
|
|
97
80
|
- [ποΈ Implementing Data Store](#%EF%B8%8F-implementing-data-store)
|
|
98
81
|
- [πͺͺ WhatsApp IDs Explain](#-whatsapp-ids-explain)
|
|
99
82
|
- [βοΈ Sending Messages](#%EF%B8%8F-sending-messages)
|
|
@@ -111,6 +94,7 @@ Hi everyone,
|
|
|
111
94
|
- [π Button Response](#-button-response)
|
|
112
95
|
- [β¨ Rich Response](#-rich-response)
|
|
113
96
|
- [π§Ύ Message with Code Block](#-message-with-code-block)
|
|
97
|
+
- [π Message with Inline Entities](#-message-with-inline-entities)
|
|
114
98
|
- [π Message with Table](#-message-with-table)
|
|
115
99
|
- [ποΈ Status Mention](#%EF%B8%8F-status-mention)
|
|
116
100
|
- [π Sending Media Messages](#-sending-media-messages)
|
|
@@ -150,6 +134,10 @@ Hi everyone,
|
|
|
150
134
|
- [πΌοΈ Image Processing](#%EF%B8%8F-image-processing)
|
|
151
135
|
- [π£ Newsletter Management](#-newsletter-management)
|
|
152
136
|
- [π₯ Group Management](#-group-management)
|
|
137
|
+
- [π€ Profile Management](#-profile-management)
|
|
138
|
+
- [π Privacy Management](#-privacy-management)
|
|
139
|
+
- [π‘ Events](#-events)
|
|
140
|
+
- [π Try the Bot](#-try-the-bot)
|
|
153
141
|
- [π¦ Fork Base](#-fork-base)
|
|
154
142
|
- [π£ Credits](#-credits)
|
|
155
143
|
|
|
@@ -245,10 +233,15 @@ const connectToWhatsApp = async () => {
|
|
|
245
233
|
connectToWhatsApp()
|
|
246
234
|
```
|
|
247
235
|
|
|
236
|
+
#### π Auth State
|
|
237
|
+
|
|
238
|
+
> [!NOTE]
|
|
239
|
+
> You can use the experimental `useSingleFileAuthState` as an alternative to `useMultiFileAuthState`. However, `useSingleFileAuthState` already includes an internal caching mechanism, so there is no need to wrap `state.keys` with `makeCacheableSignalKeyStore`.
|
|
240
|
+
|
|
248
241
|
### ποΈ Implementing Data Store
|
|
249
242
|
|
|
250
243
|
> [!CAUTION]
|
|
251
|
-
I highly recommend building your own data store, as keeping an entire chat history in memory can lead to excessive RAM usage.
|
|
244
|
+
> I highly recommend building your own data store, as keeping an entire chat history in memory can lead to excessive RAM usage.
|
|
252
245
|
|
|
253
246
|
```javascript
|
|
254
247
|
import { makeWASocket, makeInMemoryStore, delay, DisconnectReason, useMultiFileAuthState } from '@itsliaaa/baileys'
|
|
@@ -331,16 +324,68 @@ connectToWhatsApp()
|
|
|
331
324
|
### βοΈ Sending Messages
|
|
332
325
|
|
|
333
326
|
> [!NOTE]
|
|
334
|
-
You can get the `jid` from `message.key.remoteJid` in the first example.
|
|
327
|
+
> You can get the `jid` from `message.key.remoteJid` in the first example.
|
|
335
328
|
|
|
336
329
|
#### π Text
|
|
337
330
|
|
|
338
331
|
```javascript
|
|
332
|
+
// --- Send a regular text message
|
|
339
333
|
sock.sendMessage(jid, {
|
|
340
334
|
text: 'ππ» Hello'
|
|
341
335
|
}, {
|
|
342
336
|
quoted: message
|
|
343
337
|
})
|
|
338
|
+
|
|
339
|
+
// --- Send a text message with a link preview
|
|
340
|
+
const urlA = 'https://www.npmjs.com/package/@itsliaaa/baileys'
|
|
341
|
+
|
|
342
|
+
sock.sendMessage(jid, {
|
|
343
|
+
text: urlA + ' ππ» Check it out!',
|
|
344
|
+
linkPreview: {
|
|
345
|
+
'matched-text': urlA,
|
|
346
|
+
title: 'π± @itsliaaa/baileys',
|
|
347
|
+
description: 'Underrated Baileys Fork',
|
|
348
|
+
previewType: 0, // --- Use 1 for video playback in the link preview
|
|
349
|
+
jpegThumbnail: fs.readFileSync('./path/to/image.jpg')
|
|
350
|
+
}
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
// --- Send a text message with a large link preview and favicon
|
|
354
|
+
import { prepareWAMessageMedia } from '@itsliaaa/baileys'
|
|
355
|
+
|
|
356
|
+
const urlB = 'https://www.npmjs.com/package/@itsliaaa/baileys#readme'
|
|
357
|
+
|
|
358
|
+
const { imageMessage: image } = await prepareWAMessageMedia({
|
|
359
|
+
image: {
|
|
360
|
+
url: './path/to/image.jpg'
|
|
361
|
+
}
|
|
362
|
+
}, {
|
|
363
|
+
upload: sock.waUploadToServer,
|
|
364
|
+
mediaTypeOverride: 'thumbnail-link'
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
// --- Set the thumbnail display size
|
|
368
|
+
image.height = 720
|
|
369
|
+
image.width = 480
|
|
370
|
+
|
|
371
|
+
sock.sendMessage(jid, {
|
|
372
|
+
text: urlB + ' ππ» Check it out!',
|
|
373
|
+
linkPreview: {
|
|
374
|
+
'matched-text': urlB,
|
|
375
|
+
title: 'π± @itsliaaa/baileys',
|
|
376
|
+
description: 'Underrated Baileys Fork',
|
|
377
|
+
previewType: 0,
|
|
378
|
+
jpegThumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
379
|
+
highQualityThumbnail: image,
|
|
380
|
+
linkPreviewMetadata: {
|
|
381
|
+
linkMediaDuration: 0, // --- Duration in seconds (for video/audio content)
|
|
382
|
+
socialMediaPostType: 1, // --- Enum: 0 = NONE, 1 = REEL, 2 = LIVE_VIDEO, 3 = LONG_VIDEO, 4 = SINGLE_IMAGE, 5 = CAROUSEL
|
|
383
|
+
} // --- Additional metadata for large link preview
|
|
384
|
+
},
|
|
385
|
+
favicon: {
|
|
386
|
+
url: './path/to/tiny-image.jpg'
|
|
387
|
+
}
|
|
388
|
+
})
|
|
344
389
|
```
|
|
345
390
|
|
|
346
391
|
#### π Mention
|
|
@@ -621,10 +666,10 @@ sock.sendMessage(jid, {
|
|
|
621
666
|
#### β¨ Rich Response
|
|
622
667
|
|
|
623
668
|
> [!NOTE]
|
|
624
|
-
`richResponse[]` is a representation of [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) inside `richResponseMessage`.
|
|
669
|
+
> `richResponse[]` is a representation of [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) inside `richResponseMessage`.
|
|
625
670
|
|
|
626
671
|
> [!TIP]
|
|
627
|
-
You can still use the original [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) field directly.
|
|
672
|
+
> You can still use the original [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) field directly.
|
|
628
673
|
> The code example below is just an implementation using a helper, not a required structure.
|
|
629
674
|
|
|
630
675
|
```javascript
|
|
@@ -660,7 +705,7 @@ sock.sendMessage(jid, {
|
|
|
660
705
|
```
|
|
661
706
|
|
|
662
707
|
> [!TIP]
|
|
663
|
-
You can easily add syntax highlighting by importing `tokenizeCode` directly from Baileys.
|
|
708
|
+
> You can easily add syntax highlighting by importing `tokenizeCode` directly from Baileys.
|
|
664
709
|
|
|
665
710
|
```javascript
|
|
666
711
|
import { tokenizeCode } from '@itsliaaa/baileys'
|
|
@@ -683,7 +728,7 @@ sock.sendMessage(jid, {
|
|
|
683
728
|
#### π§Ύ Message with Code Block
|
|
684
729
|
|
|
685
730
|
> [!NOTE]
|
|
686
|
-
This feature already includes a built-in tokenizer.
|
|
731
|
+
> This feature already includes a built-in tokenizer.
|
|
687
732
|
|
|
688
733
|
```javascript
|
|
689
734
|
sock.sendMessage(jid, {
|
|
@@ -695,6 +740,29 @@ sock.sendMessage(jid, {
|
|
|
695
740
|
})
|
|
696
741
|
```
|
|
697
742
|
|
|
743
|
+
#### π Message with Inline Entities
|
|
744
|
+
|
|
745
|
+
```javascript
|
|
746
|
+
sock.sendMessage(jid, {
|
|
747
|
+
headerText: '## Check Out!',
|
|
748
|
+
contentText: '---',
|
|
749
|
+
links: [{
|
|
750
|
+
text: '1. Google',
|
|
751
|
+
title: 'Popular Search Engine',
|
|
752
|
+
url: 'https://www.google.com/'
|
|
753
|
+
}, {
|
|
754
|
+
text: '2. YouTube',
|
|
755
|
+
title: 'Popular Streaming Platform',
|
|
756
|
+
url: 'https://www.youtube.com/'
|
|
757
|
+
}, {
|
|
758
|
+
text: '3. Modded Baileys',
|
|
759
|
+
title: 'Underrated Baileys Fork',
|
|
760
|
+
url: 'https://www.npmjs.com/package/@itsliaaa/baileys'
|
|
761
|
+
}],
|
|
762
|
+
footerText: '---'
|
|
763
|
+
})
|
|
764
|
+
```
|
|
765
|
+
|
|
698
766
|
#### π Message with Table
|
|
699
767
|
|
|
700
768
|
```javascript
|
|
@@ -707,6 +775,7 @@ sock.sendMessage(jid, {
|
|
|
707
775
|
['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)'],
|
|
708
776
|
['Performance', '4/5', '5/5', '4/5']
|
|
709
777
|
],
|
|
778
|
+
noHeading: false, // --- Optional
|
|
710
779
|
footerText: 'Does this help clarify the differences?'
|
|
711
780
|
})
|
|
712
781
|
```
|
|
@@ -722,7 +791,7 @@ sock.sendMessage([jidA, jidB, jidC], {
|
|
|
722
791
|
### π Sending Media Messages
|
|
723
792
|
|
|
724
793
|
> [!NOTE]
|
|
725
|
-
For media messages, you can pass a `Buffer` directly, or an object with either `{ stream: Readable }` or `{ url: string }` (local file path or HTTP/HTTPS URL).
|
|
794
|
+
> For media messages, you can pass a `Buffer` directly, or an object with either `{ stream: Readable }` or `{ url: string }` (local file path or HTTP/HTTPS URL).
|
|
726
795
|
|
|
727
796
|
#### πΌοΈ Image
|
|
728
797
|
|
|
@@ -824,7 +893,7 @@ sock.sendMessage(jid, {
|
|
|
824
893
|
#### π¦ Sticker Pack
|
|
825
894
|
|
|
826
895
|
> [!IMPORTANT]
|
|
827
|
-
If `sharp` or `@napi-rs/image` is not installed, the `cover` and `stickers` must already be in WebP format.
|
|
896
|
+
> If `sharp` or `@napi-rs/image` is not installed, the `cover` and `stickers` must already be in WebP format.
|
|
828
897
|
|
|
829
898
|
```javascript
|
|
830
899
|
sock.sendMessage(jid, {
|
|
@@ -908,7 +977,7 @@ sock.sendMessage(jid, {
|
|
|
908
977
|
#### 2οΈβ£ List
|
|
909
978
|
|
|
910
979
|
> [!NOTE]
|
|
911
|
-
It only works in private chat (`@s.whatsapp.net`).
|
|
980
|
+
> It only works in private chat (`@s.whatsapp.net`).
|
|
912
981
|
|
|
913
982
|
```javascript
|
|
914
983
|
sock.sendMessage(jid, {
|
|
@@ -1086,7 +1155,7 @@ sock.sendMessage(jid, {
|
|
|
1086
1155
|
#### 2οΈβ£ Invoice
|
|
1087
1156
|
|
|
1088
1157
|
> [!NOTE]
|
|
1089
|
-
Invoice message are not supported yet.
|
|
1158
|
+
> Invoice message are not supported yet.
|
|
1090
1159
|
|
|
1091
1160
|
```javascript
|
|
1092
1161
|
sock.sendMessage(jid, {
|
|
@@ -1122,7 +1191,7 @@ sock.sendMessage(jid, {
|
|
|
1122
1191
|
#### 1οΈβ£ AI Icon
|
|
1123
1192
|
|
|
1124
1193
|
> [!NOTE]
|
|
1125
|
-
It only works in private chat (`@s.whatsapp.net`).
|
|
1194
|
+
> It only works in private chat (`@s.whatsapp.net`).
|
|
1126
1195
|
|
|
1127
1196
|
```javascript
|
|
1128
1197
|
sock.sendMessage(jid, {
|
|
@@ -1139,7 +1208,7 @@ sock.sendMessage(jid, {
|
|
|
1139
1208
|
#### 2οΈβ£ Ephemeral
|
|
1140
1209
|
|
|
1141
1210
|
> [!NOTE]
|
|
1142
|
-
Wrap message into `ephemeralMessage`
|
|
1211
|
+
> Wrap message into `ephemeralMessage`
|
|
1143
1212
|
|
|
1144
1213
|
```javascript
|
|
1145
1214
|
sock.sendMessage(jid, {
|
|
@@ -1154,7 +1223,7 @@ sock.sendMessage(jid, {
|
|
|
1154
1223
|
#### 3οΈβ£ External Ad Reply
|
|
1155
1224
|
|
|
1156
1225
|
> [!NOTE]
|
|
1157
|
-
Add an ad thumbnail to messages (may not be displayed on some WhatsApp versions).
|
|
1226
|
+
> Add an ad thumbnail to messages (may not be displayed on some WhatsApp versions).
|
|
1158
1227
|
|
|
1159
1228
|
```javascript
|
|
1160
1229
|
sock.sendMessage(jid, {
|
|
@@ -1174,7 +1243,7 @@ sock.sendMessage(jid, {
|
|
|
1174
1243
|
#### 4οΈβ£ Group Status
|
|
1175
1244
|
|
|
1176
1245
|
> [!NOTE]
|
|
1177
|
-
It only works in group chat (`@g.us`)
|
|
1246
|
+
> It only works in group chat (`@g.us`)
|
|
1178
1247
|
|
|
1179
1248
|
```javascript
|
|
1180
1249
|
sock.sendMessage(jid, {
|
|
@@ -1220,7 +1289,7 @@ sock.sendMessage(jid, {
|
|
|
1220
1289
|
#### 7οΈβ£ View Once
|
|
1221
1290
|
|
|
1222
1291
|
> [!NOTE]
|
|
1223
|
-
Wrap message into `viewOnceMessage`
|
|
1292
|
+
> Wrap message into `viewOnceMessage`
|
|
1224
1293
|
|
|
1225
1294
|
```javascript
|
|
1226
1295
|
sock.sendMessage(jid, {
|
|
@@ -1235,7 +1304,7 @@ sock.sendMessage(jid, {
|
|
|
1235
1304
|
#### 8οΈβ£ View Once V2
|
|
1236
1305
|
|
|
1237
1306
|
> [!NOTE]
|
|
1238
|
-
Wrap message into `viewOnceMessageV2`
|
|
1307
|
+
> Wrap message into `viewOnceMessageV2`
|
|
1239
1308
|
|
|
1240
1309
|
```javascript
|
|
1241
1310
|
sock.sendMessage(jid, {
|
|
@@ -1250,7 +1319,7 @@ sock.sendMessage(jid, {
|
|
|
1250
1319
|
#### 9οΈβ£ View Once V2 Extension
|
|
1251
1320
|
|
|
1252
1321
|
> [!NOTE]
|
|
1253
|
-
Wrap message into `viewOnceMessageV2Extension`
|
|
1322
|
+
> Wrap message into `viewOnceMessageV2Extension`
|
|
1254
1323
|
|
|
1255
1324
|
```javascript
|
|
1256
1325
|
sock.sendMessage(jid, {
|
|
@@ -1293,7 +1362,7 @@ sock.sendMessage(jid, {
|
|
|
1293
1362
|
#### π·οΈ Find User ID (JID|PN/LID)
|
|
1294
1363
|
|
|
1295
1364
|
> [!NOTE]
|
|
1296
|
-
The ID must contain numbers only (no +, (), or -) and must include the country code with WhatsApp ID format.
|
|
1365
|
+
> The ID must contain numbers only (no +, (), or -) and must include the country code with WhatsApp ID format.
|
|
1297
1366
|
|
|
1298
1367
|
```javascript
|
|
1299
1368
|
// --- PN (Phone Number)
|
|
@@ -1326,7 +1395,7 @@ console.log('π·οΈ Got user ID', ':', ids)
|
|
|
1326
1395
|
#### π Request Custom Pairing Code
|
|
1327
1396
|
|
|
1328
1397
|
> [!NOTE]
|
|
1329
|
-
The phone number must contain numbers only (no +, (), or -) and must include the country code.
|
|
1398
|
+
> The phone number must contain numbers only (no +, (), or -) and must include the country code.
|
|
1330
1399
|
|
|
1331
1400
|
```javascript
|
|
1332
1401
|
const phoneNumber = '6281111111111'
|
|
@@ -1340,7 +1409,7 @@ console.log('π Pairing code', ':', customPairingCode)
|
|
|
1340
1409
|
#### πΌοΈ Image Processing
|
|
1341
1410
|
|
|
1342
1411
|
> [!NOTE]
|
|
1343
|
-
Automatically use available image processing library: `sharp`, `@napi-rs/image`, or `jimp`
|
|
1412
|
+
> Automatically use available image processing library: `sharp`, `@napi-rs/image`, or `jimp`
|
|
1344
1413
|
|
|
1345
1414
|
```javascript
|
|
1346
1415
|
import { getImageProcessingLibrary } from '@itsliaaa/baileys'
|
|
@@ -1381,7 +1450,7 @@ else if (lib.jimp?.Jimp) {
|
|
|
1381
1450
|
|
|
1382
1451
|
output = await img
|
|
1383
1452
|
.resize({ w: width, mode: lib.jimp.ResizeStrategy.BILINEAR })
|
|
1384
|
-
.getBuffer('image/jpeg', { quality: 50 })
|
|
1453
|
+
.getBuffer('image/jpeg', { quality: 50 })
|
|
1385
1454
|
}
|
|
1386
1455
|
|
|
1387
1456
|
// --- Fallback
|
|
@@ -1397,10 +1466,23 @@ console.dir(output, { depth: null })
|
|
|
1397
1466
|
|
|
1398
1467
|
```javascript
|
|
1399
1468
|
// --- Create a new one
|
|
1400
|
-
sock.newsletterCreate('@itsliaaa/baileys')
|
|
1469
|
+
sock.newsletterCreate('@itsliaaa/baileys', 'π£ Fresh updates weekly')
|
|
1401
1470
|
|
|
1402
1471
|
// --- Get info
|
|
1403
|
-
sock.newsletterMetadata('1231111111111@newsletter')
|
|
1472
|
+
const metadata = sock.newsletterMetadata('1231111111111@newsletter')
|
|
1473
|
+
console.dir(metadata, { depth: null })
|
|
1474
|
+
|
|
1475
|
+
// --- Get subscribers count
|
|
1476
|
+
const subscribers = await sock.newsletterSubscribers('1231111111111@newsletter')
|
|
1477
|
+
console.dir(subscribers, { depth: null })
|
|
1478
|
+
|
|
1479
|
+
// --- Follow and Unfollow
|
|
1480
|
+
sock.newsletterFollow('1231111111111@newsletter')
|
|
1481
|
+
sock.newsletterUnfollow('1231111111111@newsletter')
|
|
1482
|
+
|
|
1483
|
+
// --- Mute and Unmute
|
|
1484
|
+
sock.newsletterMute('1231111111111@newsletter')
|
|
1485
|
+
sock.newsletterUnmute('1231111111111@newsletter')
|
|
1404
1486
|
|
|
1405
1487
|
// --- Demote admin
|
|
1406
1488
|
sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
@@ -1408,6 +1490,9 @@ sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net'
|
|
|
1408
1490
|
// --- Change owner
|
|
1409
1491
|
sock.newsletterChangeOwner('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
1410
1492
|
|
|
1493
|
+
// --- Update newsletter
|
|
1494
|
+
sock.newsletterUpdate('1231111111111@newsletter', { name: '@itsliaaa/baileys' })
|
|
1495
|
+
|
|
1411
1496
|
// --- Change name
|
|
1412
1497
|
sock.newsletterUpdateName('1231111111111@newsletter', 'π¦ @itsliaaa/baileys')
|
|
1413
1498
|
|
|
@@ -1425,27 +1510,41 @@ sock.newsletterRemovePicture('1231111111111@newsletter')
|
|
|
1425
1510
|
// --- React to a message
|
|
1426
1511
|
sock.newsletterReactMessage('1231111111111@newsletter', '100', 'π')
|
|
1427
1512
|
|
|
1513
|
+
// --- Get admin count
|
|
1514
|
+
const count = await sock.newsletterAdminCount('1231111111111@newsletter')
|
|
1515
|
+
|
|
1428
1516
|
// --- Get all subscribed newsletters
|
|
1429
1517
|
const newsletters = await sock.newsletterSubscribed()
|
|
1430
|
-
|
|
1431
1518
|
console.dir(newsletters, { depth: null })
|
|
1519
|
+
|
|
1520
|
+
// --- Fetch newsletter messages
|
|
1521
|
+
const messages = sock.newsletterFetchMessages('jid', '1231111111111@newsletter', 50, 0, 0)
|
|
1522
|
+
console.dir(messages, { depth: null })
|
|
1523
|
+
|
|
1524
|
+
// --- Delete newsletter
|
|
1525
|
+
sock.newsletterDelete('1231111111111@newsletter')
|
|
1432
1526
|
```
|
|
1433
1527
|
|
|
1434
1528
|
#### π₯ Group Management
|
|
1435
1529
|
|
|
1436
1530
|
```javascript
|
|
1437
1531
|
// --- Create a new one and add participants using their JIDs
|
|
1438
|
-
sock.groupCreate('@itsliaaa/baileys', ['628123456789@s.whatsapp.net'])
|
|
1532
|
+
const group = sock.groupCreate('@itsliaaa/baileys', ['628123456789@s.whatsapp.net'])
|
|
1533
|
+
console.dir(group, { depth: null })
|
|
1439
1534
|
|
|
1440
1535
|
// --- Get info
|
|
1441
|
-
sock.groupMetadata(jid)
|
|
1536
|
+
const metadata = await sock.groupMetadata(jid)
|
|
1537
|
+
console.dir(metadata, { depth: null })
|
|
1442
1538
|
|
|
1443
|
-
// --- Get invite code
|
|
1539
|
+
// --- Get group invite code
|
|
1444
1540
|
sock.groupInviteCode(jid)
|
|
1445
1541
|
|
|
1446
1542
|
// --- Revoke invite link
|
|
1447
1543
|
sock.groupRevokeInvite(jid)
|
|
1448
1544
|
|
|
1545
|
+
// --- Accept group invite
|
|
1546
|
+
sock.groupAcceptInvite(inviteCode)
|
|
1547
|
+
|
|
1449
1548
|
// --- Leave group
|
|
1450
1549
|
sock.groupLeave(jid)
|
|
1451
1550
|
|
|
@@ -1461,6 +1560,9 @@ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'promote')
|
|
|
1461
1560
|
// --- Demote from admin
|
|
1462
1561
|
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'demote')
|
|
1463
1562
|
|
|
1563
|
+
// --- Accept join requests
|
|
1564
|
+
sock.groupRequestParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'approve')
|
|
1565
|
+
|
|
1464
1566
|
// --- Change name
|
|
1465
1567
|
sock.groupUpdateSubject(jid, 'π¦ @itsliaaa/baileys')
|
|
1466
1568
|
|
|
@@ -1505,36 +1607,188 @@ sock.groupJoinApprovalMode(jid, 'off')
|
|
|
1505
1607
|
|
|
1506
1608
|
// --- Get all groups metadata
|
|
1507
1609
|
const groups = await sock.groupFetchAllParticipating()
|
|
1508
|
-
|
|
1509
1610
|
console.dir(groups, { depth: null })
|
|
1510
1611
|
|
|
1511
|
-
// --- Get pending
|
|
1512
|
-
const
|
|
1513
|
-
|
|
1514
|
-
console.dir(invites, { depth: null })
|
|
1515
|
-
|
|
1516
|
-
// --- Accept group invite
|
|
1517
|
-
sock.groupAcceptInvite(code)
|
|
1612
|
+
// --- Get pending join requests
|
|
1613
|
+
const requests = await sock.groupRequestParticipantsList(jid)
|
|
1614
|
+
console.dir(requests, { depth: null })
|
|
1518
1615
|
|
|
1519
1616
|
// --- Get group info from link
|
|
1520
1617
|
const group = await sock.groupGetInviteInfo('https://chat.whatsapp.com/ABC123')
|
|
1521
|
-
|
|
1522
1618
|
console.log('π₯ Got group info from link', ':', group)
|
|
1619
|
+
|
|
1620
|
+
// --- Update bot member label
|
|
1621
|
+
sock.updateMemberLabel(jid, '@itsliaaa/baileys')
|
|
1523
1622
|
```
|
|
1524
1623
|
|
|
1525
|
-
|
|
1526
|
-
|
|
1624
|
+
#### π€ Profile Management
|
|
1625
|
+
|
|
1626
|
+
```javascript
|
|
1627
|
+
// --- Get user profile picture
|
|
1628
|
+
const url = await sock.profilePictureUrl(jid, 'image')
|
|
1629
|
+
console.log('πΌοΈ Got user profile url', url)
|
|
1630
|
+
|
|
1631
|
+
// --- Update profile picture
|
|
1632
|
+
sock.updateProfilePicture(jid, buffer)
|
|
1633
|
+
sock.updateProfilePicture(jid, { url })
|
|
1634
|
+
|
|
1635
|
+
// --- Remove profile picture
|
|
1636
|
+
sock.removeProfilePicture(jid)
|
|
1637
|
+
|
|
1638
|
+
// --- Update profile name
|
|
1639
|
+
sock.updateProfileName('My Name')
|
|
1640
|
+
|
|
1641
|
+
// --- Update profile status
|
|
1642
|
+
sock.updateProfileStatus('Available')
|
|
1643
|
+
|
|
1644
|
+
// --- Presence
|
|
1645
|
+
sock.sendPresenceUpdate('available', jid)
|
|
1646
|
+
sock.presenceSubscribe(jid)
|
|
1647
|
+
|
|
1648
|
+
// --- Read receipts
|
|
1649
|
+
sock.readMessages([message.key])
|
|
1650
|
+
sock.sendReceipt(jid, participant, [messageId], 'read')
|
|
1651
|
+
|
|
1652
|
+
// --- Block user
|
|
1653
|
+
sock.updateBlockStatus(jid, 'block')
|
|
1654
|
+
|
|
1655
|
+
// --- Unblock user
|
|
1656
|
+
sock.updateBlockStatus(jid, 'unblock')
|
|
1657
|
+
|
|
1658
|
+
// --- Fetch blocklist
|
|
1659
|
+
const blocked = await sock.fetchBlocklist()
|
|
1660
|
+
console.dir(blocked, { depth: null })
|
|
1661
|
+
|
|
1662
|
+
// --- Modify chats
|
|
1663
|
+
sock.chatModify({
|
|
1664
|
+
archive: true,
|
|
1665
|
+
lastMessageOrig: message,
|
|
1666
|
+
lastMessage: message
|
|
1667
|
+
}, jid)
|
|
1668
|
+
|
|
1669
|
+
// --- Star messages
|
|
1670
|
+
sock.star(jid, [{ id: messageId, fromMe: true }], true)
|
|
1671
|
+
|
|
1672
|
+
// --- Contact
|
|
1673
|
+
sock.addOrEditContact(jid, { displayName: 'Starseed' })
|
|
1674
|
+
sock.removeContact(jid)
|
|
1675
|
+
|
|
1676
|
+
// --- Label
|
|
1677
|
+
sock.addChatLabel(jid, labelId)
|
|
1678
|
+
sock.removeChatLabel(jid, labelId)
|
|
1679
|
+
sock.addMessageLabel(jid, messageId, labelId)
|
|
1680
|
+
|
|
1681
|
+
// --- App state sync
|
|
1682
|
+
sock.resyncAppState(['regular', 'critical_block'], true)
|
|
1683
|
+
|
|
1684
|
+
// --- Get business profile
|
|
1685
|
+
const profile = await sock.getBusinessProfile(jid)
|
|
1686
|
+
console.dir(profile, { depth: null })
|
|
1687
|
+
```
|
|
1688
|
+
|
|
1689
|
+
#### π Privacy Management
|
|
1690
|
+
|
|
1691
|
+
```javascript
|
|
1692
|
+
// --- Update last seen privacy
|
|
1693
|
+
sock.updateLastSeenPrivacy('all')
|
|
1694
|
+
sock.updateLastSeenPrivacy('contacts')
|
|
1695
|
+
sock.updateLastSeenPrivacy('contact_blacklist')
|
|
1696
|
+
sock.updateLastSeenPrivacy('nobody')
|
|
1697
|
+
|
|
1698
|
+
// --- Update online privacy
|
|
1699
|
+
sock.updateOnlinePrivacy('all')
|
|
1700
|
+
sock.updateOnlinePrivacy('match_last_seen')
|
|
1701
|
+
|
|
1702
|
+
// --- Update profile picture privacy
|
|
1703
|
+
sock.updateProfilePicturePrivacy('contacts')
|
|
1704
|
+
|
|
1705
|
+
// --- Update status privacy
|
|
1706
|
+
sock.updateStatusPrivacy('contacts')
|
|
1707
|
+
|
|
1708
|
+
// --- Update read receipts privacy
|
|
1709
|
+
sock.updateReadReceiptsPrivacy('all')
|
|
1710
|
+
sock.updateReadReceiptsPrivacy('none')
|
|
1711
|
+
|
|
1712
|
+
// --- Update groups add privacy
|
|
1713
|
+
sock.updateGroupsAddPrivacy('all')
|
|
1714
|
+
sock.updateGroupsAddPrivacy('contacts')
|
|
1715
|
+
|
|
1716
|
+
// --- Update messages privacy
|
|
1717
|
+
sock.updateMessagesPrivacy('all')
|
|
1718
|
+
sock.updateMessagesPrivacy('contacts')
|
|
1719
|
+
sock.updateMessagesPrivacy('nobody')
|
|
1720
|
+
|
|
1721
|
+
// --- Update call privacy
|
|
1722
|
+
sock.updateCallPrivacy('everyone')
|
|
1723
|
+
|
|
1724
|
+
// --- Update default disappearing mode
|
|
1725
|
+
sock.updateDefaultDisappearingMode(86400)
|
|
1726
|
+
|
|
1727
|
+
// --- Update link previews privacy
|
|
1728
|
+
sock.updateDisableLinkPreviewsPrivacy(true)
|
|
1729
|
+
```
|
|
1730
|
+
|
|
1731
|
+
#### π‘ Events
|
|
1732
|
+
|
|
1733
|
+
```javascript
|
|
1734
|
+
sock.ev.on('connection.update', (update) => {})
|
|
1735
|
+
sock.ev.on('creds.update', (update) => {})
|
|
1736
|
+
sock.ev.on('messaging-history.set', (update) => {})
|
|
1737
|
+
sock.ev.on('messaging-history.status', (update) => {})
|
|
1738
|
+
sock.ev.on('chats.upsert', (update) => {})
|
|
1739
|
+
sock.ev.on('chats.update', (update) => {})
|
|
1740
|
+
sock.ev.on('chats.delete', (update) => {})
|
|
1741
|
+
sock.ev.on('chats.lock', (update) => {})
|
|
1742
|
+
sock.ev.on('lid-mapping.update', (update) => {})
|
|
1743
|
+
sock.ev.on('presence.update', (update) => {})
|
|
1744
|
+
sock.ev.on('contacts.upsert', (update) => {})
|
|
1745
|
+
sock.ev.on('contacts.update', (update) => {})
|
|
1746
|
+
sock.ev.on('messages.delete', (update) => {})
|
|
1747
|
+
sock.ev.on('messages.update', (update) => {})
|
|
1748
|
+
sock.ev.on('messages.media-update', (update) => {})
|
|
1749
|
+
sock.ev.on('messages.upsert', (update) => {})
|
|
1750
|
+
sock.ev.on('messages.reaction', (update) => {})
|
|
1751
|
+
sock.ev.on('message-receipt.update', (update) => {})
|
|
1752
|
+
sock.ev.on('groups.upsert', (update) => {})
|
|
1753
|
+
sock.ev.on('groups.update', (update) => {})
|
|
1754
|
+
sock.ev.on('group-participants.update', (update) => {})
|
|
1755
|
+
sock.ev.on('group.join-request', (update) => {})
|
|
1756
|
+
sock.ev.on('group.member-tag.update', (update) => {})
|
|
1757
|
+
sock.ev.on('blocklist.set', (update) => {})
|
|
1758
|
+
sock.ev.on('blocklist.update', (update) => {})
|
|
1759
|
+
sock.ev.on('call', (update) => {})
|
|
1760
|
+
sock.ev.on('labels.edit', (update) => {})
|
|
1761
|
+
sock.ev.on('labels.association', (update) => {})
|
|
1762
|
+
sock.ev.on('newsletter.reaction', (update) => {})
|
|
1763
|
+
sock.ev.on('newsletter.view', (update) => {})
|
|
1764
|
+
sock.ev.on('newsletter-participants.update', (update) => {})
|
|
1765
|
+
sock.ev.on('newsletter-settings.update', (update) => {})
|
|
1766
|
+
sock.ev.on('settings.update', (update) => {})
|
|
1767
|
+
```
|
|
1768
|
+
|
|
1769
|
+
### π Try the Bot
|
|
1770
|
+
|
|
1771
|
+
A fast, lightweight, and modular WhatsApp bot built with [@itsliaaa/baileys](https://www.npmjs.com/package/@itsliaaa/baileys).
|
|
1772
|
+
Perfect for managing groups, moderating chats, and adding fun with quiz games and handy tools.
|
|
1773
|
+
|
|
1774
|
+
ππ» [@itsliaaa/starseed](https://github.com/itsliaaa/starseed#readme)
|
|
1775
|
+
|
|
1776
|
+
### π¦ Fork Base
|
|
1777
|
+
|
|
1527
1778
|
This fork is based on [Baileys (GitHub)](https://github.com/WhiskeySockets/Baileys)
|
|
1528
1779
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
This
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1780
|
+
### π£ Credits
|
|
1781
|
+
|
|
1782
|
+
This project utilizes Protocol Buffer definitions maintained by [WPPConnect](https://github.com/wppconnect-team) through the [`wa-proto`](https://github.com/wppconnect-team/wa-proto) repository.
|
|
1783
|
+
|
|
1784
|
+
Full credit is attributed to the original maintainers and contributors of Baileys:
|
|
1785
|
+
- [purpshell](https://github.com/purpshell)
|
|
1786
|
+
- [jlucaso1](https://github.com/jlucaso1)
|
|
1787
|
+
- [adiwajshing](https://github.com/adiwajshing)
|
|
1788
|
+
|
|
1789
|
+
This fork includes additional enhancements and modifications by [Lia Wynn](https://github.com/itsliaaa)
|
|
1790
|
+
|
|
1791
|
+
Special thanks to [itsreimau](https://github.com/itsreimau) for the fix to the `updateBlockStatus` implementation.
|
|
1792
|
+
|
|
1793
|
+
> [!CAUTION]
|
|
1794
|
+
> β οΈ **Modification, removal, or misrepresentation of these credits is strictly prohibited. Any redistribution or fork must preserve this section in its original form without exception.**
|