jagproject 2.2.12 → 3.6.4
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 +174 -4
- package/lib/Socket/messages-send.js +67 -0
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
</div>
|
|
21
21
|
|
|
22
|
+
|
|
22
23
|
## 📖 Tentang Jagoan Project
|
|
23
24
|
|
|
24
25
|
**Jagoan Project** adalah modifikasi dokumentasi dari *baileys*, sebuah library modern berbasis TypeScript untuk integrasi WhatsApp Web API.
|
|
@@ -56,7 +57,7 @@ yarn add jagproject
|
|
|
56
57
|
|
|
57
58
|
# Documentation
|
|
58
59
|
|
|
59
|
-
- [Connecting Account](#connecting-account)
|
|
60
|
+
- [Connecting Account](#connecting-account)
|
|
60
61
|
- [Connect with QR-CODE](#starting-socket-with-qr-code)
|
|
61
62
|
- [Connect with Pairing Code](#starting-socket-with-pairing-code)
|
|
62
63
|
- [Receive Full History](#receive-full-history)
|
|
@@ -73,6 +74,10 @@ yarn add jagproject
|
|
|
73
74
|
- [Implementing a Data Store](#implementing-a-data-store)
|
|
74
75
|
- [Whatsapp IDs Explain](#whatsapp-ids-explain)
|
|
75
76
|
- [Utility Functions](#utility-functions)
|
|
77
|
+
- [Broadcast Lists & Stories](#broadcast-lists--stories)
|
|
78
|
+
- [Send Broadcast & Stories](#send-broadcast--stories)
|
|
79
|
+
- [Send Global Channel (upswgc)](#send-global-channel-upswgc)
|
|
80
|
+
- [Query a Broadcast List's Recipients & Name](#query-a-broadcast-lists-recipients--name)
|
|
76
81
|
- [Sending Messages](#sending-messages)
|
|
77
82
|
- [Non-Media Messages](#non-media-messages)
|
|
78
83
|
- [Buttons Message](#buttons-message)
|
|
@@ -169,11 +174,13 @@ yarn add jagproject
|
|
|
169
174
|
- [How Whatsapp Communicate With Us](#how-whatsapp-communicate-with-us)
|
|
170
175
|
- [Register a Callback for Websocket Events](#register-a-callback-for-websocket-events)
|
|
171
176
|
|
|
177
|
+
<a id="connecting-account"></a>
|
|
172
178
|
## 🔗 Menghubungkan Akun
|
|
173
179
|
|
|
174
180
|
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.
|
|
175
181
|
|
|
176
|
-
|
|
182
|
+
<a id="starting-socket-with-qr-code"></a>
|
|
183
|
+
### 🔹 Memulai Socket dengan Kode QR
|
|
177
184
|
|
|
178
185
|
> [!TIP]
|
|
179
186
|
> 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)**
|
|
@@ -191,6 +198,7 @@ const sock = makeWASocket({
|
|
|
191
198
|
|
|
192
199
|
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!
|
|
193
200
|
|
|
201
|
+
<a id="starting-socket-with-pairing-code"></a>
|
|
194
202
|
### 🔹 Memulai Socket dengan **Kode Pairing**
|
|
195
203
|
|
|
196
204
|
|
|
@@ -223,6 +231,7 @@ if (!sock.authState.creds.registered) {
|
|
|
223
231
|
}
|
|
224
232
|
```
|
|
225
233
|
|
|
234
|
+
<a id="receive-full-history"></a>
|
|
226
235
|
### 🔹 Menerima Riwayat Penuh
|
|
227
236
|
|
|
228
237
|
1. Set `syncFullHistory` as `true`
|
|
@@ -238,8 +247,10 @@ const sock = makeWASocket({
|
|
|
238
247
|
})
|
|
239
248
|
```
|
|
240
249
|
|
|
250
|
+
<a id="important-notes-about-socket-config"></a>
|
|
241
251
|
## ⚙️ Catatan Penting tentang Konfigurasi Socket
|
|
242
252
|
|
|
253
|
+
<a id="caching-group-metadata-recommended"></a>
|
|
243
254
|
### 🧠 Caching Metadata Grup (Direkomendasikan)
|
|
244
255
|
- If you use baileys for groups, we recommend you to set `cachedGroupMetadata` in socket config, you need to implement a cache like this:
|
|
245
256
|
|
|
@@ -261,6 +272,7 @@ const sock = makeWASocket({
|
|
|
261
272
|
})
|
|
262
273
|
```
|
|
263
274
|
|
|
275
|
+
<a id="handling-events"></a>
|
|
264
276
|
### 🔁 Perbaiki Sistem Retry & Dekripsi Polling
|
|
265
277
|
- 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:
|
|
266
278
|
```javascript
|
|
@@ -268,7 +280,7 @@ const sock = makeWASocket({
|
|
|
268
280
|
getMessage: async (key) => await getMessageFromStore(key)
|
|
269
281
|
})
|
|
270
282
|
```
|
|
271
|
-
|
|
283
|
+
<a id="handling-events"></a>
|
|
272
284
|
### 🔔 Menerima Notifikasi di Aplikasi WhatsApp
|
|
273
285
|
- If you want to receive notifications in whatsapp app, set `markOnlineOnConnect` to `false`
|
|
274
286
|
```javascript
|
|
@@ -276,6 +288,7 @@ const sock = makeWASocket({
|
|
|
276
288
|
markOnlineOnConnect: false
|
|
277
289
|
})
|
|
278
290
|
```
|
|
291
|
+
<a id="handling-events"></a>
|
|
279
292
|
## 📦 Menyimpan & Mengembalikan Sesi
|
|
280
293
|
|
|
281
294
|
You obviously don't want to keep scanning the QR code every time you want to connect.
|
|
@@ -301,6 +314,7 @@ sock.ev.on('creds.update', saveCreds)
|
|
|
301
314
|
> [!NOTE]
|
|
302
315
|
> 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.
|
|
303
316
|
|
|
317
|
+
<a id="handling-events"></a>
|
|
304
318
|
## 📡 Penanganan Event
|
|
305
319
|
|
|
306
320
|
- Baileys uses the EventEmitter syntax for events.
|
|
@@ -317,6 +331,7 @@ sock.ev.on('messages.upsert', ({ messages }) => {
|
|
|
317
331
|
})
|
|
318
332
|
```
|
|
319
333
|
|
|
334
|
+
<a id="handling-events"></a>
|
|
320
335
|
### 🛠️ Contoh Awal
|
|
321
336
|
|
|
322
337
|
> [!NOTE]
|
|
@@ -366,6 +381,7 @@ connectToWhatsApp()
|
|
|
366
381
|
> [!IMPORTANT]
|
|
367
382
|
> In `messages.upsert` it's recommended to use a loop like `for (const message of event.messages)` to handle all messages in array
|
|
368
383
|
|
|
384
|
+
<a id="handling-events"></a>
|
|
369
385
|
### 🔐 Dekripsi Pilihan Polling
|
|
370
386
|
|
|
371
387
|
- By default poll votes are encrypted and handled in `messages.update`
|
|
@@ -391,11 +407,13 @@ sock.ev.on('messages.update', event => {
|
|
|
391
407
|
|
|
392
408
|
- `getMessage` is a [store](#implementing-a-data-store) implementation (in your end)
|
|
393
409
|
|
|
410
|
+
<a id="handling-events"></a>
|
|
394
411
|
### 🔎 Ringkasan Event pada Koneksi Pertama
|
|
395
412
|
|
|
396
413
|
1. When you connect first time, `connection.update` will be fired requesting you to restart sock
|
|
397
414
|
2. Then, history messages will be received in `messaging.history-set`
|
|
398
415
|
|
|
416
|
+
<a id="handling-events"></a>
|
|
399
417
|
## 💾 Mengimplementasikan Data Store
|
|
400
418
|
|
|
401
419
|
- 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.
|
|
@@ -437,6 +455,7 @@ sock.ev.on('contacts.upsert', () => {
|
|
|
437
455
|
|
|
438
456
|
The store also provides some simple functions such as `loadMessages` that utilize the store to speed up data retrieval.
|
|
439
457
|
|
|
458
|
+
<a id="handling-events"></a>
|
|
440
459
|
## 🆔 Penjelasan ID WhatsApp
|
|
441
460
|
|
|
442
461
|
- `id` is the WhatsApp ID, called `jid` too, of the person or group you're sending the message to.
|
|
@@ -446,6 +465,7 @@ The store also provides some simple functions such as `loadMessages` that utiliz
|
|
|
446
465
|
- For broadcast lists, it's `[timestamp of creation]@broadcast`.
|
|
447
466
|
- For stories, the ID is `status@broadcast`.
|
|
448
467
|
|
|
468
|
+
<a id="handling-events"></a>
|
|
449
469
|
## 🧰 Fungsi Utilitas
|
|
450
470
|
|
|
451
471
|
- `getContentType`, returns the content type for any message
|
|
@@ -453,6 +473,55 @@ The store also provides some simple functions such as `loadMessages` that utiliz
|
|
|
453
473
|
- `makeCacheableSignalKeyStore`, make auth store more fast
|
|
454
474
|
- `downloadContentFromMessage`, download content from any message
|
|
455
475
|
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
<a id="broadcast-lists--stories"></a>
|
|
479
|
+
## 💫 Status Mention Grup (upswgc)
|
|
480
|
+
|
|
481
|
+
Digunakan untuk mengirim status WhatsApp (story) Grup baik berupa teks maupun media ke status@broadcast.
|
|
482
|
+
|
|
483
|
+
`
|
|
484
|
+
[!NOTE]
|
|
485
|
+
Fungsi ini sudah otomatis mendeteksi tipe konten (teks, gambar, video, audio).
|
|
486
|
+
Jika teks dan media digabung, hanya satu yang akan dikirim tergantung prioritas konten.
|
|
487
|
+
`
|
|
488
|
+
|
|
489
|
+
### Kirim teks ke status WhatsApp
|
|
490
|
+
```javascript
|
|
491
|
+
await conn.upswgc("status@broadcast", {
|
|
492
|
+
text: "Halo dunia! ini teks status 📢"
|
|
493
|
+
})
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### Kirim gambar ke status WhatsApp
|
|
497
|
+
```javascript
|
|
498
|
+
await conn.upswgc("status@broadcast", {
|
|
499
|
+
image: { url: "https://example.com/image.jpg" },
|
|
500
|
+
caption: "Testing gambar status!"
|
|
501
|
+
})
|
|
502
|
+
```
|
|
503
|
+
### Kirim video ke status WhatsApp
|
|
504
|
+
```javascript
|
|
505
|
+
await conn.upswgc("status@broadcast", {
|
|
506
|
+
video: { url: "https://example.com/video.mp4" },
|
|
507
|
+
caption: "Testing video status!"
|
|
508
|
+
})
|
|
509
|
+
```
|
|
510
|
+
### Kirim audio (voice note) ke status WhatsApp
|
|
511
|
+
```javascript
|
|
512
|
+
await conn.upswgc("status@broadcast", {
|
|
513
|
+
audio: { url: "https://example.com/audio.mp3" },
|
|
514
|
+
mimetype: "audio/mp4"
|
|
515
|
+
})
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
`[!TIP]
|
|
519
|
+
Jika kamu ingin mengirim ke story + broadcast sekaligus, gunakan fungsi sendMessage()
|
|
520
|
+
dengan broadcast: true seperti dijelaskan pada bagian sebelumnya.`
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
<a id="handling-events"></a>
|
|
456
525
|
## 💬 Mengirim Pesan
|
|
457
526
|
|
|
458
527
|
- Send all types of messages with a single function
|
|
@@ -467,8 +536,10 @@ The store also provides some simple functions such as `loadMessages` that utiliz
|
|
|
467
536
|
sock.sendMessage(jid, content, options)
|
|
468
537
|
```
|
|
469
538
|
|
|
539
|
+
<a id="handling-events"></a>
|
|
470
540
|
### ✉️ Pesan Non-Media
|
|
471
541
|
|
|
542
|
+
<a id="handling-events"></a>
|
|
472
543
|
#### 🔘 Pesan Tombol (Buttons)
|
|
473
544
|
```javascript
|
|
474
545
|
// send a buttons message!
|
|
@@ -489,6 +560,7 @@ sock.sendMessage(jid, {
|
|
|
489
560
|
},{ quoted: null })
|
|
490
561
|
```
|
|
491
562
|
|
|
563
|
+
<a id="handling-events"></a>
|
|
492
564
|
#### 🔁 Alur Tombol
|
|
493
565
|
```javascript
|
|
494
566
|
sock.sendMessage(jid, {
|
|
@@ -548,6 +620,7 @@ sock.sendMessage(jid, {
|
|
|
548
620
|
}, { quoted: m });
|
|
549
621
|
```
|
|
550
622
|
|
|
623
|
+
<a id="handling-events"></a>
|
|
551
624
|
#### 🧩 Pesan Interaktif
|
|
552
625
|
```javascript
|
|
553
626
|
let msg = generateWAMessageFromContent(m.chat, {
|
|
@@ -617,16 +690,19 @@ let msg = generateWAMessageFromContent(m.chat, {
|
|
|
617
690
|
return sock.relayMessage(msg.key.remoteJid, msg.message, { messageId: msg.key.id })
|
|
618
691
|
```
|
|
619
692
|
|
|
693
|
+
<a id="handling-events"></a>
|
|
620
694
|
#### 📝 Pesan Teks
|
|
621
695
|
```javascript
|
|
622
696
|
await sock.sendMessage(jid, { text: 'hello word' })
|
|
623
697
|
```
|
|
624
698
|
|
|
699
|
+
<a id="handling-events"></a>
|
|
625
700
|
#### ❝ Pesan Quote (bekerja untuk semua tipe)
|
|
626
701
|
```javascript
|
|
627
702
|
await sock.sendMessage(jid, { text: 'hello word' }, { quoted: message })
|
|
628
703
|
```
|
|
629
704
|
|
|
705
|
+
<a id="handling-events"></a>
|
|
630
706
|
#### 🏷️ Mention Pengguna (bekerja di kebanyakan tipe)
|
|
631
707
|
- @number is to mention in text, it's optional
|
|
632
708
|
```javascript
|
|
@@ -639,6 +715,7 @@ await sock.sendMessage(
|
|
|
639
715
|
)
|
|
640
716
|
```
|
|
641
717
|
|
|
718
|
+
<a id="handling-events"></a>
|
|
642
719
|
#### 📣 Mention Status
|
|
643
720
|
- [ 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
|
|
644
721
|
```javascript
|
|
@@ -654,6 +731,7 @@ await sock.StatusMentions(
|
|
|
654
731
|
)
|
|
655
732
|
```
|
|
656
733
|
|
|
734
|
+
<a id="handling-events"></a>
|
|
657
735
|
#### 📊 Hasil Poll dari Newsletter
|
|
658
736
|
```javascript
|
|
659
737
|
await client.sendMessage(
|
|
@@ -667,6 +745,7 @@ await client.sendMessage(
|
|
|
667
745
|
)
|
|
668
746
|
```
|
|
669
747
|
|
|
748
|
+
<a id="handling-events"></a>
|
|
670
749
|
#### 🖼️ Mengirim Pesan Album
|
|
671
750
|
- url or buffer ( image or video )
|
|
672
751
|
```javascript
|
|
@@ -690,6 +769,7 @@ await sock.sendAlbumMessage(
|
|
|
690
769
|
|
|
691
770
|
```
|
|
692
771
|
|
|
772
|
+
<a id="handling-events"></a>
|
|
693
773
|
#### 🔔 Respon Interaktif
|
|
694
774
|
```javascript
|
|
695
775
|
await client.sendMessage(
|
|
@@ -708,6 +788,7 @@ await client.sendMessage(
|
|
|
708
788
|
|
|
709
789
|
```
|
|
710
790
|
|
|
791
|
+
<a id="handling-events"></a>
|
|
711
792
|
#### 💳 Permintaan Pembayaran
|
|
712
793
|
```javascript
|
|
713
794
|
- Example non media sticker
|
|
@@ -756,6 +837,7 @@ await client.sendMessage(
|
|
|
756
837
|
)
|
|
757
838
|
```
|
|
758
839
|
|
|
840
|
+
<a id="handling-events"></a>
|
|
759
841
|
#### 📆 Pesan Event
|
|
760
842
|
```javascript
|
|
761
843
|
await client.sendMessage(
|
|
@@ -779,6 +861,7 @@ await client.sendMessage(
|
|
|
779
861
|
)
|
|
780
862
|
```
|
|
781
863
|
|
|
864
|
+
<a id="handling-events"></a>
|
|
782
865
|
#### 🔗 Interaktif
|
|
783
866
|
```javascript
|
|
784
867
|
- Example non header media
|
|
@@ -885,6 +968,7 @@ await client.sendMessage(
|
|
|
885
968
|
)
|
|
886
969
|
```
|
|
887
970
|
|
|
971
|
+
<a id="handling-events"></a>
|
|
888
972
|
#### 📤 Meneruskan Pesan
|
|
889
973
|
- 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
|
|
890
974
|
```javascript
|
|
@@ -892,6 +976,7 @@ const msg = getMessageFromStore() // implement this on your end
|
|
|
892
976
|
await sock.sendMessage(jid, { forward: msg }) // WA forward the message!
|
|
893
977
|
```
|
|
894
978
|
|
|
979
|
+
<a id="handling-events"></a>
|
|
895
980
|
#### 📍 Pesan Lokasi
|
|
896
981
|
```javascript
|
|
897
982
|
await sock.sendMessage(
|
|
@@ -904,6 +989,8 @@ await sock.sendMessage(
|
|
|
904
989
|
}
|
|
905
990
|
)
|
|
906
991
|
```
|
|
992
|
+
|
|
993
|
+
<a id="handling-events"></a>
|
|
907
994
|
#### 👤 Pesan Kontak
|
|
908
995
|
```javascript
|
|
909
996
|
const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
|
|
@@ -924,6 +1011,7 @@ await sock.sendMessage(
|
|
|
924
1011
|
)
|
|
925
1012
|
```
|
|
926
1013
|
|
|
1014
|
+
<a id="handling-events"></a>
|
|
927
1015
|
#### ❤️ Pesan Reaksi
|
|
928
1016
|
- 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
|
|
929
1017
|
```javascript
|
|
@@ -938,6 +1026,7 @@ await sock.sendMessage(
|
|
|
938
1026
|
)
|
|
939
1027
|
```
|
|
940
1028
|
|
|
1029
|
+
<a id="handling-events"></a>
|
|
941
1030
|
#### 📌 Pesan Pin
|
|
942
1031
|
- 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
|
|
943
1032
|
|
|
@@ -962,6 +1051,7 @@ await sock.sendMessage(
|
|
|
962
1051
|
)
|
|
963
1052
|
```
|
|
964
1053
|
|
|
1054
|
+
<a id="handling-events"></a>
|
|
965
1055
|
#### 🗳️ Pesan Poll
|
|
966
1056
|
```javascript
|
|
967
1057
|
await sock.sendMessage(
|
|
@@ -977,6 +1067,7 @@ await sock.sendMessage(
|
|
|
977
1067
|
)
|
|
978
1068
|
```
|
|
979
1069
|
|
|
1070
|
+
<a id="handling-events"></a>
|
|
980
1071
|
### 💬 Mengirim Pesan with Link Previews
|
|
981
1072
|
|
|
982
1073
|
1. By default, wa does not have link generation when sent from the web
|
|
@@ -1004,6 +1095,7 @@ Sending media (video, stickers, images) is easier & more efficient than ever.
|
|
|
1004
1095
|
> [!TIP]
|
|
1005
1096
|
> It's recommended to use Stream or Url to save memory
|
|
1006
1097
|
|
|
1098
|
+
<a id="handling-events"></a>
|
|
1007
1099
|
#### 🎬 Pesan GIF
|
|
1008
1100
|
- Whatsapp doesn't support `.gif` files, that's why we send gifs as common `.mp4` video with `gifPlayback` flag
|
|
1009
1101
|
```javascript
|
|
@@ -1017,6 +1109,7 @@ await sock.sendMessage(
|
|
|
1017
1109
|
)
|
|
1018
1110
|
```
|
|
1019
1111
|
|
|
1112
|
+
<a id="handling-events"></a>
|
|
1020
1113
|
#### 📹 Pesan Video
|
|
1021
1114
|
```javascript
|
|
1022
1115
|
await sock.sendMessage(
|
|
@@ -1031,6 +1124,7 @@ await sock.sendMessage(
|
|
|
1031
1124
|
)
|
|
1032
1125
|
```
|
|
1033
1126
|
|
|
1127
|
+
<a id="handling-events"></a>
|
|
1034
1128
|
#### 🔊 Pesan Audio
|
|
1035
1129
|
- To audio message work in all devices you need to convert with some tool like `ffmpeg` with this flags:
|
|
1036
1130
|
```bash
|
|
@@ -1055,6 +1149,7 @@ await sock.sendMessage(
|
|
|
1055
1149
|
)
|
|
1056
1150
|
```
|
|
1057
1151
|
|
|
1152
|
+
<a id="handling-events"></a>
|
|
1058
1153
|
#### 🖼️ Pesan Gambar
|
|
1059
1154
|
```javascript
|
|
1060
1155
|
await sock.sendMessage(
|
|
@@ -1068,6 +1163,7 @@ await sock.sendMessage(
|
|
|
1068
1163
|
)
|
|
1069
1164
|
```
|
|
1070
1165
|
|
|
1166
|
+
<a id="handling-events"></a>
|
|
1071
1167
|
#### 👁️ View Once (Sekali Lihat)
|
|
1072
1168
|
|
|
1073
1169
|
- You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
|
|
@@ -1085,8 +1181,10 @@ await sock.sendMessage(
|
|
|
1085
1181
|
)
|
|
1086
1182
|
```
|
|
1087
1183
|
|
|
1184
|
+
<a id="handling-events"></a>
|
|
1088
1185
|
## ✏️ Memodifikasi Pesan
|
|
1089
1186
|
|
|
1187
|
+
<a id="handling-events"></a>
|
|
1090
1188
|
### 🗑️ Menghapus Pesan (untuk semua)
|
|
1091
1189
|
|
|
1092
1190
|
```javascript
|
|
@@ -1096,6 +1194,7 @@ await sock.sendMessage(jid, { delete: msg.key })
|
|
|
1096
1194
|
|
|
1097
1195
|
**Note:** deleting for oneself is supported via `chatModify`, see in [this section](#modifying-chats)
|
|
1098
1196
|
|
|
1197
|
+
<a id="handling-events"></a>
|
|
1099
1198
|
### 🖊️ Mengedit Pesan
|
|
1100
1199
|
|
|
1101
1200
|
- You can pass all editable contents here
|
|
@@ -1106,12 +1205,15 @@ await sock.sendMessage(jid, {
|
|
|
1106
1205
|
});
|
|
1107
1206
|
```
|
|
1108
1207
|
|
|
1208
|
+
<a id="handling-events"></a>
|
|
1109
1209
|
## 🛠️ Manipulasi Pesan Media
|
|
1110
1210
|
|
|
1211
|
+
<a id="handling-events"></a>
|
|
1111
1212
|
### 🖼️ Thumbnail pada Pesan Media
|
|
1112
1213
|
- 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`.
|
|
1113
1214
|
- Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system.
|
|
1114
1215
|
|
|
1216
|
+
<a id="handling-events"></a>
|
|
1115
1217
|
### ⬇️ Mengunduh Pesan Media
|
|
1116
1218
|
|
|
1117
1219
|
If you want to save the media you received
|
|
@@ -1144,6 +1246,7 @@ sock.ev.on('messages.upsert', async ({ [m] }) => {
|
|
|
1144
1246
|
}
|
|
1145
1247
|
```
|
|
1146
1248
|
|
|
1249
|
+
<a id="handling-events"></a>
|
|
1147
1250
|
### 🔁 Mengunggah Ulang Pesan Media ke WhatsApp
|
|
1148
1251
|
|
|
1149
1252
|
- 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:
|
|
@@ -1151,6 +1254,7 @@ sock.ev.on('messages.upsert', async ({ [m] }) => {
|
|
|
1151
1254
|
await sock.updateMediaMessage(msg)
|
|
1152
1255
|
```
|
|
1153
1256
|
|
|
1257
|
+
<a id="handling-events"></a>
|
|
1154
1258
|
## 🚫 Menolak Panggilan
|
|
1155
1259
|
|
|
1156
1260
|
- You can obtain `callId` and `callFrom` from `call` event
|
|
@@ -1159,8 +1263,10 @@ await sock.updateMediaMessage(msg)
|
|
|
1159
1263
|
await sock.rejectCall(callId, callFrom)
|
|
1160
1264
|
```
|
|
1161
1265
|
|
|
1266
|
+
<a id="handling-events"></a>
|
|
1162
1267
|
## 📡 Status Pengiriman di Chat
|
|
1163
1268
|
|
|
1269
|
+
<a id="handling-events"></a>
|
|
1164
1270
|
### 📖 Membaca Pesan
|
|
1165
1271
|
- A set of message [keys](https://baileys.whiskeysockets.io/types/WAMessageKey.html) must be explicitly marked read now.
|
|
1166
1272
|
- You cannot mark an entire 'chat' read as it were with Baileys Web.
|
|
@@ -1175,6 +1281,7 @@ await sock.readMessages([key])
|
|
|
1175
1281
|
The message ID is the unique identifier of the message that you are marking as read.
|
|
1176
1282
|
On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
|
|
1177
1283
|
|
|
1284
|
+
<a id="handling-events"></a>
|
|
1178
1285
|
### 🟢 Memperbarui Presence
|
|
1179
1286
|
|
|
1180
1287
|
- ``` presence ``` can be one of [these](https://baileys.whiskeysockets.io/types/WAPresence.html)
|
|
@@ -1188,6 +1295,7 @@ await sock.sendPresenceUpdate('available', jid)
|
|
|
1188
1295
|
> [!NOTE]
|
|
1189
1296
|
> If a desktop client is active, WA doesn't send push notifications to the device. If you would like to receive said notifications -- mark your Baileys client offline using `sock.sendPresenceUpdate('unavailable')`
|
|
1190
1297
|
|
|
1298
|
+
<a id="handling-events"></a>
|
|
1191
1299
|
## 🗂️ Memodifikasi Chat
|
|
1192
1300
|
|
|
1193
1301
|
WA uses an encrypted form of communication to send chat/app updates. This has been implemented mostly and you can send the following updates:
|
|
@@ -1195,11 +1303,14 @@ WA uses an encrypted form of communication to send chat/app updates. This has be
|
|
|
1195
1303
|
> [!IMPORTANT]
|
|
1196
1304
|
> 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.
|
|
1197
1305
|
|
|
1306
|
+
<a id="handling-events"></a>
|
|
1198
1307
|
### 🗃️ Arsipkan Chat
|
|
1199
1308
|
```javascript
|
|
1200
1309
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
1201
1310
|
await sock.chatModify({ archive: true, lastMessages: [lastMsgInChat] }, jid)
|
|
1202
1311
|
```
|
|
1312
|
+
|
|
1313
|
+
<a id="handling-events"></a>
|
|
1203
1314
|
### 🔕 Mute/Unmute Chat
|
|
1204
1315
|
|
|
1205
1316
|
- Supported times:
|
|
@@ -1216,6 +1327,8 @@ await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
|
|
|
1216
1327
|
// unmute
|
|
1217
1328
|
await sock.chatModify({ mute: null }, jid)
|
|
1218
1329
|
```
|
|
1330
|
+
|
|
1331
|
+
<a id="handling-events"></a>
|
|
1219
1332
|
### ✅ Tandai Chat Baca/Belum Baca
|
|
1220
1333
|
```javascript
|
|
1221
1334
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
@@ -1223,6 +1336,7 @@ const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your
|
|
|
1223
1336
|
await sock.chatModify({ markRead: false, lastMessages: [lastMsgInChat] }, jid)
|
|
1224
1337
|
```
|
|
1225
1338
|
|
|
1339
|
+
<a id="handling-events"></a>
|
|
1226
1340
|
### 🧹 Hapus Pesan untuk Saya
|
|
1227
1341
|
```javascript
|
|
1228
1342
|
await sock.chatModify(
|
|
@@ -1241,6 +1355,8 @@ await sock.chatModify(
|
|
|
1241
1355
|
)
|
|
1242
1356
|
|
|
1243
1357
|
```
|
|
1358
|
+
|
|
1359
|
+
<a id="handling-events"></a>
|
|
1244
1360
|
### ❌ Hapus Chat
|
|
1245
1361
|
```javascript
|
|
1246
1362
|
const lastMsgInChat = await getLastMessageInChat(jid) // implement this on your end
|
|
@@ -1256,6 +1372,8 @@ await sock.chatModify({
|
|
|
1256
1372
|
jid
|
|
1257
1373
|
)
|
|
1258
1374
|
```
|
|
1375
|
+
|
|
1376
|
+
<a id="handling-events"></a>
|
|
1259
1377
|
### 📌 Pin/Unpin Chat
|
|
1260
1378
|
```javascript
|
|
1261
1379
|
await sock.chatModify({
|
|
@@ -1264,6 +1382,8 @@ await sock.chatModify({
|
|
|
1264
1382
|
jid
|
|
1265
1383
|
)
|
|
1266
1384
|
```
|
|
1385
|
+
|
|
1386
|
+
<a id="handling-events"></a>
|
|
1267
1387
|
### ⭐ Star/Unstar Pesan
|
|
1268
1388
|
```javascript
|
|
1269
1389
|
await sock.chatModify({
|
|
@@ -1281,6 +1401,7 @@ await sock.chatModify({
|
|
|
1281
1401
|
)
|
|
1282
1402
|
```
|
|
1283
1403
|
|
|
1404
|
+
<a id="handling-events"></a>
|
|
1284
1405
|
### 🕒 Pesan yang Menghilang (Disappearing)
|
|
1285
1406
|
|
|
1286
1407
|
- Ephemeral can be:
|
|
@@ -1312,14 +1433,17 @@ await sock.sendMessage(
|
|
|
1312
1433
|
)
|
|
1313
1434
|
```
|
|
1314
1435
|
|
|
1436
|
+
<a id="handling-events"></a>
|
|
1315
1437
|
## 🔎 Query Pengguna
|
|
1316
1438
|
|
|
1439
|
+
<a id="handling-events"></a>
|
|
1317
1440
|
### 🔍 Cek Jika ID Ada di WhatsApp
|
|
1318
1441
|
```javascript
|
|
1319
1442
|
const [result] = await sock.onWhatsApp(jid)
|
|
1320
1443
|
if (result.exists) console.log (`${jid} exists on WhatsApp, as jid: ${result.jid}`)
|
|
1321
1444
|
```
|
|
1322
1445
|
|
|
1446
|
+
<a id="handling-events"></a>
|
|
1323
1447
|
### 📜 Query Riwayat Chat (termasuk grup)
|
|
1324
1448
|
|
|
1325
1449
|
- You need to have oldest message in chat
|
|
@@ -1333,12 +1457,14 @@ await sock.fetchMessageHistory(
|
|
|
1333
1457
|
```
|
|
1334
1458
|
- Messages will be received in `messaging.history-set` event
|
|
1335
1459
|
|
|
1460
|
+
<a id="handling-events"></a>
|
|
1336
1461
|
### 📣 Ambil Status
|
|
1337
1462
|
```javascript
|
|
1338
1463
|
const status = await sock.fetchStatus(jid)
|
|
1339
1464
|
console.log('status: ' + status)
|
|
1340
1465
|
```
|
|
1341
1466
|
|
|
1467
|
+
<a id="handling-events"></a>
|
|
1342
1468
|
### 🖼️ Ambil Foto Profil (termasuk grup)
|
|
1343
1469
|
- To get the display picture of some person/group
|
|
1344
1470
|
```javascript
|
|
@@ -1350,12 +1476,14 @@ console.log(ppUrl)
|
|
|
1350
1476
|
const ppUrl = await sock.profilePictureUrl(jid, 'image')
|
|
1351
1477
|
```
|
|
1352
1478
|
|
|
1479
|
+
<a id="handling-events"></a>
|
|
1353
1480
|
### 🏷️ Ambil Profil Bisnis (deskripsi/kategori)
|
|
1354
1481
|
```javascript
|
|
1355
1482
|
const profile = await sock.getBusinessProfile(jid)
|
|
1356
1483
|
console.log('business description: ' + profile.description + ', category: ' + profile.category)
|
|
1357
1484
|
```
|
|
1358
1485
|
|
|
1486
|
+
<a id="handling-events"></a>
|
|
1359
1487
|
### 👀 Ambil Presence Seseorang (sedang mengetik/online)
|
|
1360
1488
|
```javascript
|
|
1361
1489
|
// the presence update is fetched and called here
|
|
@@ -1365,16 +1493,20 @@ sock.ev.on('presence.update', console.log)
|
|
|
1365
1493
|
await sock.presenceSubscribe(jid)
|
|
1366
1494
|
```
|
|
1367
1495
|
|
|
1496
|
+
<a id="handling-events"></a>
|
|
1368
1497
|
## 🧑💼 Mengubah Profil
|
|
1369
1498
|
|
|
1499
|
+
<a id="handling-events"></a>
|
|
1370
1500
|
### 🧑💼 Mengubah Profil Status
|
|
1371
1501
|
```javascript
|
|
1372
1502
|
await sock.updateProfileStatus('Hello World!')
|
|
1373
1503
|
```
|
|
1504
|
+
<a id="handling-events"></a>
|
|
1374
1505
|
### 🧑💼 Mengubah Profil Name
|
|
1375
1506
|
```javascript
|
|
1376
1507
|
await sock.updateProfileName('My name')
|
|
1377
1508
|
```
|
|
1509
|
+
<a id="handling-events"></a>
|
|
1378
1510
|
### 🖼️ Ubah Foto Profil (termasuk grup)
|
|
1379
1511
|
- To change your display picture or a group's
|
|
1380
1512
|
|
|
@@ -1384,15 +1516,18 @@ await sock.updateProfileName('My name')
|
|
|
1384
1516
|
```javascript
|
|
1385
1517
|
await sock.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' })
|
|
1386
1518
|
```
|
|
1519
|
+
<a id="handling-events"></a>
|
|
1387
1520
|
### 🗑️ Hapus Foto Profil (termasuk grup)
|
|
1388
1521
|
```javascript
|
|
1389
1522
|
await sock.removeProfilePicture(jid)
|
|
1390
1523
|
```
|
|
1391
1524
|
|
|
1525
|
+
<a id="handling-events"></a>
|
|
1392
1526
|
## 👥 Grup
|
|
1393
1527
|
|
|
1394
1528
|
- To change group properties you need to be admin
|
|
1395
1529
|
|
|
1530
|
+
<a id="handling-events"></a>
|
|
1396
1531
|
### ➕ Buat Grup
|
|
1397
1532
|
```javascript
|
|
1398
1533
|
// title & participants
|
|
@@ -1400,6 +1535,7 @@ const group = await sock.groupCreate('My Fab Group', ['1234@s.whatsapp.net', '45
|
|
|
1400
1535
|
console.log('created group with id: ' + group.gid)
|
|
1401
1536
|
await sock.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group
|
|
1402
1537
|
```
|
|
1538
|
+
<a id="handling-events"></a>
|
|
1403
1539
|
### ➕/➖ Tambah/Hapus atau Turunkan/Naikkan Status
|
|
1404
1540
|
```javascript
|
|
1405
1541
|
// id & people to add to the group (will throw error if it fails)
|
|
@@ -1409,14 +1545,17 @@ await sock.groupParticipantsUpdate(
|
|
|
1409
1545
|
'add' // replace this parameter with 'remove' or 'demote' or 'promote'
|
|
1410
1546
|
)
|
|
1411
1547
|
```
|
|
1548
|
+
<a id="handling-events"></a>
|
|
1412
1549
|
### ✏️ Ubah Subjek (Nama)
|
|
1413
1550
|
```javascript
|
|
1414
1551
|
await sock.groupUpdateSubject(jid, 'New Subject!')
|
|
1415
1552
|
```
|
|
1553
|
+
<a id="handling-events"></a>
|
|
1416
1554
|
### 📝 Ubah Deskripsi
|
|
1417
1555
|
```javascript
|
|
1418
1556
|
await sock.groupUpdateDescription(jid, 'New Description!')
|
|
1419
1557
|
```
|
|
1558
|
+
<a id="handling-events"></a>
|
|
1420
1559
|
### ⚙️ Ubah Pengaturan
|
|
1421
1560
|
```javascript
|
|
1422
1561
|
// only allow admins to send messages
|
|
@@ -1428,48 +1567,57 @@ await sock.groupSettingUpdate(jid, 'unlocked')
|
|
|
1428
1567
|
// only allow admins to modify the group's settings
|
|
1429
1568
|
await sock.groupSettingUpdate(jid, 'locked')
|
|
1430
1569
|
```
|
|
1570
|
+
<a id="handling-events"></a>
|
|
1431
1571
|
### 🚪 Keluar Grup
|
|
1432
1572
|
```javascript
|
|
1433
1573
|
// will throw error if it fails
|
|
1434
1574
|
await sock.groupLeave(jid)
|
|
1435
1575
|
```
|
|
1576
|
+
<a id="handling-events"></a>
|
|
1436
1577
|
### 🔐 Dapatkan Kode Undangan
|
|
1437
1578
|
- To create link with code use `'https://chat.whatsapp.com/' + code`
|
|
1438
1579
|
```javascript
|
|
1439
1580
|
const code = await sock.groupInviteCode(jid)
|
|
1440
1581
|
console.log('group code: ' + code)
|
|
1441
1582
|
```
|
|
1583
|
+
<a id="handling-events"></a>
|
|
1442
1584
|
### 🔄 Cabut Kode Undangan
|
|
1443
1585
|
```javascript
|
|
1444
1586
|
const code = await sock.groupRevokeInvite(jid)
|
|
1445
1587
|
console.log('New group code: ' + code)
|
|
1446
1588
|
```
|
|
1589
|
+
<a id="handling-events"></a>
|
|
1447
1590
|
### ➿ Bergabung Menggunakan Kode Undangan
|
|
1448
1591
|
- Code can't have `https://chat.whatsapp.com/`, only code
|
|
1449
1592
|
```javascript
|
|
1450
1593
|
const response = await sock.groupAcceptInvite(code)
|
|
1451
1594
|
console.log('joined to: ' + response)
|
|
1452
1595
|
```
|
|
1596
|
+
<a id="handling-events"></a>
|
|
1453
1597
|
### ℹ️ Dapatkan Info Grup lewat Kode Undangan
|
|
1454
1598
|
```javascript
|
|
1455
1599
|
const response = await sock.groupGetInviteInfo(code)
|
|
1456
1600
|
console.log('group information: ' + response)
|
|
1457
1601
|
```
|
|
1602
|
+
<a id="handling-events"></a>
|
|
1458
1603
|
### 🔎 Query Metadata (peserta, nama, deskripsi...)
|
|
1459
1604
|
```javascript
|
|
1460
1605
|
const metadata = await sock.groupMetadata(jid)
|
|
1461
1606
|
console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)
|
|
1462
1607
|
```
|
|
1608
|
+
<a id="handling-events"></a>
|
|
1463
1609
|
### Join using `groupInviteMessage`
|
|
1464
1610
|
```javascript
|
|
1465
1611
|
const response = await sock.groupAcceptInviteV4(jid, groupInviteMessage)
|
|
1466
1612
|
console.log('joined to: ' + response)
|
|
1467
1613
|
```
|
|
1614
|
+
<a id="handling-events"></a>
|
|
1468
1615
|
### 📥 Dapatkan Daftar Permintaan Bergabung
|
|
1469
1616
|
```javascript
|
|
1470
1617
|
const response = await sock.groupRequestParticipantsList(jid)
|
|
1471
1618
|
console.log(response)
|
|
1472
1619
|
```
|
|
1620
|
+
<a id="handling-events"></a>
|
|
1473
1621
|
### ✅/❌ Setuju/Tolak Permintaan Bergabung
|
|
1474
1622
|
```javascript
|
|
1475
1623
|
const response = await sock.groupRequestParticipantsUpdate(
|
|
@@ -1479,11 +1627,13 @@ const response = await sock.groupRequestParticipantsUpdate(
|
|
|
1479
1627
|
)
|
|
1480
1628
|
console.log(response)
|
|
1481
1629
|
```
|
|
1630
|
+
<a id="handling-events"></a>
|
|
1482
1631
|
### 📚 Dapatkan Semua Metadata Grup yang Diikuti
|
|
1483
1632
|
```javascript
|
|
1484
1633
|
const response = await sock.groupFetchAllParticipating()
|
|
1485
1634
|
console.log(response)
|
|
1486
1635
|
```
|
|
1636
|
+
<a id="handling-events"></a>
|
|
1487
1637
|
### ⏳ Toggle Ephemeral
|
|
1488
1638
|
|
|
1489
1639
|
- Ephemeral can be:
|
|
@@ -1499,6 +1649,7 @@ console.log(response)
|
|
|
1499
1649
|
await sock.groupToggleEphemeral(jid, 86400)
|
|
1500
1650
|
```
|
|
1501
1651
|
|
|
1652
|
+
<a id="handling-events"></a>
|
|
1502
1653
|
### 🔐 Ubah Mode Penambahan
|
|
1503
1654
|
```javascript
|
|
1504
1655
|
await sock.groupMemberAddMode(
|
|
@@ -1507,53 +1658,64 @@ await sock.groupMemberAddMode(
|
|
|
1507
1658
|
)
|
|
1508
1659
|
```
|
|
1509
1660
|
|
|
1661
|
+
<a id="handling-events"></a>
|
|
1510
1662
|
## 🔒 Privasi
|
|
1511
1663
|
|
|
1664
|
+
<a id="handling-events"></a>
|
|
1512
1665
|
### ⛔/✅ Blokir/Buka Blokir Pengguna
|
|
1513
1666
|
```javascript
|
|
1514
1667
|
await sock.updateBlockStatus(jid, 'block') // Block user
|
|
1515
1668
|
await sock.updateBlockStatus(jid, 'unblock') // Unblock user
|
|
1516
1669
|
```
|
|
1670
|
+
<a id="handling-events"></a>
|
|
1517
1671
|
### ⚙️ Dapatkan Pengaturan Privasi
|
|
1518
1672
|
```javascript
|
|
1519
1673
|
const privacySettings = await sock.fetchPrivacySettings(true)
|
|
1520
1674
|
console.log('privacy settings: ' + privacySettings)
|
|
1521
1675
|
```
|
|
1676
|
+
<a id="handling-events"></a>
|
|
1522
1677
|
### 📛 Dapatkan Daftar Blokir
|
|
1523
1678
|
```javascript
|
|
1524
1679
|
const response = await sock.fetchBlocklist()
|
|
1525
1680
|
console.log(response)
|
|
1526
1681
|
```
|
|
1682
|
+
<a id="handling-events"></a>
|
|
1527
1683
|
### 👀 Update Privasi LastSeen
|
|
1528
1684
|
```javascript
|
|
1529
1685
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
1530
1686
|
await sock.updateLastSeenPrivacy(value)
|
|
1531
1687
|
```
|
|
1688
|
+
<a id="handling-events"></a>
|
|
1532
1689
|
### 🟢 Update Privasi Online
|
|
1533
1690
|
```javascript
|
|
1534
1691
|
const value = 'all' // 'match_last_seen'
|
|
1535
1692
|
await sock.updateOnlinePrivacy(value)
|
|
1536
1693
|
```
|
|
1694
|
+
<a id="handling-events"></a>
|
|
1537
1695
|
### 🖼️ Update Privasi Foto Profil
|
|
1538
1696
|
```javascript
|
|
1539
1697
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
1540
1698
|
await sock.updateProfilePicturePrivacy(value)
|
|
1541
1699
|
```
|
|
1700
|
+
<a id="handling-events"></a>
|
|
1542
1701
|
### 📣 Update Privasi Status
|
|
1543
1702
|
```javascript
|
|
1544
1703
|
const value = 'all' // 'contacts' | 'contact_blacklist' | 'none'
|
|
1545
1704
|
await sock.updateStatusPrivacy(value)
|
|
1546
1705
|
```
|
|
1706
|
+
<a id="handling-events"></a>
|
|
1547
1707
|
### ✅ Update Privasi Read Receipts
|
|
1548
1708
|
```javascript
|
|
1549
1709
|
const value = 'all' // 'none'
|
|
1550
1710
|
await sock.updateReadReceiptsPrivacy(value)
|
|
1551
1711
|
```
|
|
1712
|
+
<a id="handling-events"></a>
|
|
1552
1713
|
### 👥 Update Privasi Tambah Grup
|
|
1553
1714
|
```javascript
|
|
1554
1715
|
const value = 'all' // 'contacts' | 'contact_blacklist'
|
|
1555
1716
|
await sock.updateGroupsAddPrivacy(value)
|
|
1556
1717
|
```
|
|
1718
|
+
<a id="handling-events"></a>
|
|
1557
1719
|
### 🕒 Update Mode Default Disappearing
|
|
1558
1720
|
|
|
1559
1721
|
- Like [this](#disappearing-messages), ephemeral can be:
|
|
@@ -1570,8 +1732,10 @@ const ephemeral = 86400
|
|
|
1570
1732
|
await sock.updateDefaultDisappearingMode(ephemeral)
|
|
1571
1733
|
```
|
|
1572
1734
|
|
|
1735
|
+
<a id="handling-events"></a>
|
|
1573
1736
|
## 📢 Broadcast & Story
|
|
1574
1737
|
|
|
1738
|
+
<a id="handling-events"></a>
|
|
1575
1739
|
### 📤 Kirim Broadcast & Story
|
|
1576
1740
|
- Messages can be sent to broadcasts & stories. You need to add the following message options in sendMessage, like this:
|
|
1577
1741
|
```javascript
|
|
@@ -1599,15 +1763,18 @@ await sock.sendMessage(
|
|
|
1599
1763
|
- You can send messages to broadcast lists the same way you send messages to groups & individual chats.
|
|
1600
1764
|
- Right now, WA Web does not support creating broadcast lists, but you can still delete them.
|
|
1601
1765
|
- Broadcast IDs are in the format `12345678@broadcast`
|
|
1766
|
+
<a id="handling-events"></a>
|
|
1602
1767
|
### 🔎 Query Penerima & Nama Broadcast List
|
|
1603
1768
|
```javascript
|
|
1604
1769
|
const bList = await sock.getBroadcastListInfo('1234@broadcast')
|
|
1605
1770
|
console.log (`list name: ${bList.name}, recps: ${bList.recipients}`)
|
|
1606
1771
|
```
|
|
1607
1772
|
|
|
1773
|
+
<a id="handling-events"></a>
|
|
1608
1774
|
## ✍️ Menulis Fungsionalitas Kustom
|
|
1609
1775
|
Baileys is written with custom functionality in mind. Instead of forking the project & re-writing the internals, you can simply write your own extensions.
|
|
1610
1776
|
|
|
1777
|
+
<a id="handling-events"></a>
|
|
1611
1778
|
### 🐛 Mengaktifkan Level Debug di Log Baileys
|
|
1612
1779
|
First, enable the logging of unhandled messages from WhatsApp by setting:
|
|
1613
1780
|
```javascript
|
|
@@ -1617,6 +1784,7 @@ const sock = makeWASocket({
|
|
|
1617
1784
|
```
|
|
1618
1785
|
This will enable you to see all sorts of messages WhatsApp sends in the console.
|
|
1619
1786
|
|
|
1787
|
+
<a id="handling-events"></a>
|
|
1620
1788
|
### 🔬 Bagaimana WhatsApp Berkomunikasi dengan Kita
|
|
1621
1789
|
|
|
1622
1790
|
> [!TIP]
|
|
@@ -1659,6 +1827,7 @@ The `'frame'` is what the message received is, it has three components:
|
|
|
1659
1827
|
- `content` -- the actual data (eg. a message node will have the actual message content in it)
|
|
1660
1828
|
- read more about this format [here](/src/WABinary/readme.md)
|
|
1661
1829
|
|
|
1830
|
+
<a id="handling-events"></a>
|
|
1662
1831
|
### 🔁 Mendaftarkan Callback untuk Event Websocket
|
|
1663
1832
|
|
|
1664
1833
|
> [!TIP]
|
|
@@ -1679,7 +1848,7 @@ sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node: BinaryNode) => { })
|
|
|
1679
1848
|
> Also, this repo is now licenced under GPL 3 since it uses [libsignal-node](https://git.questbook.io/backend/service-coderunner/-/merge_requests/1)
|
|
1680
1849
|
|
|
1681
1850
|
|
|
1682
|
-
|
|
1851
|
+
<a id="handling-events"></a>
|
|
1683
1852
|
## ⚠️ Catatan
|
|
1684
1853
|
|
|
1685
1854
|
Proyek ini **tidak berafiliasi dengan WhatsApp Inc.**
|
|
@@ -1687,6 +1856,7 @@ Gunakan secara bertanggung jawab dan hindari aktivitas ilegal atau penyalahgunaa
|
|
|
1687
1856
|
|
|
1688
1857
|
---
|
|
1689
1858
|
|
|
1859
|
+
<a id="handling-events"></a>
|
|
1690
1860
|
## Lisensi
|
|
1691
1861
|
|
|
1692
1862
|
📘 *Documentation powered by jagoan project*
|
|
@@ -686,6 +686,73 @@ const makeMessagesSocket = (config) => {
|
|
|
686
686
|
]);
|
|
687
687
|
return message;
|
|
688
688
|
},
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* === PATCH: upswgc ===
|
|
692
|
+
* Fungsi untuk mengirim group status message / story grup
|
|
693
|
+
* Contoh:
|
|
694
|
+
* await sock.upswgc(jid, { text: "Hello World" })
|
|
695
|
+
*/
|
|
696
|
+
/**
|
|
697
|
+
* === PATCH: upswgc (Final Combo) ===
|
|
698
|
+
* Support teks + semua media (image, video, doc, audio)
|
|
699
|
+
*/
|
|
700
|
+
upswgc: async (jid, storyContent = {}) => {
|
|
701
|
+
try {
|
|
702
|
+
const userJid = authState?.creds?.me?.id || sock?.user?.id;
|
|
703
|
+
let waMsgContent;
|
|
704
|
+
|
|
705
|
+
// Deteksi apakah konten punya media
|
|
706
|
+
const hasMedia = storyContent.image || storyContent.video || storyContent.document || storyContent.audio;
|
|
707
|
+
|
|
708
|
+
if (storyContent.message) {
|
|
709
|
+
waMsgContent = storyContent;
|
|
710
|
+
} else if (hasMedia) {
|
|
711
|
+
// Untuk media
|
|
712
|
+
if (typeof Utils_1.generateWAMessageContent === "function") {
|
|
713
|
+
waMsgContent = await Utils_1.generateWAMessageContent(storyContent, {
|
|
714
|
+
upload: waUploadToServer
|
|
715
|
+
});
|
|
716
|
+
} else if (typeof sock?.generateWAMessageContent === "function") {
|
|
717
|
+
waMsgContent = await sock.generateWAMessageContent(storyContent, {
|
|
718
|
+
upload: waUploadToServer
|
|
719
|
+
});
|
|
720
|
+
} else {
|
|
721
|
+
waMsgContent = storyContent;
|
|
722
|
+
}
|
|
723
|
+
} else if (storyContent.text) {
|
|
724
|
+
// Untuk teks biasa
|
|
725
|
+
waMsgContent = {
|
|
726
|
+
conversation: storyContent.text
|
|
727
|
+
};
|
|
728
|
+
} else {
|
|
729
|
+
waMsgContent = storyContent;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
const msg = {
|
|
733
|
+
message: {
|
|
734
|
+
groupStatusMessageV2: {
|
|
735
|
+
message: waMsgContent.message || waMsgContent
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
const messageId = (typeof Utils_1.generateMessageIDV2 === "function")
|
|
741
|
+
? Utils_1.generateMessageIDV2(sock?.user?.id)
|
|
742
|
+
: Utils_1.generateMessageID();
|
|
743
|
+
|
|
744
|
+
await relayMessage(jid, msg.message, { messageId });
|
|
745
|
+
|
|
746
|
+
console.log("upswgc success:", jid);
|
|
747
|
+
return msg;
|
|
748
|
+
} catch (err) {
|
|
749
|
+
console.error("upswgc error:", err);
|
|
750
|
+
throw err;
|
|
751
|
+
}
|
|
752
|
+
},
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
689
756
|
sendMessage: async (jid, content, options = {}) => {
|
|
690
757
|
var _a, _b, _c;
|
|
691
758
|
|