bellacloudy 26.3.13

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 (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.MD +1875 -0
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +4775 -0
  5. package/WAProto/index.js +169661 -0
  6. package/WAProto/p.html +1 -0
  7. package/engine-requirements.js +10 -0
  8. package/lib/Defaults/index.js +121 -0
  9. package/lib/Defaults/update-wa-version.js +56 -0
  10. package/lib/Defaults/wileys-version.json +3 -0
  11. package/lib/Signal/Group/ciphertext-message.js +15 -0
  12. package/lib/Signal/Group/group-session-builder.js +64 -0
  13. package/lib/Signal/Group/group_cipher.js +96 -0
  14. package/lib/Signal/Group/index.js +57 -0
  15. package/lib/Signal/Group/keyhelper.js +55 -0
  16. package/lib/Signal/Group/queue-job.js +57 -0
  17. package/lib/Signal/Group/sender-chain-key.js +34 -0
  18. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  19. package/lib/Signal/Group/sender-key-message.js +69 -0
  20. package/lib/Signal/Group/sender-key-name.js +51 -0
  21. package/lib/Signal/Group/sender-key-record.js +53 -0
  22. package/lib/Signal/Group/sender-key-state.js +99 -0
  23. package/lib/Signal/Group/sender-message-key.js +29 -0
  24. package/lib/Signal/libsignal.js +174 -0
  25. package/lib/Socket/Client/index.js +18 -0
  26. package/lib/Socket/Client/types.js +13 -0
  27. package/lib/Socket/Client/websocket.js +72 -0
  28. package/lib/Socket/business.js +260 -0
  29. package/lib/Socket/chats.js +972 -0
  30. package/lib/Socket/groups.js +332 -0
  31. package/lib/Socket/index.js +10 -0
  32. package/lib/Socket/messages-recv.js +1104 -0
  33. package/lib/Socket/messages-send.js +1002 -0
  34. package/lib/Socket/newsletter.js +250 -0
  35. package/lib/Socket/socket.js +646 -0
  36. package/lib/Socket/usync.js +70 -0
  37. package/lib/Store/index.js +8 -0
  38. package/lib/Store/make-in-memory-store.js +439 -0
  39. package/lib/Store/make-ordered-dictionary.js +81 -0
  40. package/lib/Store/object-repository.js +27 -0
  41. package/lib/Types/Auth.js +2 -0
  42. package/lib/Types/Call.js +2 -0
  43. package/lib/Types/Chat.js +4 -0
  44. package/lib/Types/Contact.js +2 -0
  45. package/lib/Types/Events.js +2 -0
  46. package/lib/Types/GroupMetadata.js +2 -0
  47. package/lib/Types/Label.js +27 -0
  48. package/lib/Types/LabelAssociation.js +9 -0
  49. package/lib/Types/Message.js +7 -0
  50. package/lib/Types/Newsletter.js +18 -0
  51. package/lib/Types/Product.js +2 -0
  52. package/lib/Types/Signal.js +2 -0
  53. package/lib/Types/Socket.js +2 -0
  54. package/lib/Types/State.js +2 -0
  55. package/lib/Types/USync.js +2 -0
  56. package/lib/Types/index.js +42 -0
  57. package/lib/Utils/auth-utils.js +199 -0
  58. package/lib/Utils/browser-utils.js +35 -0
  59. package/lib/Utils/business.js +234 -0
  60. package/lib/Utils/chat-utils.js +730 -0
  61. package/lib/Utils/crypto.js +193 -0
  62. package/lib/Utils/decode-wa-message.js +207 -0
  63. package/lib/Utils/event-buffer.js +518 -0
  64. package/lib/Utils/generics.js +467 -0
  65. package/lib/Utils/history.js +94 -0
  66. package/lib/Utils/index.js +35 -0
  67. package/lib/Utils/link-preview.js +126 -0
  68. package/lib/Utils/logger.js +7 -0
  69. package/lib/Utils/lt-hash.js +51 -0
  70. package/lib/Utils/make-mutex.js +43 -0
  71. package/lib/Utils/message-retry-manager.js +128 -0
  72. package/lib/Utils/messages-media.js +957 -0
  73. package/lib/Utils/messages.js +1049 -0
  74. package/lib/Utils/noise-handler.js +150 -0
  75. package/lib/Utils/process-message.js +404 -0
  76. package/lib/Utils/signal.js +153 -0
  77. package/lib/Utils/use-multi-file-auth-state.js +125 -0
  78. package/lib/Utils/validate-connection.js +229 -0
  79. package/lib/Utils/wileys-event-stream.js +63 -0
  80. package/lib/WABinary/constants.js +1303 -0
  81. package/lib/WABinary/decode.js +265 -0
  82. package/lib/WABinary/encode.js +250 -0
  83. package/lib/WABinary/generic-utils.js +110 -0
  84. package/lib/WABinary/index.js +21 -0
  85. package/lib/WABinary/jid-utils.js +85 -0
  86. package/lib/WABinary/types.js +2 -0
  87. package/lib/WAM/BinaryInfo.js +13 -0
  88. package/lib/WAM/constants.js +15350 -0
  89. package/lib/WAM/encode.js +155 -0
  90. package/lib/WAM/index.js +19 -0
  91. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  92. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  93. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  94. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  95. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  96. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  97. package/lib/WAUSync/Protocols/index.js +20 -0
  98. package/lib/WAUSync/USyncQuery.js +89 -0
  99. package/lib/WAUSync/USyncUser.js +26 -0
  100. package/lib/WAUSync/index.js +19 -0
  101. package/lib/index.js +174 -0
  102. package/lib/index.js.bak +128 -0
  103. package/package.json +119 -0
package/README.MD ADDED
@@ -0,0 +1,1875 @@
1
+ <h1 align="center">Baileys Modification</h1>
2
+
3
+ <p align="center">
4
+ <sub>Last update: <strong>15 Februari 2026</strong></sub>
5
+ </p>
6
+
7
+ <div align="center">
8
+ <a href="https://www.npmjs.com/package/wileys">
9
+ <img src="https://img.shields.io/badge/From-@wileys-blue?logo=npm&logoColor=white" />
10
+ </a>
11
+ </div>
12
+
13
+
14
+
15
+ <div align="center">
16
+
17
+ <img src="https://cdn.antaranews.com/cache/800x533/2023/05/17/Screenshot_20230517_132501_Gallery.jpg" />
18
+
19
+ <a href="https://youtube.com/jagoanproject">
20
+ <img src="https://img.shields.io/badge/YouTube-Bellacloudy-red?logo=youtube&logoColor=white" alt="YouTube JagoanProject" />
21
+ </a>
22
+
23
+
24
+ <a href="https://whatsapp.com/channel/0029VbD09aQ23n3nq2E0K645">
25
+ <img src="https://img.shields.io/badge/WhatsApp-Channel-25D366?logo=whatsapp&logoColor=white" alt="WhatsApp Channel" />
26
+ </a>
27
+
28
+ </div>
29
+
30
+
31
+ ## 📖 Tentang Jagoan Project
32
+
33
+ **Jagoan Project** adalah modifikasi dokumentasi dari *baileys* Mod https://www.npmjs.com/package/wileys, Di Karenakan Dev aslinya sudah tidak melanjutkan update maka saya melanjutkan update pada project tersebut disini. namun saya tetap menghargai dev dengan mencantumkan nama Creator utama. terimaksih.
34
+
35
+ Library ini sudah mendukung sistem *multi-device*, enkripsi end-to-end, dan kompatibilitas tinggi untuk semua tipe pesan di WhatsApp.
36
+ Selain itu, Jagoan Project menghadirkan dokumentasi bergaya modern agar mudah dibaca dan dipahami oleh para pengembang, dan inshaallah akan selalu update.
37
+
38
+ 📦 **Donasi (Klik Qris)**
39
+ [Jagoan Project](https://raw.githubusercontent.com/ChandraGO/Data-Jagoan-Project/refs/heads/master/qris.jpg)
40
+
41
+ [Wileys - Original Dev.](https://raw.githubusercontent.com/ChandraGO/Data-Jagoan-Project/refs/heads/master/qris.jpg)
42
+
43
+
44
+
45
+
46
+ ---
47
+
48
+ ## ⚙️ Fitur Utama
49
+
50
+ - Pemetaaan `@lid` dan `@jid`
51
+ - Dukungan *multi-device*
52
+ - Dukungan enkripsi *End-to-End*
53
+ - Menangani semua jenis pesan WhatsApp
54
+ - Kinerja cepat dan stabil ⚡
55
+
56
+ ---
57
+
58
+ ## 📦 Instalasi
59
+
60
+ Gunakan salah satu perintah berikut untuk menginstal:
61
+
62
+ ```bash
63
+ npm install jagproject
64
+ # atau
65
+ yarn add jagproject
66
+ ```
67
+
68
+ ---
69
+
70
+
71
+ # Documentation
72
+
73
+ - [Connecting Account](#connecting-account)
74
+ - [Connect with QR-CODE](#starting-socket-with-qr-code)
75
+ - [Connect with Pairing Code](#starting-socket-with-pairing-code)
76
+ - [Receive Full History](#receive-full-history)
77
+ - [Important Notes About Socket Config](#important-notes-about-socket-config)
78
+ - [Caching Group Metadata (Recommended)](#caching-group-metadata-recommended)
79
+ - [Improve Retry System & Decrypt Poll Votes](#improve-retry-system--decrypt-poll-votes)
80
+ - [Receive Notifications in Whatsapp App](#receive-notifications-in-whatsapp-app)
81
+
82
+ - [Save Auth Info](#saving--restoring-sessions)
83
+ - [Handling Events](#handling-events)
84
+ - [Example to Start](#example-to-start)
85
+ - [Decrypt Poll Votes](#decrypt-poll-votes)
86
+ - [Summary of Events on First Connection](#summary-of-events-on-first-connection)
87
+ - [Implementing a Data Store](#implementing-a-data-store)
88
+ - [Whatsapp IDs Explain](#whatsapp-ids-explain)
89
+ - [Utility Functions](#utility-functions)
90
+ - [Broadcast Lists & Stories](#broadcast-lists--stories)
91
+ - [Send Broadcast & Stories](#send-broadcast--stories)
92
+ - [Send Global Channel (upswgc)](#send-global-channel-upswgc)
93
+ - [Query a Broadcast List's Recipients & Name](#query-a-broadcast-lists-recipients--name)
94
+ - [Sending Messages](#sending-messages)
95
+ - [Non-Media Messages](#non-media-messages)
96
+ - [Buttons Message](#buttons-message)
97
+ - [Buttons Flow](#buttons-flow)
98
+ - [Interactive Message](#interactive-message)
99
+ - [Text Message](#text-message)
100
+ - [Quote Message](#quote-message-works-with-all-types)
101
+ - [Mention User](#mention-user-works-with-most-types)
102
+ - [Mention Status](#mention-status)
103
+ - [Result Poll From Newsletter](#result-poll-from-newsletter)
104
+ - [SendAlbumMessage](#send-album-message)
105
+ - [Interactive Response](#interactive-response)
106
+ - [Request Payment](#request-payment)
107
+ - [Event Message](#event-message)
108
+ - [Interactive](#interactive)
109
+ - [Forward Messages](#forward-messages)
110
+ - [Location Message](#location-message)
111
+ - [Contact Message](#contact-message)
112
+ - [Reaction Message](#reaction-message)
113
+ - [Pin Message](#pin-message)
114
+ - [Poll Message](#poll-message)
115
+ - [Sending with Link Preview](#sending-messages-with-link-previews)
116
+ - [Media Messages](#media-messages)
117
+ - [Gif Message](#gif-message)
118
+ - [Video Message](#video-message)
119
+ - [Audio Message](#audio-message)
120
+ - [Image Message](#image-message)
121
+ - [ViewOnce Message](#view-once-message)
122
+ - [Modify Messages](#modify-messages)
123
+ - [Delete Messages (for everyone)](#deleting-messages-for-everyone)
124
+ - [Edit Messages](#editing-messages)
125
+ - [Manipulating Media Messages](#manipulating-media-messages)
126
+ - [Thumbnail in Media Messages](#thumbnail-in-media-messages)
127
+ - [Downloading Media Messages](#downloading-media-messages)
128
+ - [Re-upload Media Message to Whatsapp](#re-upload-media-message-to-whatsapp)
129
+ - [Reject Call](#reject-call)
130
+ - [Send States in Chat](#send-states-in-chat)
131
+ - [Reading Messages](#reading-messages)
132
+ - [Update Presence](#update-presence)
133
+ - [Modifying Chats](#modifying-chats)
134
+ - [Archive a Chat](#archive-a-chat)
135
+ - [Mute/Unmute a Chat](#muteunmute-a-chat)
136
+ - [Mark a Chat Read/Unread](#mark-a-chat-readunread)
137
+ - [Delete a Message for Me](#delete-a-message-for-me)
138
+ - [Delete a Chat](#delete-a-chat)
139
+ - [Star/Unstar a Message](#starunstar-a-message)
140
+ - [Disappearing Messages](#disappearing-messages)
141
+ - [User Querys](#user-querys)
142
+ - [Check If ID Exists in Whatsapp](#check-if-id-exists-in-whatsapp)
143
+ - [Query Chat History (groups too)](#query-chat-history-groups-too)
144
+ - [Fetch Status](#fetch-status)
145
+ - [Fetch Profile Picture (groups too)](#fetch-profile-picture-groups-too)
146
+ - [Fetch Bussines Profile (such as description or category)](#fetch-bussines-profile-such-as-description-or-category)
147
+ - [Fetch Someone's Presence (if they're typing or online)](#fetch-someones-presence-if-theyre-typing-or-online)
148
+ - [Change Profile](#change-profile)
149
+ - [Change Profile Status](#change-profile-status)
150
+ - [Change Profile Name](#change-profile-name)
151
+ - [Change Display Picture (groups too)](#change-display-picture-groups-too)
152
+ - [Remove display picture (groups too)](#remove-display-picture-groups-too)
153
+ - [Groups](#groups)
154
+ - [Create a Group](#create-a-group)
155
+ - [Add/Remove or Demote/Promote](#addremove-or-demotepromote)
156
+ - [Change Subject (name)](#change-subject-name)
157
+ - [Change Description](#change-description)
158
+ - [Change Settings](#change-settings)
159
+ - [Leave a Group](#leave-a-group)
160
+ - [Get Invite Code](#get-invite-code)
161
+ - [Revoke Invite Code](#revoke-invite-code)
162
+ - [Join Using Invitation Code](#join-using-invitation-code)
163
+ - [Get Group Info by Invite Code](#get-group-info-by-invite-code)
164
+ - [Query Metadata (participants, name, description...)](#query-metadata-participants-name-description)
165
+ - [Join using groupInviteMessage](#join-using-groupinvitemessage)
166
+ - [Get Request Join List](#get-request-join-list)
167
+ - [Approve/Reject Request Join](#approvereject-request-join)
168
+ - [Get All Participating Groups Metadata](#get-all-participating-groups-metadata)
169
+ - [Toggle Ephemeral](#toggle-ephemeral)
170
+ - [Change Add Mode](#change-add-mode)
171
+ - [Privacy](#privacy)
172
+ - [Block/Unblock User](#blockunblock-user)
173
+ - [Get Privacy Settings](#get-privacy-settings)
174
+ - [Get BlockList](#get-blocklist)
175
+ - [Update LastSeen Privacy](#update-lastseen-privacy)
176
+ - [Update Online Privacy](#update-online-privacy)
177
+ - [Update Profile Picture Privacy](#update-profile-picture-privacy)
178
+ - [Update Status Privacy](#update-status-privacy)
179
+ - [Update Read Receipts Privacy](#update-read-receipts-privacy)
180
+ - [Update Groups Add Privacy](#update-groups-add-privacy)
181
+ - [Update Default Disappearing Mode](#update-default-disappearing-mode)
182
+ - [Broadcast Lists & Stories](#broadcast-lists--stories)
183
+ - [Send Broadcast & Stories](#send-broadcast--stories)
184
+ - [Query a Broadcast List's Recipients & Name](#query-a-broadcast-lists-recipients--name)
185
+ - [Writing Custom Functionality](#writing-custom-functionality)
186
+ - [Enabling Debug Level in Baileys Logs](#enabling-debug-level-in-baileys-logs)
187
+ - [How Whatsapp Communicate With Us](#how-whatsapp-communicate-with-us)
188
+ - [Register a Callback for Websocket Events](#register-a-callback-for-websocket-events)
189
+
190
+ <a id="connecting-account"></a>
191
+ ## 🔗 Menghubungkan Akun
192
+
193
+ WhatsApp provides a multi-device API that allows Baileys to be authenticated as a second WhatsApp client by scanning a **QR code** or **Pairing Code** with WhatsApp on your phone.
194
+
195
+ <a id="starting-socket-with-qr-code"></a>
196
+ ### 🔹 Memulai Socket dengan Kode QR
197
+
198
+ > [!TIP]
199
+ > You can customize browser name if you connect with **QR-CODE**, with `Browser` constant, we have some browsers config, **see [here](https://baileys.whiskeysockets.io/types/BrowsersMap.html)**
200
+
201
+ ```javascript
202
+ const { default: makeWASocket } = require("jagproject")
203
+
204
+
205
+ const sock = makeWASocket({
206
+ // can provide additional config here
207
+ browser: Browsers.ubuntu('My App'),
208
+ printQRInTerminal: true
209
+ })
210
+ ```
211
+
212
+ 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!
213
+
214
+ <a id="starting-socket-with-pairing-code"></a>
215
+ ### 🔹 Memulai Socket dengan **Kode Pairing**
216
+
217
+
218
+ > [!IMPORTANT]
219
+ > Pairing Code isn't Mobile API, it's a method to connect Whatsapp Web without QR-CODE, you can connect only with one device, see [here](https://faq.whatsapp.com/1324084875126592/?cms_platform=web)
220
+
221
+ The phone number can't have `+` or `()` or `-`, only numbers, you must provide country code
222
+
223
+ ```javascript
224
+ const { default: makeWASocket } = require("jagproject")
225
+
226
+ const sock = makeWASocket({
227
+ // can provide additional config here
228
+ printQRInTerminal: false //need to be false
229
+ })
230
+
231
+ - Normal Pairing
232
+ if (!sock.authState.creds.registered) {
233
+ const number = 'XXXXXXXXXXX'
234
+ const code = await sock.requestPairingCode(number)
235
+ console.log(code)
236
+ }
237
+
238
+ - Costum Pairing
239
+ if (!sock.authState.creds.registered) {
240
+ const pair = "12345678" // only 8 digit numbers or letters (no more or less)
241
+ const number = 'XXXXXXXXXXX'
242
+ const code = await sock.requestPairingCode(number, pair)
243
+ console.log(code)
244
+ }
245
+ ```
246
+
247
+ <a id="receive-full-history"></a>
248
+ ### 🔹 Menerima Riwayat Penuh
249
+
250
+ 1. Set `syncFullHistory` as `true`
251
+ 2. Baileys, by default, use chrome browser config
252
+ - If you'd like to emulate a desktop connection (and receive more message history), this browser setting to your Socket config:
253
+
254
+ ```javascript
255
+ const sock = makeWASocket({
256
+ ...otherOpts,
257
+ // can use Windows, Ubuntu here too
258
+ browser: Browsers.macOS('Desktop'),
259
+ syncFullHistory: true
260
+ })
261
+ ```
262
+
263
+ <a id="important-notes-about-socket-config"></a>
264
+ ## ⚙️ Catatan Penting tentang Konfigurasi Socket
265
+
266
+ <a id="caching-group-metadata-recommended"></a>
267
+ ### 🧠 Caching Metadata Grup (Direkomendasikan)
268
+ - If you use baileys for groups, we recommend you to set `cachedGroupMetadata` in socket config, you need to implement a cache like this:
269
+
270
+ ```javascript
271
+ const groupCache = new NodeCache({stdTTL: 5 * 60, useClones: false})
272
+
273
+ const sock = makeWASocket({
274
+ cachedGroupMetadata: async (jid) => groupCache.get(jid)
275
+ })
276
+
277
+ sock.ev.on('groups.update', async ([event]) => {
278
+ const metadata = await sock.groupMetadata(event.id)
279
+ groupCache.set(event.id, metadata)
280
+ })
281
+
282
+ sock.ev.on('group-participants.update', async (event) => {
283
+ const metadata = await sock.groupMetadata(event.id)
284
+ groupCache.set(event.id, metadata)
285
+ })
286
+ ```
287
+
288
+ <a id="handling-events"></a>
289
+ ### 🔁 Perbaiki Sistem Retry & Dekripsi Polling
290
+ - If you want to improve sending message, retrying when error occurs and decrypt poll votes, you need to have a store and set `getMessage` config in socket like this:
291
+ ```javascript
292
+ const sock = makeWASocket({
293
+ getMessage: async (key) => await getMessageFromStore(key)
294
+ })
295
+ ```
296
+ <a id="handling-events"></a>
297
+ ### 🔔 Menerima Notifikasi di Aplikasi WhatsApp
298
+ - If you want to receive notifications in whatsapp app, set `markOnlineOnConnect` to `false`
299
+ ```javascript
300
+ const sock = makeWASocket({
301
+ markOnlineOnConnect: false
302
+ })
303
+ ```
304
+ <a id="handling-events"></a>
305
+ ## 📦 Menyimpan & Mengembalikan Sesi
306
+
307
+ You obviously don't want to keep scanning the QR code every time you want to connect.
308
+
309
+ So, you can load the credentials to log back in:
310
+ ```javascript
311
+ const makeWASocket = require("jagproject").default;
312
+ const { useMultiFileAuthState } = require("jagproject");
313
+
314
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
315
+
316
+ // will use the given state to connect
317
+ // so if valid credentials are available -- it'll connect without QR
318
+ const sock = makeWASocket({ auth: state })
319
+
320
+ // this will be called as soon as the credentials are updated
321
+ sock.ev.on('creds.update', saveCreds)
322
+ ```
323
+
324
+ > [!IMPORTANT]
325
+ > `useMultiFileAuthState` is a utility function to help save the auth state in a single folder, 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.
326
+
327
+ > [!NOTE]
328
+ > When a message is received/sent, due to signal sessions needing updating, the auth keys (`authState.keys`) will update. Whenever that happens, you must save the updated keys (`authState.keys.set()` is called). Not doing so will prevent your messages from reaching the recipient & cause other unexpected consequences. The `useMultiFileAuthState` function automatically takes care of that, but for any other serious implementation -- you will need to be very careful with the key state management.
329
+
330
+ <a id="handling-events"></a>
331
+ ## 📡 Penanganan Event
332
+
333
+ - Baileys uses the EventEmitter syntax for events.
334
+ They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code.
335
+
336
+ > [!IMPORTANT]
337
+ > **The events are [these](https://baileys.whiskeysockets.io/types/BaileysEventMap.html)**, it's important you see all events
338
+
339
+ You can listen to these events like this:
340
+ ```javascript
341
+ const sock = makeWASocket()
342
+ sock.ev.on('messages.upsert', ({ messages }) => {
343
+ console.log('got messages', messages)
344
+ })
345
+ ```
346
+
347
+ <a id="handling-events"></a>
348
+ ### 🛠️ Contoh Awal
349
+
350
+ > [!NOTE]
351
+ > This example includes basic auth storage too
352
+
353
+ ```javascript
354
+ const makeWASocket = require("jagproject").default;
355
+ const { DisconnectReason, useMultiFileAuthState } = require("jagproject");
356
+ const Boom = require('@hapi/boom');
357
+
358
+ async function connectToWhatsApp () {
359
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
360
+ const sock = makeWASocket({
361
+ // can provide additional config here
362
+ auth: state,
363
+ printQRInTerminal: true
364
+ })
365
+ sock.ev.on('connection.update', (update) => {
366
+ const { connection, lastDisconnect } = update
367
+ if(connection === 'close') {
368
+ const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
369
+ console.log('connection closed due to ', lastDisconnect.error, ', reconnecting ', shouldReconnect)
370
+ // reconnect if not logged out
371
+ if(shouldReconnect) {
372
+ connectToWhatsApp()
373
+ }
374
+ } else if(connection === 'open') {
375
+ console.log('opened connection')
376
+ }
377
+ })
378
+ sock.ev.on('messages.upsert', event => {
379
+ for (const m of event.messages) {
380
+ console.log(JSON.stringify(m, undefined, 2))
381
+
382
+ console.log('replying to', m.key.remoteJid)
383
+ await sock.sendMessage(m.key.remoteJid!, { text: 'Hello Word' })
384
+ }
385
+ })
386
+
387
+ // to storage creds (session info) when it updates
388
+ sock.ev.on('creds.update', saveCreds)
389
+ }
390
+ // run in main file
391
+ connectToWhatsApp()
392
+ ```
393
+
394
+ > [!IMPORTANT]
395
+ > In `messages.upsert` it's recommended to use a loop like `for (const message of event.messages)` to handle all messages in array
396
+
397
+ <a id="handling-events"></a>
398
+ ### 🔐 Dekripsi Pilihan Polling
399
+
400
+ - By default poll votes are encrypted and handled in `messages.update`
401
+ - That's a simple example
402
+ ```javascript
403
+ sock.ev.on('messages.update', event => {
404
+ for(const { key, update } of event) {
405
+ if(update.pollUpdates) {
406
+ const pollCreation = await getMessage(key)
407
+ if(pollCreation) {
408
+ console.log(
409
+ 'got poll update, aggregation: ',
410
+ getAggregateVotesInPollMessage({
411
+ message: pollCreation,
412
+ pollUpdates: update.pollUpdates,
413
+ })
414
+ )
415
+ }
416
+ }
417
+ }
418
+ })
419
+ ```
420
+
421
+ - `getMessage` is a [store](#implementing-a-data-store) implementation (in your end)
422
+
423
+ <a id="handling-events"></a>
424
+ ### 🔎 Ringkasan Event pada Koneksi Pertama
425
+
426
+ 1. When you connect first time, `connection.update` will be fired requesting you to restart sock
427
+ 2. Then, history messages will be received in `messaging.history-set`
428
+
429
+ <a id="handling-events"></a>
430
+ ## 💾 Mengimplementasikan Data Store
431
+
432
+ - 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.
433
+
434
+ > [!IMPORTANT]
435
+ > I highly recommend building your own data store, as storing someone's entire chat history in memory is a terrible waste of RAM.
436
+
437
+ It can be used as follows:
438
+
439
+ ```javascript
440
+ const makeWASocket = require("jagproject").default;
441
+ const { makeInMemoryStore } = require("jagproject");
442
+ // the store maintains the data of the WA connection in memory
443
+ // can be written out to a file & read from it
444
+ const store = makeInMemoryStore({ })
445
+ // can be read from a file
446
+ store.readFromFile('./baileys_store.json')
447
+ // saves the state to a file every 10s
448
+ setInterval(() => {
449
+ store.writeToFile('./baileys_store.json')
450
+ }, 10_000)
451
+
452
+ const sock = makeWASocket({ })
453
+ // will listen from this socket
454
+ // the store can listen from a new socket once the current socket outlives its lifetime
455
+ store.bind(sock.ev)
456
+
457
+ sock.ev.on('chats.upsert', () => {
458
+ // can use 'store.chats' however you want, even after the socket dies out
459
+ // 'chats' => a KeyedDB instance
460
+ console.log('got chats', store.chats.all())
461
+ })
462
+
463
+ sock.ev.on('contacts.upsert', () => {
464
+ console.log('got contacts', Object.values(store.contacts))
465
+ })
466
+
467
+ ```
468
+
469
+ The store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.
470
+
471
+ <a id="handling-events"></a>
472
+ ## 🆔 Penjelasan ID WhatsApp
473
+
474
+ - `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.
475
+ - It must be in the format ```[country code][phone number]@s.whatsapp.net```
476
+ - Example for people: ```+19999999999@s.whatsapp.net```.
477
+ - For groups, it must be in the format ``` 123456789-123345@g.us ```.
478
+ - For broadcast lists, it's `[timestamp of creation]@broadcast`.
479
+ - For stories, the ID is `status@broadcast`.
480
+
481
+ <a id="handling-events"></a>
482
+ ## 🧰 Fungsi Utilitas
483
+
484
+ - `getContentType`, returns the content type for any message
485
+ - `getDevice`, returns the device from message
486
+ - `makeCacheableSignalKeyStore`, make auth store more fast
487
+ - `downloadContentFromMessage`, download content from any message
488
+
489
+
490
+ ---
491
+ <a id="broadcast-lists--stories"></a>
492
+ ## 💫 Status Mention Grup (upswgc)
493
+
494
+ Digunakan untuk mengirim status WhatsApp (story) Grup baik berupa teks maupun media ke status@broadcast.
495
+
496
+ `
497
+ [!NOTE]
498
+ Fungsi ini sudah otomatis mendeteksi tipe konten (teks, gambar, video, audio).
499
+ Jika teks dan media digabung, hanya satu yang akan dikirim tergantung prioritas konten.
500
+ `
501
+
502
+ ### Kirim teks ke status WhatsApp
503
+ ```javascript
504
+ await conn.upswgc(m.chat, { text: "Halo dari upswgc versi final!" })
505
+ ```
506
+
507
+ ### Kirim gambar ke status WhatsApp
508
+ ```javascript
509
+ await conn.upswgc(m.chat, {
510
+ image: { url: "https://m.media-amazon.com/images/S/pv-target-images/f75db71efd62ea2eff81bd7cc01c44a9344b4ac18615ab71a80f58459ddf8791.jpg" },
511
+ caption : "apasi"
512
+       });
513
+
514
+ ```
515
+ ### Kirim video ke status WhatsApp
516
+ ```javascript
517
+ await conn.upswgc(m.chat, {
518
+ video: { url: "https://m.media-amazon.com/images/S/pv-target-images/f75db71efd62ea2eff81bd7cc01c44a9344b4ac18615ab71a80f58459ddf8791.jpg" },
519
+ caption : "apasi"
520
+       });
521
+ ```
522
+ ### Kirim audio (voice note) ke status WhatsApp
523
+ ```javascript
524
+ await conn.upswgc(m.chat, {
525
+ audio: { url: "https://cdn.yupra.my.id/yp/xkv99g06.opus" },
526
+ caption : "apasi"
527
+       });
528
+ ```
529
+
530
+ `[!TIP]
531
+ Jika kamu ingin mengirim ke story + broadcast sekaligus, gunakan fungsi sendMessage()
532
+ dengan broadcast: true seperti dijelaskan pada bagian sebelumnya.`
533
+
534
+ ---
535
+
536
+ <a id="handling-events"></a>
537
+ ## 💬 Mengirim Pesan
538
+
539
+ - Send all types of messages with a single function
540
+ - **[Here](https://baileys.whiskeysockets.io/types/AnyMessageContent.html) you can see all message contents supported, like text message**
541
+ - **[Here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html) you can see all options supported, like quote message**
542
+
543
+ ```javascript
544
+ const jid: string
545
+ const content: AnyMessageContent
546
+ const options: MiscMessageGenerationOptions
547
+
548
+ sock.sendMessage(jid, content, options)
549
+ ```
550
+
551
+ <a id="handling-events"></a>
552
+ ### ✉️ Pesan Non-Media
553
+
554
+ <a id="handling-events"></a>
555
+ #### 🔘 Pesan Tombol (Buttons)
556
+ ```javascript
557
+ // send a buttons message!
558
+ sock.sendMessage(jid, {
559
+ text: "Hello World !",
560
+ footer: "jagproject - 2025",
561
+ buttons: [
562
+ {
563
+ buttonId: `🚀`,
564
+ buttonText: {
565
+ displayText: '🗿'
566
+ },
567
+ type: 1
568
+ }
569
+ ],
570
+ headerType: 1,
571
+ viewOnce: true
572
+ },{ quoted: null })
573
+ ```
574
+
575
+ <a id="handling-events"></a>
576
+ #### 🔁 Alur Tombol
577
+ ```javascript
578
+ sock.sendMessage(jid, {
579
+ text: "Hello Wolrd !;",
580
+ footer: "© jagproject Dev",
581
+ buttons: [
582
+ {
583
+ buttonId: '.tes',
584
+ buttonText: {
585
+ displayText: 'TESTING BOT'
586
+ },
587
+ type: 1,
588
+ },
589
+ {
590
+ buttonId: ' ',
591
+ buttonText: {
592
+ displayText: 'PRIVATE SCRIPT'
593
+ },
594
+ type: 1,
595
+ },
596
+ {
597
+ buttonId: 'action',
598
+ buttonText: {
599
+ displayText: 'ini pesan interactiveMeta'
600
+ },
601
+ type: 4,
602
+ nativeFlowInfo: {
603
+ name: 'single_select',
604
+ paramsJson: JSON.stringify({
605
+ title: 'message',
606
+ sections: [
607
+ {
608
+ title: 'jagproject - 2025',
609
+ highlight_label: '😜',
610
+ rows: [
611
+ {
612
+ header: 'HEADER',
613
+ title: 'TITLE',
614
+ description: 'DESCRIPTION',
615
+ id: 'YOUR ID',
616
+ },
617
+ {
618
+ header: 'HEADER',
619
+ title: 'TITLE',
620
+ description: 'DESCRIPTION',
621
+ id: 'YOUR ID',
622
+ },
623
+ ],
624
+ },
625
+ ],
626
+ }),
627
+ },
628
+ },
629
+ ],
630
+ headerType: 1,
631
+ viewOnce: true
632
+ }, { quoted: m });
633
+ ```
634
+
635
+ <a id="handling-events"></a>
636
+ #### 🧩 Pesan Interaktif
637
+ ```javascript
638
+ let msg = generateWAMessageFromContent(m.chat, {
639
+ viewOnceMessage: {
640
+ message: {
641
+ "messageContextInfo": {
642
+ "deviceListMetadata": {},
643
+ "deviceListMetadataVersion": 2
644
+ },
645
+ interactiveMessage: proto.Message.InteractiveMessage.create({
646
+ body: proto.Message.InteractiveMessage.Body.create({
647
+ text: "jagproject Dev"
648
+ }),
649
+ footer: proto.Message.InteractiveMessage.Footer.create({
650
+ text: "Bot"
651
+ }),
652
+ header: proto.Message.InteractiveMessage.Header.create({
653
+ title: "Igna",
654
+ subtitle: "test",
655
+ hasMediaAttachment: false
656
+ }),
657
+ nativeFlowMessage: proto.Message.InteractiveMessage.NativeFlowMessage.create({
658
+ buttons: [
659
+ {
660
+ "name": "single_select",
661
+ "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\"}]}]}"
662
+ },
663
+ {
664
+ "name": "cta_reply",
665
+ "buttonParamsJson": "{\"display_text\":\"quick_reply\",\"id\":\"message\"}"
666
+ },
667
+ {
668
+ "name": "cta_url",
669
+ "buttonParamsJson": "{\"display_text\":\"url\",\"url\":\"https://www.google.com\",\"merchant_url\":\"https://www.google.com\"}"
670
+ },
671
+ {
672
+ "name": "cta_call",
673
+ "buttonParamsJson": "{\"display_text\":\"call\",\"id\":\"message\"}"
674
+ },
675
+ {
676
+ "name": "cta_copy",
677
+ "buttonParamsJson": "{\"display_text\":\"copy\",\"id\":\"123456789\",\"copy_code\":\"message\"}"
678
+ },
679
+ {
680
+ "name": "cta_reminder",
681
+ "buttonParamsJson": "{\"display_text\":\"Recordatorio\",\"id\":\"message\"}"
682
+ },
683
+ {
684
+ "name": "cta_cancel_reminder",
685
+ "buttonParamsJson": "{\"display_text\":\"cta_cancel_reminder\",\"id\":\"message\"}"
686
+ },
687
+ {
688
+ "name": "address_message",
689
+ "buttonParamsJson": "{\"display_text\":\"address_message\",\"id\":\"message\"}"
690
+ },
691
+ {
692
+ "name": "send_location",
693
+ "buttonParamsJson": ""
694
+ }
695
+ ],
696
+ })
697
+ })
698
+ }
699
+ }
700
+ }, {})
701
+
702
+ return sock.relayMessage(msg.key.remoteJid, msg.message, { messageId: msg.key.id })
703
+ ```
704
+
705
+ <a id="handling-events"></a>
706
+ #### 📝 Pesan Teks
707
+ ```javascript
708
+ await sock.sendMessage(jid, { text: 'hello word' })
709
+ ```
710
+
711
+ <a id="handling-events"></a>
712
+ #### ❝ Pesan Quote (bekerja untuk semua tipe)
713
+ ```javascript
714
+ await sock.sendMessage(jid, { text: 'hello word' }, { quoted: message })
715
+ ```
716
+
717
+ <a id="handling-events"></a>
718
+ #### 🏷️ Mention Pengguna (bekerja di kebanyakan tipe)
719
+ - @number is to mention in text, it's optional
720
+ ```javascript
721
+ await sock.sendMessage(
722
+ jid,
723
+ {
724
+ text: '@12345678901',
725
+ mentions: ['12345678901@s.whatsapp.net']
726
+ }
727
+ )
728
+ ```
729
+
730
+ <a id="handling-events"></a>
731
+ #### 📣 Mention Status
732
+ - [ jid ] 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
733
+ ```javascript
734
+ await sock.StatusMentions(
735
+ {
736
+ text: "Hello", // or image / video / audio ( url or buffer )
737
+ },
738
+ [
739
+ "123456789123456789@g.us",
740
+ "123456789@s.whatsapp.net",
741
+ // Enter jid chat here
742
+ ]
743
+ )
744
+ ```
745
+
746
+ <a id="handling-events"></a>
747
+ #### 📊 Hasil Poll dari Newsletter
748
+ ```javascript
749
+ await client.sendMessage(
750
+ jid,
751
+ {
752
+ pollResult: {
753
+ name: "Text poll",
754
+ votes: [["Options 1", 10], ["Options 2", 10]], // 10 For Fake Polling Count Results
755
+ }
756
+ }, { quoted : message }
757
+ )
758
+ ```
759
+
760
+ <a id="handling-events"></a>
761
+ #### 🖼️ Mengirim Pesan Album
762
+ - url or buffer ( image or video )
763
+ ```javascript
764
+ await sock.sendAlbumMessage(
765
+ jid,
766
+ [
767
+ {
768
+ image: { url: "https://example.jpg" }, // or buffer
769
+ caption: "Hello World",
770
+ },
771
+ {
772
+ video: { url: "https://example.mp4" }, // or buffer
773
+ caption: "Hello World",
774
+ },
775
+ ],
776
+ {
777
+ quoted : message,
778
+ delay : 2000 // number in seconds
779
+ }
780
+ )
781
+
782
+ ```
783
+
784
+ <a id="handling-events"></a>
785
+ #### 🔔 Respon Interaktif
786
+ ```javascript
787
+ await client.sendMessage(
788
+ jid,
789
+ {
790
+ buttonReply: {
791
+ text: 'Text',
792
+ nativeFlow: {
793
+ version: 3,
794
+ },
795
+ },
796
+ type: 'interactive',
797
+ ephemeral: true,
798
+ }
799
+ )
800
+
801
+ ```
802
+
803
+ <a id="handling-events"></a>
804
+ #### 💳 Permintaan Pembayaran
805
+ ```javascript
806
+ - Example non media sticker
807
+ await client.sendMessage(
808
+ jid,
809
+ {
810
+ requestPayment: {
811
+ currency: "IDR",
812
+ amount: "10000000",
813
+ from: "123456@s.whatsapp.net",
814
+ note: "Hai Guys",
815
+ background: { ...background of the message }
816
+ }
817
+ },
818
+ { quoted : message }
819
+ )
820
+
821
+ - with media sticker buffer
822
+ await client.sendMessage(
823
+ jid,
824
+ {
825
+ requestPayment: {
826
+ currency: "IDR",
827
+ amount: "10000000",
828
+ from: "123456@s.whatsapp.net",
829
+ sticker: Buffer,
830
+ background: { ...background of the message }
831
+ }
832
+ },
833
+ { quoted : message }
834
+ )
835
+
836
+ - with media sticker url
837
+ await client.sendMessage(
838
+ jid,
839
+ {
840
+ requestPayment: {
841
+ currency: "IDR",
842
+ amount: "10000000",
843
+ from: "123456@s.whatsapp.net",
844
+ sticker: { url: Sticker Url },
845
+ background: { ...background of the message }
846
+ }
847
+ },
848
+ { quoted : message }
849
+ )
850
+ ```
851
+
852
+ <a id="handling-events"></a>
853
+ #### 📆 Pesan Event
854
+ ```javascript
855
+ await client.sendMessage(
856
+ jid,
857
+ {
858
+ event: {
859
+ isCanceled: false, // or true for cancel event
860
+ name: "Name Event",
861
+ description: "Description Event",
862
+ location: {
863
+ degressLatitude: -0,
864
+ degressLongitude: - 0
865
+ },
866
+ link: Call Link,
867
+ startTime: m.messageTimestamp.low,
868
+ endTime: m.messageTimestamp.low + 86400, // 86400 is day in seconds
869
+ extraGuestsAllowed: true // or false
870
+ }
871
+ },
872
+ { quoted : message }
873
+ )
874
+ ```
875
+
876
+ <a id="handling-events"></a>
877
+ #### 🔗 Interaktif
878
+ ```javascript
879
+ - Example non header media
880
+ await client.sendMessage(
881
+ jid,
882
+ {
883
+ text: "Description Of Messages", //Additional information
884
+ title: "Title Of Messages",
885
+ subtitle: "Subtitle Message",
886
+ footer: "Footer Messages",
887
+ interactiveButtons: [
888
+ {
889
+ name: "quick_reply",
890
+ buttonParamsJson: JSON.stringify({
891
+ display_text: "Display Button",
892
+ id: "ID"
893
+ })
894
+ },
895
+ {
896
+ name: "cta_url",
897
+ buttonParamsJson: JSON.stringify({
898
+ display_text: "Display Button",
899
+ url: "https://www.example.com"
900
+ })
901
+ }
902
+ ]
903
+ },
904
+ {
905
+ quoted : message
906
+ }
907
+ )
908
+
909
+ - Example with media
910
+ await client.sendMessage(
911
+ jid,
912
+ {
913
+ image: { url : "https://example.jpg" }, // Can buffer
914
+ caption: "Description Of Messages", //Additional information
915
+ title: "Title Of Messages",
916
+ subtitle: "Subtile Message",
917
+ footer: "Footer Messages",
918
+ media: true,
919
+ interactiveButtons: [
920
+ {
921
+ name: "quick_reply",
922
+ buttonParamsJson: JSON.stringify({
923
+ display_text: "Display Button",
924
+ id: "ID"
925
+ })
926
+ },
927
+ {
928
+ name: "cta_url",
929
+ buttonParamsJson: JSON.stringify({
930
+ display_text: "Display Button",
931
+ url: "https://www.example.com"
932
+ })
933
+ }
934
+ ]
935
+ },
936
+ {
937
+ quoted : message
938
+ }
939
+ )
940
+
941
+ - Example with header product
942
+ await client.sendMessage(
943
+ jid,
944
+ {
945
+ product: {
946
+ productImage: { url: "https://example.jpg }, //or buffer
947
+ productImageCount: 1,
948
+ title: "Title Product",
949
+ description: "Description Product",
950
+ priceAmount1000: 20000 * 1000,
951
+ currencyCode: "IDR",
952
+ retailerId: "Retail",
953
+ url: "https://example.com",
954
+ },
955
+ businessOwnerJid: "1234@s.whatsapp.net",
956
+ caption: "Description Of Messages", //Additional information
957
+ title: "Title Of Messages",
958
+ footer: "Footer Messages",
959
+ media: true,
960
+ interactiveButtons: [
961
+ {
962
+ name: "quick_reply",
963
+ buttonParamsJson: JSON.stringify({
964
+ display_text: "Display Button",
965
+ id: "ID"
966
+ })
967
+ },
968
+ {
969
+ name: "cta_url",
970
+ buttonParamsJson: JSON.stringify({
971
+ display_text: "Display Button",
972
+ url: "https://www.example.com"
973
+ })
974
+ }
975
+ ]
976
+ },
977
+ {
978
+ quoted : message
979
+ }
980
+ )
981
+ ```
982
+
983
+ <a id="handling-events"></a>
984
+ #### 📤 Meneruskan Pesan
985
+ - You need to have message object, can be retrieved from [store](#implementing-a-data-store) or use a [message](https://baileys.whiskeysockets.io/types/WAMessage.html) object
986
+ ```javascript
987
+ const msg = getMessageFromStore() // implement this on your end
988
+ await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
989
+ ```
990
+
991
+ <a id="handling-events"></a>
992
+ #### 📍 Pesan Lokasi
993
+ ```javascript
994
+ await sock.sendMessage(
995
+ jid,
996
+ {
997
+ location: {
998
+ degreesLatitude: 24.121231,
999
+ degreesLongitude: 55.1121221
1000
+ }
1001
+ }
1002
+ )
1003
+ ```
1004
+
1005
+ <a id="handling-events"></a>
1006
+ #### 👤 Pesan Kontak
1007
+ ```javascript
1008
+ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
1009
+ + 'VERSION:3.0\n'
1010
+ + 'FN:Jeff Singh\n' // full name
1011
+ + 'ORG:Ashoka Uni;\n' // the organization of the contact
1012
+ + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
1013
+ + 'END:VCARD'
1014
+
1015
+ await sock.sendMessage(
1016
+ id,
1017
+ {
1018
+ contacts: {
1019
+ displayName: 'Jeff',
1020
+ contacts: [{ vcard }]
1021
+ }
1022
+ }
1023
+ )
1024
+ ```
1025
+
1026
+ <a id="handling-events"></a>
1027
+ #### ❤️ Pesan Reaksi
1028
+ - 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
1029
+ ```javascript
1030
+ await sock.sendMessage(
1031
+ jid,
1032
+ {
1033
+ react: {
1034
+ text: '💖', // use an empty string to remove the reaction
1035
+ key: message.key
1036
+ }
1037
+ }
1038
+ )
1039
+ ```
1040
+
1041
+ <a id="handling-events"></a>
1042
+ #### 📌 Pesan Pin
1043
+ - 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
1044
+
1045
+ - Time can be:
1046
+
1047
+ | Time | Seconds |
1048
+ |-------|----------------|
1049
+ | 24h | 86.400 |
1050
+ | 7d | 604.800 |
1051
+ | 30d | 2.592.000 |
1052
+
1053
+ ```javascript
1054
+ await sock.sendMessage(
1055
+ jid,
1056
+ {
1057
+ pin: {
1058
+ type: 1, // 0 to remove
1059
+ time: 86400
1060
+ key: message.key
1061
+ }
1062
+ }
1063
+ )
1064
+ ```
1065
+
1066
+ <a id="handling-events"></a>
1067
+ #### 🗳️ Pesan Poll
1068
+ ```javascript
1069
+ await sock.sendMessage(
1070
+ jid,
1071
+ {
1072
+ poll: {
1073
+ name: 'My Poll',
1074
+ values: ['Option 1', 'Option 2', ...],
1075
+ selectableCount: 1,
1076
+ toAnnouncementGroup: false // or true
1077
+ }
1078
+ }
1079
+ )
1080
+ ```
1081
+
1082
+ <a id="handling-events"></a>
1083
+ ### 💬 Mengirim Pesan with Link Previews
1084
+
1085
+ 1. By default, wa does not have link generation when sent from the web
1086
+ 2. Baileys has a function to generate the content for these link previews
1087
+ 3. To enable this function's usage, add `link-preview-js` as a dependency to your project with `yarn add link-preview-js`
1088
+ 4. Send a link:
1089
+ ```javascript
1090
+ await sock.sendMessage(
1091
+ jid,
1092
+ {
1093
+ text: 'Hi, this was sent using https://github.com/whiskeysockets/baileys'
1094
+ }
1095
+ )
1096
+ ```
1097
+
1098
+ ### 🎞️ Pesan Media
1099
+
1100
+ Sending media (video, stickers, images) is easier & more efficient than ever.
1101
+
1102
+ > [!NOTE]
1103
+ > In media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)
1104
+
1105
+ - When specifying a media url, Baileys never loads the entire buffer into memory; it even encrypts the media as a readable stream.
1106
+
1107
+ > [!TIP]
1108
+ > It's recommended to use Stream or Url to save memory
1109
+
1110
+ <a id="handling-events"></a>
1111
+ #### 🎬 Pesan GIF
1112
+ - Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
1113
+ ```javascript
1114
+ await sock.sendMessage(
1115
+ jid,
1116
+ {
1117
+ video: fs.readFileSync('Media/ma_gif.mp4'),
1118
+ caption: 'hello word',
1119
+ gifPlayback: true
1120
+ }
1121
+ )
1122
+ ```
1123
+
1124
+ <a id="handling-events"></a>
1125
+ #### 📹 Pesan Video
1126
+ ```javascript
1127
+ await sock.sendMessage(
1128
+ id,
1129
+ {
1130
+ video: {
1131
+ url: './Media/ma_gif.mp4'
1132
+ },
1133
+ caption: 'hello word',
1134
+ ptv: false // if set to true, will send as a `video note`
1135
+ }
1136
+ )
1137
+ ```
1138
+
1139
+ <a id="handling-events"></a>
1140
+ #### 🔊 Pesan Audio
1141
+ - To audio message work in all devices you need to convert with some tool like `ffmpeg` with this flags:
1142
+ ```bash
1143
+ codec: libopus //ogg file
1144
+ ac: 1 //one channel
1145
+ avoid_negative_ts
1146
+ make_zero
1147
+ ```
1148
+ - Example:
1149
+ ```bash
1150
+ ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
1151
+ ```
1152
+ ```javascript
1153
+ await sock.sendMessage(
1154
+ jid,
1155
+ {
1156
+ audio: {
1157
+ url: './Media/audio.mp3'
1158
+ },
1159
+ mimetype: 'audio/mp4'
1160
+ }
1161
+ )
1162
+ ```
1163
+
1164
+ <a id="handling-events"></a>
1165
+ #### 🖼️ Pesan Gambar
1166
+ ```javascript
1167
+ await sock.sendMessage(
1168
+ id,
1169
+ {
1170
+ image: {
1171
+ url: './Media/ma_img.png'
1172
+ },
1173
+ caption: 'hello word'
1174
+ }
1175
+ )
1176
+ ```
1177
+
1178
+ <a id="handling-events"></a>
1179
+ #### 👁️ View Once (Sekali Lihat)
1180
+
1181
+ - You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
1182
+
1183
+ ```javascript
1184
+ await sock.sendMessage(
1185
+ id,
1186
+ {
1187
+ image: {
1188
+ url: './Media/ma_img.png'
1189
+ },
1190
+ viewOnce: true, //works with video, audio too
1191
+ caption: 'hello word'
1192
+ }
1193
+ )
1194
+ ```
1195
+
1196
+ <a id="handling-events"></a>
1197
+ ## ✏️ Memodifikasi Pesan
1198
+
1199
+ <a id="handling-events"></a>
1200
+ ### 🗑️ Menghapus Pesan (untuk semua)
1201
+
1202
+ ```javascript
1203
+ const msg = await sock.sendMessage(jid, { text: 'hello word' })
1204
+ await sock.sendMessage(jid, { delete: msg.key })
1205
+ ```
1206
+
1207
+ **Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)
1208
+
1209
+ <a id="handling-events"></a>
1210
+ ### 🖊️ Mengedit Pesan
1211
+
1212
+ - You can pass all editable contents here
1213
+ ```javascript
1214
+ await sock.sendMessage(jid, {
1215
+ text: 'updated text goes here',
1216
+ edit: response.key,
1217
+ });
1218
+ ```
1219
+
1220
+ <a id="handling-events"></a>
1221
+ ## 🛠️ Manipulasi Pesan Media
1222
+
1223
+ <a id="handling-events"></a>
1224
+ ### 🖼️ Thumbnail pada Pesan Media
1225
+ - 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`.
1226
+ - Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.
1227
+
1228
+ <a id="handling-events"></a>
1229
+ ### ⬇️ Mengunduh Pesan Media
1230
+
1231
+ If you want to save the media you received
1232
+ ```javascript
1233
+ const { createWriteStream } = require('fs');
1234
+ const { downloadMediaMessage, getContentType } = require("jagproject");
1235
+
1236
+ sock.ev.on('messages.upsert', async ({ [m] }) => {
1237
+ if (!m.message) return // if there is no text or media message
1238
+ const messageType = getContentType(m) // get what type of message it is (text, image, video...)
1239
+
1240
+ // if the message is an image
1241
+ if (messageType === 'imageMessage') {
1242
+ // download the message
1243
+ const stream = await downloadMediaMessage(
1244
+ m,
1245
+ 'stream', // can be 'buffer' too
1246
+ { },
1247
+ {
1248
+ logger,
1249
+ // pass this so that baileys can request a reupload of media
1250
+ // that has been deleted
1251
+ reuploadRequest: sock.updateMediaMessage
1252
+ }
1253
+ )
1254
+ // save to file
1255
+ const writeStream = createWriteStream('./my-download.jpeg')
1256
+ stream.pipe(writeStream)
1257
+ }
1258
+ }
1259
+ ```
1260
+
1261
+ <a id="handling-events"></a>
1262
+ ### 🔁 Mengunggah Ulang Pesan Media ke WhatsApp
1263
+
1264
+ - WhatsApp automatically removes old media from their servers. For the device to access said media -- a re-upload is required by another device that has it. This can be accomplished using:
1265
+ ```javascript
1266
+ await sock.updateMediaMessage(msg)
1267
+ ```
1268
+
1269
+ <a id="handling-events"></a>
1270
+ ## 🚫 Menolak Panggilan
1271
+
1272
+ - You can obtain `callId` and `callFrom` from `call` event
1273
+
1274
+ ```javascript
1275
+ await sock.rejectCall(callId, callFrom)
1276
+ ```
1277
+
1278
+ <a id="handling-events"></a>
1279
+ ## 📡 Status Pengiriman di Chat
1280
+
1281
+ <a id="handling-events"></a>
1282
+ ### 📖 Membaca Pesan
1283
+ - A set of message [keys](https://baileys.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.
1284
+ - You cannot mark an entire 'chat' read as it were with Baileys Web.
1285
+ This means you have to keep track of unread messages.
1286
+
1287
+ ```javascript
1288
+ const key: WAMessageKey
1289
+ // can pass multiple keys to read multiple messages as well
1290
+ await sock.readMessages([key])
1291
+ ```
1292
+
1293
+ The message ID is the unique identifier of the message that you are marking as read.
1294
+ On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
1295
+
1296
+ <a id="handling-events"></a>
1297
+ ### 🟢 Memperbarui Presence
1298
+
1299
+ - ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
1300
+ - The presence expires after about 10 seconds.
1301
+ - This lets the person/group with `jid` know whether you're online, offline, typing etc.
1302
+
1303
+ ```javascript
1304
+ await sock.sendPresenceUpdate('available', jid)
1305
+ ```
1306
+
1307
+ > [!NOTE]
1308
+ > 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')`
1309
+
1310
+ <a id="handling-events"></a>
1311
+ ## 🗂️ Memodifikasi Chat
1312
+
1313
+ WA uses an encrypted form of communication to send chat/app updates. This has been implemented mostly and you can send the following updates:
1314
+
1315
+ > [!IMPORTANT]
1316
+ > If you mess up one of your updates, WA can log you out of all your devices and you'll have to log in again.
1317
+
1318
+ <a id="handling-events"></a>
1319
+ ### 🗃️ Arsipkan Chat
1320
+ ```javascript
1321
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
1322
+ await sock.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
1323
+ ```
1324
+
1325
+ <a id="handling-events"></a>
1326
+ ### 🔕 Mute/Unmute Chat
1327
+
1328
+ - Supported times:
1329
+
1330
+ | Time | Miliseconds |
1331
+ |-------|-----------------|
1332
+ | Remove | null |
1333
+ | 8h | 86.400.000 |
1334
+ | 7d | 604.800.000 |
1335
+
1336
+ ```javascript
1337
+ // mute for 8 hours
1338
+ await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
1339
+ // unmute
1340
+ await sock.chatModify({ mute: null }, jid)
1341
+ ```
1342
+
1343
+ <a id="handling-events"></a>
1344
+ ### ✅ Tandai Chat Baca/Belum Baca
1345
+ ```javascript
1346
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
1347
+ // mark it unread
1348
+ await sock.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
1349
+ ```
1350
+
1351
+ <a id="handling-events"></a>
1352
+ ### 🧹 Hapus Pesan untuk Saya
1353
+ ```javascript
1354
+ await sock.chatModify(
1355
+ {
1356
+ clear: {
1357
+ messages: [
1358
+ {
1359
+ id: 'ATWYHDNNWU81732J',
1360
+ fromMe: true,
1361
+ timestamp: '1654823909'
1362
+ }
1363
+ ]
1364
+ }
1365
+ },
1366
+ jid
1367
+ )
1368
+
1369
+ ```
1370
+
1371
+ <a id="handling-events"></a>
1372
+ ### ❌ Hapus Chat
1373
+ ```javascript
1374
+ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
1375
+ await sock.chatModify({
1376
+ delete: true,
1377
+ lastMessages: [
1378
+ {
1379
+ key: lastMsgInChat.key,
1380
+ messageTimestamp: lastMsgInChat.messageTimestamp
1381
+ }
1382
+ ]
1383
+ },
1384
+ jid
1385
+ )
1386
+ ```
1387
+
1388
+ <a id="handling-events"></a>
1389
+ ### 📌 Pin/Unpin Chat
1390
+ ```javascript
1391
+ await sock.chatModify({
1392
+ pin: true // or `false` to unpin
1393
+ },
1394
+ jid
1395
+ )
1396
+ ```
1397
+
1398
+ <a id="handling-events"></a>
1399
+ ### ⭐ Star/Unstar Pesan
1400
+ ```javascript
1401
+ await sock.chatModify({
1402
+ star: {
1403
+ messages: [
1404
+ {
1405
+ id: 'messageID',
1406
+ fromMe: true // or `false`
1407
+ }
1408
+ ],
1409
+ star: true // - true: Star Message; false: Unstar Message
1410
+ }
1411
+ },
1412
+ jid
1413
+ )
1414
+ ```
1415
+
1416
+ <a id="handling-events"></a>
1417
+ ### 🕒 Pesan yang Menghilang (Disappearing)
1418
+
1419
+ - Ephemeral can be:
1420
+
1421
+ | Time | Seconds |
1422
+ |-------|----------------|
1423
+ | Remove | 0 |
1424
+ | 24h | 86.400 |
1425
+ | 7d | 604.800 |
1426
+ | 90d | 7.776.000 |
1427
+
1428
+ - You need to pass in **Seconds**, default is 7 days
1429
+
1430
+ ```javascript
1431
+ // turn on disappearing messages
1432
+ await sock.sendMessage(
1433
+ jid,
1434
+ // this is 1 week in seconds -- how long you want messages to appear for
1435
+ { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL }
1436
+ )
1437
+
1438
+ // will send as a disappearing message
1439
+ await sock.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL })
1440
+
1441
+ // turn off disappearing messages
1442
+ await sock.sendMessage(
1443
+ jid,
1444
+ { disappearingMessagesInChat: false }
1445
+ )
1446
+ ```
1447
+
1448
+ <a id="handling-events"></a>
1449
+ ## 🔎 Query Pengguna
1450
+
1451
+ <a id="handling-events"></a>
1452
+ ### 🔍 Cek Jika ID Ada di WhatsApp
1453
+ ```javascript
1454
+ const [result] = await sock.onWhatsApp(jid)
1455
+ if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
1456
+ ```
1457
+
1458
+ <a id="handling-events"></a>
1459
+ ### 📜 Query Riwayat Chat (termasuk grup)
1460
+
1461
+ - You need to have oldest message in chat
1462
+ ```javascript
1463
+ const msg = await getOldestMessageInChat(jid)
1464
+ await sock.fetchMessageHistory(
1465
+ 50, //quantity (max: 50 per query)
1466
+ msg.key,
1467
+ msg.messageTimestamp
1468
+ )
1469
+ ```
1470
+ - Messages will be received in `messaging.history-set` event
1471
+
1472
+ <a id="handling-events"></a>
1473
+ ### 📣 Ambil Status
1474
+ ```javascript
1475
+ const status = await sock.fetchStatus(jid)
1476
+ console.log('status: ' + status)
1477
+ ```
1478
+
1479
+ <a id="handling-events"></a>
1480
+ ### 🖼️ Ambil Foto Profil (termasuk grup)
1481
+ - To get the display picture of some person/group
1482
+ ```javascript
1483
+ // for low res picture
1484
+ const ppUrl = await sock.profilePictureUrl(jid)
1485
+ console.log(ppUrl)
1486
+
1487
+ // for high res picture
1488
+ const ppUrl = await sock.profilePictureUrl(jid, 'image')
1489
+ ```
1490
+
1491
+ <a id="handling-events"></a>
1492
+ ### 🏷️ Ambil Profil Bisnis (deskripsi/kategori)
1493
+ ```javascript
1494
+ const profile = await sock.getBusinessProfile(jid)
1495
+ console.log('business description: ' + profile.description + ', category: ' + profile.category)
1496
+ ```
1497
+
1498
+ <a id="handling-events"></a>
1499
+ ### 👀 Ambil Presence Seseorang (sedang mengetik/online)
1500
+ ```javascript
1501
+ // the presence update is fetched and called here
1502
+ sock.ev.on('presence.update', console.log)
1503
+
1504
+ // request updates for a chat
1505
+ await sock.presenceSubscribe(jid)
1506
+ ```
1507
+
1508
+ <a id="handling-events"></a>
1509
+ ## 🧑‍💼 Mengubah Profil
1510
+
1511
+ <a id="handling-events"></a>
1512
+ ### 🧑‍💼 Mengubah Profil Status
1513
+ ```javascript
1514
+ await sock.updateProfileStatus('Hello World!')
1515
+ ```
1516
+ <a id="handling-events"></a>
1517
+ ### 🧑‍💼 Mengubah Profil Name
1518
+ ```javascript
1519
+ await sock.updateProfileName('My name')
1520
+ ```
1521
+ <a id="handling-events"></a>
1522
+ ### 🖼️ Ubah Foto Profil (termasuk grup)
1523
+ - To change your display picture or a group's
1524
+
1525
+ > [!NOTE]
1526
+ > Like media messages, you can pass `{ stream: Stream }` or `{ url: Url }` or `Buffer` directly, you can see more [here](https://baileys.whiskeysockets.io/types/WAMediaUpload.html)
1527
+
1528
+ ```javascript
1529
+ await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
1530
+ ```
1531
+ <a id="handling-events"></a>
1532
+ ### 🗑️ Hapus Foto Profil (termasuk grup)
1533
+ ```javascript
1534
+ await sock.removeProfilePicture(jid)
1535
+ ```
1536
+
1537
+ <a id="handling-events"></a>
1538
+ ## 👥 Grup
1539
+
1540
+ - To change group properties you need to be admin
1541
+
1542
+ <a id="handling-events"></a>
1543
+ ### ➕ Buat Grup
1544
+ ```javascript
1545
+ // title & participants
1546
+ const group = await sock.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '4564@s.whatsapp.net'])
1547
+ console.log('created group with id: ' + group.gid)
1548
+ await sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
1549
+ ```
1550
+ <a id="handling-events"></a>
1551
+ ### ➕/➖ Tambah/Hapus atau Turunkan/Naikkan Status
1552
+ ```javascript
1553
+ // id & people to add to the group (will throw error if it fails)
1554
+ await sock.groupParticipantsUpdate(
1555
+ jid,
1556
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1557
+ 'add' // replace this parameter with 'remove' or 'demote' or 'promote'
1558
+ )
1559
+ ```
1560
+ <a id="handling-events"></a>
1561
+ ### ✏️ Ubah Subjek (Nama)
1562
+ ```javascript
1563
+ await sock.groupUpdateSubject(jid, 'New Subject!')
1564
+ ```
1565
+ <a id="handling-events"></a>
1566
+ ### 📝 Ubah Deskripsi
1567
+ ```javascript
1568
+ await sock.groupUpdateDescription(jid, 'New Description!')
1569
+ ```
1570
+ <a id="handling-events"></a>
1571
+ ### ⚙️ Ubah Pengaturan
1572
+ ```javascript
1573
+ // only allow admins to send messages
1574
+ await sock.groupSettingUpdate(jid, 'announcement')
1575
+ // allow everyone to send messages
1576
+ await sock.groupSettingUpdate(jid, 'not_announcement')
1577
+ // allow everyone to modify the group's settings -- like display picture etc.
1578
+ await sock.groupSettingUpdate(jid, 'unlocked')
1579
+ // only allow admins to modify the group's settings
1580
+ await sock.groupSettingUpdate(jid, 'locked')
1581
+ ```
1582
+ <a id="handling-events"></a>
1583
+ ### 🚪 Keluar Grup
1584
+ ```javascript
1585
+ // will throw error if it fails
1586
+ await sock.groupLeave(jid)
1587
+ ```
1588
+ <a id="handling-events"></a>
1589
+ ### 🔐 Dapatkan Kode Undangan
1590
+ - To create link with code use `'https://chat.whatsapp.com/' + code`
1591
+ ```javascript
1592
+ const code = await sock.groupInviteCode(jid)
1593
+ console.log('group code: ' + code)
1594
+ ```
1595
+ <a id="handling-events"></a>
1596
+ ### 🔄 Cabut Kode Undangan
1597
+ ```javascript
1598
+ const code = await sock.groupRevokeInvite(jid)
1599
+ console.log('New group code: ' + code)
1600
+ ```
1601
+ <a id="handling-events"></a>
1602
+ ### ➿ Bergabung Menggunakan Kode Undangan
1603
+ - Code can't have `https://chat.whatsapp.com/`, only code
1604
+ ```javascript
1605
+ const response = await sock.groupAcceptInvite(code)
1606
+ console.log('joined to: ' + response)
1607
+ ```
1608
+ <a id="handling-events"></a>
1609
+ ### ℹ️ Dapatkan Info Grup lewat Kode Undangan
1610
+ ```javascript
1611
+ const response = await sock.groupGetInviteInfo(code)
1612
+ console.log('group information: ' + response)
1613
+ ```
1614
+ <a id="handling-events"></a>
1615
+ ### 🔎 Query Metadata (peserta, nama, deskripsi...)
1616
+ ```javascript
1617
+ const metadata = await sock.groupMetadata(jid)
1618
+ console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
1619
+ ```
1620
+ <a id="handling-events"></a>
1621
+ ### Join using `groupInviteMessage`
1622
+ ```javascript
1623
+ const response = await sock.groupAcceptInviteV4(jid, groupInviteMessage)
1624
+ console.log('joined to: ' + response)
1625
+ ```
1626
+ <a id="handling-events"></a>
1627
+ ### 📥 Dapatkan Daftar Permintaan Bergabung
1628
+ ```javascript
1629
+ const response = await sock.groupRequestParticipantsList(jid)
1630
+ console.log(response)
1631
+ ```
1632
+ <a id="handling-events"></a>
1633
+ ### ✅/❌ Setuju/Tolak Permintaan Bergabung
1634
+ ```javascript
1635
+ const response = await sock.groupRequestParticipantsUpdate(
1636
+ jid, // group id
1637
+ ['abcd@s.whatsapp.net', 'efgh@s.whatsapp.net'],
1638
+ 'approve' // or 'reject'
1639
+ )
1640
+ console.log(response)
1641
+ ```
1642
+ <a id="handling-events"></a>
1643
+ ### 📚 Dapatkan Semua Metadata Grup yang Diikuti
1644
+ ```javascript
1645
+ const response = await sock.groupFetchAllParticipating()
1646
+ console.log(response)
1647
+ ```
1648
+ <a id="handling-events"></a>
1649
+ ### ⏳ Toggle Ephemeral
1650
+
1651
+ - Ephemeral can be:
1652
+
1653
+ | Time | Seconds |
1654
+ |-------|----------------|
1655
+ | Remove | 0 |
1656
+ | 24h | 86.400 |
1657
+ | 7d | 604.800 |
1658
+ | 90d | 7.776.000 |
1659
+
1660
+ ```javascript
1661
+ await sock.groupToggleEphemeral(jid, 86400)
1662
+ ```
1663
+
1664
+ <a id="handling-events"></a>
1665
+ ### 🔐 Ubah Mode Penambahan
1666
+ ```javascript
1667
+ await sock.groupMemberAddMode(
1668
+ jid,
1669
+ 'all_member_add' // or 'admin_add'
1670
+ )
1671
+ ```
1672
+
1673
+ <a id="handling-events"></a>
1674
+ ## 🔒 Privasi
1675
+
1676
+ <a id="handling-events"></a>
1677
+ ### ⛔/✅ Blokir/Buka Blokir Pengguna
1678
+ ```javascript
1679
+ await sock.updateBlockStatus(jid, 'block') // Block user
1680
+ await sock.updateBlockStatus(jid, 'unblock') // Unblock user
1681
+ ```
1682
+ <a id="handling-events"></a>
1683
+ ### ⚙️ Dapatkan Pengaturan Privasi
1684
+ ```javascript
1685
+ const privacySettings = await sock.fetchPrivacySettings(true)
1686
+ console.log('privacy settings: ' + privacySettings)
1687
+ ```
1688
+ <a id="handling-events"></a>
1689
+ ### 📛 Dapatkan Daftar Blokir
1690
+ ```javascript
1691
+ const response = await sock.fetchBlocklist()
1692
+ console.log(response)
1693
+ ```
1694
+ <a id="handling-events"></a>
1695
+ ### 👀 Update Privasi LastSeen
1696
+ ```javascript
1697
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1698
+ await sock.updateLastSeenPrivacy(value)
1699
+ ```
1700
+ <a id="handling-events"></a>
1701
+ ### 🟢 Update Privasi Online
1702
+ ```javascript
1703
+ const value = 'all' // 'match_last_seen'
1704
+ await sock.updateOnlinePrivacy(value)
1705
+ ```
1706
+ <a id="handling-events"></a>
1707
+ ### 🖼️ Update Privasi Foto Profil
1708
+ ```javascript
1709
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1710
+ await sock.updateProfilePicturePrivacy(value)
1711
+ ```
1712
+ <a id="handling-events"></a>
1713
+ ### 📣 Update Privasi Status
1714
+ ```javascript
1715
+ const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
1716
+ await sock.updateStatusPrivacy(value)
1717
+ ```
1718
+ <a id="handling-events"></a>
1719
+ ### ✅ Update Privasi Read Receipts
1720
+ ```javascript
1721
+ const value = 'all' // 'none'
1722
+ await sock.updateReadReceiptsPrivacy(value)
1723
+ ```
1724
+ <a id="handling-events"></a>
1725
+ ### 👥 Update Privasi Tambah Grup
1726
+ ```javascript
1727
+ const value = 'all' // 'contacts' | 'contact_blacklist'
1728
+ await sock.updateGroupsAddPrivacy(value)
1729
+ ```
1730
+ <a id="handling-events"></a>
1731
+ ### 🕒 Update Mode Default Disappearing
1732
+
1733
+ - Like [this](#disappearing-messages), ephemeral can be:
1734
+
1735
+ | Time | Seconds |
1736
+ |-------|----------------|
1737
+ | Remove | 0 |
1738
+ | 24h | 86.400 |
1739
+ | 7d | 604.800 |
1740
+ | 90d | 7.776.000 |
1741
+
1742
+ ```javascript
1743
+ const ephemeral = 86400
1744
+ await sock.updateDefaultDisappearingMode(ephemeral)
1745
+ ```
1746
+
1747
+ <a id="handling-events"></a>
1748
+ ## 📢 Broadcast & Story
1749
+
1750
+ <a id="handling-events"></a>
1751
+ ### 📤 Kirim Broadcast & Story
1752
+ - Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
1753
+ ```javascript
1754
+ await sock.sendMessage(
1755
+ jid,
1756
+ {
1757
+ image: {
1758
+ url: url
1759
+ },
1760
+ caption: caption
1761
+ },
1762
+ {
1763
+ backgroundColor: backgroundColor,
1764
+ font: font,
1765
+ statusJidList: statusJidList,
1766
+ broadcast: true
1767
+ }
1768
+ )
1769
+ ```
1770
+ - Message body can be a `extendedTextMessage` or `imageMessage` or `videoMessage` or `voiceMessage`, see [here](https://baileys.whiskeysockets.io/types/AnyRegularMessageContent.html)
1771
+ - You can add `backgroundColor` and other options in the message options, see [here](https://baileys.whiskeysockets.io/types/MiscMessageGenerationOptions.html)
1772
+ - `broadcast: true` enables broadcast mode
1773
+ - `statusJidList`: a list of people that you can get which you need to provide, which are the people who will get this status message.
1774
+
1775
+ - You can send messages to broadcast lists the same way you send messages to groups & individual chats.
1776
+ - Right now, WA Web does not support creating broadcast lists, but you can still delete them.
1777
+ - Broadcast IDs are in the format `12345678@broadcast`
1778
+ <a id="handling-events"></a>
1779
+ ### 🔎 Query Penerima & Nama Broadcast List
1780
+ ```javascript
1781
+ const bList = await sock.getBroadcastListInfo('1234@broadcast')
1782
+ console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
1783
+ ```
1784
+
1785
+ <a id="handling-events"></a>
1786
+ ## ✍️ Menulis Fungsionalitas Kustom
1787
+ Baileys is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.
1788
+
1789
+ <a id="handling-events"></a>
1790
+ ### 🐛 Mengaktifkan Level Debug di Log Baileys
1791
+ First, enable the logging of unhandled messages from WhatsApp by setting:
1792
+ ```javascript
1793
+ const sock = makeWASocket({
1794
+ logger: P({ level: 'debug' }),
1795
+ })
1796
+ ```
1797
+ This will enable you to see all sorts of messages WhatsApp sends in the console.
1798
+
1799
+ <a id="handling-events"></a>
1800
+ ### 🔬 Bagaimana WhatsApp Berkomunikasi dengan Kita
1801
+
1802
+ > [!TIP]
1803
+ > If you want to learn whatsapp protocol, we recommend to study about Libsignal Protocol and Noise Protocol
1804
+
1805
+ - **Example:** Functionality to track the battery percentage of your phone. You enable logging and you'll see a message about your battery pop up in the console:
1806
+ ```
1807
+ {
1808
+ "level": 10,
1809
+ "fromMe": false,
1810
+ "frame": {
1811
+ "tag": "ib",
1812
+ "attrs": {
1813
+ "from": "@s.whatsapp.net"
1814
+ },
1815
+ "content": [
1816
+ {
1817
+ "tag": "edge_routing",
1818
+ "attrs": {},
1819
+ "content": [
1820
+ {
1821
+ "tag": "routing_info",
1822
+ "attrs": {},
1823
+ "content": {
1824
+ "type": "Buffer",
1825
+ "data": [8,2,8,5]
1826
+ }
1827
+ }
1828
+ ]
1829
+ }
1830
+ ]
1831
+ },
1832
+ "msg":"communication"
1833
+ }
1834
+ ```
1835
+
1836
+ The `'frame'` is what the message received is, it has three components:
1837
+ - `tag` -- what this frame is about (eg. message will have 'message')
1838
+ - `attrs` -- a string key-value pair with some metadata (contains ID of the message usually)
1839
+ - `content` -- the actual data (eg. a message node will have the actual message content in it)
1840
+ - read more about this format [here](/src/WABinary/readme.md)
1841
+
1842
+ <a id="handling-events"></a>
1843
+ ### 🔁 Mendaftarkan Callback untuk Event Websocket
1844
+
1845
+ > [!TIP]
1846
+ > Recommended to see `onMessageReceived` function in `socket.ts` file to understand how websockets events are fired
1847
+
1848
+ ```javascript
1849
+ // for any message with tag 'edge_routing'
1850
+ sock.ws.on('CB:edge_routing', (node: BinaryNode) => { })
1851
+
1852
+ // for any message with tag 'edge_routing' and id attribute = abcd
1853
+ sock.ws.on('CB:edge_routing,id:abcd', (node: BinaryNode) => { })
1854
+
1855
+ // for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
1856
+ sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })
1857
+ ```
1858
+
1859
+ > [!NOTE]
1860
+ > Also, this repo is now licenced under GPL 3 since it uses [libsignal-node](https://git.questbook.io/backend/service-coderunner/-/merge_requests/1)
1861
+
1862
+
1863
+ <a id="handling-events"></a>
1864
+ ## ⚠️ Catatan
1865
+
1866
+ Proyek ini **tidak berafiliasi dengan WhatsApp Inc.**
1867
+ Gunakan secara bertanggung jawab dan hindari aktivitas ilegal atau penyalahgunaan.
1868
+
1869
+ ---
1870
+
1871
+ <a id="handling-events"></a>
1872
+ ## Lisensi
1873
+
1874
+ 📘 *Documentation powered by jagoan project*
1875
+ 🧑‍💻 **Modified and Presented by Jagoan Project**