@vinzsocket/baileys 3.3.0 → 3.3.1
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/LICENSE +21 -0
- package/README.md +1337 -2685
- package/WAProto/WAProto.proto +916 -360
- package/WAProto/fix-imports.js +18 -22
- package/WAProto/index.d.ts +0 -14015
- package/WAProto/index.js +80576 -45941
- package/lib/Defaults/index.d.ts +14 -15
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +109 -98
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Modded/message_builder.js +2330 -0
- package/lib/Signal/Group/group_cipher.js.map +1 -1
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -1
- package/lib/Signal/Group/keyhelper.js.map +1 -1
- package/lib/Signal/Group/sender-chain-key.js.map +1 -1
- package/lib/Signal/Group/sender-key-message.js.map +1 -1
- package/lib/Signal/Group/sender-message-key.js.map +1 -1
- package/lib/Signal/libsignal.d.ts.map +1 -1
- package/lib/Signal/libsignal.js +17 -45
- package/lib/Signal/libsignal.js.map +1 -1
- package/lib/Signal/lid-mapping.d.ts +0 -4
- package/lib/Signal/lid-mapping.d.ts.map +1 -1
- package/lib/Signal/lid-mapping.js +0 -6
- package/lib/Signal/lid-mapping.js.map +1 -1
- package/lib/Socket/business.d.ts +532 -213
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/business.js +401 -358
- package/lib/Socket/chats.d.ts +2 -15
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +40 -247
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +641 -269
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/dugong.d.ts +127 -315
- package/lib/Socket/dugong.d.ts.map +1 -0
- package/lib/Socket/dugong.js +749 -623
- package/lib/Socket/dugong.js.map +1 -0
- package/lib/Socket/groups.d.ts +2 -13
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/groups.js +1 -21
- package/lib/Socket/groups.js.map +1 -1
- package/lib/Socket/index.d.ts +631 -256
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/index.js +12 -9
- package/lib/Socket/index.js.map +1 -1
- package/lib/Socket/messages-recv.d.ts +58 -23
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-recv.js +181 -645
- package/lib/Socket/messages-recv.js.map +1 -1
- package/lib/Socket/messages-send.d.ts +575 -201
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/messages-send.js +1552 -1185
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Socket/mex.d.ts.map +1 -1
- package/lib/Socket/mex.js +8 -2
- package/lib/Socket/mex.js.map +1 -1
- package/lib/Socket/newsletter.d.ts +18 -11
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Socket/newsletter.js +440 -165
- package/lib/Socket/newsletter.js.map +1 -1
- package/lib/Socket/socket.d.ts +2 -6
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +25 -59
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Types/Auth.d.ts +0 -1
- package/lib/Types/Auth.d.ts.map +1 -1
- package/lib/Types/Bussines.d.ts +34 -22
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Call.d.ts.map +1 -1
- package/lib/Types/Chat.d.ts +0 -1
- package/lib/Types/Chat.d.ts.map +1 -1
- package/lib/Types/Contact.d.ts +0 -2
- package/lib/Types/Contact.d.ts.map +1 -1
- package/lib/Types/Events.d.ts +1 -20
- package/lib/Types/Events.d.ts.map +1 -1
- package/lib/Types/GroupMetadata.d.ts +1 -4
- package/lib/Types/GroupMetadata.d.ts.map +1 -1
- package/lib/Types/Message.d.ts +348 -294
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Types/Message.js.map +1 -1
- package/lib/Types/{Mex.d.ts → Newsletter.d.ts} +5 -11
- package/lib/Types/Newsletter.d.ts.map +1 -0
- package/lib/Types/{Mex.js → Newsletter.js} +3 -9
- package/lib/Types/Newsletter.js.map +1 -0
- package/lib/Types/Signal.d.ts +1 -12
- package/lib/Types/Signal.d.ts.map +1 -1
- package/lib/Types/Socket.d.ts +148 -126
- package/lib/Types/Socket.d.ts.map +1 -1
- package/lib/Types/State.d.ts +0 -58
- package/lib/Types/State.d.ts.map +1 -1
- package/lib/Types/State.js +0 -43
- package/lib/Types/State.js.map +1 -1
- package/lib/Types/index.d.ts +52 -52
- package/lib/Types/index.d.ts.map +1 -1
- package/lib/Types/index.js +30 -23
- package/lib/Types/index.js.map +1 -1
- package/lib/Utils/auth-utils.d.ts +0 -5
- package/lib/Utils/auth-utils.d.ts.map +1 -1
- package/lib/Utils/auth-utils.js +0 -12
- package/lib/Utils/auth-utils.js.map +1 -1
- package/lib/Utils/browser-utils.js +0 -1
- package/lib/Utils/chat-utils.d.ts +4 -34
- package/lib/Utils/chat-utils.d.ts.map +1 -1
- package/lib/Utils/chat-utils.js +20 -80
- package/lib/Utils/chat-utils.js.map +1 -1
- package/lib/Utils/crypto.d.ts +12 -12
- package/lib/Utils/crypto.d.ts.map +1 -1
- package/lib/Utils/crypto.js.map +1 -1
- package/lib/Utils/decode-wa-message.d.ts +0 -18
- package/lib/Utils/decode-wa-message.d.ts.map +1 -1
- package/lib/Utils/decode-wa-message.js +0 -34
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/event-buffer.d.ts +0 -2
- package/lib/Utils/event-buffer.d.ts.map +1 -1
- package/lib/Utils/event-buffer.js +1 -49
- package/lib/Utils/event-buffer.js.map +1 -1
- package/lib/Utils/generics.d.ts +2 -2
- package/lib/Utils/generics.d.ts.map +1 -1
- package/lib/Utils/generics.js +1 -10
- package/lib/Utils/generics.js.map +1 -1
- package/lib/Utils/history.d.ts +0 -2
- package/lib/Utils/history.d.ts.map +1 -1
- package/lib/Utils/history.js +9 -12
- package/lib/Utils/history.js.map +1 -1
- package/lib/Utils/identity-change-handler.d.ts +0 -7
- package/lib/Utils/identity-change-handler.d.ts.map +1 -1
- package/lib/Utils/identity-change-handler.js +0 -1
- package/lib/Utils/identity-change-handler.js.map +1 -1
- package/lib/Utils/index.d.ts +23 -23
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +2 -3
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/link-preview.js +2 -2
- package/lib/Utils/link-preview.js.map +1 -1
- package/lib/Utils/logger.d.ts +2 -1
- package/lib/Utils/logger.d.ts.map +1 -1
- package/lib/Utils/message-retry-manager.d.ts +0 -5
- package/lib/Utils/message-retry-manager.d.ts.map +1 -1
- package/lib/Utils/message-retry-manager.js +0 -40
- package/lib/Utils/message-retry-manager.js.map +1 -1
- package/lib/Utils/messages-media.d.ts +13 -16
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +79 -85
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts +1 -16
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +1121 -1021
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/noise-handler.d.ts +1 -1
- package/lib/Utils/process-message.d.ts.map +1 -1
- package/lib/Utils/process-message.js +1 -103
- package/lib/Utils/process-message.js.map +1 -1
- package/lib/Utils/rich-messages.d.ts +277 -0
- package/lib/Utils/rich-messages.d.ts.map +1 -0
- package/lib/Utils/rich-messages.js +1144 -0
- package/lib/Utils/rich-messages.js.map +1 -0
- package/lib/Utils/signal.d.ts +0 -13
- package/lib/Utils/signal.d.ts.map +1 -1
- package/lib/Utils/signal.js +0 -42
- package/lib/Utils/signal.js.map +1 -1
- package/lib/Utils/sticker-pack.d.ts +10 -0
- package/lib/Utils/sticker-pack.js +111 -0
- package/lib/Utils/sync-action-utils.d.ts.map +1 -1
- package/lib/Utils/sync-action-utils.js +0 -1
- package/lib/Utils/sync-action-utils.js.map +1 -1
- package/lib/Utils/tc-token-utils.d.ts +1 -26
- package/lib/Utils/tc-token-utils.d.ts.map +1 -1
- package/lib/Utils/tc-token-utils.js +5 -151
- package/lib/Utils/tc-token-utils.js.map +1 -1
- package/lib/Utils/validate-connection.d.ts.map +1 -1
- package/lib/Utils/validate-connection.js +2 -12
- package/lib/Utils/validate-connection.js.map +1 -1
- package/lib/VoIP/audio-feeder.d.ts +15 -0
- package/lib/VoIP/audio-feeder.js +132 -0
- package/lib/VoIP/index.js +277 -0
- package/lib/VoIP/relay-transport.d.ts +43 -0
- package/lib/VoIP/relay-transport.js +559 -0
- package/lib/VoIP/signaling.js +594 -0
- package/lib/VoIP/types.d.ts +69 -0
- package/lib/VoIP/types.js +17 -0
- package/lib/VoIP/wasm-engine.d.ts +103 -0
- package/lib/VoIP/wasm-engine.js +1214 -0
- package/lib/VoIP/worker-bootstrap.js +1042 -0
- package/lib/WABinary/decode.d.ts +1 -1
- package/lib/WABinary/decode.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.d.ts +3 -1
- package/lib/WABinary/generic-utils.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.js +78 -0
- package/lib/WABinary/generic-utils.js.map +1 -1
- package/lib/WAM/encode.d.ts +1 -1
- package/lib/WAM/encode.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -26
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/index.d.ts +0 -1
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/index.js +0 -1
- package/lib/WAUSync/Protocols/index.js.map +1 -1
- package/lib/WAUSync/USyncQuery.d.ts +0 -1
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -1
- package/lib/WAUSync/USyncQuery.js +2 -6
- package/lib/WAUSync/USyncQuery.js.map +1 -1
- package/lib/WAUSync/USyncUser.d.ts +0 -4
- package/lib/WAUSync/USyncUser.d.ts.map +1 -1
- package/lib/WAUSync/USyncUser.js +0 -8
- package/lib/WAUSync/USyncUser.js.map +1 -1
- package/lib/assets/wasm/loader.js +5 -0
- package/lib/assets/wasm/whatsapp.wasm +0 -0
- package/lib/assets/wasm/worker-modules.js +273 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/package.json +29 -92
- package/engine-requirements.js +0 -27
- package/lib/Types/Mex.d.ts.map +0 -1
- package/lib/Types/Mex.js.map +0 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +0 -17
- package/lib/Utils/companion-reg-client-utils.d.ts.map +0 -1
- package/lib/Utils/companion-reg-client-utils.js +0 -35
- package/lib/Utils/companion-reg-client-utils.js.map +0 -1
- package/lib/Utils/mention.d.ts +0 -14
- package/lib/Utils/mention.js +0 -138
- package/lib/Utils/story-card.js +0 -107
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +0 -25
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,3006 +1,1658 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<div align="center">
|
|
4
|
-
|
|
5
|
-
**Fork WebSocket library WhatsApp Web Multi-Device — dasar dari ekosistem bot Harps-MD**
|
|
6
|
-
|
|
7
|
-
[](https://github.com/VinzSocket/Baileys)
|
|
8
|
-

|
|
9
|
-

|
|
10
|
-

|
|
11
|
-

|
|
12
|
-
|
|
13
|
-
`npm install @vinzsocket/baileys`
|
|
14
|
-
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## 📚 Daftar Isi
|
|
20
|
-
|
|
21
|
-
1. [Tentang Harps-Baileys](#-tentang-harps-baileys)
|
|
22
|
-
2. [Kenapa Fork Ini Dibuat](#-kenapa-fork-ini-dibuat)
|
|
23
|
-
3. [Instalasi](#-instalasi)
|
|
24
|
-
4. [Requirements](#-requirements)
|
|
25
|
-
5. [Quick Start](#-quick-start)
|
|
26
|
-
6. [Autentikasi (Auth State)](#-autentikasi-auth-state)
|
|
27
|
-
7. [Konfigurasi Koneksi](#-konfigurasi-koneksi)
|
|
28
|
-
8. [Struktur Package](#-struktur-package)
|
|
29
|
-
9. [JID & Utilitas Dasar](#-jid--utilitas-dasar)
|
|
30
|
-
10. [Mengirim Pesan — Dasar](#-mengirim-pesan--dasar)
|
|
31
|
-
- [Teks & Link Preview](#teks--link-preview)
|
|
32
|
-
- [Media: Gambar, Video, Audio, Sticker, Dokumen](#media-gambar-video-audio-sticker-dokumen)
|
|
33
|
-
- [Kontak](#kontak)
|
|
34
|
-
- [Lokasi](#lokasi)
|
|
35
|
-
- [Reaksi (Reaction)](#reaksi-reaction)
|
|
36
|
-
- [Polling (Poll)](#polling-poll)
|
|
37
|
-
- [Event / Undangan Acara](#event--undangan-acara)
|
|
38
|
-
- [Hapus, Edit, Pin Pesan](#hapus-edit-pin-pesan)
|
|
39
|
-
- [View Once & PTV](#view-once--ptv)
|
|
40
|
-
- [Mention & Tag Semua](#mention--tag-semua)
|
|
41
|
-
- [Forward Pesan](#forward-pesan)
|
|
42
|
-
11. [Tombol & List — Native Flow](#-tombol--list--native-flow)
|
|
43
|
-
- [Shorthand `buttons` / `templateButtons` / `interactiveButtons`](#shorthand-buttons--templatebuttons--interactivebuttons)
|
|
44
|
-
- [Shorthand `sections` (List Message)](#shorthand-sections-list-message)
|
|
45
|
-
- [Shorthand `cards` (Carousel)](#shorthand-cards-carousel)
|
|
46
|
-
12. [Fitur Eksklusif Harps-Baileys (`dugong.js`)](#-fitur-eksklusif-harps-baileys-dugongjs)
|
|
47
|
-
- [NF V7 Button Builders](#nf-v7-button-builders)
|
|
48
|
-
- [Multi-Select Message](#multi-select-message)
|
|
49
|
-
- [Nested List Message](#nested-list-message)
|
|
50
|
-
- [Group Status V2 (Story Grup)](#group-status-v2-story-grup)
|
|
51
|
-
- [Story Card Generator (`renderStoryCard`)](#story-card-generator-renderstorycard)
|
|
52
|
-
- [Payment Request Message](#payment-request-message)
|
|
53
|
-
- [Product Message](#product-message)
|
|
54
|
-
- [Album Message](#album-message)
|
|
55
|
-
- [Poll Result Snapshot](#poll-result-snapshot)
|
|
56
|
-
- [`buildInteractiveAdditionalNodes` — Kenapa Wajib Ada](#buildinteractiveadditionalnodes--kenapa-wajib-ada)
|
|
57
|
-
13. [Mention Utilities (`mention.js`)](#-mention-utilities-mentionjs)
|
|
58
|
-
14. [Sistem Event](#-sistem-event)
|
|
59
|
-
15. [Grup (Groups API)](#-grup-groups-api)
|
|
60
|
-
16. [Komunitas (Communities API)](#-komunitas-communities-api)
|
|
61
|
-
17. [Business API](#-business-api)
|
|
62
|
-
18. [Newsletter / Channel API](#-newsletter--channel-api)
|
|
63
|
-
19. [Chats, Profil & Privasi](#-chats-profil--privasi)
|
|
64
|
-
20. [Mengunduh & Memperbarui Media](#-mengunduh--memperbarui-media)
|
|
65
|
-
21. [Penanganan Error](#-penanganan-error)
|
|
66
|
-
22. [Reliabilitas & Retry](#-reliabilitas--retry)
|
|
67
|
-
23. [Referensi Shorthand Field `sendMessage`](#-referensi-shorthand-field-sendmessage)
|
|
68
|
-
24. [Tipe Data (Types) Penting](#-tipe-data-types-penting)
|
|
69
|
-
24. [WAProto](#-waproto)
|
|
70
|
-
25. [Contoh Lengkap: Struktur Bot dengan Plugin](#-contoh-lengkap-struktur-bot-dengan-plugin)
|
|
71
|
-
26. [Migrasi dari Baileys Upstream / Fork Lain](#-migrasi-dari-baileys-upstream--fork-lain)
|
|
72
|
-
27. [Troubleshooting / FAQ](#-troubleshooting--faq)
|
|
73
|
-
28. [Referensi Cepat: Semua Method `sock`](#-referensi-cepat-semua-method-sock)
|
|
74
|
-
29. [Contoh Penerapan di Sistem RPG](#-contoh-penerapan-di-sistem-rpg)
|
|
75
|
-
30. [Tips Performa](#-tips-performa)
|
|
76
|
-
31. [Keamanan & Best Practices](#-keamanan--best-practices)
|
|
77
|
-
32. [Opsi Lengkap `sendMessage`](#-opsi-lengkap-sendmessagejid-content-options)
|
|
78
|
-
33. [Deployment](#-deployment)
|
|
79
|
-
34. [Perbandingan dengan Baileys Upstream](#-perbandingan-dengan-baileys-upstream)
|
|
80
|
-
35. [Glosarium Istilah](#-glosarium-istilah)
|
|
81
|
-
36. [Changelog Ringkas](#-changelog-ringkas)
|
|
82
|
-
37. [Ucapan Terima Kasih](#-ucapan-terima-kasih)
|
|
83
|
-
38. [Sumber Daya Tambahan](#-sumber-daya-tambahan)
|
|
84
|
-
39. [Kontribusi](#-kontribusi)
|
|
85
|
-
40. [Lisensi](#-lisensi)
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## 📖 Tentang Harps-Baileys
|
|
90
|
-
|
|
91
|
-
**Harps-Baileys** (dipublikasikan sebagai `@vinzsocket/baileys`) adalah fork dari library [Baileys](https://github.com/WhiskeySockets/Baileys) — WebSocket client untuk WhatsApp Web Multi-Device — yang dikembangkan dan dirawat oleh Alvin (VinzSocket) sebagai fondasi dari ekosistem bot **Harps-MD**.
|
|
92
|
-
|
|
93
|
-
Fork ini mempertahankan seluruh API inti Baileys (koneksi socket, autentikasi Signal Protocol, sinkronisasi riwayat chat, pengiriman & penerimaan pesan multi-device) sambil menambahkan sejumlah kapabilitas baru yang tidak tersedia di upstream, khususnya di area:
|
|
94
|
-
|
|
95
|
-
- **Native Flow interaktif generasi terbaru (NF V7)** — tombol URL, telepon, salin kode, reminder, alamat, lokasi, quick reply, dropdown tunggal/ganda, review pembayaran, review order, hingga multi-product message (MPM).
|
|
96
|
-
- **Group Status V2** — mengirim story/status langsung ke dalam grup, mendukung semua tipe media dengan caption.
|
|
97
|
-
- **Multi-Select Message** — satu pesan dengan beberapa dropdown independen sekaligus.
|
|
98
|
-
- **Nested List Message** — list legacy dengan auto-flatten section bersarang.
|
|
99
|
-
- **Story Card Generator** — membuat gambar status bergaya gradient (title/body/footer) secara programatik tanpa tools desain eksternal.
|
|
100
|
-
- **Shorthand pengiriman pesan** (`buttons`, `sections`, `cards`) yang menyederhanakan pembuatan payload interactive message modern.
|
|
101
|
-
- Perbaikan-perbaikan kompatibilitas & bug fix yang bersumber dari pengalaman menjalankan bot produksi (Harps-MD) sehari-hari.
|
|
102
|
-
|
|
103
|
-
Semua fitur tambahan ini dirancang agar **backward compatible** dengan pola-pola umum yang dipakai komunitas Baileys (mis. `buttonsMessage`, `templateButtons`, shape dari fork-fork populer lain) sehingga migrasi dari Baileys/fork lain ke Harps-Baileys seharusnya minim gesekan.
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## 🎯 Kenapa Fork Ini Dibuat
|
|
108
|
-
|
|
109
|
-
Baileys upstream berkembang cepat mengikuti perubahan protokol WhatsApp Web, tapi API interaktifnya (button, list, carousel) sering kali:
|
|
110
|
-
|
|
111
|
-
- Tidak konsisten antara versi (`buttonsMessage` legacy vs `interactiveMessage` modern).
|
|
112
|
-
- Tidak menyertakan binary node hint (`additionalNodes`) yang diperlukan supaya pesan interaktif benar-benar **tampil** di client penerima — banyak bot yang mengirim pesan sukses (tidak ada error) tapi pesannya kosong/tidak muncul di HP penerima.
|
|
113
|
-
- Tidak punya cara mudah untuk fitur-fitur yang cukup dibutuhkan komunitas bot Indonesia: kirim status ke grup, dropdown ganda dalam satu pesan, atau list bersarang.
|
|
114
|
-
|
|
115
|
-
Harps-Baileys mengisi celah tersebut dengan lapisan `dugong.js` (`ExtendedMessageBuilder`) dan util pendukungnya, sambil tetap 100% memakai jalur `relayMessage()` bawaan Baileys sehingga tidak menyimpang dari cara kerja protokol resminya.
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## 📦 Instalasi
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
npm install @vinzsocket/baileys
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Atau dengan Yarn:
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
yarn add @vinzsocket/baileys
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
Atau dengan pnpm:
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
pnpm add @vinzsocket/baileys
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Peer Dependencies Opsional
|
|
138
|
-
|
|
139
|
-
Beberapa fitur bersifat opsional dan baru aktif kalau peer dependency-nya terpasang:
|
|
140
|
-
|
|
141
|
-
| Package | Dibutuhkan Untuk | Wajib? |
|
|
142
|
-
|---|---|---|
|
|
143
|
-
| `jimp` | `renderStoryCard()`, decoding sticker/gambar tanpa native binding | Opsional |
|
|
144
|
-
| `sharp` | Konversi/optimasi gambar performa tinggi (alternatif `jimp`) | Opsional |
|
|
145
|
-
| `link-preview-js` | Link preview otomatis pada `extendedTextMessage` | Opsional |
|
|
146
|
-
| `audio-decode` | Decode metadata/durasi audio untuk voice note | Opsional |
|
|
147
|
-
|
|
148
|
-
Pasang sesuai kebutuhan, misalnya:
|
|
149
|
-
|
|
150
|
-
```bash
|
|
151
|
-
npm install jimp sharp link-preview-js audio-decode
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Jika Anda memanggil fitur yang butuh salah satu package di atas tanpa menginstallnya, Harps-Baileys akan melempar error `Boom` yang jelas (bukan crash diam-diam), contohnya:
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
Error: renderStoryCard() requires the optional "jimp" peer dependency. Install it with: npm i jimp
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## ✅ Requirements
|
|
163
|
-
|
|
164
|
-
- **Node.js ≥ 20.0.0** (dicek otomatis lewat script `preinstall` → `engine-requirements.js`)
|
|
165
|
-
- Package ini adalah **ESM murni** (`"type": "module"` di `package.json`). Untuk import di proyek CommonJS:
|
|
166
|
-
|
|
167
|
-
```js
|
|
168
|
-
// CJS project — pakai dynamic import
|
|
169
|
-
const baileys = await import('@vinzsocket/baileys')
|
|
170
|
-
const makeWASocket = baileys.default
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
Atau, jika Node.js Anda sudah ≥ 20.19.0 (atau ≥ 22.12.0 / ≥ 23.x), Anda bisa memakai `require()` langsung berkat dukungan `require(esm)` bawaan Node:
|
|
174
|
-
|
|
175
|
-
```js
|
|
176
|
-
const { default: makeWASocket } = require('@vinzsocket/baileys')
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
Skrip `engine-requirements.js` akan:
|
|
180
|
-
|
|
181
|
-
- **Menghentikan instalasi** (`process.exit(1)`) jika Node.js Anda di bawah versi 20.
|
|
182
|
-
- Menampilkan **peringatan** (bukan error fatal) jika Node.js Anda di antara 20.0–20.18 / 22.0–22.11, karena `require(esm)` belum stabil di rentang tersebut — solusinya pakai `import()` dinamis seperti contoh di atas.
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
## 🚀 Quick Start
|
|
187
|
-
|
|
188
|
-
Contoh paling sederhana: konek ke WhatsApp, tampilkan QR, dan balas pesan “ping” dengan “pong”.
|
|
189
|
-
|
|
190
|
-
```js
|
|
191
|
-
import makeWASocket, { useMultiFileAuthState, DisconnectReason } from '@vinzsocket/baileys'
|
|
192
|
-
import { Boom } from '@hapi/boom'
|
|
193
|
-
|
|
194
|
-
async function startBot() {
|
|
195
|
-
const { state, saveCreds } = await useMultiFileAuthState('sesi_auth')
|
|
196
|
-
|
|
197
|
-
const sock = makeWASocket({
|
|
198
|
-
auth: state,
|
|
199
|
-
printQRInTerminal: true // catatan: opsi ini deprecated di Baileys upstream terbaru,
|
|
200
|
-
// gunakan qrcode-terminal manual jika ingin QR di console modern
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
sock.ev.on('creds.update', saveCreds)
|
|
204
|
-
|
|
205
|
-
sock.ev.on('connection.update', (update) => {
|
|
206
|
-
const { connection, lastDisconnect } = update
|
|
207
|
-
if (connection === 'close') {
|
|
208
|
-
const shouldReconnect =
|
|
209
|
-
lastDisconnect?.error instanceof Boom &&
|
|
210
|
-
lastDisconnect.error.output?.statusCode !== DisconnectReason.loggedOut
|
|
211
|
-
console.log('Koneksi terputus, reconnect:', shouldReconnect)
|
|
212
|
-
if (shouldReconnect) startBot()
|
|
213
|
-
} else if (connection === 'open') {
|
|
214
|
-
console.log('✅ Terhubung ke WhatsApp!')
|
|
215
|
-
}
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
sock.ev.on('messages.upsert', async ({ messages, type }) => {
|
|
219
|
-
if (type !== 'notify') return
|
|
220
|
-
const msg = messages[0]
|
|
221
|
-
if (!msg.message || msg.key.fromMe) return
|
|
222
|
-
|
|
223
|
-
const text =
|
|
224
|
-
msg.message.conversation ||
|
|
225
|
-
msg.message.extendedTextMessage?.text ||
|
|
226
|
-
''
|
|
227
|
-
|
|
228
|
-
if (text.toLowerCase() === 'ping') {
|
|
229
|
-
await sock.sendMessage(msg.key.remoteJid, { text: 'pong 🏓' }, { quoted: msg })
|
|
230
|
-
}
|
|
231
|
-
})
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
startBot()
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
Jalankan:
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
node index.js
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
Scan QR yang muncul di terminal menggunakan WhatsApp di HP Anda (**Linked Devices → Link a Device**).
|
|
244
|
-
|
|
245
|
-
---
|
|
246
|
-
|
|
247
|
-
## 🔐 Autentikasi (Auth State)
|
|
248
|
-
|
|
249
|
-
Harps-Baileys menyediakan helper `useMultiFileAuthState()` yang menyimpan kredensial sesi (`creds.json`) beserta seluruh key Signal Protocol (pre-key, sender key, session) sebagai file-file terpisah di sebuah folder — cocok untuk development maupun deployment sederhana berbasis filesystem.
|
|
250
|
-
|
|
251
|
-
```js
|
|
252
|
-
import { useMultiFileAuthState } from '@vinzsocket/baileys'
|
|
253
|
-
|
|
254
|
-
const { state, saveCreds } = await useMultiFileAuthState('./sesi_auth')
|
|
255
|
-
|
|
256
|
-
const sock = makeWASocket({ auth: state })
|
|
257
|
-
sock.ev.on('creds.update', saveCreds)
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
**Cara kerja:**
|
|
261
|
-
|
|
262
|
-
- Folder `./sesi_auth` akan otomatis dibuat jika belum ada.
|
|
263
|
-
- Setiap file di dalamnya merepresentasikan satu "kunci" (`creds.json`, `app-state-sync-key-*.json`, `pre-key-*.json`, `session-*.json`, `sender-key-*.json`, dst).
|
|
264
|
-
- `saveCreds()` dipanggil setiap kali event `creds.update` terpicu (biasanya setelah pairing awal, rotasi key, atau update signature akun).
|
|
265
|
-
- Untuk produksi berskala besar / multi-instance, disarankan mengganti implementasi ini dengan auth state custom yang menyimpan ke database (Redis, MongoDB, Postgres) — cukup implementasikan interface `AuthenticationState` yang sama (`creds` + `keys` dengan method `get`/`set`).
|
|
266
|
-
|
|
267
|
-
### Auth State Custom (Database)
|
|
268
|
-
|
|
269
|
-
Pola umum jika ingin menulis auth state sendiri:
|
|
270
|
-
|
|
271
|
-
```js
|
|
272
|
-
const authState = {
|
|
273
|
-
creds: /* objek AuthenticationCreds, load dari DB atau buat baru via initAuthCreds() */,
|
|
274
|
-
keys: {
|
|
275
|
-
get: async (type, ids) => {
|
|
276
|
-
// ambil banyak key sekaligus by id, kembalikan sebagai { [id]: value }
|
|
277
|
-
},
|
|
278
|
-
set: async (data) => {
|
|
279
|
-
// data: { [type]: { [id]: value | null } }
|
|
280
|
-
// null berarti key tsb harus dihapus
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
Lihat `Types/Auth.js` / `Types/Auth.d.ts` untuk bentuk lengkap `AuthenticationCreds` dan `SignalDataTypeMap` yang harus didukung oleh implementasi `keys.get` / `keys.set` Anda (pre-key, session, sender-key, app-state-sync-key, app-state-sync-version, sender-key-memory).
|
|
287
|
-
|
|
288
|
-
### Pairing dengan Nomor Telepon (tanpa scan QR)
|
|
289
|
-
|
|
290
|
-
```js
|
|
291
|
-
const sock = makeWASocket({ auth: state })
|
|
292
|
-
|
|
293
|
-
if (!sock.authState?.creds?.registered) {
|
|
294
|
-
const code = await sock.requestPairingCode('6281234567890') // nomor tanpa tanda +
|
|
295
|
-
console.log('Kode pairing Anda:', code)
|
|
296
|
-
}
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
Masukkan kode tersebut di WhatsApp: **Linked Devices → Link with phone number instead**.
|
|
300
|
-
|
|
301
|
-
---
|
|
302
|
-
|
|
303
|
-
## ⚙️ Konfigurasi Koneksi
|
|
304
|
-
|
|
305
|
-
`makeWASocket(config)` menerima objek konfigurasi yang di-*merge* di atas `DEFAULT_CONNECTION_CONFIG`. Berikut opsi-opsi yang tersedia beserta nilai default aktualnya (dari `Defaults/index.js`):
|
|
306
|
-
|
|
307
|
-
| Opsi | Default | Keterangan |
|
|
308
|
-
|---|---|---|
|
|
309
|
-
| `version` | `[2, 3000, 1035194821]` | Versi protokol WhatsApp Web yang disimulasikan. |
|
|
310
|
-
| `browser` | `Browsers.macOS('Chrome')` | Identitas browser yang dikirim saat pairing (memengaruhi tampilan "linked device" di HP). |
|
|
311
|
-
| `waWebSocketUrl` | `'wss://web.whatsapp.com/ws/chat'` | Endpoint WebSocket WhatsApp Web. |
|
|
312
|
-
| `connectTimeoutMs` | `20000` | Timeout koneksi awal (ms). |
|
|
313
|
-
| `keepAliveIntervalMs` | `30000` | Interval ping keep-alive (ms). |
|
|
314
|
-
| `logger` | `pino` child logger | Instance logger (pino-compatible). |
|
|
315
|
-
| `emitOwnEvents` | `true` | Jika `true`, pesan yang dikirim sendiri via `sendMessage` ikut memicu `messages.upsert`. |
|
|
316
|
-
| `defaultQueryTimeoutMs` | `60000` | Timeout default untuk query IQ ke server. |
|
|
317
|
-
| `customUploadHosts` | `[]` | Daftar host upload media custom (override host bawaan WA). |
|
|
318
|
-
| `retryRequestDelayMs` | `250` | Delay antar retry request yang gagal. |
|
|
319
|
-
| `maxMsgRetryCount` | `5` | Batas maksimum percobaan ulang pengiriman pesan gagal. |
|
|
320
|
-
| `fireInitQueries` | `true` | Jalankan query inisialisasi standar (privacy, blocklist, dll) saat konek. |
|
|
321
|
-
| `auth` | `undefined` | **Wajib diisi** — objek `AuthenticationState` (lihat bagian Auth State). |
|
|
322
|
-
| `markOnlineOnConnect` | `true` | Set status "online" otomatis saat tersambung. |
|
|
323
|
-
| `syncFullHistory` | `true` | Minta sinkronisasi riwayat chat penuh dari HP saat pairing pertama. |
|
|
324
|
-
| `patchMessageBeforeSending` | `msg => msg` | Hook untuk memodifikasi payload pesan mentah sebelum dikirim (lanjutan). |
|
|
325
|
-
| `shouldSyncHistoryMessage` | `({syncType}) => syncType !== FULL` | Filter jenis histori mana yang diproses. |
|
|
326
|
-
| `shouldIgnoreJid` | `() => false` | Hook untuk mengabaikan JID tertentu (mis. broadcast list, JID spam). |
|
|
327
|
-
| `linkPreviewImageThumbnailWidth` | `192` | Lebar thumbnail untuk link preview otomatis. |
|
|
328
|
-
| `transactionOpts` | `{ maxCommitRetries: 10, delayBetweenTriesMs: 3000 }` | Retry policy transaksi signal store. |
|
|
329
|
-
| `generateHighQualityLinkPreview` | `false` | Jika `true`, thumbnail link preview diunggah kualitas tinggi (butuh 1 request tambahan). |
|
|
330
|
-
| `enableAutoSessionRecreation` | `true` | Otomatis membuat ulang sesi Signal jika terdeteksi rusak/kadaluarsa. |
|
|
331
|
-
| `enableRecentMessageCache` | `true` | Cache pesan terbaru untuk mempercepat resolusi `getMessage` (retry, edit, delete). |
|
|
332
|
-
| `options` | `{}` | Opsi tambahan untuk `fetch` (mis. custom agent/dispatcher). |
|
|
333
|
-
| `appStateMacVerification` | `{ patch: false, snapshot: false }` | Verifikasi MAC saat sinkronisasi app-state (kontak, chat, dsb). |
|
|
334
|
-
| `countryCode` | `'US'` | Kode negara default untuk normalisasi nomor. |
|
|
335
|
-
| `getMessage` | `async () => undefined` | **Sangat disarankan diisi** — resolver pesan by key, dipakai untuk retry/decrypt ulang. |
|
|
336
|
-
| `cachedGroupMetadata` | `async () => undefined` | Resolver metadata grup dari cache Anda sendiri (mengurangi query `groupMetadata`). |
|
|
337
|
-
| `makeSignalRepository` | `makeLibSignalRepository` | Implementasi Signal repository (bisa diganti custom). |
|
|
338
|
-
|
|
339
|
-
### Contoh Konfigurasi Lengkap Produksi
|
|
340
|
-
|
|
341
|
-
```js
|
|
342
|
-
import makeWASocket, { useMultiFileAuthState, Browsers, makeCacheableSignalKeyStore } from '@vinzsocket/baileys'
|
|
343
|
-
import pino from 'pino'
|
|
344
|
-
import NodeCache from '@cacheable/node-cache'
|
|
345
|
-
|
|
346
|
-
const logger = pino({ level: 'silent' })
|
|
347
|
-
const msgRetryCounterCache = new NodeCache()
|
|
348
|
-
const groupCache = new NodeCache({ stdTTL: 5 * 60, useClones: false })
|
|
349
|
-
|
|
350
|
-
const { state, saveCreds } = await useMultiFileAuthState('sesi_auth')
|
|
351
|
-
|
|
352
|
-
const sock = makeWASocket({
|
|
353
|
-
auth: {
|
|
354
|
-
creds: state.creds,
|
|
355
|
-
keys: makeCacheableSignalKeyStore(state.keys, logger)
|
|
356
|
-
},
|
|
357
|
-
logger,
|
|
358
|
-
browser: Browsers.ubuntu('Chrome'),
|
|
359
|
-
syncFullHistory: false,
|
|
360
|
-
markOnlineOnConnect: false,
|
|
361
|
-
generateHighQualityLinkPreview: true,
|
|
362
|
-
msgRetryCounterCache,
|
|
363
|
-
cachedGroupMetadata: async (jid) => groupCache.get(jid),
|
|
364
|
-
getMessage: async (key) => {
|
|
365
|
-
// idealnya diarahkan ke store pesan Anda sendiri (DB/cache)
|
|
366
|
-
return undefined
|
|
367
|
-
}
|
|
368
|
-
})
|
|
369
|
-
|
|
370
|
-
sock.ev.on('groups.update', ([update]) => {
|
|
371
|
-
const cached = groupCache.get(update.id)
|
|
372
|
-
if (cached) groupCache.set(update.id, { ...cached, ...update })
|
|
373
|
-
})
|
|
374
|
-
|
|
375
|
-
sock.ev.on('group-participants.update', async ({ id }) => {
|
|
376
|
-
groupCache.del(id) // invalidate, biar di-fetch ulang saat dibutuhkan
|
|
377
|
-
})
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
`Browsers` menyediakan beberapa preset umum: `Browsers.ubuntu(name)`, `Browsers.macOS(name)`, `Browsers.windows(name)`, `Browsers.appropriate(name)` — masing-masing memengaruhi bagaimana perangkat ini tampil di daftar "Linked Devices" pengguna.
|
|
381
|
-
|
|
382
|
-
---
|
|
383
|
-
|
|
384
|
-
## 🗂️ Struktur Package
|
|
385
|
-
|
|
386
|
-
```
|
|
387
|
-
@vinzsocket/baileys
|
|
388
|
-
├── WAProto/ → definisi protobuf pesan WhatsApp (proto.Message, dll)
|
|
389
|
-
├── engine-requirements.js → cek versi Node.js saat preinstall
|
|
390
|
-
└── lib/
|
|
391
|
-
├── Defaults/ → konstanta & DEFAULT_CONNECTION_CONFIG
|
|
392
|
-
├── Signal/ → implementasi Signal Protocol (libsignal repository)
|
|
393
|
-
├── Socket/ → lapisan socket bertingkat (lihat di bawah) + dugong.js
|
|
394
|
-
│ └── Client/ → WebSocket transport & tipe client
|
|
395
|
-
├── Types/ → semua TypeScript type (Auth, Chat, Message, dll)
|
|
396
|
-
├── Utils/ → helper: pesan, media, mention, auth-state, story-card, dll
|
|
397
|
-
├── WABinary/ → encode/decode binary XML node WhatsApp + util JID
|
|
398
|
-
├── WAM/ → WhatsApp Analytics/Metrics binary encoder
|
|
399
|
-
└── WAUSync/ → USync protocol (query device/status massal)
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
Socket dibangun **bertingkat** (setiap layer membungkus layer sebelumnya), urutannya dari `Socket/index.js`:
|
|
403
|
-
|
|
404
|
-
```
|
|
405
|
-
makeCommunitiesSocket
|
|
406
|
-
└─ makeChatsSocket
|
|
407
|
-
└─ makeNewsletterSocket (dan seterusnya menurun ke)
|
|
408
|
-
└─ makeBusinessSocket
|
|
409
|
-
└─ makeGroupsSocket
|
|
410
|
-
└─ makeMessagesSocket (messages-send + messages-recv)
|
|
411
|
-
└─ socket dasar (Socket/socket.js — WebSocket, noise handshake, dsb)
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
Setiap layer menambahkan sekumpulan method ke objek `sock` yang dikembalikan `makeWASocket()`, sehingga API akhirnya terasa seperti satu objek datar (`sock.sendMessage`, `sock.groupCreate`, `sock.newsletterCreate`, dst) meskipun implementasinya berlapis.
|
|
415
|
-
|
|
416
|
-
---
|
|
417
|
-
|
|
418
|
-
## 🔎 JID & Utilitas Dasar
|
|
419
|
-
|
|
420
|
-
WhatsApp mengidentifikasi entitas (user, grup, channel, dst) lewat **JID** (Jabber ID). Harps-Baileys mengekspor beberapa helper dari `WABinary`:
|
|
421
|
-
|
|
422
|
-
```js
|
|
423
|
-
import {
|
|
424
|
-
jidEncode, jidDecode, areJidsSameUser,
|
|
425
|
-
isJidUser, isPnUser, isLidUser,
|
|
426
|
-
isJidGroup, isJidBroadcast, isJidStatusBroadcast,
|
|
427
|
-
isJidNewsletter, isJidMetaAI
|
|
428
|
-
} from '@vinzsocket/baileys'
|
|
429
|
-
```
|
|
430
|
-
|
|
431
|
-
| Fungsi | Kegunaan |
|
|
432
|
-
|---|---|
|
|
433
|
-
| `jidDecode(jid)` | Pecah JID jadi `{ user, server, device, agent }`. |
|
|
434
|
-
| `jidEncode(user, server, device?, agent?)` | Rakit ulang JID dari komponennya. |
|
|
435
|
-
| `areJidsSameUser(a, b)` | Bandingkan apakah dua JID merujuk user yang sama (mengabaikan device). |
|
|
436
|
-
| `isPnUser(jid)` | `true` jika JID berformat nomor telepon (`@s.whatsapp.net`). |
|
|
437
|
-
| `isLidUser(jid)` | `true` jika JID berformat LID (`@lid`) — identitas privasi baru WhatsApp. |
|
|
438
|
-
| `isJidGroup(jid)` | `true` jika JID adalah grup (`@g.us`). |
|
|
439
|
-
| `isJidBroadcast(jid)` | `true` jika JID adalah broadcast list. |
|
|
440
|
-
| `isJidStatusBroadcast(jid)` | `true` khusus untuk `status@broadcast`. |
|
|
441
|
-
|
|
442
|
-
### Konstanta JID Penting
|
|
443
|
-
|
|
444
|
-
```js
|
|
445
|
-
import { S_WHATSAPP_NET, STORIES_JID, OFFICIAL_BIZ_JID } from '@vinzsocket/baileys'
|
|
446
|
-
|
|
447
|
-
console.log(S_WHATSAPP_NET) // '@s.whatsapp.net'
|
|
448
|
-
console.log(STORIES_JID) // 'status@broadcast'
|
|
449
|
-
```
|
|
450
|
-
|
|
451
|
-
### Catatan Tentang LID (Linked Identity)
|
|
452
|
-
|
|
453
|
-
WhatsApp secara bertahap memigrasikan identitas pengguna dari nomor telepon (`@s.whatsapp.net`) ke identitas tersamar (`@lid`) demi privasi, terutama di dalam grup besar. Ini berarti:
|
|
454
|
-
|
|
455
|
-
- `msg.key.participant` di sebuah grup **bisa** berupa `@lid`, bukan nomor telepon asli.
|
|
456
|
-
- Jangan asumsikan Anda selalu bisa menampilkan nomor telepon dari sebuah JID — kadang WhatsApp memang tidak mengungkapkannya.
|
|
457
|
-
- Harps-Baileys menyediakan `buildTagAllText()` (lihat bagian [Mention Utilities](#-mention-utilities-mentionjs)) yang menangani kasus ini dengan aman, alih-alih menampilkan digit LID mentah yang membingungkan pengguna.
|
|
458
|
-
|
|
459
|
-
---
|
|
460
|
-
|
|
461
|
-
## ✉️ Mengirim Pesan — Dasar
|
|
462
|
-
|
|
463
|
-
Semua pengiriman pesan melewati satu pintu: `sock.sendMessage(jid, content, options?)`. Bentuk `content` menentukan tipe pesan apa yang dihasilkan — Harps-Baileys memakai pola *"shorthand key detection"*: Anda cukup memberi field yang relevan (`text`, `image`, `poll`, dst) dan library akan merakit payload protobuf yang benar secara otomatis lewat `generateWAMessageContent()`.
|
|
464
|
-
|
|
465
|
-
### Teks & Link Preview
|
|
466
|
-
|
|
467
|
-
```js
|
|
468
|
-
await sock.sendMessage(jid, { text: 'Halo dari Harps-Baileys!' })
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
Reply / quote pesan lain:
|
|
472
|
-
|
|
473
|
-
```js
|
|
474
|
-
await sock.sendMessage(jid, { text: 'Ini balasan' }, { quoted: msg })
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
Link preview otomatis terdeteksi dari URL di dalam teks (butuh `link-preview-js` terpasang):
|
|
478
|
-
|
|
479
|
-
```js
|
|
480
|
-
await sock.sendMessage(jid, {
|
|
481
|
-
text: 'Cek repo ini: https://github.com/VinzSocket/Baileys'
|
|
482
|
-
})
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
Kontrol manual link preview:
|
|
486
|
-
|
|
487
|
-
```js
|
|
488
|
-
await sock.sendMessage(jid, {
|
|
489
|
-
text: 'Lihat websitenya di bawah',
|
|
490
|
-
linkPreview: {
|
|
491
|
-
'matched-text': 'https://example.com',
|
|
492
|
-
title: 'Judul Custom',
|
|
493
|
-
description: 'Deskripsi custom',
|
|
494
|
-
jpegThumbnail: fs.readFileSync('./thumb.jpg')
|
|
495
|
-
}
|
|
496
|
-
})
|
|
497
|
-
```
|
|
498
|
-
|
|
499
|
-
Matikan link preview sama sekali:
|
|
500
|
-
|
|
501
|
-
```js
|
|
502
|
-
await sock.sendMessage(jid, { text: 'https://example.com tanpa preview', linkPreview: null })
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
Teks dengan warna latar (bubble style — umumnya tampil di beberapa versi client sebagai "status text style"):
|
|
506
|
-
|
|
507
|
-
```js
|
|
508
|
-
await sock.sendMessage(jid, {
|
|
509
|
-
text: 'Teks dengan gaya',
|
|
510
|
-
backgroundColor: '#FF5722', // atau nilai integer ARGB
|
|
511
|
-
font: 2 // 0-5, tergantung dukungan client
|
|
512
|
-
})
|
|
513
|
-
```
|
|
514
|
-
|
|
515
|
-
### Media: Gambar, Video, Audio, Sticker, Dokumen
|
|
516
|
-
|
|
517
|
-
**Gambar dengan caption:**
|
|
518
|
-
|
|
519
|
-
```js
|
|
520
|
-
await sock.sendMessage(jid, {
|
|
521
|
-
image: { url: 'https://example.com/foto.jpg' }, // atau Buffer / { stream }
|
|
522
|
-
caption: 'Ini captionnya'
|
|
523
|
-
})
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
**Video dengan caption + GIF playback:**
|
|
527
|
-
|
|
528
|
-
```js
|
|
529
|
-
await sock.sendMessage(jid, {
|
|
530
|
-
video: fs.readFileSync('./video.mp4'),
|
|
531
|
-
caption: 'Video kegiatan',
|
|
532
|
-
gifPlayback: false // true = tampil sebagai GIF loop
|
|
533
|
-
})
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
**Audio / Voice Note:**
|
|
537
|
-
|
|
538
|
-
```js
|
|
539
|
-
// Voice note (PTT)
|
|
540
|
-
await sock.sendMessage(jid, {
|
|
541
|
-
audio: { url: 'https://example.com/voice.ogg' },
|
|
542
|
-
ptt: true,
|
|
543
|
-
mimetype: 'audio/ogg; codecs=opus'
|
|
544
|
-
})
|
|
545
|
-
|
|
546
|
-
// Audio musik biasa
|
|
547
|
-
await sock.sendMessage(jid, {
|
|
548
|
-
audio: fs.readFileSync('./lagu.mp3'),
|
|
549
|
-
ptt: false,
|
|
550
|
-
mimetype: 'audio/mp4'
|
|
551
|
-
})
|
|
552
|
-
```
|
|
553
|
-
|
|
554
|
-
**Sticker:**
|
|
555
|
-
|
|
556
|
-
```js
|
|
557
|
-
await sock.sendMessage(jid, { sticker: { url: 'https://example.com/sticker.webp' } })
|
|
558
|
-
```
|
|
559
|
-
|
|
560
|
-
**Dokumen:**
|
|
561
|
-
|
|
562
|
-
```js
|
|
563
|
-
await sock.sendMessage(jid, {
|
|
564
|
-
document: { url: 'https://example.com/laporan.pdf' },
|
|
565
|
-
mimetype: 'application/pdf',
|
|
566
|
-
fileName: 'Laporan-Bulanan.pdf',
|
|
567
|
-
caption: 'Laporan bulan ini'
|
|
568
|
-
})
|
|
569
|
-
```
|
|
570
|
-
|
|
571
|
-
**Dokumen dengan thumbnail preview (patch fork ini):**
|
|
572
|
-
|
|
573
|
-
Harps-Baileys mendukung `jpegThumbnail` untuk dokumen (di-*monkey-patch* agar dokumen bisa menampilkan preview gambar seperti file PDF/gambar di WhatsApp Desktop):
|
|
574
|
-
|
|
575
|
-
```js
|
|
576
|
-
await sock.sendMessage(jid, {
|
|
577
|
-
document: fs.readFileSync('./brosur.pdf'),
|
|
578
|
-
mimetype: 'application/pdf',
|
|
579
|
-
fileName: 'Brosur.pdf',
|
|
580
|
-
jpegThumbnail: fs.readFileSync('./cover-brosur.jpg')
|
|
581
|
-
})
|
|
582
|
-
```
|
|
583
|
-
|
|
584
|
-
### Kontak
|
|
585
|
-
|
|
586
|
-
```js
|
|
587
|
-
await sock.sendMessage(jid, {
|
|
588
|
-
contacts: {
|
|
589
|
-
displayName: 'Nama Kontak',
|
|
590
|
-
contacts: [{
|
|
591
|
-
vcard:
|
|
592
|
-
'BEGIN:VCARD\nVERSION:3.0\nFN:Nama Kontak\nTEL;type=CELL;type=VOICE;waid=6281234567890:+62 812-3456-7890\nEND:VCARD'
|
|
593
|
-
}]
|
|
594
|
-
}
|
|
595
|
-
})
|
|
596
|
-
```
|
|
597
|
-
|
|
598
|
-
Untuk mengirim lebih dari satu kontak sekaligus, cukup tambahkan lebih banyak entri ke array `contacts.contacts` — Harps-Baileys otomatis memilih antara `contactMessage` (1 kontak) dan `contactsArrayMessage` (lebih dari 1).
|
|
599
|
-
|
|
600
|
-
### Lokasi
|
|
601
|
-
|
|
602
|
-
```js
|
|
603
|
-
await sock.sendMessage(jid, {
|
|
604
|
-
location: {
|
|
605
|
-
degreesLatitude: -6.200000,
|
|
606
|
-
degreesLongitude: 106.816666,
|
|
607
|
-
name: 'Monas',
|
|
608
|
-
address: 'Jakarta Pusat'
|
|
609
|
-
}
|
|
610
|
-
})
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
### Reaksi (Reaction)
|
|
614
|
-
|
|
615
|
-
```js
|
|
616
|
-
await sock.sendMessage(jid, {
|
|
617
|
-
react: {
|
|
618
|
-
text: '❤️', // kosongkan string ('') untuk menghapus reaksi
|
|
619
|
-
key: msg.key
|
|
620
|
-
}
|
|
621
|
-
})
|
|
622
|
-
```
|
|
623
|
-
|
|
624
|
-
### Polling (Poll)
|
|
625
|
-
|
|
626
|
-
```js
|
|
627
|
-
// Single-choice poll
|
|
628
|
-
await sock.sendMessage(jid, {
|
|
629
|
-
poll: {
|
|
630
|
-
name: 'Menu makan siang hari ini?',
|
|
631
|
-
values: ['Nasi Padang', 'Bakso', 'Mie Ayam', 'Soto'],
|
|
632
|
-
selectableCount: 1
|
|
633
|
-
}
|
|
634
|
-
})
|
|
635
|
-
|
|
636
|
-
// Multiple-choice poll
|
|
637
|
-
await sock.sendMessage(jid, {
|
|
638
|
-
poll: {
|
|
639
|
-
name: 'Pilih semua yang kamu suka',
|
|
640
|
-
values: ['Gunung', 'Pantai', 'Kota', 'Hutan'],
|
|
641
|
-
selectableCount: 2
|
|
642
|
-
}
|
|
643
|
-
})
|
|
644
|
-
|
|
645
|
-
// Poll khusus grup komunitas/announcement
|
|
646
|
-
await sock.sendMessage(jid, {
|
|
647
|
-
poll: {
|
|
648
|
-
name: 'Pengumuman: pilih jadwal rapat',
|
|
649
|
-
values: ['Senin', 'Rabu', 'Jumat'],
|
|
650
|
-
selectableCount: 1,
|
|
651
|
-
toAnnouncementGroup: true
|
|
652
|
-
}
|
|
653
|
-
})
|
|
654
|
-
```
|
|
655
|
-
|
|
656
|
-
> Catatan: `selectableCount: 1` otomatis menghasilkan `pollCreationMessageV3` (single-select), sedangkan `> 1` menghasilkan `pollCreationMessage` (multi-select). `toAnnouncementGroup: true` mengarah ke `pollCreationMessageV2` untuk grup komunitas.
|
|
657
|
-
|
|
658
|
-
Membaca hasil vote dari event `messages.update`:
|
|
659
|
-
|
|
660
|
-
```js
|
|
661
|
-
import { getAggregateVotesInPollMessage } from '@vinzsocket/baileys'
|
|
662
|
-
|
|
663
|
-
sock.ev.on('messages.update', (updates) => {
|
|
664
|
-
for (const { key, update } of updates) {
|
|
665
|
-
if (update.pollUpdates) {
|
|
666
|
-
const votes = getAggregateVotesInPollMessage({
|
|
667
|
-
message: originalPollMessage, // ambil dari store Anda via key
|
|
668
|
-
pollUpdates: update.pollUpdates
|
|
669
|
-
}, sock.user.id)
|
|
670
|
-
console.log(votes)
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
})
|
|
674
|
-
```
|
|
675
|
-
|
|
676
|
-
### Event / Undangan Acara
|
|
677
|
-
|
|
678
|
-
```js
|
|
679
|
-
await sock.sendMessage(jid, {
|
|
680
|
-
event: {
|
|
681
|
-
name: 'Rapat Koordinasi Bulanan',
|
|
682
|
-
description: 'Bahas roadmap fitur Q3',
|
|
683
|
-
startDate: new Date('2026-08-01T09:00:00+07:00'),
|
|
684
|
-
endDate: new Date('2026-08-01T11:00:00+07:00'),
|
|
685
|
-
location: { degreesLatitude: -6.2, degreesLongitude: 106.8, name: 'Kantor Pusat' },
|
|
686
|
-
extraGuestsAllowed: true
|
|
687
|
-
}
|
|
688
|
-
})
|
|
689
|
-
```
|
|
690
|
-
|
|
691
|
-
Event dengan tombol join-call otomatis (audio/video call link):
|
|
692
|
-
|
|
693
|
-
```js
|
|
694
|
-
await sock.sendMessage(jid, {
|
|
695
|
-
event: {
|
|
696
|
-
name: 'Sync Mingguan (Voice)',
|
|
697
|
-
description: 'Join lewat tombol di bawah',
|
|
698
|
-
startDate: new Date(),
|
|
699
|
-
call: 'audio' // atau 'video' — butuh getCallLink di config (createCallLink)
|
|
700
|
-
}
|
|
701
|
-
})
|
|
702
|
-
```
|
|
703
|
-
|
|
704
|
-
### Hapus, Edit, Pin Pesan
|
|
705
|
-
|
|
706
|
-
**Hapus (revoke) pesan:**
|
|
707
|
-
|
|
708
|
-
```js
|
|
709
|
-
await sock.sendMessage(jid, { delete: msg.key })
|
|
710
|
-
```
|
|
711
|
-
|
|
712
|
-
**Edit pesan:**
|
|
713
|
-
|
|
714
|
-
```js
|
|
715
|
-
await sock.sendMessage(jid, {
|
|
716
|
-
text: 'Teks yang sudah diperbarui',
|
|
717
|
-
edit: msg.key
|
|
718
|
-
})
|
|
719
|
-
```
|
|
720
|
-
|
|
721
|
-
**Pin pesan di chat (1 hari):**
|
|
722
|
-
|
|
723
|
-
```js
|
|
724
|
-
await sock.sendMessage(jid, {
|
|
725
|
-
pin: msg.key,
|
|
726
|
-
type: 1, // 1 = pin, 2 = unpin
|
|
727
|
-
time: 86400 // durasi pin dalam detik
|
|
728
|
-
})
|
|
729
|
-
```
|
|
730
|
-
|
|
731
|
-
### View Once & PTV
|
|
732
|
-
|
|
733
|
-
**View once (media sekali lihat):**
|
|
734
|
-
|
|
735
|
-
```js
|
|
736
|
-
await sock.sendMessage(jid, {
|
|
737
|
-
image: { url: 'https://example.com/rahasia.jpg' },
|
|
738
|
-
caption: 'Cuma bisa dilihat sekali',
|
|
739
|
-
viewOnce: true
|
|
740
|
-
})
|
|
741
|
-
```
|
|
742
|
-
|
|
743
|
-
**Video pesan bulat (PTV — Push To Video, seperti voice note tapi video):**
|
|
744
|
-
|
|
745
|
-
```js
|
|
746
|
-
await sock.sendMessage(jid, {
|
|
747
|
-
video: fs.readFileSync('./ptv.mp4'),
|
|
748
|
-
ptv: true
|
|
749
|
-
})
|
|
750
|
-
```
|
|
751
|
-
|
|
752
|
-
### Mention & Tag Semua
|
|
753
|
-
|
|
754
|
-
Mention manual di teks:
|
|
755
|
-
|
|
756
|
-
```js
|
|
757
|
-
await sock.sendMessage(jid, {
|
|
758
|
-
text: `Halo @${'6281234567890'}, cek pesan ini ya!`,
|
|
759
|
-
mentions: ['6281234567890@s.whatsapp.net']
|
|
760
|
-
})
|
|
761
|
-
```
|
|
762
|
-
|
|
763
|
-
Tag semua anggota grup (tanpa menuliskan satu per satu — non-JID mentions, muncul sebagai "@all" style di beberapa client):
|
|
764
|
-
|
|
765
|
-
```js
|
|
766
|
-
await sock.sendMessage(jid, {
|
|
767
|
-
text: 'Pengumuman penting untuk semua anggota!',
|
|
768
|
-
mentionAll: true
|
|
769
|
-
})
|
|
770
|
-
```
|
|
771
|
-
|
|
772
|
-
> Untuk tag-all yang menampilkan nama tiap anggota dengan aman (menangani kasus JID `@lid`), gunakan `buildTagAllText()` — lihat bagian [Mention Utilities](#-mention-utilities-mentionjs).
|
|
773
|
-
|
|
774
|
-
### Forward Pesan
|
|
775
|
-
|
|
776
|
-
```js
|
|
777
|
-
await sock.sendMessage(jid, {
|
|
778
|
-
forward: msg, // pesan WAMessage yang ingin diteruskan
|
|
779
|
-
force: false // true untuk memaksa status forwarded meski baru diteruskan 1x
|
|
780
|
-
})
|
|
781
|
-
```
|
|
782
|
-
|
|
783
|
-
---
|
|
784
|
-
|
|
785
|
-
## 🔘 Tombol & List — Native Flow
|
|
786
|
-
|
|
787
|
-
WhatsApp modern hanya mendukung **Native Flow** (`interactiveMessage.nativeFlowMessage`) untuk tombol interaktif. Bentuk lama (`buttonsMessage`, `templateMessage`/hydrated template) sudah **deprecated oleh WhatsApp** dan sempat menjadi subjek advisory keamanan (rawan spoofing) di komunitas Baileys — karena itu Harps-Baileys **tidak pernah** menghasilkan payload legacy tersebut, walaupun Anda menulis kode dengan gaya lama. Semua shorthand di bawah ini otomatis dikonversi ke Native Flow modern.
|
|
788
|
-
|
|
789
|
-
### Shorthand `buttons` / `templateButtons` / `interactiveButtons`
|
|
790
|
-
|
|
791
|
-
Ketiga nama field ini diperlakukan sama — pilih mana saja yang paling familiar untuk Anda (berguna saat migrasi dari fork lain).
|
|
792
|
-
|
|
793
|
-
```js
|
|
794
|
-
await sock.sendMessage(jid, {
|
|
795
|
-
text: 'Pilih salah satu opsi di bawah:',
|
|
796
|
-
footer: 'Harps-MD',
|
|
797
|
-
buttons: [
|
|
798
|
-
{ id: 'menu_1', text: '📋 Menu Utama' },
|
|
799
|
-
{ id: 'menu_2', text: '⚙️ Pengaturan' },
|
|
800
|
-
{ id: 'menu_3', text: '❓ Bantuan' }
|
|
801
|
-
]
|
|
802
|
-
}, { quoted: msg })
|
|
803
|
-
```
|
|
804
|
-
|
|
805
|
-
Dengan gambar/video sebagai header (otomatis dijadikan `interactiveMessage.header`):
|
|
806
|
-
|
|
807
|
-
```js
|
|
808
|
-
await sock.sendMessage(jid, {
|
|
809
|
-
image: { url: 'https://example.com/banner.jpg' },
|
|
810
|
-
caption: 'Selamat datang di Harps-MD!',
|
|
811
|
-
footer: 'Ketuk salah satu tombol',
|
|
812
|
-
buttons: [
|
|
813
|
-
{ id: 'start', text: '🚀 Mulai' },
|
|
814
|
-
{ id: 'info', text: 'ℹ️ Info Bot' }
|
|
815
|
-
]
|
|
816
|
-
})
|
|
817
|
-
```
|
|
818
|
-
|
|
819
|
-
Format button yang didukung `normalizeToNativeFlowButtons()` (semua di bawah ini valid & saling setara secara fungsi):
|
|
820
|
-
|
|
821
|
-
```js
|
|
822
|
-
// 1. Native flow langsung (paling eksplisit)
|
|
823
|
-
{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'OK', id: 'ok' }) }
|
|
824
|
-
|
|
825
|
-
// 2. Legacy template wrapper
|
|
826
|
-
{ urlButton: { displayText: 'Website', url: 'https://example.com' } }
|
|
827
|
-
{ callButton: { displayText: 'Telepon', phoneNumber: '+6281234567890' } }
|
|
828
|
-
{ quickReplyButton: { displayText: 'Ya', id: 'yes' } }
|
|
829
|
-
|
|
830
|
-
// 3. Classic buttonsMessage shape
|
|
831
|
-
{ buttonId: 'yes', buttonText: { displayText: 'Ya' } }
|
|
832
|
-
|
|
833
|
-
// 4. Simple shape (paling ringkas, direkomendasikan)
|
|
834
|
-
{ id: 'yes', text: 'Ya' }
|
|
835
|
-
{ id: 'yes', displayText: 'Ya' }
|
|
836
|
-
```
|
|
837
|
-
|
|
838
|
-
### Shorthand `sections` (List Message)
|
|
839
|
-
|
|
840
|
-
```js
|
|
841
|
-
await sock.sendMessage(jid, {
|
|
842
|
-
text: 'Silakan pilih menu:',
|
|
843
|
-
title: '📋 Katalog Harps Shop',
|
|
844
|
-
buttonText: 'Buka Menu',
|
|
845
|
-
footer: 'Harps-MD',
|
|
846
|
-
sections: [
|
|
847
|
-
{
|
|
848
|
-
title: '⚔️ Senjata',
|
|
849
|
-
rows: [
|
|
850
|
-
{ rowId: 'sword', title: 'Pedang Besi', description: '40 ATK' },
|
|
851
|
-
{ rowId: 'bow', title: 'Busur', description: '30 ATK' }
|
|
852
|
-
]
|
|
853
|
-
},
|
|
854
|
-
{
|
|
855
|
-
title: '🛡️ Armor',
|
|
856
|
-
rows: [
|
|
857
|
-
{ rowId: 'shield', title: 'Perisai Kayu', description: '15 DEF' }
|
|
858
|
-
]
|
|
859
|
-
}
|
|
860
|
-
]
|
|
861
|
-
}, { quoted: msg })
|
|
862
|
-
```
|
|
863
|
-
|
|
864
|
-
### Shorthand `cards` (Carousel)
|
|
865
|
-
|
|
866
|
-
Carousel horizontal-scroll — cocok untuk katalog produk atau daftar item RPG dengan gambar:
|
|
867
|
-
|
|
868
|
-
```js
|
|
869
|
-
await sock.sendMessage(jid, {
|
|
870
|
-
text: 'Geser untuk lihat item lainnya:',
|
|
871
|
-
footer: 'Harps Shop',
|
|
872
|
-
cards: [
|
|
873
|
-
{
|
|
874
|
-
image: { url: 'https://example.com/sword.jpg' },
|
|
875
|
-
title: 'Pedang Legendaris',
|
|
876
|
-
body: 'ATK +100, harga 5000 gold',
|
|
877
|
-
buttons: [{ id: 'buy_sword', text: '💰 Beli' }]
|
|
878
|
-
},
|
|
879
|
-
{
|
|
880
|
-
image: { url: 'https://example.com/shield.jpg' },
|
|
881
|
-
title: 'Perisai Naga',
|
|
882
|
-
body: 'DEF +80, harga 3500 gold',
|
|
883
|
-
buttons: [{ id: 'buy_shield', text: '💰 Beli' }]
|
|
884
|
-
}
|
|
885
|
-
]
|
|
886
|
-
})
|
|
887
|
-
```
|
|
888
|
-
|
|
889
|
-
Setiap kartu (`card`) menerima field yang sama seperti pesan interaktif tunggal: `image`/`video`, `title`, `body` (atau `text`/`caption`), `footer`, dan `buttons` (format sama seperti shorthand `buttons` di atas).
|
|
890
|
-
|
|
891
|
-
---
|
|
892
|
-
|
|
893
|
-
## 🐉 Fitur Eksklusif Harps-Baileys (`dugong.js`)
|
|
894
|
-
|
|
895
|
-
`Socket/dugong.js` adalah jantung dari fitur-fitur khas Harps-Baileys — sebuah `ExtendedMessageBuilder` yang dipasang otomatis di dalam `sendMessage()`. Ia mendeteksi tipe pesan lanjutan berdasarkan field yang Anda kirim (`requestPaymentMessage`, `productMessage`, `interactiveMessage`, `albumMessage`, `eventMessage`, `pollResultMessage`, `groupStatusMessage`, `nestedListMessage`, `multiSelectMessage`) dan merakit payload protobuf yang sesuai — termasuk `additionalNodes` binary hint yang wajib ada supaya WhatsApp benar-benar merender pesan tersebut.
|
|
896
|
-
|
|
897
|
-
### NF V7 Button Builders
|
|
898
|
-
|
|
899
|
-
Semua builder ini bisa diimpor langsung untuk kontrol penuh atas payload (dipakai bersama `interactiveMessage.buttons` di level rendah, atau lewat shorthand `buttons` seperti dijelaskan sebelumnya):
|
|
900
|
-
|
|
901
|
-
```js
|
|
902
|
-
import {
|
|
903
|
-
nfButtonUrl, nfButtonCall, nfButtonCopy,
|
|
904
|
-
nfButtonReminder, nfButtonCancelReminder,
|
|
905
|
-
nfButtonAddress, nfButtonLocation,
|
|
906
|
-
nfButtonQuickReply, nfButtonSingleSelect,
|
|
907
|
-
nfButtonMultiSelect,
|
|
908
|
-
nfButtonReviewPay, nfButtonReviewOrder, nfButtonMPM
|
|
909
|
-
} from '@vinzsocket/baileys/lib/Socket/dugong.js'
|
|
910
|
-
```
|
|
911
|
-
|
|
912
|
-
| Builder | `name` Proto | Fungsi |
|
|
913
|
-
|---|---|---|
|
|
914
|
-
| `nfButtonUrl` | `cta_url` | Buka URL eksternal |
|
|
915
|
-
| `nfButtonCall` | `cta_call` | Panggil nomor telepon |
|
|
916
|
-
| `nfButtonCopy` | `cta_copy` | Salin kode/teks ke clipboard |
|
|
917
|
-
| `nfButtonReminder` | `cta_reminder` | Set reminder kalender |
|
|
918
|
-
| `nfButtonCancelReminder` | `cta_cancel_reminder` | Batalkan reminder yang sudah dibuat |
|
|
919
|
-
| `nfButtonAddress` | `address_message` | Minta pengguna isi & kirim alamat |
|
|
920
|
-
| `nfButtonLocation` | `send_location` | Minta pengguna kirim lokasi GPS |
|
|
921
|
-
| `nfButtonQuickReply` | `quick_reply` | Balasan cepat (mengirim id ke bot) |
|
|
922
|
-
| `nfButtonSingleSelect` | `single_select` | Satu tombol dropdown (list picker) |
|
|
923
|
-
| `nfButtonMultiSelect` | `single_select` × N | Beberapa tombol dropdown sekaligus |
|
|
924
|
-
| `nfButtonReviewPay` | `review_and_pay` | Alur pembayaran (review & pay) |
|
|
925
|
-
| `nfButtonReviewOrder` | `review_order` | Review status pesanan |
|
|
926
|
-
| `nfButtonMPM` | `mpm` | Multi-Product Message (katalog produk) |
|
|
927
|
-
|
|
928
|
-
Contoh penggunaan campuran beberapa builder dalam satu `interactiveMessage`:
|
|
929
|
-
|
|
930
|
-
```js
|
|
931
|
-
await conn.sendMessage(jid, {
|
|
932
|
-
interactiveMessage: {
|
|
933
|
-
title: '🎛️ Mixed Buttons',
|
|
934
|
-
footer: 'Harps-MD',
|
|
935
|
-
buttons: [
|
|
936
|
-
nfButtonQuickReply({ id: 'ok', displayText: '✅ OK' }),
|
|
937
|
-
nfButtonUrl({ displayText: '🌐 Website', url: 'https://example.com' }),
|
|
938
|
-
nfButtonCopy({ displayText: '📋 Salin', copyCode: 'KODE123' }),
|
|
939
|
-
nfButtonCall({ displayText: '📞 Hubungi Kami', phoneNumber: '+6281234567890' }),
|
|
940
|
-
nfButtonReminder({
|
|
941
|
-
displayText: '⏰ Ingatkan Saya',
|
|
942
|
-
title: 'Cek stok baru',
|
|
943
|
-
notes: 'Reminder dari Harps-MD',
|
|
944
|
-
startTime: Math.floor(Date.now() / 1000) + 3600,
|
|
945
|
-
endTime: Math.floor(Date.now() / 1000) + 7200
|
|
946
|
-
}),
|
|
947
|
-
nfButtonLocation({ displayText: '📍 Bagikan Lokasi' }),
|
|
948
|
-
nfButtonSingleSelect({
|
|
949
|
-
displayText: '📋 Pilih Kategori',
|
|
950
|
-
sections: [
|
|
951
|
-
{ title: 'Kategori', rows: [
|
|
952
|
-
{ id: 'a', title: 'Opsi A' },
|
|
953
|
-
{ id: 'b', title: 'Opsi B' }
|
|
954
|
-
]}
|
|
955
|
-
]
|
|
956
|
-
})
|
|
957
|
-
]
|
|
958
|
-
}
|
|
959
|
-
}, { quoted: msg })
|
|
960
|
-
```
|
|
961
|
-
|
|
962
|
-
Contoh `nfButtonReviewPay` (alur pembayaran):
|
|
963
|
-
|
|
964
|
-
```js
|
|
965
|
-
const paymentButton = nfButtonReviewPay({
|
|
966
|
-
currency: 'IDR',
|
|
967
|
-
totalAmount1000: 150000000, // Rp150.000 (dikalikan 1000 sesuai konvensi WA)
|
|
968
|
-
subtotal: 140000000,
|
|
969
|
-
tax: 10000000,
|
|
970
|
-
items: [{ name: 'Paket Premium Harps-MD', amount: { value: 140000000, offset: 1000 }, quantity: 1 }],
|
|
971
|
-
merchant: { displayName: 'Harps Store' }
|
|
972
|
-
})
|
|
973
|
-
```
|
|
974
|
-
|
|
975
|
-
Contoh `nfButtonMPM` (multi-product message):
|
|
976
|
-
|
|
977
|
-
```js
|
|
978
|
-
const mpmButton = nfButtonMPM({
|
|
979
|
-
sections: [
|
|
980
|
-
{ title: 'Produk Unggulan', productItems: [{ productId: 'prod_001' }, { productId: 'prod_002' }] }
|
|
981
|
-
]
|
|
982
|
-
})
|
|
983
|
-
```
|
|
984
|
-
|
|
985
|
-
### Multi-Select Message
|
|
986
|
-
|
|
987
|
-
Satu pesan dengan **beberapa** tombol dropdown independen — masing-masing tombol membuka bottom sheet-nya sendiri dengan section & row berbeda. Sangat berguna untuk form konfigurasi multi-langkah (mis. pilih senjata + armor sekaligus di RPG).
|
|
988
|
-
|
|
989
|
-
```js
|
|
990
|
-
await conn.sendMessage(jid, {
|
|
991
|
-
multiSelectMessage: {
|
|
992
|
-
title: '⚙️ Konfigurasi Karakter',
|
|
993
|
-
footer: 'Pilih semua opsi',
|
|
994
|
-
selectors: [
|
|
995
|
-
{
|
|
996
|
-
displayText: '⚔️ Pilih Senjata',
|
|
997
|
-
sections: [
|
|
998
|
-
{
|
|
999
|
-
title: '🗡️ Melee',
|
|
1000
|
-
rows: [
|
|
1001
|
-
{ id: 'sword', title: '⚔️ Iron Sword', description: '40 ATK' },
|
|
1002
|
-
{ id: 'axe', title: '🪓 Battle Axe', description: '60 ATK' }
|
|
1003
|
-
]
|
|
1004
|
-
},
|
|
1005
|
-
{
|
|
1006
|
-
title: '🏹 Ranged',
|
|
1007
|
-
rows: [
|
|
1008
|
-
{ id: 'bow', title: '🏹 Busur', description: '30 ATK' },
|
|
1009
|
-
{ id: 'xbow', title: '🔫 Crossbow', description: '55 ATK' }
|
|
1010
|
-
]
|
|
1011
|
-
}
|
|
1012
|
-
]
|
|
1013
|
-
},
|
|
1014
|
-
{
|
|
1015
|
-
displayText: '🛡️ Pilih Armor',
|
|
1016
|
-
sections: [
|
|
1017
|
-
{
|
|
1018
|
-
title: '🧥 Light',
|
|
1019
|
-
rows: [
|
|
1020
|
-
{ id: 'cloth', title: '👕 Cloth', description: '10 DEF' },
|
|
1021
|
-
{ id: 'leather', title: '🥼 Leather', description: '25 DEF' }
|
|
1022
|
-
]
|
|
1023
|
-
}
|
|
1024
|
-
]
|
|
1025
|
-
}
|
|
1026
|
-
],
|
|
1027
|
-
// Tombol tambahan opsional, digabung setelah semua dropdown selector
|
|
1028
|
-
extraButtons: [
|
|
1029
|
-
{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: '✅ Konfirmasi', id: 'confirm' }) }
|
|
1030
|
-
]
|
|
1031
|
-
}
|
|
1032
|
-
}, { quoted: msg })
|
|
1033
|
-
```
|
|
1034
|
-
|
|
1035
|
-
Menangkap balasan dari selector di handler pesan masuk — setiap selector merespons sebagai `single_select` biasa, jadi Anda membaca `selectedRowId` dari respons native flow seperti biasa, dan gunakan konteks percakapan (state bot Anda) untuk tahu selector mana yang sedang dijawab.
|
|
1036
|
-
|
|
1037
|
-
### Nested List Message
|
|
1038
|
-
|
|
1039
|
-
`listMessage` legacy dengan **auto-flatten**: baris (`row`) yang memiliki `rows` miliknya sendiri otomatis dipecah menjadi *section* baru, bukan nested secara visual (karena WhatsApp tidak mendukung nesting sungguhan di list message).
|
|
1040
|
-
|
|
1041
|
-
```js
|
|
1042
|
-
await conn.sendMessage(jid, {
|
|
1043
|
-
nestedListMessage: {
|
|
1044
|
-
title: '🛒 Harps Shop',
|
|
1045
|
-
buttonText: '📋 Buka Katalog',
|
|
1046
|
-
footer: 'Pilih item',
|
|
1047
|
-
sections: [
|
|
1048
|
-
{
|
|
1049
|
-
title: '⚔️ Senjata',
|
|
1050
|
-
rows: [
|
|
1051
|
-
// Row biasa (flat), tetap ada di section "⚔️ Senjata"
|
|
1052
|
-
{ rowId: 'dagger', title: '🗡️ Dagger', description: '25 ATK' },
|
|
1053
|
-
// Row dengan `.rows` → otomatis jadi SECTION BARU "🏹 Jarak Jauh"
|
|
1054
|
-
{
|
|
1055
|
-
title: '🏹 Jarak Jauh',
|
|
1056
|
-
rows: [
|
|
1057
|
-
{ rowId: 'bow', title: '🏹 Busur', description: '30 ATK' },
|
|
1058
|
-
{ rowId: 'xbow', title: '🔫 Crossbow', description: '55 ATK' }
|
|
1059
|
-
]
|
|
1060
|
-
}
|
|
1061
|
-
]
|
|
1062
|
-
}
|
|
1063
|
-
]
|
|
1064
|
-
}
|
|
1065
|
-
}, { quoted: msg })
|
|
1066
|
-
```
|
|
1067
|
-
|
|
1068
|
-
Hasil setelah flatten (`buildNestedListMessage()`) akan berupa 2 section terpisah: `⚔️ Senjata` (berisi Dagger) dan `🏹 Jarak Jauh` (berisi Busur & Crossbow) — keduanya tetap tampil sebagai list picker WhatsApp standar.
|
|
1069
|
-
|
|
1070
|
-
`buildNestedListMessage()` juga bisa dipanggil langsung tanpa lewat `sendMessage` jika Anda hanya ingin objek payload-nya:
|
|
1071
|
-
|
|
1072
|
-
```js
|
|
1073
|
-
import { buildNestedListMessage } from '@vinzsocket/baileys/lib/Socket/dugong.js'
|
|
1074
|
-
|
|
1075
|
-
const payload = buildNestedListMessage({
|
|
1076
|
-
title: 'Menu',
|
|
1077
|
-
buttonText: 'Buka',
|
|
1078
|
-
sections: [ /* ... */ ]
|
|
1079
|
-
})
|
|
1080
|
-
// payload => { listMessage: { title, description, buttonText, listType: 1, sections: [...] } }
|
|
1081
|
-
```
|
|
1082
|
-
|
|
1083
|
-
### Group Status V2 (Story Grup)
|
|
1084
|
-
|
|
1085
|
-
Fitur untuk mengirim **story/status langsung ke sebuah grup** (bukan status pribadi Anda) — muncul sebagai ring status khusus untuk anggota grup tersebut. Mendukung semua tipe media dengan caption.
|
|
1086
|
-
|
|
1087
|
-
**Teks biasa:**
|
|
1088
|
-
|
|
1089
|
-
```js
|
|
1090
|
-
await conn.sendMessage(groupJid, {
|
|
1091
|
-
groupStatusMessage: { text: '📢 Pengumuman penting dari admin!' }
|
|
1092
|
-
})
|
|
1093
|
-
```
|
|
1094
|
-
|
|
1095
|
-
**Teks dengan gaya warna latar:**
|
|
1096
|
-
|
|
1097
|
-
```js
|
|
1098
|
-
await conn.sendMessage(groupJid, {
|
|
1099
|
-
groupStatusMessage: {
|
|
1100
|
-
text: 'Status dengan background merah',
|
|
1101
|
-
backgroundColor: 0xFFE53935, // ARGB
|
|
1102
|
-
textArgb: 0xFFFFFFFF,
|
|
1103
|
-
font: 1 // 0-5
|
|
1104
|
-
}
|
|
1105
|
-
})
|
|
1106
|
-
```
|
|
1107
|
-
|
|
1108
|
-
**Foto dengan caption:**
|
|
1109
|
-
|
|
1110
|
-
```js
|
|
1111
|
-
await conn.sendMessage(groupJid, {
|
|
1112
|
-
groupStatusMessage: {
|
|
1113
|
-
image: { url: 'https://example.com/photo.jpg' }, // atau Buffer
|
|
1114
|
-
caption: '📸 Foto kegiatan hari ini!'
|
|
1115
|
-
}
|
|
1116
|
-
})
|
|
1117
|
-
```
|
|
1118
|
-
|
|
1119
|
-
**Video dengan caption:**
|
|
1120
|
-
|
|
1121
|
-
```js
|
|
1122
|
-
await conn.sendMessage(groupJid, {
|
|
1123
|
-
groupStatusMessage: {
|
|
1124
|
-
video: { url: 'https://example.com/video.mp4' },
|
|
1125
|
-
caption: '🎬 Video kegiatan',
|
|
1126
|
-
seconds: 30 // opsional, durasi
|
|
1127
|
-
}
|
|
1128
|
-
})
|
|
1129
|
-
```
|
|
1130
|
-
|
|
1131
|
-
**GIF (video dengan `gifPlayback`):**
|
|
1132
|
-
|
|
1133
|
-
```js
|
|
1134
|
-
await conn.sendMessage(groupJid, {
|
|
1135
|
-
groupStatusMessage: {
|
|
1136
|
-
video: { url: 'https://example.com/anim.mp4' },
|
|
1137
|
-
gifPlayback: true
|
|
1138
|
-
}
|
|
1139
|
-
})
|
|
1140
|
-
```
|
|
1141
|
-
|
|
1142
|
-
**Audio voice note:**
|
|
1143
|
-
|
|
1144
|
-
```js
|
|
1145
|
-
await conn.sendMessage(groupJid, {
|
|
1146
|
-
groupStatusMessage: {
|
|
1147
|
-
audio: { url: 'https://example.com/voice.ogg' },
|
|
1148
|
-
ptt: true,
|
|
1149
|
-
seconds: 15
|
|
1150
|
-
}
|
|
1151
|
-
})
|
|
1152
|
-
```
|
|
1153
|
-
|
|
1154
|
-
**Audio musik:**
|
|
1155
|
-
|
|
1156
|
-
```js
|
|
1157
|
-
await conn.sendMessage(groupJid, {
|
|
1158
|
-
groupStatusMessage: {
|
|
1159
|
-
audio: { url: 'https://example.com/music.mp3' },
|
|
1160
|
-
ptt: false,
|
|
1161
|
-
mimetype: 'audio/mp4' // atau 'audio/mpeg'
|
|
1162
|
-
}
|
|
1163
|
-
})
|
|
1164
|
-
```
|
|
1165
|
-
|
|
1166
|
-
**Sticker:**
|
|
1167
|
-
|
|
1168
|
-
```js
|
|
1169
|
-
await conn.sendMessage(groupJid, {
|
|
1170
|
-
groupStatusMessage: { sticker: { url: 'https://example.com/sticker.webp' } }
|
|
1171
|
-
})
|
|
1172
|
-
```
|
|
1173
|
-
|
|
1174
|
-
**Dokumen dengan caption:**
|
|
1175
|
-
|
|
1176
|
-
```js
|
|
1177
|
-
await conn.sendMessage(groupJid, {
|
|
1178
|
-
groupStatusMessage: {
|
|
1179
|
-
document: { url: 'https://example.com/file.pdf' },
|
|
1180
|
-
mimetype: 'application/pdf',
|
|
1181
|
-
fileName: 'Laporan.pdf',
|
|
1182
|
-
caption: '📄 Laporan bulan ini'
|
|
1183
|
-
}
|
|
1184
|
-
})
|
|
1185
|
-
```
|
|
1186
|
-
|
|
1187
|
-
**Story card yang di-generate otomatis (lihat bagian berikutnya):**
|
|
1188
|
-
|
|
1189
|
-
```js
|
|
1190
|
-
await conn.sendMessage(groupJid, {
|
|
1191
|
-
groupStatusMessage: {
|
|
1192
|
-
card: {
|
|
1193
|
-
title: 'Level Up!',
|
|
1194
|
-
body: 'Karaktermu naik ke level 25',
|
|
1195
|
-
footer: 'Harps-MD RPG System',
|
|
1196
|
-
gradient: 'sunset'
|
|
1197
|
-
},
|
|
1198
|
-
caption: '🎉 Selamat!'
|
|
1199
|
-
}
|
|
1200
|
-
})
|
|
1201
|
-
```
|
|
1202
|
-
|
|
1203
|
-
**Pre-built WAMessage (advanced, kontrol penuh):**
|
|
1204
|
-
|
|
1205
|
-
```js
|
|
1206
|
-
await conn.sendMessage(groupJid, {
|
|
1207
|
-
groupStatusMessage: {
|
|
1208
|
-
message: { imageMessage: { /* ...payload imageMessage lengkap yang sudah jadi... */ } }
|
|
1209
|
-
}
|
|
1210
|
-
})
|
|
1211
|
-
```
|
|
1212
|
-
|
|
1213
|
-
**Raw relay (forward story apa adanya):**
|
|
1214
|
-
|
|
1215
|
-
```js
|
|
1216
|
-
await conn.sendMessage(groupJid, {
|
|
1217
|
-
groupStatusMessage: { raw: existingMessagePayload }
|
|
1218
|
-
})
|
|
1219
|
-
```
|
|
1220
|
-
|
|
1221
|
-
> ⚠️ **Penting:** sejak v3.3.0, setiap mode `handleGroupStory()` **wajib** menyertakan `additionalNodes` (node `<meta is_vsn2="1">`) di panggilan `relayMessage()`-nya. Tanpa ini, pesan tetap terkirim & ter-enkripsi normal (tidak ada error), tapi klien penerima tidak tahu payload tersebut harus dirender sebagai story grup — sehingga tidak pernah muncul sebagai ring status untuk anggota lain. Detail lengkap bug ini ada di [Changelog v3.3.0](#-changelog-ringkas). Jika Anda memakai versi ≥ 3.3.0, ini sudah otomatis tertangani.
|
|
1222
|
-
|
|
1223
|
-
### Story Card Generator (`renderStoryCard`)
|
|
1224
|
-
|
|
1225
|
-
`Utils/story-card.js` menyediakan generator gambar status bergaya gradient — **tanpa dependency native**, hanya memakai [Jimp](https://github.com/jimp-dev/jimp) (opsional peer dependency, di-*lazy import* sehingga tidak membebani konsumen yang tidak memakainya).
|
|
1226
|
-
|
|
1227
|
-
```js
|
|
1228
|
-
import { renderStoryCard, STORY_GRADIENTS } from '@vinzsocket/baileys'
|
|
1229
|
-
|
|
1230
|
-
const buffer = await renderStoryCard({
|
|
1231
|
-
title: 'Selamat Datang!',
|
|
1232
|
-
body: 'Bot Harps-MD sudah online 24 jam.',
|
|
1233
|
-
footer: 'harps-md.dev',
|
|
1234
|
-
gradient: 'ocean', // lihat daftar preset di bawah
|
|
1235
|
-
direction: 'vertical' // atau 'diagonal'
|
|
1236
|
-
})
|
|
1237
|
-
|
|
1238
|
-
await sock.sendMessage(jid, { image: buffer, caption: 'Story otomatis!' })
|
|
1239
|
-
```
|
|
1240
|
-
|
|
1241
|
-
**Opsi `renderStoryCard(opts)`:**
|
|
1242
|
-
|
|
1243
|
-
| Opsi | Default | Keterangan |
|
|
1244
|
-
|---|---|---|
|
|
1245
|
-
| `title` | — | Teks besar (headline) |
|
|
1246
|
-
| `body` | — | Teks subtitle di bawah title |
|
|
1247
|
-
| `footer` | — | Teks kecil branding, ditempel di bawah kanvas |
|
|
1248
|
-
| `gradient` | `'purple'` | Preset gradasi: lihat `STORY_GRADIENTS` |
|
|
1249
|
-
| `colors` | — | `[from, to]` ARGB hex eksplisit — mengalahkan `gradient` jika diisi |
|
|
1250
|
-
| `direction` | `'vertical'` | `'vertical'` atau `'diagonal'` |
|
|
1251
|
-
| `width` | `1080` | Lebar kanvas (rasio default status WA: 1080×1920) |
|
|
1252
|
-
| `height` | `1920` | Tinggi kanvas |
|
|
1253
|
-
|
|
1254
|
-
**Preset gradient (`STORY_GRADIENTS`):**
|
|
1255
|
-
|
|
1256
|
-
```js
|
|
1257
|
-
console.log(STORY_GRADIENTS)
|
|
1258
|
-
// ['sunset', 'purple', 'ocean', 'forest', 'midnight', 'fire']
|
|
1259
|
-
```
|
|
1260
|
-
|
|
1261
|
-
| Preset | Warna |
|
|
1262
|
-
|---|---|
|
|
1263
|
-
| `sunset` | Oranye → Peach |
|
|
1264
|
-
| `purple` | Ungu tua → Ungu terang |
|
|
1265
|
-
| `ocean` | Biru laut → Cyan muda |
|
|
1266
|
-
| `forest` | Hijau tua → Hijau muda |
|
|
1267
|
-
| `midnight` | Abu gelap → Abu lebih terang |
|
|
1268
|
-
| `fire` | Merah → Kuning |
|
|
1269
|
-
|
|
1270
|
-
Warna kustom (override total, mengabaikan preset):
|
|
1271
|
-
|
|
1272
|
-
```js
|
|
1273
|
-
const buffer = await renderStoryCard({
|
|
1274
|
-
title: 'Custom Color',
|
|
1275
|
-
colors: ['#FF0080', '#7928CA'],
|
|
1276
|
-
direction: 'diagonal'
|
|
1277
|
-
})
|
|
1278
|
-
```
|
|
1279
|
-
|
|
1280
|
-
Jika `jimp` tidak terpasang, pemanggilan ini akan melempar:
|
|
1281
|
-
|
|
1282
|
-
```
|
|
1283
|
-
Error: renderStoryCard() requires the optional "jimp" peer dependency. Install it with: npm i jimp
|
|
1284
|
-
```
|
|
1285
|
-
|
|
1286
|
-
### Payment Request Message
|
|
1287
|
-
|
|
1288
|
-
```js
|
|
1289
|
-
await conn.sendMessage(jid, {
|
|
1290
|
-
requestPaymentMessage: {
|
|
1291
|
-
amount: 5000000, // Rp50.000 (x1000)
|
|
1292
|
-
currency: 'IDR',
|
|
1293
|
-
from: '0@s.whatsapp.net',
|
|
1294
|
-
note: 'Pembayaran untuk item RPG',
|
|
1295
|
-
expiry: Math.floor(Date.now() / 1000) + 86400
|
|
1296
|
-
}
|
|
1297
|
-
})
|
|
1298
|
-
```
|
|
1299
|
-
|
|
1300
|
-
Dengan sticker sebagai catatan visual (opsional, menggantikan `note` teks):
|
|
1301
|
-
|
|
1302
|
-
```js
|
|
1303
|
-
await conn.sendMessage(jid, {
|
|
1304
|
-
requestPaymentMessage: {
|
|
1305
|
-
amount: 10000000,
|
|
1306
|
-
currency: 'IDR',
|
|
1307
|
-
sticker: { stickerMessage: preparedStickerMessage }
|
|
1308
|
-
}
|
|
1309
|
-
})
|
|
1310
|
-
```
|
|
1311
|
-
|
|
1312
|
-
### Product Message
|
|
1313
|
-
|
|
1314
|
-
```js
|
|
1315
|
-
await conn.sendMessage(jid, {
|
|
1316
|
-
productMessage: {
|
|
1317
|
-
title: 'Sword of Fire',
|
|
1318
|
-
description: 'Senjata legendaris dengan efek terbakar',
|
|
1319
|
-
thumbnail: { url: 'https://example.com/sword.jpg' },
|
|
1320
|
-
productId: 'sword_fire_001',
|
|
1321
|
-
retailerId: 'harps-shop',
|
|
1322
|
-
priceAmount1000: 500000000,
|
|
1323
|
-
currencyCode: 'IDR',
|
|
1324
|
-
body: 'Dapatkan sekarang di Harps Shop!',
|
|
1325
|
-
footer: 'Stok terbatas',
|
|
1326
|
-
buttons: [{ id: 'buy', text: '💰 Beli Sekarang' }]
|
|
1327
|
-
}
|
|
1328
|
-
})
|
|
1329
|
-
```
|
|
1330
|
-
|
|
1331
|
-
Product message dibungkus otomatis sebagai `viewOnceMessage` berisi `interactiveMessage` dengan header produk (`header.productMessage`) — konsisten dengan cara WhatsApp Business menampilkan katalog produk single-item.
|
|
1332
|
-
|
|
1333
|
-
### Album Message
|
|
1334
|
-
|
|
1335
|
-
Kirim beberapa foto/video sebagai satu **album** (dikelompokkan visual di client, mirip carousel foto Instagram):
|
|
1336
|
-
|
|
1337
|
-
```js
|
|
1338
|
-
await conn.sendMessage(jid, {
|
|
1339
|
-
albumMessage: [
|
|
1340
|
-
{ image: { url: 'https://example.com/1.jpg' } },
|
|
1341
|
-
{ image: { url: 'https://example.com/2.jpg' } },
|
|
1342
|
-
{ video: { url: 'https://example.com/clip.mp4' } }
|
|
1343
|
-
]
|
|
1344
|
-
})
|
|
1345
|
-
```
|
|
1346
|
-
|
|
1347
|
-
Di balik layar, `handleAlbum()`:
|
|
1348
|
-
|
|
1349
|
-
1. Mengirim pesan "container" album kosong (`albumMessage` dengan `expectedImageCount` / `expectedVideoCount`).
|
|
1350
|
-
2. Mengirim setiap item media satu per satu sebagai pesan terpisah yang di-*link* ke container lewat `messageContextInfo.messageAssociation` (`associationType: MEDIA_ALBUM`), sehingga client mengelompokkannya secara visual sebagai satu album.
|
|
1351
|
-
|
|
1352
|
-
### Poll Result Snapshot
|
|
1353
|
-
|
|
1354
|
-
Mengirim **snapshot hasil polling** (mis. untuk mengumumkan pemenang polling tanpa perlu vote lagi):
|
|
1355
|
-
|
|
1356
|
-
```js
|
|
1357
|
-
await conn.sendMessage(jid, {
|
|
1358
|
-
pollResultMessage: {
|
|
1359
|
-
name: 'Menu favorit bulan ini',
|
|
1360
|
-
pollVotes: [
|
|
1361
|
-
{ optionName: 'Nasi Padang', optionVoteCount: 42 },
|
|
1362
|
-
{ optionName: 'Bakso', optionVoteCount: 27 },
|
|
1363
|
-
{ optionName: 'Mie Ayam', optionVoteCount: 15 }
|
|
1364
|
-
]
|
|
1365
|
-
}
|
|
1366
|
-
})
|
|
1367
|
-
```
|
|
1368
|
-
|
|
1369
|
-
### `buildInteractiveAdditionalNodes` — Kenapa Wajib Ada
|
|
1370
|
-
|
|
1371
|
-
Ini adalah salah satu fitur paling penting (dan paling mudah terlewat) di seluruh keluarga fork Baileys. WhatsApp **tidak cukup** hanya menerima payload protobuf pesan interaktif — server juga butuh **binary node hint** terpisah yang dikirim bersamaan lewat parameter `additionalNodes` pada `relayMessage()`, di luar isi pesan itu sendiri. Tanpa hint ini:
|
|
1372
|
-
|
|
1373
|
-
- Pesan tetap **terkirim & ter-enkripsi dengan sukses** (tidak ada exception).
|
|
1374
|
-
- Tapi klien penerima **tidak tahu** bahwa payload tersebut harus dirender sebagai list/interactive/story — pesan bisa muncul kosong, sebagai pesan biasa, atau tidak muncul sama sekali.
|
|
1375
|
-
|
|
1376
|
-
`buildInteractiveAdditionalNodes(jid, message)` di `Utils/messages.js` menghasilkan node yang tepat berdasarkan isi pesan:
|
|
1377
|
-
|
|
1378
|
-
| Isi Pesan | Node yang Dihasilkan |
|
|
1379
|
-
|---|---|
|
|
1380
|
-
| `listMessage` | `<biz><list type="product_list" v="2"/></biz>` |
|
|
1381
|
-
| `interactiveMessage` / `buttonsMessage` / `templateMessage` / `productMessage` | `<biz><interactive type="native_flow" v="1"><native_flow name="mixed" v="9"/></interactive></biz>` |
|
|
1382
|
-
| `interactiveMessage.carouselMessage` | sama seperti di atas, tapi `name="carousel"` |
|
|
1383
|
-
| `groupStatusMessageV2` (khusus di dalam grup) | `<meta is_vsn2="1"/>` |
|
|
1384
|
-
| (tambahan, jika bukan grup & ada node interaktif) | `<bot biz_bot="1"/>` |
|
|
1385
|
-
|
|
1386
|
-
**Harps-Baileys sudah memanggil fungsi ini secara otomatis** di dalam `sendMessage()` dan seluruh handler `dugong.js` — Anda **tidak perlu** memanggilnya manual untuk penggunaan normal. Namun jika Anda melakukan `relayMessage()` secara manual (mis. dari plugin custom yang bypass `sendMessage`), pastikan menyertakannya:
|
|
1387
|
-
|
|
1388
|
-
```js
|
|
1389
|
-
import { buildInteractiveAdditionalNodes } from '@vinzsocket/baileys'
|
|
1390
|
-
|
|
1391
|
-
await sock.relayMessage(jid, msg.message, {
|
|
1392
|
-
messageId: msg.key.id,
|
|
1393
|
-
additionalNodes: buildInteractiveAdditionalNodes(jid, msg.message)
|
|
1394
|
-
})
|
|
1395
|
-
```
|
|
1396
|
-
|
|
1397
|
-
Fungsi pendukung terkait, `patchInteractiveMessage(m)`, membungkus payload interactive/button/list/product ke dalam `viewOnceMessage` dengan `messageContextInfo.deviceListMetadataVersion` — konvensi yang dipakai mayoritas fork komunitas (baileys-pro, dsb) agar kompatibel dengan cara WhatsApp memvalidasi pesan tersebut. Fungsi ini juga dipanggil otomatis oleh `generateWAMessageContent()`.
|
|
1398
|
-
|
|
1399
|
-
---
|
|
1400
|
-
|
|
1401
|
-
## 🏷️ Mention Utilities (`mention.js`)
|
|
1402
|
-
|
|
1403
|
-
`Utils/mention.js` diporting dari fork **baileys-lily** dan diadaptasi ke ESM untuk Harps-Baileys. Menyediakan tiga fungsi:
|
|
1404
|
-
|
|
1405
|
-
### `normalizeMentions(mentions)`
|
|
1406
|
-
|
|
1407
|
-
Menormalisasi input mention (string tunggal, array, atau campuran nomor mentah/JID) menjadi array JID valid. Hasilnya **di-cache** (maksimum 1000 entri, auto-clear jika penuh) untuk performa di bot dengan volume mention tinggi.
|
|
1408
|
-
|
|
1409
|
-
```js
|
|
1410
|
-
import { normalizeMentions } from '@vinzsocket/baileys/lib/Utils/mention.js'
|
|
1411
|
-
|
|
1412
|
-
normalizeMentions('6281234567890')
|
|
1413
|
-
// => ['6281234567890@s.whatsapp.net']
|
|
1414
|
-
|
|
1415
|
-
normalizeMentions(['6281234567890', '6289876543210@s.whatsapp.net', null, ''])
|
|
1416
|
-
// => ['6281234567890@s.whatsapp.net', '6289876543210@s.whatsapp.net']
|
|
1417
|
-
```
|
|
1418
|
-
|
|
1419
|
-
### `applyMentions(msg, mentions, contextInfo?)`
|
|
1420
|
-
|
|
1421
|
-
Menyisipkan daftar mention ke dalam sebuah objek pesan mentah — menangani tiga lokasi berbeda sekaligus (`messageContextInfo.mentionedJid`, `contextInfo.mentionedJid` yang diberikan, dan `interactiveMessage.contextInfo.mentionedJid` jika ada), tanpa duplikasi.
|
|
1422
|
-
|
|
1423
|
-
```js
|
|
1424
|
-
import { applyMentions } from '@vinzsocket/baileys/lib/Utils/mention.js'
|
|
1425
|
-
|
|
1426
|
-
const msg = { extendedTextMessage: { text: 'Halo semua' } }
|
|
1427
|
-
applyMentions(msg, ['6281234567890@s.whatsapp.net'])
|
|
1428
|
-
```
|
|
1429
|
-
|
|
1430
|
-
### `buildTagAllText(participants, options?)`
|
|
1431
|
-
|
|
1432
|
-
Membangun teks "tag semua anggota" beserta daftar `mentions`-nya dari `participants` hasil `groupMetadata(jid)` — **menangani kasus JID `@lid` dengan aman**: jika WhatsApp tidak mengungkapkan nomor telepon asli seorang anggota (mode privasi `addressingMode: 'lid'`), fungsi ini **tidak** menampilkan digit LID mentah sebagai `@206244447002720` (yang tidak berarti apa-apa bagi manusia), melainkan jatuh ke nama tampilan (jika Anda punya lookup) atau label generik `@Member`.
|
|
1433
|
-
|
|
1434
|
-
```js
|
|
1435
|
-
import { buildTagAllText } from '@vinzsocket/baileys/lib/Utils/mention.js'
|
|
1436
|
-
|
|
1437
|
-
const metadata = await sock.groupMetadata(groupJid)
|
|
1438
|
-
|
|
1439
|
-
const { text, mentions } = buildTagAllText(metadata.participants, {
|
|
1440
|
-
header: '📢 Pengumuman untuk semua anggota grup!',
|
|
1441
|
-
footer: 'Harap dibaca sampai selesai.',
|
|
1442
|
-
getDisplayName: (jid) => myContactStore[jid]?.notify // opsional, lookup nama dari store Anda
|
|
1443
|
-
})
|
|
1444
|
-
|
|
1445
|
-
await sock.sendMessage(groupJid, { text, mentions })
|
|
1446
|
-
```
|
|
1447
|
-
|
|
1448
|
-
**Perilaku penamaan per anggota:**
|
|
1449
|
-
|
|
1450
|
-
| Kondisi | Yang Ditampilkan |
|
|
1451
|
-
|---|---|
|
|
1452
|
-
| WhatsApp mengungkapkan nomor telepon asli | `@6281234567890` (nomor asli) |
|
|
1453
|
-
| Hanya LID + ada `getDisplayName` yang mengembalikan nama | `@NamaKontak` |
|
|
1454
|
-
| Hanya LID + tidak ada lookup nama | `@Member` (label generik, bukan digit LID) |
|
|
1455
|
-
|
|
1456
|
-
Ini penting karena menampilkan LID mentah bisa terlihat seperti nomor telepon acak/rusak dan membingungkan pengguna — dengan `buildTagAllText`, tampilan tetap rapi apa pun status privasi anggotanya.
|
|
1457
|
-
|
|
1458
|
-
---
|
|
1459
|
-
|
|
1460
|
-
## 📡 Sistem Event
|
|
1461
|
-
|
|
1462
|
-
Semua event WhatsApp diterima lewat `sock.ev` — sebuah `EventEmitter` (dari `@hapi/boom`-style bare event emitter, bukan dari library eksternal). Berikut daftar lengkap event yang dipancarkan oleh Harps-Baileys:
|
|
1463
|
-
|
|
1464
|
-
| Event | Kapan Dipancarkan |
|
|
1465
|
-
|---|---|
|
|
1466
|
-
| `connection.update` | Status koneksi berubah (`connecting`, `open`, `close`) atau QR baru tersedia. |
|
|
1467
|
-
| `creds.update` | Kredensial auth berubah — **wajib** disimpan via `saveCreds()`. |
|
|
1468
|
-
| `messages.upsert` | Pesan baru masuk (atau riwayat sedang sinkron, cek `type`). |
|
|
1469
|
-
| `messages.update` | Pesan yang sudah ada berubah (status baca, reaksi, poll vote, dst). |
|
|
1470
|
-
| `messages.delete` | Satu atau beberapa pesan dihapus. |
|
|
1471
|
-
| `messages.reaction` | Reaksi emoji baru pada sebuah pesan. |
|
|
1472
|
-
| `messages.media-update` | Hasil `updateMediaMessage()` — media berhasil/gagal di-refresh. |
|
|
1473
|
-
| `message-receipt.update` | Update tanda terima (delivered/read) per device. |
|
|
1474
|
-
| `message-capping.update` | Update terkait batasan tampilan pesan (mis. status kadaluarsa). |
|
|
1475
|
-
| `messaging-history.set` | Batch sinkronisasi riwayat chat/kontak/pesan diterima. |
|
|
1476
|
-
| `messaging-history.status` | Status progres sinkronisasi riwayat (mulai/selesai/timeout). |
|
|
1477
|
-
| `chats.upsert` | Chat baru ditambahkan ke daftar. |
|
|
1478
|
-
| `chats.update` | Metadata chat berubah (unread count, pin, mute, dst). |
|
|
1479
|
-
| `chats.delete` | Chat dihapus dari daftar. |
|
|
1480
|
-
| `chats.lock` | (internal) penguncian transaksi app-state untuk chat tertentu. |
|
|
1481
|
-
| `contacts.upsert` | Kontak baru ditambahkan/disinkronkan. |
|
|
1482
|
-
| `contacts.update` | Data kontak berubah (nama, status, dsb). |
|
|
1483
|
-
| `groups.upsert` | Grup baru ditemukan/dibuat. |
|
|
1484
|
-
| `groups.update` | Metadata grup berubah (subjek, deskripsi, setting). |
|
|
1485
|
-
| `group-participants.update` | Anggota ditambah/dikeluarkan/dipromosikan/diturunkan. |
|
|
1486
|
-
| `group.join-request` | Ada permintaan join grup baru (mode approval). |
|
|
1487
|
-
| `group.member-tag.update` | Update label/tag anggota grup. |
|
|
1488
|
-
| `blocklist.update` | Daftar kontak yang diblokir berubah. |
|
|
1489
|
-
| `call` | Ada panggilan masuk/status panggilan berubah. |
|
|
1490
|
-
| `presence.update` | Status online/typing/recording seseorang berubah. |
|
|
1491
|
-
| `labels.edit` | Label chat (fitur WhatsApp Business) diubah. |
|
|
1492
|
-
| `labels.association` | Label ditambahkan/dilepas dari chat/pesan tertentu. |
|
|
1493
|
-
| `newsletter.view` | Statistik view newsletter/channel berubah. |
|
|
1494
|
-
| `newsletter.reaction` | Reaksi baru pada post newsletter/channel. |
|
|
1495
|
-
| `newsletter-settings.update` | Pengaturan newsletter/channel berubah. |
|
|
1496
|
-
| `newsletter-participants.update` | Admin/follower newsletter berubah. |
|
|
1497
|
-
| `lid-mapping.update` | Pemetaan JID nomor telepon ↔ LID diperbarui. |
|
|
1498
|
-
| `settings.update` | Pengaturan akun WhatsApp berubah. |
|
|
1499
|
-
| `event` | Update terkait event/undangan (RSVP, dsb). |
|
|
1500
|
-
|
|
1501
|
-
### Contoh Pola Umum
|
|
1
|
+
<div align="center">
|
|
1502
2
|
|
|
1503
|
-
|
|
1504
|
-
sock.ev.on('messages.upsert', async ({ messages, type }) => {
|
|
1505
|
-
if (type !== 'notify') return // 'notify' = pesan baru real-time
|
|
1506
|
-
for (const msg of messages) {
|
|
1507
|
-
if (!msg.message) continue
|
|
1508
|
-
console.log('Pesan masuk dari:', msg.key.remoteJid)
|
|
1509
|
-
}
|
|
1510
|
-
})
|
|
3
|
+
<img src="https://files.catbox.moe/4rft6r.png" alt="ourin-baileys banner" width="100%" />
|
|
1511
4
|
|
|
1512
|
-
|
|
1513
|
-
if (action === 'add') {
|
|
1514
|
-
for (const p of participants) {
|
|
1515
|
-
await sock.sendMessage(id, { text: `Selamat datang @${p.split('@')[0]}!`, mentions: [p] })
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
})
|
|
5
|
+
### Modded Baileys — Interactive Messages, AI Rich Responses, Albums & More
|
|
1519
6
|
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
}
|
|
1526
|
-
})
|
|
1527
|
-
```
|
|
7
|
+
[](https://www.npmjs.com/package/ourin-baileys)
|
|
8
|
+
[](https://www.npmjs.com/package/ourin-baileys)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://nodejs.org)
|
|
11
|
+
[](#)
|
|
1528
12
|
|
|
1529
|
-
|
|
13
|
+
---
|
|
1530
14
|
|
|
1531
|
-
|
|
15
|
+
**A modded build of [WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)**
|
|
16
|
+
with native support for interactive messages, album messages, unified rich responses, newsletter helpers, status mentions, and additional business/community utilities.
|
|
1532
17
|
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
// ...lakukan banyak operasi...
|
|
1536
|
-
await sock.ev.flush() // proses semua event yang tertunda sekaligus
|
|
1537
|
-
```
|
|
18
|
+
This repository is a **distribution/build repo** for `ourin-baileys`.
|
|
19
|
+
It ships compiled runtime files in `lib/` and protobuf artifacts in `WAProto/`, and is intended to be consumed directly from npm or as a vendored dependency inside the **Ourin-MD** ecosystem.
|
|
1538
20
|
|
|
1539
|
-
|
|
21
|
+
</div>
|
|
1540
22
|
|
|
1541
23
|
---
|
|
1542
24
|
|
|
1543
|
-
##
|
|
25
|
+
## 🆕 Changelog / Updates (v9.0.1)
|
|
1544
26
|
|
|
1545
|
-
|
|
27
|
+
**1. Fix `additionalNodes` Conflict (v9.0.1)**
|
|
1546
28
|
|
|
1547
|
-
|
|
29
|
+
- Fixed an issue where supplying a custom `<biz>` node in `additionalNodes` alongside interactive messages caused duplicate `<biz>` nodes in the stanza, which led to the message being silently rejected by WhatsApp.
|
|
1548
30
|
|
|
1549
|
-
|
|
1550
|
-
// Buat grup baru
|
|
1551
|
-
const group = await sock.groupCreate('Nama Grup Baru', ['6281234567890@s.whatsapp.net', '6289876543210@s.whatsapp.net'])
|
|
1552
|
-
console.log(group.id) // JID grup baru
|
|
31
|
+
**2. Built-in VoIP (Voice Call) Engine (v9.0.0)**
|
|
1553
32
|
|
|
1554
|
-
|
|
1555
|
-
await sock.groupLeave(groupJid)
|
|
33
|
+
- Full integration of the WebRTC and WASM engines to enable native WhatsApp voice calling, eliminating the need for a separate package.
|
|
1556
34
|
|
|
1557
|
-
|
|
1558
|
-
await sock.groupUpdateSubject(groupJid, 'Nama Grup yang Diperbarui')
|
|
35
|
+
**2. Fix View Once Error (Anti-Crash)**
|
|
1559
36
|
|
|
1560
|
-
|
|
1561
|
-
await sock.groupUpdateDescription(groupJid, 'Deskripsi baru untuk grup ini')
|
|
1562
|
-
```
|
|
37
|
+
- WhatsApp (Meta) Web API no longer receives media content for View Once messages, which previously caused the socket to crash. We've added robust parsing (`viewOnceMessageV3` & `ptvMessage`) to gracefully handle these empty stubs without crashing your bot.
|
|
1563
38
|
|
|
1564
|
-
|
|
39
|
+
**2. Decryption Retry Fix (Private Chats)**
|
|
1565
40
|
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
await sock.groupParticipantsUpdate(groupJid, ['6281234567890@s.whatsapp.net'], 'add')
|
|
41
|
+
- Fixed an issue in `messages-recv.js` where "Bad MAC" / decryption errors would close the connection. Combined with a proper `getMessage` hook in your main connection setup, the bot now seamlessly retries failed decryptions.
|
|
42
|
+
- Browser parameter spoofing upgraded to MacOS to prevent Error 405 (Method Not Allowed) during pairing.
|
|
1569
43
|
|
|
1570
|
-
|
|
1571
|
-
await sock.groupParticipantsUpdate(groupJid, ['6281234567890@s.whatsapp.net'], 'remove')
|
|
44
|
+
**3. AI Rich Implementation (`ORich`)**
|
|
1572
45
|
|
|
1573
|
-
|
|
1574
|
-
|
|
46
|
+
- Added the `ORich` class (an extension of `AIRich` from `message_builder.js`) to generate stunning AI response layouts easily.
|
|
47
|
+
- **Example Usage:**
|
|
1575
48
|
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
49
|
+
```javascript
|
|
50
|
+
import { ORich } from 'ourin-baileys';
|
|
51
|
+
|
|
52
|
+
const ourin = new ORich(sock)
|
|
53
|
+
.addText('Hello from ORich AI!')
|
|
54
|
+
.addSuggest(['Tell me more', 'Next']);
|
|
55
|
+
|
|
56
|
+
await ourin.send(jid);
|
|
57
|
+
```
|
|
1579
58
|
|
|
1580
|
-
|
|
59
|
+
---
|
|
1581
60
|
|
|
1582
|
-
|
|
61
|
+
## Table of Contents
|
|
62
|
+
|
|
63
|
+
- [ourin-baileys](#ourin-baileys)
|
|
64
|
+
- [Modded Baileys v7 — Interactive Messages, AI Rich Responses, Albums & More](#modded-baileys-v7--interactive-messages-ai-rich-responses-albums--more)
|
|
65
|
+
- [Table of Contents](#table-of-contents)
|
|
66
|
+
- [✨ Features](#-features)
|
|
67
|
+
- [✅ Requirements](#-requirements)
|
|
68
|
+
- [🗂️ What’s Inside This Repo](#-whats-inside-this-repo)
|
|
69
|
+
- [📦 Installation](#-installation)
|
|
70
|
+
- [From NPM](#from-npm)
|
|
71
|
+
- [Using Alias (Recommended for Ourin-MD Bots)](#using-alias-recommended-for-ourin-md-bots)
|
|
72
|
+
- [🛠️ Quick Start](#️-quick-start)
|
|
73
|
+
- [1. Project Setup](#1-project-setup)
|
|
74
|
+
- [2. Install Dependencies](#2-install-dependencies)
|
|
75
|
+
- [3. Create `index.js`](#3-create-indexjs)
|
|
76
|
+
- [4. Run](#4-run)
|
|
77
|
+
- [5. Pairing Code Example](#5-pairing-code-example)
|
|
78
|
+
- [🏗️ Architecture](#️-architecture)
|
|
79
|
+
- [Socket Layer Chain](#socket-layer-chain)
|
|
80
|
+
- [Key Modules](#key-modules)
|
|
81
|
+
- [Build Repo Layout](#build-repo-layout)
|
|
82
|
+
- [Connection Flow](#connection-flow)
|
|
83
|
+
- [📡 Socket API Reference](#-socket-api-reference)
|
|
84
|
+
- [Connection \& Authentication](#connection--authentication)
|
|
85
|
+
- [VoIP (Voice Calls)](#voip-voice-calls)
|
|
86
|
+
- [Message Sending](#message-sending)
|
|
87
|
+
- [Interactive Messages](#interactive-messages)
|
|
88
|
+
- [Album Messages](#album-messages)
|
|
89
|
+
- [AI Rich Response Messages](#ai-rich-response-messages)
|
|
90
|
+
- [Code Block V2 (Unified Response)](#code-block-v2-unified-response)
|
|
91
|
+
- [Other Message Types](#other-message-types)
|
|
92
|
+
- [Newsletter Methods](#newsletter-methods)
|
|
93
|
+
- [Group Methods](#group-methods)
|
|
94
|
+
- [Community Methods](#community-methods)
|
|
95
|
+
- [Business Methods](#business-methods)
|
|
96
|
+
- [Chat \& Profile Methods](#chat--profile-methods)
|
|
97
|
+
- [Privacy Settings](#privacy-settings)
|
|
98
|
+
- [📡 Event Reference](#-event-reference)
|
|
99
|
+
- [🔧 Utility Exports](#-utility-exports)
|
|
100
|
+
- [🏗️ Building This Package](#️-building-this-package)
|
|
101
|
+
- [🔀 Differences from Official Baileys](#-differences-from-official-baileys)
|
|
102
|
+
- [🤝 Contributing](#-contributing)
|
|
103
|
+
- [📄 License](#-license)
|
|
1583
104
|
|
|
1584
|
-
|
|
105
|
+
---
|
|
1585
106
|
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
107
|
+
## ✨ Features
|
|
108
|
+
|
|
109
|
+
| Feature | Description | Status |
|
|
110
|
+
| --------------------------- | -------------------------------------------------------------------------------------- | ------ |
|
|
111
|
+
| **VoIP Voice Calls** | Native VoIP engine (WASM/WebRTC) via `VoipClient`, single shared socket | ✅ |
|
|
112
|
+
| **Interactive Messages** | Native flow buttons, list/select menus, button wrappers, carousel support via `Dugong` | ✅ |
|
|
113
|
+
| **Album Messages** | Multi-image/video album relay with count metadata and grouped delivery | ✅ |
|
|
114
|
+
| **Rich Response Helpers** | `sendTable`, `sendList`, `sendCodeBlock`, `sendRichMessage`, `sendUnifiedResponse` | ✅ |
|
|
115
|
+
| **Unified Response V2** | `sendTableV2`, `sendCodeBlockV2`, `sendLinkV2` with Meta-AI-style unified sections | ✅ |
|
|
116
|
+
| **Link Messages** | Rich inline links with citations, proofs, and forwarded bot context | ✅ |
|
|
117
|
+
| **Latex Rendering Hooks** | `sendLatex`, `sendLatexImage`, `sendLatexInlineImage` helper APIs | ✅ |
|
|
118
|
+
| **Payment Messages** | Request payment messages with note/sticker support | ✅ |
|
|
119
|
+
| **Product / Catalog** | Business product messages, catalog fetch/create/update/delete, cover photo helpers | ✅ |
|
|
120
|
+
| **Event / Poll Result** | Event message builders and poll result snapshots | ✅ |
|
|
121
|
+
| **Newsletter Extras** | URL resolve, metadata fetch, create/update, bulk follow, admin utilities, live updates | ✅ |
|
|
122
|
+
| **Communities & Groups** | Community CRUD, linked groups, invite workflows, join approval, labels | ✅ |
|
|
123
|
+
| **Status Mention** | `sendStatusMention()` helper to mention users/groups in status flows | ✅ |
|
|
124
|
+
| **LID & Session Handling** | LID↔PN mapping, session migration, retry/session recreation helpers | ✅ |
|
|
125
|
+
| **Build Output Ready** | Published runtime in `lib/` and protobuf artifacts in `WAProto/` | ✅ |
|
|
126
|
+
| **TypeScript Declarations** | Included `.d.ts` files for exported APIs and socket methods | ✅ |
|
|
1589
127
|
|
|
1590
|
-
|
|
1591
|
-
await sock.groupRequestParticipantsUpdate(groupJid, ['6281234567890@s.whatsapp.net'], 'approve')
|
|
1592
|
-
await sock.groupRequestParticipantsUpdate(groupJid, ['6281234567890@s.whatsapp.net'], 'reject')
|
|
1593
|
-
```
|
|
128
|
+
---
|
|
1594
129
|
|
|
1595
|
-
|
|
130
|
+
## ✅ Requirements
|
|
1596
131
|
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
132
|
+
- **Node.js** `>= 20.0.0`
|
|
133
|
+
- **ESM project** (`"type": "module"` in your `package.json`)
|
|
134
|
+
- A persistent auth store implementation for production use
|
|
135
|
+
- Optional helpers depending on your use case:
|
|
136
|
+
- `pino` for logging
|
|
137
|
+
- `qrcode-terminal` if you want to render QR codes in the terminal yourself
|
|
138
|
+
- `sharp`, `jimp`, `audio-decode`, `link-preview-js` for optional media/rich utilities
|
|
1601
139
|
|
|
1602
|
-
|
|
1603
|
-
|
|
140
|
+
> [!IMPORTANT]
|
|
141
|
+
> `ourin-baileys` is **ESM-only**. CommonJS projects will need migration or dynamic import wrappers.
|
|
1604
142
|
|
|
1605
|
-
|
|
1606
|
-
const joinedGroupId = await sock.groupAcceptInvite(inviteCode)
|
|
143
|
+
---
|
|
1607
144
|
|
|
1608
|
-
|
|
1609
|
-
const info = await sock.groupGetInviteInfo(inviteCode)
|
|
145
|
+
## 📁 What’s Inside This Repo
|
|
1610
146
|
|
|
1611
|
-
|
|
1612
|
-
await sock.groupRevokeInviteV4(groupJid, targetJid)
|
|
1613
|
-
```
|
|
147
|
+
This package is not the TypeScript source workspace. It contains the compiled distributable files you actually publish/use.
|
|
1614
148
|
|
|
1615
|
-
|
|
149
|
+
| Path | Purpose |
|
|
150
|
+
| --------------------- | ------------------------------------------------------ |
|
|
151
|
+
| `lib/` | Main compiled runtime, types, socket layers, utilities |
|
|
152
|
+
| `WAProto/` | Generated protobuf runtime and typings |
|
|
153
|
+
| `package.json` | Published package metadata, dependencies, build script |
|
|
154
|
+
| `tsconfig.json` | TypeScript config used for authoring/build pipeline |
|
|
155
|
+
| `tsconfig.build.json` | Build-specific TS emit config targeting `lib/` |
|
|
156
|
+
| `proto-extract/` | Protobuf-related extraction/build assets |
|
|
1616
157
|
|
|
1617
|
-
|
|
1618
|
-
// Hanya admin yang bisa kirim pesan ('announcement') atau semua anggota ('not_announcement')
|
|
1619
|
-
await sock.groupSettingUpdate(groupJid, 'announcement')
|
|
158
|
+
If you are documenting or integrating this project, treat `lib/index.js` and `lib/index.d.ts` as the primary public surface.
|
|
1620
159
|
|
|
1621
|
-
|
|
1622
|
-
await sock.groupSettingUpdate(groupJid, 'locked')
|
|
160
|
+
---
|
|
1623
161
|
|
|
1624
|
-
|
|
1625
|
-
await sock.groupMemberAddMode(groupJid, 'admin_add')
|
|
162
|
+
## 📦 Installation
|
|
1626
163
|
|
|
1627
|
-
|
|
1628
|
-
await sock.groupJoinApprovalMode(groupJid, 'on')
|
|
164
|
+
### From NPM
|
|
1629
165
|
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
await sock.groupToggleEphemeral(groupJid, 0) // matikan
|
|
166
|
+
```bash
|
|
167
|
+
npm install ourin-baileys
|
|
1633
168
|
```
|
|
1634
169
|
|
|
1635
|
-
|
|
170
|
+
Recommended companion packages for examples in this README:
|
|
1636
171
|
|
|
1637
|
-
```
|
|
1638
|
-
|
|
1639
|
-
console.log({
|
|
1640
|
-
subject: metadata.subject,
|
|
1641
|
-
desc: metadata.desc,
|
|
1642
|
-
owner: metadata.owner,
|
|
1643
|
-
participants: metadata.participants.length,
|
|
1644
|
-
memberAddMode: metadata.memberAddMode
|
|
1645
|
-
})
|
|
1646
|
-
|
|
1647
|
-
// Ambil semua grup yang diikuti akun ini
|
|
1648
|
-
const allGroups = await sock.groupFetchAllParticipating()
|
|
1649
|
-
console.log(Object.keys(allGroups).length, 'grup diikuti')
|
|
172
|
+
```bash
|
|
173
|
+
npm install pino qrcode-terminal
|
|
1650
174
|
```
|
|
1651
175
|
|
|
1652
|
-
|
|
176
|
+
### Using Alias (Recommended for Ourin-MD Bots)
|
|
1653
177
|
|
|
1654
|
-
|
|
178
|
+
Add to `package.json`:
|
|
1655
179
|
|
|
1656
|
-
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"dependencies": {
|
|
183
|
+
"ourin": "npm:ourin-baileys@latest"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
1657
187
|
|
|
1658
|
-
|
|
188
|
+
Then run:
|
|
1659
189
|
|
|
1660
|
-
```
|
|
1661
|
-
|
|
1662
|
-
const community = await sock.communityCreate('Nama Komunitas', 'Deskripsi komunitas')
|
|
1663
|
-
|
|
1664
|
-
// Buat grup baru langsung di dalam komunitas
|
|
1665
|
-
const subGroup = await sock.communityCreateGroup('Nama Grup', ['6281234567890@s.whatsapp.net'], community.id)
|
|
1666
|
-
|
|
1667
|
-
// Keluar dari komunitas
|
|
1668
|
-
await sock.communityLeave(communityJid)
|
|
1669
|
-
|
|
1670
|
-
// Ubah subjek/deskripsi
|
|
1671
|
-
await sock.communityUpdateSubject(communityJid, 'Nama Baru')
|
|
1672
|
-
await sock.communityUpdateDescription(communityJid, 'Deskripsi baru')
|
|
1673
|
-
|
|
1674
|
-
// Hubungkan / lepaskan grup yang sudah ada ke/dari komunitas
|
|
1675
|
-
await sock.communityLinkGroup(existingGroupJid, communityJid)
|
|
1676
|
-
await sock.communityUnlinkGroup(existingGroupJid, communityJid)
|
|
1677
|
-
|
|
1678
|
-
// Lihat semua grup yang terhubung ke komunitas ini
|
|
1679
|
-
const linkedGroups = await sock.communityFetchLinkedGroups(communityJid)
|
|
1680
|
-
|
|
1681
|
-
// Kelola anggota (sama seperti grup)
|
|
1682
|
-
await sock.communityParticipantsUpdate(communityJid, [jid], 'add')
|
|
1683
|
-
await sock.communityRequestParticipantsList(communityJid)
|
|
1684
|
-
await sock.communityRequestParticipantsUpdate(communityJid, [jid], 'approve')
|
|
1685
|
-
|
|
1686
|
-
// Undangan
|
|
1687
|
-
const code = await sock.communityInviteCode(communityJid)
|
|
1688
|
-
await sock.communityRevokeInvite(communityJid)
|
|
1689
|
-
await sock.communityAcceptInvite(code)
|
|
1690
|
-
await sock.communityRevokeInviteV4(communityJid, targetJid)
|
|
1691
|
-
const info = await sock.communityGetInviteInfo(code)
|
|
1692
|
-
|
|
1693
|
-
// Pengaturan
|
|
1694
|
-
await sock.communityToggleEphemeral(communityJid, 0)
|
|
1695
|
-
await sock.communitySettingUpdate(communityJid, 'announcement')
|
|
1696
|
-
await sock.communityMemberAddMode(communityJid, 'admin_add')
|
|
1697
|
-
await sock.communityJoinApprovalMode(communityJid, 'on')
|
|
1698
|
-
|
|
1699
|
-
// Metadata & daftar semua komunitas yang diikuti
|
|
1700
|
-
const metadata = await sock.communityMetadata(communityJid)
|
|
1701
|
-
const all = await sock.communityFetchAllParticipating()
|
|
190
|
+
```bash
|
|
191
|
+
npm install
|
|
1702
192
|
```
|
|
1703
193
|
|
|
1704
|
-
|
|
194
|
+
> [!TIP]
|
|
195
|
+
> Using the alias `ourin` allows you to `import ourin from 'ourin'` without changing existing code.
|
|
1705
196
|
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
## 💼 Business API
|
|
197
|
+
> [!NOTE]
|
|
198
|
+
> Peer dependencies such as `sharp`, `jimp`, `audio-decode`, and `link-preview-js` are optional. Install only what your bot features need.
|
|
1709
199
|
|
|
1710
|
-
|
|
200
|
+
---
|
|
1711
201
|
|
|
1712
|
-
|
|
1713
|
-
// Ambil detail order (mis. dari pesan review_order)
|
|
1714
|
-
const order = await sock.getOrderDetails(orderId, tokenBase64)
|
|
202
|
+
## 🛠️ Quick Start
|
|
1715
203
|
|
|
1716
|
-
|
|
1717
|
-
const catalog = await sock.getCatalog({ jid: businessJid, limit: 20 })
|
|
204
|
+
### 1. Project Setup
|
|
1718
205
|
|
|
1719
|
-
|
|
1720
|
-
|
|
206
|
+
```bash
|
|
207
|
+
mkdir my-bot && cd my-bot
|
|
208
|
+
npm init -y
|
|
209
|
+
```
|
|
1721
210
|
|
|
1722
|
-
|
|
1723
|
-
const newProduct = await sock.productCreate({
|
|
1724
|
-
name: 'Kaos Harps-MD',
|
|
1725
|
-
description: 'Kaos official merchandise',
|
|
1726
|
-
price: 15000000, // dalam sen/x1000 tergantung mata uang
|
|
1727
|
-
currency: 'IDR',
|
|
1728
|
-
images: [{ url: 'https://example.com/kaos.jpg' }]
|
|
1729
|
-
})
|
|
211
|
+
Ensure `package.json` has `"type": "module"`:
|
|
1730
212
|
|
|
1731
|
-
|
|
1732
|
-
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"name": "my-bot",
|
|
216
|
+
"type": "module",
|
|
217
|
+
"dependencies": {
|
|
218
|
+
"ourin": "npm:ourin-baileys@latest"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
1733
222
|
|
|
1734
|
-
|
|
1735
|
-
|
|
223
|
+
> [!IMPORTANT]
|
|
224
|
+
> **Required**: `"type": "module"` — ourin-baileys is ESM-only. Without this, imports will fail.
|
|
1736
225
|
|
|
1737
|
-
|
|
1738
|
-
await sock.updateBussinesProfile({ description: 'Toko resmi Harps-MD', address: 'Jakarta' })
|
|
226
|
+
### 2. Install Dependencies
|
|
1739
227
|
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
await sock.removeCoverPhoto()
|
|
228
|
+
```bash
|
|
229
|
+
npm install ourin-baileys pino qrcode-terminal
|
|
1743
230
|
```
|
|
1744
231
|
|
|
1745
|
-
|
|
232
|
+
### 3. Create `index.js`
|
|
1746
233
|
|
|
1747
|
-
|
|
234
|
+
```js
|
|
235
|
+
import makeWASocket, {
|
|
236
|
+
useMultiFileAuthState,
|
|
237
|
+
DisconnectReason,
|
|
238
|
+
Browsers,
|
|
239
|
+
} from "ourin-baileys";
|
|
240
|
+
import pino from "pino";
|
|
241
|
+
import qrcode from "qrcode-terminal";
|
|
1748
242
|
|
|
1749
|
-
|
|
243
|
+
const logger = pino({ level: "silent" });
|
|
1750
244
|
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
const channel = await sock.newsletterCreate('Nama Channel', 'Deskripsi channel')
|
|
245
|
+
async function startBot() {
|
|
246
|
+
const { state, saveCreds } = await useMultiFileAuthState("./session");
|
|
1754
247
|
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
248
|
+
const sock = makeWASocket({
|
|
249
|
+
auth: state,
|
|
250
|
+
logger,
|
|
251
|
+
browser: Browsers.ubuntu("Chrome"),
|
|
252
|
+
syncFullHistory: false,
|
|
253
|
+
});
|
|
1758
254
|
|
|
1759
|
-
|
|
1760
|
-
await sock.newsletterUpdateName(channelJid, 'Nama Baru')
|
|
1761
|
-
await sock.newsletterUpdateDescription(channelJid, 'Deskripsi baru')
|
|
1762
|
-
await sock.newsletterUpdatePicture(channelJid, imageBuffer)
|
|
1763
|
-
await sock.newsletterRemovePicture(channelJid)
|
|
255
|
+
sock.ev.on("creds.update", saveCreds);
|
|
1764
256
|
|
|
1765
|
-
|
|
1766
|
-
|
|
257
|
+
sock.ev.on("connection.update", ({ connection, lastDisconnect, qr }) => {
|
|
258
|
+
if (qr) {
|
|
259
|
+
qrcode.generate(qr, { small: true });
|
|
260
|
+
}
|
|
1767
261
|
|
|
1768
|
-
|
|
1769
|
-
|
|
262
|
+
if (connection === "close") {
|
|
263
|
+
const shouldReconnect =
|
|
264
|
+
lastDisconnect?.error?.output?.statusCode !==
|
|
265
|
+
DisconnectReason.loggedOut;
|
|
266
|
+
if (shouldReconnect) startBot();
|
|
267
|
+
}
|
|
268
|
+
if (connection === "open") console.log("Connected!");
|
|
269
|
+
});
|
|
1770
270
|
|
|
1771
|
-
|
|
1772
|
-
const
|
|
271
|
+
sock.ev.on("messages.upsert", async ({ messages }) => {
|
|
272
|
+
const msg = messages[0];
|
|
273
|
+
if (!msg?.message || msg.key.fromMe) return;
|
|
1773
274
|
|
|
1774
|
-
|
|
1775
|
-
|
|
275
|
+
const text =
|
|
276
|
+
msg.message.conversation || msg.message.extendedTextMessage?.text || "";
|
|
1776
277
|
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
278
|
+
if (text === ".ping") {
|
|
279
|
+
await sock.sendMessage(msg.key.remoteJid, { text: "Pong!" });
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
1781
283
|
|
|
1782
|
-
|
|
1783
|
-
await sock.newsletterDelete(channelJid)
|
|
284
|
+
startBot();
|
|
1784
285
|
```
|
|
1785
286
|
|
|
1786
|
-
|
|
287
|
+
### 4. Run
|
|
1787
288
|
|
|
1788
|
-
|
|
289
|
+
```bash
|
|
290
|
+
node index.js
|
|
291
|
+
```
|
|
1789
292
|
|
|
1790
|
-
|
|
293
|
+
Scan the QR code, wait until the socket reaches `connection: "open"`, then send `.ping` to test.
|
|
1791
294
|
|
|
1792
|
-
|
|
295
|
+
### 5. Pairing Code Example
|
|
1793
296
|
|
|
1794
|
-
|
|
297
|
+
If you prefer pairing code over QR:
|
|
1795
298
|
|
|
1796
299
|
```js
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
// Mute chat 8 jam (dalam ms, atau `null` untuk unmute)
|
|
1804
|
-
await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
|
|
1805
|
-
|
|
1806
|
-
// Tandai chat sudah dibaca / belum dibaca
|
|
1807
|
-
await sock.chatModify({ markRead: true, lastMessages: [msg] }, jid)
|
|
1808
|
-
|
|
1809
|
-
// Hapus chat
|
|
1810
|
-
await sock.chatModify({ delete: true, lastMessages: [msg] }, jid)
|
|
1811
|
-
|
|
1812
|
-
// Bintangi / batalkan pesan tertentu
|
|
1813
|
-
await sock.star([{ id: msg.key.id, remoteJid: jid, fromMe: msg.key.fromMe }], true)
|
|
1814
|
-
```
|
|
1815
|
-
|
|
1816
|
-
### Label Chat & Pesan (WhatsApp Business)
|
|
300
|
+
const sock = makeWASocket({
|
|
301
|
+
auth: state,
|
|
302
|
+
logger,
|
|
303
|
+
browser: Browsers.windows("Chrome"),
|
|
304
|
+
});
|
|
1817
305
|
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
await sock.
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
306
|
+
sock.ev.on("connection.update", async ({ connection }) => {
|
|
307
|
+
if (connection === "connecting") {
|
|
308
|
+
const code = await sock.requestPairingCode("6281234567890");
|
|
309
|
+
console.log("Pairing code:", code);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
1824
312
|
```
|
|
1825
313
|
|
|
1826
|
-
|
|
314
|
+
You can also provide your own custom pairing code:
|
|
1827
315
|
|
|
1828
316
|
```js
|
|
1829
|
-
await sock.
|
|
1830
|
-
|
|
317
|
+
const code = await sock.requestPairingCode("6281234567890", "A1B2C3D4");
|
|
318
|
+
console.log("Custom pairing code:", code);
|
|
1831
319
|
```
|
|
1832
320
|
|
|
1833
|
-
|
|
321
|
+
Custom pairing codes must be exactly `8` characters.
|
|
1834
322
|
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
await sock.removeContact(jid)
|
|
1838
|
-
```
|
|
323
|
+
> [!WARNING]
|
|
324
|
+
> `printQRInTerminal` still exists in the type surface for compatibility, but it is **deprecated** in the current build. Prefer handling the `qr` value from `connection.update` yourself.
|
|
1839
325
|
|
|
1840
|
-
|
|
326
|
+
---
|
|
1841
327
|
|
|
1842
|
-
|
|
1843
|
-
// Ganti nama tampilan (push name)
|
|
1844
|
-
await sock.updateProfileName('Nama Bot Baru')
|
|
328
|
+
## 🏗️ Architecture
|
|
1845
329
|
|
|
1846
|
-
|
|
1847
|
-
await sock.updateProfileStatus('Sibuk melayani pengguna 🤖')
|
|
330
|
+
### Socket Layer Chain
|
|
1848
331
|
|
|
1849
|
-
|
|
1850
|
-
await sock.updateProfilePicture(sock.user.id, imageBuffer)
|
|
1851
|
-
await sock.removeProfilePicture(sock.user.id)
|
|
332
|
+
Each socket layer extends the previous via composition, adding functionality from bottom to top:
|
|
1852
333
|
|
|
1853
|
-
|
|
1854
|
-
|
|
334
|
+
```
|
|
335
|
+
makeSocket → WebSocket + Noise protocol + pre-key management
|
|
336
|
+
makeChatsSocket → App state sync + chat modifications + profile
|
|
337
|
+
makeGroupsSocket → Group CRUD + participant management
|
|
338
|
+
makeMessagesSendSocket → Message sending + rich messages + relay
|
|
339
|
+
makeMessagesRecvSocket → Message receiving + decryption + notifications
|
|
340
|
+
makeBusinessSocket → Product catalog + business profile
|
|
341
|
+
makeCommunitiesSocket → Community CRUD + sub-groups
|
|
342
|
+
makeNewsletterSocket → Newsletter follow/unfollow/metadata
|
|
343
|
+
makeWASocket ← TOP LEVEL EXPORT
|
|
1855
344
|
```
|
|
1856
345
|
|
|
1857
|
-
###
|
|
346
|
+
### Key Modules
|
|
1858
347
|
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
await sock.updateBlockStatus(jid, 'block') // 'block' | 'unblock'
|
|
1870
|
-
|
|
1871
|
-
const settings = await sock.fetchPrivacySettings()
|
|
1872
|
-
const blocklist = await sock.fetchBlocklist()
|
|
1873
|
-
const duration = await sock.fetchDisappearingDuration(jid)
|
|
1874
|
-
const businessProfile = await sock.getBusinessProfile(jid)
|
|
1875
|
-
```
|
|
348
|
+
| Module | Path | Description |
|
|
349
|
+
| ------------ | --------------- | ---------------------------------------------------------------- |
|
|
350
|
+
| **Socket** | `lib/Socket/` | Connection, messaging, groups, newsletter, business, communities |
|
|
351
|
+
| **Signal** | `lib/Signal/` | Signal protocol: 1:1 encryption, group SenderKey, LID mapping |
|
|
352
|
+
| **WABinary** | `lib/WABinary/` | Binary node encoding/decoding, JID utilities |
|
|
353
|
+
| **Utils** | `lib/Utils/` | Crypto, auth state, noise handler, rich messages, media |
|
|
354
|
+
| **WAProto** | `WAProto/` | Compiled protobuf encode/decode |
|
|
355
|
+
| **WAUSync** | `lib/WAUSync/` | User sync protocol (contact, device, LID) |
|
|
356
|
+
| **WAM** | `lib/WAM/` | WhatsApp analytics binary encoding |
|
|
357
|
+
| **Types** | `lib/Types/` | Full TypeScript type definitions |
|
|
1876
358
|
|
|
1877
|
-
###
|
|
359
|
+
### Build Repo Layout
|
|
1878
360
|
|
|
1879
|
-
|
|
1880
|
-
await sock.sendPresenceUpdate('available') // online
|
|
1881
|
-
await sock.sendPresenceUpdate('unavailable') // offline
|
|
1882
|
-
await sock.sendPresenceUpdate('composing', jid) // "sedang mengetik..."
|
|
1883
|
-
await sock.sendPresenceUpdate('recording', jid) // "sedang merekam suara..."
|
|
1884
|
-
await sock.sendPresenceUpdate('paused', jid) // berhenti mengetik/merekam
|
|
1885
|
-
|
|
1886
|
-
// Berlangganan update presence seseorang (perlu untuk melihat "online"/"typing" mereka)
|
|
1887
|
-
await sock.presenceSubscribe(jid)
|
|
1888
|
-
```
|
|
361
|
+
This repository does **not** currently expose a `src/` directory in the checked-in package tree.
|
|
1889
362
|
|
|
1890
|
-
|
|
363
|
+
That means:
|
|
1891
364
|
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
365
|
+
- Documentation should reference **`lib/` as the public implementation**
|
|
366
|
+
- API discovery is best done through:
|
|
367
|
+
- `lib/index.js`
|
|
368
|
+
- `lib/index.d.ts`
|
|
369
|
+
- `lib/Socket/*.d.ts`
|
|
370
|
+
- `lib/Utils/*.d.ts`
|
|
371
|
+
- Consumers should treat this repo as a **ready-to-install runtime artifact**, not the authoring source tree
|
|
1895
372
|
|
|
1896
|
-
###
|
|
373
|
+
### Connection Flow
|
|
1897
374
|
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
375
|
+
1. WebSocket connect → Noise XX handshake (Curve25519 + AES-256-GCM)
|
|
376
|
+
2. QR code or Pairing Code authentication
|
|
377
|
+
3. `CB:success` → upload pre-keys → send passive IQ → emit `connection: 'open'`
|
|
378
|
+
4. Store own LID↔PN mapping, migrate own session
|
|
379
|
+
5. Buffer events → process offline notifications → flush → `receivedPendingNotifications: true`
|
|
1902
380
|
|
|
1903
381
|
---
|
|
1904
382
|
|
|
1905
|
-
##
|
|
383
|
+
## 📡 Socket API Reference
|
|
1906
384
|
|
|
1907
|
-
###
|
|
385
|
+
### Connection & Authentication
|
|
1908
386
|
|
|
1909
387
|
```js
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
Parameter ke-4 (`ctx`) menyediakan `reuploadRequest` — jika media sudah kedaluwarsa di server WA (biasanya setelah beberapa hari/re-fetch gagal), Baileys otomatis meminta pengirim untuk mengunggah ulang media tersebut lewat mekanisme *media retry*.
|
|
1931
|
-
|
|
1932
|
-
### `updateMediaMessage`
|
|
1933
|
-
|
|
1934
|
-
Dipakai secara internal oleh `downloadMediaMessage` saat retry, tapi bisa dipanggil manual jika Anda tahu sebuah media perlu di-refresh URL/direct path-nya:
|
|
388
|
+
const sock = makeWASocket({
|
|
389
|
+
auth: state, // AuthenticationState from useMultiFileAuthState
|
|
390
|
+
logger, // pino logger instance
|
|
391
|
+
browser: Browsers.ubuntu("Chrome"), // Browser identity
|
|
392
|
+
version: [2, 3000, 1035194821], // WA version
|
|
393
|
+
connectTimeoutMs: 20_000, // Connection timeout
|
|
394
|
+
defaultQueryTimeoutMs: 60_000, // Query timeout
|
|
395
|
+
retryRequestDelayMs: 250, // Retry delay
|
|
396
|
+
maxMsgRetryCount: 5, // Max message retry count
|
|
397
|
+
enableRecentMessageCache: true, // Enable message retry manager
|
|
398
|
+
enableAutoSessionRecreation: true,
|
|
399
|
+
syncFullHistory: false, // Sync full chat history
|
|
400
|
+
shouldIgnoreJid: (jid) => false, // Filter specific JIDs
|
|
401
|
+
qrTimeout: 60_000,
|
|
402
|
+
generateHighQualityLinkPreview: false,
|
|
403
|
+
});
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**Pairing Code Authentication:**
|
|
1935
407
|
|
|
1936
408
|
```js
|
|
1937
|
-
const
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
## 🛡️ Penanganan Error
|
|
409
|
+
const sock = makeWASocket({
|
|
410
|
+
auth: state,
|
|
411
|
+
logger,
|
|
412
|
+
browser: Browsers.windows("Chrome"),
|
|
413
|
+
});
|
|
1944
414
|
|
|
1945
|
-
|
|
415
|
+
sock.ev.on("connection.update", async ({ connection, qr, isNewLogin }) => {
|
|
416
|
+
if (qr) {
|
|
417
|
+
// QR code available (fallback)
|
|
418
|
+
}
|
|
419
|
+
});
|
|
1946
420
|
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
sock.ev.on('connection.update', (update) => {
|
|
1952
|
-
const { connection, lastDisconnect } = update
|
|
1953
|
-
if (connection === 'close') {
|
|
1954
|
-
const statusCode = (lastDisconnect?.error instanceof Boom)
|
|
1955
|
-
? lastDisconnect.error.output?.statusCode
|
|
1956
|
-
: undefined
|
|
1957
|
-
|
|
1958
|
-
switch (statusCode) {
|
|
1959
|
-
case DisconnectReason.badSession:
|
|
1960
|
-
console.log('Sesi rusak, hapus folder auth dan pairing ulang.')
|
|
1961
|
-
break
|
|
1962
|
-
case DisconnectReason.connectionClosed:
|
|
1963
|
-
case DisconnectReason.connectionLost:
|
|
1964
|
-
case DisconnectReason.timedOut:
|
|
1965
|
-
console.log('Koneksi putus sementara, reconnect otomatis.')
|
|
1966
|
-
startBot()
|
|
1967
|
-
break
|
|
1968
|
-
case DisconnectReason.connectionReplaced:
|
|
1969
|
-
console.log('Sesi diambil alih perangkat lain, hentikan instance ini.')
|
|
1970
|
-
break
|
|
1971
|
-
case DisconnectReason.loggedOut:
|
|
1972
|
-
console.log('Akun logout dari HP, perlu pairing ulang dari nol.')
|
|
1973
|
-
break
|
|
1974
|
-
case DisconnectReason.restartRequired:
|
|
1975
|
-
console.log('WhatsApp minta restart socket, reconnect.')
|
|
1976
|
-
startBot()
|
|
1977
|
-
break
|
|
1978
|
-
case DisconnectReason.multideviceMismatch:
|
|
1979
|
-
console.log('Perangkat tidak mendukung multi-device, cek versi WA.')
|
|
1980
|
-
break
|
|
1981
|
-
default:
|
|
1982
|
-
console.log('Terputus, alasan tidak diketahui:', statusCode)
|
|
1983
|
-
startBot()
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
})
|
|
421
|
+
// Request pairing code
|
|
422
|
+
const code = await sock.requestPairingCode("6281234567890");
|
|
423
|
+
console.log("Pairing code:", code); // e.g. "A1B2-C3D4"
|
|
1987
424
|
```
|
|
1988
425
|
|
|
1989
|
-
**
|
|
426
|
+
**Authentication State:**
|
|
1990
427
|
|
|
1991
428
|
```js
|
|
1992
|
-
|
|
1993
|
-
await sock.sendMessage(jid, { text: 'Halo' })
|
|
1994
|
-
} catch (err) {
|
|
1995
|
-
if (err instanceof Boom) {
|
|
1996
|
-
console.error('Gagal kirim pesan:', err.output?.statusCode, err.message)
|
|
1997
|
-
} else {
|
|
1998
|
-
console.error('Error tidak terduga:', err)
|
|
1999
|
-
}
|
|
2000
|
-
}
|
|
2001
|
-
```
|
|
2002
|
-
|
|
2003
|
-
---
|
|
2004
|
-
|
|
2005
|
-
## 🔁 Reliabilitas & Retry
|
|
429
|
+
import { useMultiFileAuthState } from "ourin-baileys";
|
|
2006
430
|
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
- **`offline-node-processor`** (`Utils/offline-node-processor.js`) — memproses antrian node yang sempat diterima saat koneksi terputus (mis. pesan yang masuk saat bot offline sesaat) setelah koneksi pulih.
|
|
2013
|
-
- **`identity-change-handler`** (`Utils/identity-change-handler.js`) — menangani notifikasi perubahan identitas Signal (mis. lawan bicara ganti HP/install ulang WhatsApp), memastikan pesan berikutnya tetap terenkripsi dengan key yang benar alih-alih gagal diam-diam.
|
|
2014
|
-
- **`stanza-ack`** (`Utils/stanza-ack.js`) — melacak acknowledgment level-protokol dari server untuk setiap node yang dikirim, dengan timeout & retry.
|
|
2015
|
-
- **`pre-key-manager`** (`Utils/pre-key-manager.js`) — mengelola pool pre-key Signal Protocol, otomatis mengisi ulang (`MIN_PREKEY_COUNT: 5`, target `INITIAL_PREKEY_COUNT: 812`) saat stok menipis agar sesi enkripsi baru selalu bisa dibuat.
|
|
431
|
+
const { state, saveCreds } = await useMultiFileAuthState("./session");
|
|
432
|
+
// state.creds → credentials (me, platform, noise keys, etc.)
|
|
433
|
+
// state.keys → SignalKeyStore (pre-keys, sessions, identity keys, etc.)
|
|
434
|
+
// saveCreds() → persist credentials to disk
|
|
435
|
+
```
|
|
2016
436
|
|
|
2017
|
-
|
|
437
|
+
**Custom Data Store / Memory Store Pattern:**
|
|
2018
438
|
|
|
2019
439
|
```js
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
cachedGroupMetadata: async (jid) => await myGroupCache.get(jid),
|
|
2026
|
-
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 }
|
|
2027
|
-
})
|
|
2028
|
-
```
|
|
2029
|
-
|
|
2030
|
-
---
|
|
440
|
+
import {
|
|
441
|
+
BufferJSON,
|
|
442
|
+
initAuthCreds,
|
|
443
|
+
makeCacheableSignalKeyStore,
|
|
444
|
+
} from "ourin-baileys";
|
|
2031
445
|
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
Tabel lengkap semua field shorthand yang dikenali `generateWAMessageContent()` pada parameter `content` dari `sendMessage(jid, content)`, untuk dijadikan referensi cepat saat lupa nama field yang tepat.
|
|
2035
|
-
|
|
2036
|
-
| Field | Menghasilkan Tipe Pesan | Field Pendamping |
|
|
2037
|
-
|---|---|---|
|
|
2038
|
-
| `text` | `conversation` / `extendedTextMessage` | `linkPreview`, `mentions`, `mentionAll`, `backgroundColor`, `font` |
|
|
2039
|
-
| `image` | `imageMessage` | `caption`, `viewOnce`, `jpegThumbnail` |
|
|
2040
|
-
| `video` | `videoMessage` | `caption`, `gifPlayback`, `ptv`, `viewOnce`, `seconds` |
|
|
2041
|
-
| `audio` | `audioMessage` | `ptt`, `mimetype`, `seconds` |
|
|
2042
|
-
| `sticker` | `stickerMessage` | — |
|
|
2043
|
-
| `document` | `documentMessage` | `mimetype`, `fileName`, `caption`, `jpegThumbnail` |
|
|
2044
|
-
| `contacts` | `contactMessage` / `contactsArrayMessage` | `displayName` |
|
|
2045
|
-
| `location` | `locationMessage` | `name`, `address` |
|
|
2046
|
-
| `react` | `reactionMessage` | `key` |
|
|
2047
|
-
| `poll` | `pollCreationMessage(V2/V3)` | `values`, `selectableCount`, `toAnnouncementGroup` |
|
|
2048
|
-
| `event` | `eventMessage` | `startDate`, `endDate`, `location`, `call`, `extraGuestsAllowed` |
|
|
2049
|
-
| `delete` | `protocolMessage` (REVOKE) | — |
|
|
2050
|
-
| `edit` | `protocolMessage` (MESSAGE_EDIT) | `text` |
|
|
2051
|
-
| `pin` | `pinInChatMessage` | `type`, `time` |
|
|
2052
|
-
| `forward` | (menyalin `message` dari sumber) | `force` |
|
|
2053
|
-
| `buttons` / `templateButtons` / `interactiveButtons` | `interactiveMessage.nativeFlowMessage` | `footer`, `image`/`video` header |
|
|
2054
|
-
| `sections` | `listMessage` | `title`, `buttonText`, `footer` |
|
|
2055
|
-
| `cards` | `interactiveMessage.carouselMessage` | `footer` |
|
|
2056
|
-
| `requestPaymentMessage` | `requestPaymentMessage` | `amount`, `currency`, `note`/`sticker` |
|
|
2057
|
-
| `productMessage` | `interactiveMessage` (viewOnce, header produk) | `title`, `thumbnail`, `buttons` |
|
|
2058
|
-
| `albumMessage` | `albumMessage` + item terpisah | array item media |
|
|
2059
|
-
| `pollResultMessage` | `pollResultMessage` | `name`, `pollVotes` |
|
|
2060
|
-
| `groupStatusMessage` | `groupStatusMessageV2` (khusus di grup) | `text`/`image`/`video`/`audio`/`sticker`/`document`/`card`/`message`/`raw` |
|
|
2061
|
-
| `multiSelectMessage` | `interactiveMessage` (multi `single_select`) | `selectors`, `extraButtons` |
|
|
2062
|
-
| `nestedListMessage` | `listMessage` (auto-flatten) | `sections` |
|
|
2063
|
-
|
|
2064
|
-
### Mentions & Konteks
|
|
2065
|
-
|
|
2066
|
-
| Field | Keterangan |
|
|
2067
|
-
|---|---|
|
|
2068
|
-
| `mentions` | Array JID yang di-mention di dalam teks. |
|
|
2069
|
-
| `mentionAll` | `true` untuk tag semua anggota grup tanpa menuliskan JID satu-satu. |
|
|
2070
|
-
| `quoted` | Bukan bagian dari `content`, melainkan opsi kedua `sendMessage` — pesan yang di-reply. |
|
|
2071
|
-
| `contextInfo` | Override manual `contextInfo` mentah (jarang perlu diisi langsung). |
|
|
2072
|
-
|
|
2073
|
-
### Aturan Prioritas Deteksi
|
|
2074
|
-
|
|
2075
|
-
`generateWAMessageContent()` memeriksa field dalam urutan tertentu — jika beberapa field "utama" hadir sekaligus (jarang terjadi, tapi penting diketahui saat debugging), prioritas umumnya mengikuti urutan: pesan sistem (`delete`/`edit`/`pin`/`react`) → pesan interaktif eksklusif fork (`groupStatusMessage`, `multiSelectMessage`, `nestedListMessage`, `requestPaymentMessage`, `productMessage`, `albumMessage`, `pollResultMessage`) → shorthand interaktif standar (`buttons`/`sections`/`cards`) → media dasar (`image`/`video`/`audio`/`sticker`/`document`) → `text` sebagai fallback paling akhir.
|
|
446
|
+
const credsStore = new Map();
|
|
447
|
+
const keyStoreData = new Map();
|
|
2076
448
|
|
|
2077
|
-
|
|
449
|
+
const creds = credsStore.get("creds") || initAuthCreds();
|
|
2078
450
|
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
| `PresenceData` | `Types/Chat.d.ts` | `{ lastKnownPresence, lastSeen? }`. |
|
|
2099
|
-
| `BaileysEventMap` | `Types/Events.d.ts` | Interface pemetaan nama event → tipe payloadnya (dipakai untuk type-safety `sock.ev.on(...)`). |
|
|
2100
|
-
| `WAUSyncQuery` / `USyncUser` | `WAUSync/*.d.ts` | Query batch untuk cek status device banyak user sekaligus (dipakai internal saat kirim pesan). |
|
|
2101
|
-
| `BusinessProfile` | `Types/Bussines.d.ts` | Struktur profil bisnis (`description`, `email`, `website`, `category`, dst). |
|
|
2102
|
-
| `WAMessageStubType` | `Types/index.d.ts` | Enum tipe pesan "stub" (event sistem seperti ganti subjek grup, anggota keluar, dst — muncul sebagai pesan tanpa `message` asli). |
|
|
2103
|
-
| `WAMessageAddressingMode` | `Types/index.d.ts` | `'pn'` atau `'lid'` — mode pengalamatan grup (memengaruhi bagaimana `participant` JID terbentuk). |
|
|
2104
|
-
| `DisconnectReason` | `Types/index.d.ts` | Enum kode alasan disconnect (lihat tabel di bagian [Penanganan Error](#-penanganan-error)). |
|
|
2105
|
-
|
|
2106
|
-
### Type-Safety untuk Event Listener (TypeScript)
|
|
2107
|
-
|
|
2108
|
-
```ts
|
|
2109
|
-
import type { BaileysEventMap } from '@vinzsocket/baileys'
|
|
2110
|
-
|
|
2111
|
-
sock.ev.on('messages.upsert', (data) => {
|
|
2112
|
-
// `data` otomatis ter-infer sebagai BaileysEventMap['messages.upsert']
|
|
2113
|
-
const { messages, type } = data
|
|
2114
|
-
})
|
|
2115
|
-
```
|
|
451
|
+
const keys = makeCacheableSignalKeyStore({
|
|
452
|
+
get: async (type, ids) => {
|
|
453
|
+
const data = {};
|
|
454
|
+
for (const id of ids) {
|
|
455
|
+
data[id] = keyStoreData.get(`${type}:${id}`);
|
|
456
|
+
}
|
|
457
|
+
return data;
|
|
458
|
+
},
|
|
459
|
+
set: async (data) => {
|
|
460
|
+
for (const category in data) {
|
|
461
|
+
for (const id in data[category]) {
|
|
462
|
+
const value = data[category][id];
|
|
463
|
+
const key = `${category}:${id}`;
|
|
464
|
+
if (value == null) keyStoreData.delete(key);
|
|
465
|
+
else keyStoreData.set(key, value);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
});
|
|
2116
470
|
|
|
2117
|
-
|
|
471
|
+
const state = { creds, keys };
|
|
2118
472
|
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
// loggedOut: 401,
|
|
2129
|
-
// badSession: 500,
|
|
2130
|
-
// restartRequired: 515,
|
|
2131
|
-
// multideviceMismatch: 411,
|
|
2132
|
-
// forbidden: 403,
|
|
2133
|
-
// unavailableService: 503
|
|
2134
|
-
// }
|
|
473
|
+
const saveCreds = async () => {
|
|
474
|
+
credsStore.set(
|
|
475
|
+
"creds",
|
|
476
|
+
JSON.parse(
|
|
477
|
+
JSON.stringify(state.creds, BufferJSON.replacer),
|
|
478
|
+
BufferJSON.reviver,
|
|
479
|
+
),
|
|
480
|
+
);
|
|
481
|
+
};
|
|
2135
482
|
```
|
|
2136
483
|
|
|
2137
|
-
|
|
484
|
+
This package does **not** currently ship a built-in `makeInMemoryStore()` helper.
|
|
2138
485
|
|
|
2139
|
-
|
|
486
|
+
Use these patterns instead:
|
|
2140
487
|
|
|
2141
|
-
|
|
488
|
+
- `useMultiFileAuthState()` for bot/local usage
|
|
489
|
+
- `initAuthCreds()` + custom `SignalKeyStore` for DB/Redis/in-memory persistence
|
|
490
|
+
- `makeCacheableSignalKeyStore()` when you want faster repeated key access with caching
|
|
2142
491
|
|
|
2143
|
-
|
|
492
|
+
> [!WARNING]
|
|
493
|
+
> `useMultiFileAuthState()` is convenient for bots and local testing, but the package itself warns against using it as your long-term production persistence layer. For production, write your own SQL/NoSQL-backed auth store.
|
|
2144
494
|
|
|
2145
|
-
|
|
2146
|
-
import { proto } from '@vinzsocket/baileys'
|
|
2147
|
-
|
|
2148
|
-
// Membuat instance pesan protobuf secara manual (jarang dibutuhkan langsung,
|
|
2149
|
-
// biasanya sudah dibungkus oleh generateWAMessageContent dsb)
|
|
2150
|
-
const reaction = proto.Message.ReactionMessage.create({
|
|
2151
|
-
key: msg.key,
|
|
2152
|
-
text: '🔥',
|
|
2153
|
-
senderTimestampMs: Date.now()
|
|
2154
|
-
})
|
|
2155
|
-
|
|
2156
|
-
// Enum penting yang sering dipakai
|
|
2157
|
-
console.log(proto.Message.ProtocolMessage.Type.REVOKE)
|
|
2158
|
-
console.log(proto.Message.ListMessage.ListType.SINGLE_SELECT)
|
|
2159
|
-
console.log(proto.HistorySync.HistorySyncType.FULL)
|
|
2160
|
-
console.log(proto.MediaRetryNotification.ResultType.SUCCESS)
|
|
2161
|
-
```
|
|
495
|
+
**Useful companion helpers:**
|
|
2162
496
|
|
|
2163
|
-
|
|
497
|
+
```js
|
|
498
|
+
import {
|
|
499
|
+
Browsers,
|
|
500
|
+
DisconnectReason,
|
|
501
|
+
fetchLatestBaileysVersion,
|
|
502
|
+
makeCacheableSignalKeyStore,
|
|
503
|
+
} from "ourin-baileys";
|
|
2164
504
|
|
|
2165
|
-
|
|
2166
|
-
|
|
505
|
+
const { version, isLatest } = await fetchLatestBaileysVersion();
|
|
506
|
+
console.log(version, isLatest);
|
|
2167
507
|
```
|
|
2168
508
|
|
|
2169
|
-
Anda **tidak perlu** melakukan ini sebagai konsumen library — cukup update ke versi terbaru `@vinzsocket/baileys` saat WhatsApp mengubah protokolnya.
|
|
2170
|
-
|
|
2171
509
|
---
|
|
2172
510
|
|
|
2173
|
-
|
|
511
|
+
### VoIP (Voice Calls)
|
|
2174
512
|
|
|
2175
|
-
|
|
513
|
+
Modul VoIP kini terintegrasi langsung di `ourin-baileys` menggunakan `VoipClient` dan memanfaatkan *shared socket* (tanpa double pairing). Aset WebAssembly sudah built-in.
|
|
2176
514
|
|
|
2177
|
-
|
|
2178
|
-
// index.js — entry point
|
|
2179
|
-
import makeWASocket, { useMultiFileAuthState, DisconnectReason } from '@vinzsocket/baileys'
|
|
2180
|
-
import { Boom } from '@hapi/boom'
|
|
2181
|
-
import { handleMessage } from './handler.js'
|
|
2182
|
-
|
|
2183
|
-
async function connectToWhatsApp() {
|
|
2184
|
-
const { state, saveCreds } = await useMultiFileAuthState('sesi_auth')
|
|
2185
|
-
|
|
2186
|
-
const sock = makeWASocket({
|
|
2187
|
-
auth: state,
|
|
2188
|
-
syncFullHistory: false,
|
|
2189
|
-
markOnlineOnConnect: true,
|
|
2190
|
-
getMessage: async () => undefined
|
|
2191
|
-
})
|
|
2192
|
-
|
|
2193
|
-
sock.ev.on('creds.update', saveCreds)
|
|
2194
|
-
|
|
2195
|
-
sock.ev.on('connection.update', (update) => {
|
|
2196
|
-
const { connection, lastDisconnect, qr } = update
|
|
2197
|
-
if (qr) console.log('Scan QR ini:', qr)
|
|
2198
|
-
if (connection === 'close') {
|
|
2199
|
-
const code = (lastDisconnect?.error instanceof Boom) ? lastDisconnect.error.output?.statusCode : 0
|
|
2200
|
-
if (code !== DisconnectReason.loggedOut) {
|
|
2201
|
-
connectToWhatsApp()
|
|
2202
|
-
} else {
|
|
2203
|
-
console.log('Logged out. Hapus folder sesi_auth dan pairing ulang.')
|
|
2204
|
-
}
|
|
2205
|
-
}
|
|
2206
|
-
})
|
|
2207
|
-
|
|
2208
|
-
sock.ev.on('messages.upsert', async (m) => handleMessage(sock, m))
|
|
2209
|
-
|
|
2210
|
-
return sock
|
|
2211
|
-
}
|
|
2212
|
-
|
|
2213
|
-
connectToWhatsApp()
|
|
2214
|
-
```
|
|
515
|
+
**Inisiasi VoIP Client:**
|
|
2215
516
|
|
|
2216
517
|
```js
|
|
2217
|
-
|
|
2218
|
-
const commands = new Map()
|
|
2219
|
-
|
|
2220
|
-
commands.set('ping', async (sock, msg) => {
|
|
2221
|
-
await sock.sendMessage(msg.key.remoteJid, { text: 'pong 🏓' }, { quoted: msg })
|
|
2222
|
-
})
|
|
2223
|
-
|
|
2224
|
-
commands.set('menu', async (sock, msg) => {
|
|
2225
|
-
await sock.sendMessage(msg.key.remoteJid, {
|
|
2226
|
-
text: 'Pilih menu:',
|
|
2227
|
-
footer: 'Harps-MD',
|
|
2228
|
-
buttons: [
|
|
2229
|
-
{ id: 'ping', text: '🏓 Ping' },
|
|
2230
|
-
{ id: 'info', text: 'ℹ️ Info' }
|
|
2231
|
-
]
|
|
2232
|
-
}, { quoted: msg })
|
|
2233
|
-
})
|
|
2234
|
-
|
|
2235
|
-
export async function handleMessage(sock, { messages, type }) {
|
|
2236
|
-
if (type !== 'notify') return
|
|
2237
|
-
const msg = messages[0]
|
|
2238
|
-
if (!msg.message || msg.key.fromMe) return
|
|
518
|
+
import { VoipClient, CallState } from "ourin-baileys";
|
|
2239
519
|
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
msg.message.listResponseMessage?.singleSelectReply?.selectedRowId ||
|
|
2246
|
-
''
|
|
2247
|
-
|
|
2248
|
-
const prefix = '.'
|
|
2249
|
-
if (!text.startsWith(prefix)) return
|
|
2250
|
-
|
|
2251
|
-
const [cmd] = text.slice(prefix.length).trim().split(/\s+/)
|
|
2252
|
-
const handler = commands.get(cmd.toLowerCase())
|
|
2253
|
-
if (handler) {
|
|
2254
|
-
try {
|
|
2255
|
-
await handler(sock, msg)
|
|
2256
|
-
} catch (err) {
|
|
2257
|
-
console.error(`Error di command "${cmd}":`, err)
|
|
2258
|
-
await sock.sendMessage(msg.key.remoteJid, { text: '⚠️ Terjadi kesalahan saat memproses perintah.' })
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
520
|
+
// Lakukan ini SETELAH connection === "open"
|
|
521
|
+
if (!global.voipClient) {
|
|
522
|
+
global.voipClient = new VoipClient();
|
|
523
|
+
await global.voipClient.connectWithSocket(sock);
|
|
524
|
+
console.log("VoIP engine aktif!");
|
|
2261
525
|
}
|
|
2262
526
|
```
|
|
2263
527
|
|
|
2264
|
-
**
|
|
2265
|
-
|
|
2266
|
-
- `msg.message.interactiveResponseMessage?.nativeFlowResponseMessage` — untuk balasan `quick_reply`, `single_select`, dst dari `interactiveMessage`. Payload aslinya berupa string JSON di field `.paramsJson` yang perlu di-`JSON.parse()`.
|
|
2267
|
-
- `msg.message.buttonsResponseMessage?.selectedButtonId` — untuk balasan yang dibuat dari shorthand `buttons` klasik (jika masih terdeteksi sebagai legacy oleh WhatsApp Anda sendiri — jarang terjadi di client terbaru).
|
|
2268
|
-
- `msg.message.listResponseMessage?.singleSelectReply?.selectedRowId` — untuk balasan `nestedListMessage` / list legacy.
|
|
2269
|
-
|
|
2270
|
-
Contoh parsing `nativeFlowResponseMessage`:
|
|
528
|
+
**Melakukan Panggilan:**
|
|
2271
529
|
|
|
2272
530
|
```js
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
531
|
+
try {
|
|
532
|
+
// Panggil nomor target (PN) - harus terhubung
|
|
533
|
+
const call = await global.voipClient.call("6281234567890", {
|
|
534
|
+
durationMs: 60000, // Timeout dalam ms
|
|
535
|
+
audioSource: "silence", // Atau "mic" / "file" (butuh audio-feeder & ffmpeg)
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
call.on("ringing", () => console.log("Berdering..."));
|
|
539
|
+
call.on("connected", () => console.log("Terhubung!"));
|
|
540
|
+
call.on("ended", (reason) => console.log("Panggilan berakhir:", reason));
|
|
541
|
+
|
|
542
|
+
// Menunggu hingga panggilan selesai
|
|
543
|
+
await call.waitForEnd();
|
|
544
|
+
} catch (e) {
|
|
545
|
+
console.error("Gagal menelpon:", e);
|
|
2277
546
|
}
|
|
2278
547
|
```
|
|
2279
548
|
|
|
2280
549
|
---
|
|
2281
550
|
|
|
2282
|
-
|
|
551
|
+
### Message Sending
|
|
2283
552
|
|
|
2284
|
-
|
|
553
|
+
```js
|
|
554
|
+
// Text
|
|
555
|
+
await sock.sendMessage(jid, { text: "Hello!" });
|
|
2285
556
|
|
|
2286
|
-
|
|
557
|
+
// Text with mention
|
|
558
|
+
await sock.sendMessage(jid, {
|
|
559
|
+
text: "Hello @628xxx!",
|
|
560
|
+
mentions: ["628xxx@s.whatsapp.net"],
|
|
561
|
+
});
|
|
2287
562
|
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
563
|
+
// Image
|
|
564
|
+
await sock.sendMessage(jid, {
|
|
565
|
+
image: { url: "./photo.jpg" },
|
|
566
|
+
caption: "A photo",
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
// Video
|
|
570
|
+
await sock.sendMessage(jid, {
|
|
571
|
+
video: { url: "./video.mp4" },
|
|
572
|
+
caption: "A video",
|
|
573
|
+
gifPlayback: false,
|
|
574
|
+
});
|
|
2292
575
|
|
|
2293
|
-
|
|
576
|
+
// Audio
|
|
577
|
+
await sock.sendMessage(jid, {
|
|
578
|
+
audio: { url: "./audio.ogg" },
|
|
579
|
+
mimetype: "audio/ogg; codecs=opus",
|
|
580
|
+
ptt: true, // voice note
|
|
581
|
+
});
|
|
2294
582
|
|
|
2295
|
-
|
|
583
|
+
// Sticker
|
|
584
|
+
await sock.sendMessage(jid, {
|
|
585
|
+
sticker: { url: "./sticker.webp" },
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
// Sticker pack
|
|
589
|
+
await sock.sendMessage(
|
|
590
|
+
jid,
|
|
591
|
+
makeStickerPack({
|
|
592
|
+
name: "Ourin Starter Pack",
|
|
593
|
+
publisher: "Ourin",
|
|
594
|
+
description: "Starter sticker pack",
|
|
595
|
+
stickers: [
|
|
596
|
+
{ url: "./stickers/1.webp", emojis: ["🔥"] },
|
|
597
|
+
{ url: "./stickers/2.webp", emojis: ["😎"] },
|
|
598
|
+
],
|
|
599
|
+
cover: { url: "./stickers/cover.webp" },
|
|
600
|
+
}),
|
|
601
|
+
);
|
|
602
|
+
|
|
603
|
+
// Document
|
|
604
|
+
await sock.sendMessage(jid, {
|
|
605
|
+
document: { url: "./file.pdf" },
|
|
606
|
+
fileName: "document.pdf",
|
|
607
|
+
mimetype: "application/pdf",
|
|
608
|
+
});
|
|
2296
609
|
|
|
2297
|
-
|
|
610
|
+
// Reaction
|
|
611
|
+
await sock.sendMessage(jid, {
|
|
612
|
+
react: { key: msg.key, text: "👍" },
|
|
613
|
+
});
|
|
2298
614
|
|
|
2299
|
-
|
|
615
|
+
// Location
|
|
616
|
+
await sock.sendMessage(jid, {
|
|
617
|
+
location: {
|
|
618
|
+
degreesLatitude: -6.2,
|
|
619
|
+
degreesLongitude: 106.8,
|
|
620
|
+
name: "Jakarta",
|
|
621
|
+
},
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
// Contact
|
|
625
|
+
await sock.sendMessage(jid, {
|
|
626
|
+
contacts: {
|
|
627
|
+
displayName: "Contacts",
|
|
628
|
+
contacts: [
|
|
629
|
+
{ vcard: "BEGIN:VCARD\nVERSION:3.0\nFN:John\nTEL:+628xxx\nEND:VCARD" },
|
|
630
|
+
],
|
|
631
|
+
},
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
// Poll
|
|
635
|
+
await sock.sendMessage(jid, {
|
|
636
|
+
poll: {
|
|
637
|
+
name: "Vote!",
|
|
638
|
+
values: ["Option A", "Option B", "Option C"],
|
|
639
|
+
selectableCount: 1,
|
|
640
|
+
},
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
// Forward message
|
|
644
|
+
await sock.sendMessage(jid, {
|
|
645
|
+
forward: msg,
|
|
646
|
+
forwardingScore: 1,
|
|
647
|
+
isForwarded: true,
|
|
648
|
+
});
|
|
2300
649
|
|
|
2301
|
-
|
|
650
|
+
// Delete message
|
|
651
|
+
await sock.sendMessage(jid, { delete: msg.key });
|
|
2302
652
|
|
|
2303
|
-
|
|
653
|
+
// Edit message
|
|
654
|
+
await sock.sendMessage(jid, {
|
|
655
|
+
text: "Edited text",
|
|
656
|
+
edit: msg.key,
|
|
657
|
+
});
|
|
658
|
+
```
|
|
2304
659
|
|
|
2305
|
-
|
|
660
|
+
---
|
|
2306
661
|
|
|
2307
|
-
###
|
|
662
|
+
### Interactive Messages
|
|
2308
663
|
|
|
2309
|
-
|
|
664
|
+
**Native Flow Buttons:**
|
|
2310
665
|
|
|
2311
|
-
|
|
666
|
+
```js
|
|
667
|
+
await sock.sendMessage(jid, {
|
|
668
|
+
interactiveMessage: {
|
|
669
|
+
title: "Welcome!",
|
|
670
|
+
footer: "Powered by Ourin",
|
|
671
|
+
buttons: [
|
|
672
|
+
{
|
|
673
|
+
name: "quick_reply",
|
|
674
|
+
buttonParamsJson: JSON.stringify({
|
|
675
|
+
display_text: "Menu",
|
|
676
|
+
id: "menu",
|
|
677
|
+
}),
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
name: "cta_url",
|
|
681
|
+
buttonParamsJson: JSON.stringify({
|
|
682
|
+
display_text: "Website",
|
|
683
|
+
url: "https://example.com",
|
|
684
|
+
}),
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
name: "cta_copy",
|
|
688
|
+
buttonParamsJson: JSON.stringify({
|
|
689
|
+
display_text: "Copy Code",
|
|
690
|
+
copy_code: "OURIN2024",
|
|
691
|
+
}),
|
|
692
|
+
},
|
|
693
|
+
],
|
|
694
|
+
header: "Choose an option",
|
|
695
|
+
image: { url: "https://example.com/banner.jpg" },
|
|
696
|
+
},
|
|
697
|
+
});
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
**List Menu (single_select):**
|
|
2312
701
|
|
|
2313
|
-
|
|
702
|
+
```js
|
|
703
|
+
await sock.sendMessage(jid, {
|
|
704
|
+
interactiveMessage: {
|
|
705
|
+
title: "Select Category",
|
|
706
|
+
footer: "Powered by Ourin",
|
|
707
|
+
buttons: [
|
|
708
|
+
{
|
|
709
|
+
name: "single_select",
|
|
710
|
+
buttonParamsJson: JSON.stringify({
|
|
711
|
+
title: "Menu",
|
|
712
|
+
sections: [
|
|
713
|
+
{
|
|
714
|
+
title: "Games",
|
|
715
|
+
rows: [
|
|
716
|
+
{ title: "Quiz", id: ".quiz" },
|
|
717
|
+
{ title: "Tebak Gambar", id: ".tebakgambar" },
|
|
718
|
+
],
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
title: "Tools",
|
|
722
|
+
rows: [
|
|
723
|
+
{ title: "Sticker", id: ".sticker" },
|
|
724
|
+
{ title: "TTS", id: ".tts" },
|
|
725
|
+
],
|
|
726
|
+
},
|
|
727
|
+
],
|
|
728
|
+
}),
|
|
729
|
+
},
|
|
730
|
+
],
|
|
731
|
+
header: "Bot Menu",
|
|
732
|
+
},
|
|
733
|
+
});
|
|
734
|
+
```
|
|
2314
735
|
|
|
2315
736
|
---
|
|
2316
737
|
|
|
2317
|
-
|
|
738
|
+
### Album Messages
|
|
2318
739
|
|
|
2319
|
-
|
|
740
|
+
```js
|
|
741
|
+
await sock.sendMessage(jid, {
|
|
742
|
+
albumMessage: [
|
|
743
|
+
{ image: { url: "./photo1.jpg" }, caption: "First" },
|
|
744
|
+
{ image: { url: "./photo2.jpg" }, caption: "Second" },
|
|
745
|
+
{ video: { url: "./clip.mp4" }, caption: "Video" },
|
|
746
|
+
],
|
|
747
|
+
});
|
|
748
|
+
```
|
|
2320
749
|
|
|
2321
|
-
|
|
750
|
+
> [!NOTE]
|
|
751
|
+
> Albums automatically set `expectedImageCount` and `expectedVideoCount` based on array content.
|
|
2322
752
|
|
|
2323
|
-
|
|
753
|
+
---
|
|
2324
754
|
|
|
2325
|
-
|
|
2326
|
-
1. Upgrade Node.js ke ≥ 20.19.0 (atau ≥ 22.12.0 / ≥ 23.x) agar `require(esm)` bawaan Node bisa dipakai, **atau**
|
|
2327
|
-
2. Ganti `require()` menjadi `import()` dinamis:
|
|
2328
|
-
```js
|
|
2329
|
-
const { default: makeWASocket } = await import('@vinzsocket/baileys')
|
|
2330
|
-
```
|
|
2331
|
-
3. Ubah `package.json` proyek Anda menjadi `"type": "module"` dan pakai `import` secara native.
|
|
755
|
+
### AI Rich Response Messages
|
|
2332
756
|
|
|
2333
|
-
|
|
757
|
+
Send messages styled like Meta AI — tables, code blocks, and rich text. All rendered via `botForwardedMessage` > `richResponseMessage`.
|
|
2334
758
|
|
|
2335
|
-
**
|
|
759
|
+
**Table (with heading):**
|
|
2336
760
|
|
|
2337
|
-
|
|
761
|
+
```js
|
|
762
|
+
await sock.sendTable(
|
|
763
|
+
jid,
|
|
764
|
+
"Java vs JavaScript",
|
|
765
|
+
["Feature", "Java", "JavaScript"],
|
|
766
|
+
[
|
|
767
|
+
["Type", "Compiled", "Interpreted"],
|
|
768
|
+
["Typing", "Static", "Dynamic"],
|
|
769
|
+
["Main Use", "Enterprise", "Web, Full-stack"],
|
|
770
|
+
],
|
|
771
|
+
quoted,
|
|
772
|
+
{
|
|
773
|
+
headerText: "Comparison:",
|
|
774
|
+
footer: "Hope this helps!",
|
|
775
|
+
},
|
|
776
|
+
);
|
|
777
|
+
```
|
|
2338
778
|
|
|
2339
|
-
**
|
|
2340
|
-
|
|
2341
|
-
|
|
779
|
+
**List (without heading):**
|
|
780
|
+
|
|
781
|
+
```js
|
|
782
|
+
await sock.sendList(
|
|
783
|
+
jid,
|
|
784
|
+
"Bot Info",
|
|
785
|
+
[
|
|
786
|
+
["Name", "Ourin AI"],
|
|
787
|
+
["Version", "2.4.0"],
|
|
788
|
+
["Developer", "Zann"],
|
|
789
|
+
],
|
|
790
|
+
quoted,
|
|
791
|
+
{ footer: "© Ourin AI" },
|
|
792
|
+
);
|
|
2342
793
|
```
|
|
2343
|
-
Modul ini sengaja **lazy-imported** (tidak jadi hard dependency) supaya konsumen yang tidak memakai fitur story card tidak perlu menanggung ukuran bundle `jimp`.
|
|
2344
794
|
|
|
2345
|
-
|
|
795
|
+
**Code Block V1 (basic syntax highlighting):**
|
|
2346
796
|
|
|
2347
|
-
|
|
797
|
+
```js
|
|
798
|
+
await sock.sendCodeBlock(
|
|
799
|
+
jid,
|
|
800
|
+
`const greeting = "Hello World"
|
|
801
|
+
function sayHello(name) {
|
|
802
|
+
return greeting + " " + name
|
|
803
|
+
}
|
|
804
|
+
sayHello("Ourin")`,
|
|
805
|
+
quoted,
|
|
806
|
+
{
|
|
807
|
+
language: "javascript",
|
|
808
|
+
title: "Example Code",
|
|
809
|
+
footer: "Powered by Ourin",
|
|
810
|
+
},
|
|
811
|
+
);
|
|
812
|
+
```
|
|
2348
813
|
|
|
2349
|
-
|
|
814
|
+
**Supported V1 languages:** `javascript`, `typescript`, `python`
|
|
2350
815
|
|
|
2351
|
-
**
|
|
816
|
+
**Table V2 (Unified Response):**
|
|
2352
817
|
|
|
2353
|
-
|
|
818
|
+
The V2 table uses the **unified response** format with `GenATableUXPrimitive` typename and base64-encoded data, matching the Meta AI rich response protocol.
|
|
2354
819
|
|
|
2355
|
-
**
|
|
2356
|
-
- URL-nya tidak cocok dengan `URL_REGEX` bawaan (harus diawali `https://`).
|
|
2357
|
-
- Situs tujuan memblokir scraping metadata Open Graph.
|
|
2358
|
-
- Anda menyetel `linkPreview: null` secara eksplisit di payload.
|
|
820
|
+
**Features over V1:**
|
|
2359
821
|
|
|
2360
|
-
|
|
822
|
+
- String-based table input with flexible delimiters (`|` or `,` for columns, `;;` for rows)
|
|
823
|
+
- Unified response sections with `GenATableUXPrimitive` / `GenAIMarkdownTextUXPrimitive` typenames
|
|
824
|
+
- Dual output: `rows` (for submessages) + `unified_rows` (for sections)
|
|
825
|
+
- Enhanced `contextInfo` with `botMessageSharingInfo`
|
|
2361
826
|
|
|
2362
|
-
**A:**
|
|
2363
827
|
```js
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
828
|
+
await sock.sendTableV2(
|
|
829
|
+
jid,
|
|
830
|
+
[
|
|
831
|
+
"Java vs JavaScript", // title
|
|
832
|
+
"Feature | Java | JavaScript", // header (pipe-delimited)
|
|
833
|
+
"Type | Compiled | Interpreted;;Typing | Static | Dynamic;;Main Use | Enterprise | Web, Full-stack", // rows (;; separated, | or , delimited)
|
|
834
|
+
],
|
|
835
|
+
quoted,
|
|
836
|
+
{
|
|
837
|
+
headerText: "Comparison:",
|
|
838
|
+
text: "Here is a comparison table:",
|
|
839
|
+
footer: "Hope this helps!",
|
|
840
|
+
},
|
|
841
|
+
);
|
|
2367
842
|
```
|
|
2368
843
|
|
|
2369
|
-
|
|
844
|
+
**Input format:**
|
|
2370
845
|
|
|
2371
|
-
|
|
2372
|
-
-
|
|
2373
|
-
-
|
|
2374
|
-
- Terlalu banyak percobaan koneksi gagal beruntun terdeteksi sebagai aktivitas mencurigakan oleh WhatsApp.
|
|
846
|
+
- `table[0]` — title string
|
|
847
|
+
- `table[1]` — header row (columns separated by `|` or `,`)
|
|
848
|
+
- `table[2+]` — data rows (rows separated by `;;`, columns by `|` or `,`)
|
|
2375
849
|
|
|
2376
|
-
|
|
850
|
+
**V2 Options:**
|
|
2377
851
|
|
|
2378
|
-
|
|
852
|
+
| Option | Type | Default | Description |
|
|
853
|
+
| ------------ | -------- | ------- | ---------------------------------------------------- |
|
|
854
|
+
| `title` | `string` | — | Title (used if `headerText` not set) |
|
|
855
|
+
| `headerText` | `string` | — | Text shown before the table |
|
|
856
|
+
| `text` | `string` | — | Markdown text section (GenAIMarkdownTextUXPrimitive) |
|
|
857
|
+
| `footer` | `string` | — | Text shown after the table |
|
|
2379
858
|
|
|
2380
|
-
|
|
859
|
+
---
|
|
2381
860
|
|
|
2382
|
-
###
|
|
861
|
+
### Code Block V2 (Unified Response)
|
|
2383
862
|
|
|
2384
|
-
|
|
863
|
+
The V2 code block uses the **unified response** format with `sections/view_model/primitive` structure and base64-encoded data, matching the Meta AI rich response protocol exactly.
|
|
2385
864
|
|
|
2386
|
-
|
|
865
|
+
**Features over V1:**
|
|
2387
866
|
|
|
2388
|
-
|
|
867
|
+
- 6 language families with keyword detection
|
|
868
|
+
- `/* */` block comment support
|
|
869
|
+
- `#` comment support for python/bash/lua
|
|
870
|
+
- Hex/binary/octal number literals
|
|
871
|
+
- Dual token output: numeric `codeBlock` + string-typed `unified_codeBlock`
|
|
872
|
+
- Unified response sections with `GenAICodeUXPrimitive` / `GenAIMarkdownTextUXPrimitive` typenames
|
|
873
|
+
- Enhanced `contextInfo` with `botMessageSharingInfo`
|
|
2389
874
|
|
|
2390
875
|
```js
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
for (const jid of daftarPenerima) {
|
|
2395
|
-
queue.add(() => sock.sendMessage(jid, { text: 'Pengumuman broadcast' }))
|
|
2396
|
-
}
|
|
2397
|
-
```
|
|
2398
|
-
|
|
2399
|
-
### Q: Apa bedanya `groupStatusMessage` dengan mengirim status pribadi biasa?
|
|
2400
|
-
|
|
2401
|
-
**A:** Status pribadi biasa dikirim ke `status@broadcast` dan tampil di tab Status semua kontak Anda. `groupStatusMessage` (Group Status V2) mengirim story **khusus untuk sebuah grup tertentu** — hanya anggota grup tersebut yang melihatnya sebagai ring status, terpisah dari status pribadi Anda.
|
|
876
|
+
await sock.sendCodeBlockV2(
|
|
877
|
+
jid,
|
|
878
|
+
`package main
|
|
2402
879
|
|
|
2403
|
-
|
|
880
|
+
import "fmt"
|
|
2404
881
|
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
}
|
|
882
|
+
func main() {
|
|
883
|
+
fmt.Println("Hello, World!")
|
|
884
|
+
}`,
|
|
885
|
+
quoted,
|
|
886
|
+
{
|
|
887
|
+
language: "go",
|
|
888
|
+
title: "Go Example",
|
|
889
|
+
text: "Here is a Go code snippet:",
|
|
890
|
+
footer: "Powered by Ourin",
|
|
891
|
+
},
|
|
892
|
+
);
|
|
2417
893
|
```
|
|
2418
894
|
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
### Q: Kenapa `groupMetadata()` kadang mengembalikan data anggota yang sudah tidak akurat (mis. admin yang sebenarnya sudah di-demote)?
|
|
895
|
+
**Supported V2 languages:**
|
|
2422
896
|
|
|
2423
|
-
|
|
897
|
+
| Language Key | Aliases |
|
|
898
|
+
| ------------ | ------------------------ |
|
|
899
|
+
| `javascript` | `js`, `typescript`, `ts` |
|
|
900
|
+
| `python` | `py` |
|
|
901
|
+
| `go` | `golang` |
|
|
902
|
+
| `lua` | — |
|
|
903
|
+
| `bash` | `sh`, `shell` |
|
|
2424
904
|
|
|
2425
|
-
|
|
905
|
+
**V2 Options:**
|
|
2426
906
|
|
|
2427
|
-
|
|
907
|
+
| Option | Type | Default | Description |
|
|
908
|
+
| ---------- | -------- | -------------- | ---------------------------------------------------- |
|
|
909
|
+
| `language` | `string` | `'javascript'` | Programming language for syntax highlighting |
|
|
910
|
+
| `title` | `string` | — | Title text shown before the code block |
|
|
911
|
+
| `text` | `string` | — | Markdown text section (GenAIMarkdownTextUXPrimitive) |
|
|
912
|
+
| `footer` | `string` | — | Footer text shown after the code block |
|
|
2428
913
|
|
|
2429
|
-
|
|
914
|
+
**V2 Token Types:**
|
|
2430
915
|
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
916
|
+
| Code | V1 Name | V2 Name | Description |
|
|
917
|
+
| ---- | --------- | --------- | -------------------------------------------------- |
|
|
918
|
+
| 0 | `DEFAULT` | `DEFAULT` | Normal text, whitespace, operators |
|
|
919
|
+
| 1 | `KEYWORD` | `KEYWORD` | Language keywords (`const`, `func`, `if`, etc.) |
|
|
920
|
+
| 2 | `METHOD` | `METHOD` | Function/method calls (identifier followed by `(`) |
|
|
921
|
+
| 3 | `STRING` | `STR` | String literals (`"..."`, `'...'`, `` `...` ``) |
|
|
922
|
+
| 4 | `NUMBER` | `NUMBER` | Numeric values (int, float, hex, binary, octal) |
|
|
923
|
+
| 5 | `COMMENT` | `COMMENT` | Comments (`//`, `/* */`, `#`) |
|
|
2434
924
|
|
|
2435
925
|
---
|
|
2436
926
|
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
|
2475
|
-
|
|
|
2476
|
-
| `
|
|
2477
|
-
| `
|
|
2478
|
-
| `
|
|
2479
|
-
| `
|
|
2480
|
-
| `
|
|
2481
|
-
| `
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
|
2486
|
-
|
|
|
2487
|
-
| `
|
|
2488
|
-
| `
|
|
2489
|
-
| `
|
|
2490
|
-
| `
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
|
2495
|
-
|
|
2496
|
-
| `
|
|
2497
|
-
| `
|
|
2498
|
-
| `
|
|
2499
|
-
| `
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
| `sock.newsletterMetadata(type, key)` | Ambil metadata channel. |
|
|
2530
|
-
| `sock.newsletterUpdateName/Description/Picture(...)` | Update info channel. |
|
|
2531
|
-
| `sock.newsletterRemovePicture(jid)` | Hapus foto channel. |
|
|
2532
|
-
| `sock.newsletterSubscribers(jid)` | Lihat daftar subscriber. |
|
|
2533
|
-
| `sock.newsletterReactMessage(jid, serverId, reaction)` | React ke post channel. |
|
|
2534
|
-
| `sock.newsletterFetchMessages(jid, count, since, after)` | Ambil histori post channel. |
|
|
2535
|
-
| `sock.subscribeNewsletterUpdates(jid)` | Berlangganan update real-time channel. |
|
|
2536
|
-
| `sock.newsletterAdminCount(jid)` | Hitung jumlah admin channel. |
|
|
2537
|
-
| `sock.newsletterChangeOwner(jid, newOwnerJid)` | Pindah kepemilikan channel. |
|
|
2538
|
-
| `sock.newsletterDemote(jid, userJid)` | Copot admin channel. |
|
|
2539
|
-
| `sock.newsletterDelete(jid)` | Hapus channel. |
|
|
2540
|
-
|
|
2541
|
-
### Chat, Profil & Privasi
|
|
2542
|
-
|
|
2543
|
-
| Method | Deskripsi |
|
|
2544
|
-
|---|---|
|
|
2545
|
-
| `sock.chatModify(mod, jid)` | Primitif dasar untuk semua modifikasi chat (arsip/pin/mute/dll). |
|
|
2546
|
-
| `sock.star(keys, star)` | Bintangi/batalkan bintang pesan. |
|
|
2547
|
-
| `sock.addLabel/addChatLabel/removeChatLabel/addMessageLabel/removeMessageLabel` | Kelola label (Business). |
|
|
2548
|
-
| `sock.addOrEditQuickReply(qr)` / `removeQuickReply(ts)` | Kelola balasan cepat. |
|
|
2549
|
-
| `sock.addOrEditContact(jid, contact)` / `removeContact(jid)` | Kelola kontak. |
|
|
2550
|
-
| `sock.updateProfileName/Status/Picture` | Update profil akun sendiri. |
|
|
2551
|
-
| `sock.removeProfilePicture(jid)` | Hapus foto profil. |
|
|
2552
|
-
| `sock.profilePictureUrl(jid, type)` | Ambil URL foto profil siapa pun. |
|
|
2553
|
-
| `sock.getBusinessProfile(jid)` | Ambil profil bisnis JID tertentu. |
|
|
2554
|
-
| `sock.update*Privacy(...)` (last seen, online, dsb) | Semua pengaturan privasi. |
|
|
2555
|
-
| `sock.fetchPrivacySettings()` / `fetchBlocklist()` / `fetchDisappearingDuration(jid)` | Ambil pengaturan privasi saat ini. |
|
|
2556
|
-
| `sock.updateBlockStatus(jid, action)` | Blokir/buka blokir kontak. |
|
|
2557
|
-
| `sock.sendPresenceUpdate(type, jid?)` | Kirim status online/typing/recording. |
|
|
2558
|
-
| `sock.presenceSubscribe(jid)` | Berlangganan presence seseorang. |
|
|
2559
|
-
| `sock.createCallLink(type)` | Buat link panggilan audio/video. |
|
|
2560
|
-
| `sock.resyncAppState(collections, isInitial)` | Paksa resync app-state. |
|
|
927
|
+
### Link Message (Inline Embeds)
|
|
928
|
+
|
|
929
|
+
Send rich text with inline clickable links using `{{IE_N}}display_text{{/IE_N}}` placeholders, with optional citation metadata and verification proofs.
|
|
930
|
+
|
|
931
|
+
```js
|
|
932
|
+
await sock.sendLink(
|
|
933
|
+
jid,
|
|
934
|
+
"Upload results:\n✅ Freeimage\n🔗 Klik: {{IE_0}}link disini{{/IE_0}}\n✅ Yardsansh\n🔗 Klik: {{IE_1}}link disini{{/IE_1}}",
|
|
935
|
+
["https://example.com/upload1", "https://example.com/upload2"],
|
|
936
|
+
quoted,
|
|
937
|
+
{
|
|
938
|
+
headerText: "📁 Media Uploader V3",
|
|
939
|
+
footer: "✨ Selesai!",
|
|
940
|
+
botJid: "867051314767696@bot",
|
|
941
|
+
forwardingScore: 3,
|
|
942
|
+
citations: [
|
|
943
|
+
{
|
|
944
|
+
sourceTitle: "Freeimage",
|
|
945
|
+
citationNumber: 1,
|
|
946
|
+
faviconCdnUrl: "https://cdn.example.com/favicon.ico",
|
|
947
|
+
},
|
|
948
|
+
{ sourceTitle: "Yardsansh", citationNumber: 2 },
|
|
949
|
+
],
|
|
950
|
+
proofs: [
|
|
951
|
+
{
|
|
952
|
+
version: 1,
|
|
953
|
+
useCase: 1,
|
|
954
|
+
signature: "base64signature==",
|
|
955
|
+
certificateChain: ["base64cert1", "base64cert2"],
|
|
956
|
+
},
|
|
957
|
+
],
|
|
958
|
+
},
|
|
959
|
+
);
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
**Link Options:**
|
|
963
|
+
|
|
964
|
+
| Option | Type | Default | Description |
|
|
965
|
+
| ----------------- | ------------ | ----------------------- | ------------------------------------- |
|
|
966
|
+
| `headerText` | `string` | — | Text shown before the link content |
|
|
967
|
+
| `footer` | `string` | — | Text shown after the link content |
|
|
968
|
+
| `botJid` | `string` | `'867051314767696@bot'` | Bot JID for forwardedAiBotMessageInfo |
|
|
969
|
+
| `forwardingScore` | `number` | `3` | Forward score for context info |
|
|
970
|
+
| `citations` | `Citation[]` | `[]` | Citation metadata entries |
|
|
971
|
+
| `proofs` | `Proof[]` | `[]` | Verification proof entries |
|
|
972
|
+
|
|
973
|
+
**Citation object:**
|
|
974
|
+
|
|
975
|
+
| Field | Type | Description |
|
|
976
|
+
| ---------------- | -------- | -------------------------------------------- |
|
|
977
|
+
| `sourceQuery` | `string` | Source query text |
|
|
978
|
+
| `faviconCdnUrl` | `string` | CDN URL for favicon |
|
|
979
|
+
| `citationNumber` | `number` | Citation index (auto-incremented if omitted) |
|
|
980
|
+
| `sourceTitle` | `string` | Title of the source |
|
|
981
|
+
|
|
982
|
+
**Proof object:**
|
|
983
|
+
|
|
984
|
+
| Field | Type | Description |
|
|
985
|
+
| ------------------ | ---------- | ------------------------ |
|
|
986
|
+
| `version` | `number` | Proof version |
|
|
987
|
+
| `useCase` | `number` | Use case identifier |
|
|
988
|
+
| `signature` | `string` | Base64 signature |
|
|
989
|
+
| `certificateChain` | `string[]` | Base64 certificate chain |
|
|
990
|
+
|
|
991
|
+
**Link V2 (search-result style):**
|
|
992
|
+
|
|
993
|
+
```js
|
|
994
|
+
await sock.sendLinkV2(
|
|
995
|
+
jid,
|
|
996
|
+
"Search results:\n- {{IE_0}}Official docs{{/IE_0}}\n- {{IE_1}}GitHub repo{{/IE_1}}",
|
|
997
|
+
[
|
|
998
|
+
{
|
|
999
|
+
url: "https://www.npmjs.com/package/ourin-baileys",
|
|
1000
|
+
displayName: "Official docs",
|
|
1001
|
+
sourceDisplayName: "npm",
|
|
1002
|
+
sourceSubtitle: "package registry",
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
url: "https://github.com/LuckyArch/ourin-baileys",
|
|
1006
|
+
displayName: "GitHub repo",
|
|
1007
|
+
sourceDisplayName: "github",
|
|
1008
|
+
sourceSubtitle: "source hosting",
|
|
1009
|
+
},
|
|
1010
|
+
],
|
|
1011
|
+
quoted,
|
|
1012
|
+
{
|
|
1013
|
+
headerText: "ourin-baileys",
|
|
1014
|
+
footer: "Reference links",
|
|
1015
|
+
searchEngine: "MAME",
|
|
1016
|
+
},
|
|
1017
|
+
);
|
|
1018
|
+
```
|
|
2561
1019
|
|
|
2562
1020
|
---
|
|
2563
1021
|
|
|
2564
|
-
|
|
1022
|
+
### Other Message Types
|
|
2565
1023
|
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
### Menu Konfigurasi Karakter dengan Multi-Select
|
|
1024
|
+
**Payment Request:**
|
|
2569
1025
|
|
|
2570
1026
|
```js
|
|
2571
1027
|
await sock.sendMessage(jid, {
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
{ title: 'Kelas Tempur', rows: [
|
|
2580
|
-
{ id: 'warrior', title: '⚔️ Warrior', description: 'HP tinggi, damage fisik' },
|
|
2581
|
-
{ id: 'mage', title: '🔮 Mage', description: 'Damage sihir, HP rendah' }
|
|
2582
|
-
]}
|
|
2583
|
-
]
|
|
2584
|
-
},
|
|
2585
|
-
{
|
|
2586
|
-
displayText: '🏳️ Pilih Fraksi Negara',
|
|
2587
|
-
sections: [
|
|
2588
|
-
{ title: 'Fraksi', rows: [
|
|
2589
|
-
{ id: 'kerajaan_utara', title: '❄️ Kerajaan Utara' },
|
|
2590
|
-
{ id: 'republik_selatan', title: '☀️ Republik Selatan' }
|
|
2591
|
-
]}
|
|
2592
|
-
]
|
|
2593
|
-
}
|
|
2594
|
-
]
|
|
2595
|
-
}
|
|
2596
|
-
}, { quoted: msg })
|
|
1028
|
+
requestPaymentMessage: {
|
|
1029
|
+
amount: 50000,
|
|
1030
|
+
currency: "IDR",
|
|
1031
|
+
note: "Payment for order #123",
|
|
1032
|
+
from: "628xxx@s.whatsapp.net",
|
|
1033
|
+
},
|
|
1034
|
+
});
|
|
2597
1035
|
```
|
|
2598
1036
|
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
Untuk sistem `rpg-negara.js` yang punya mekanik geopolitik (full-conquest, food crisis, ceasefire, dst), Group Status V2 + `renderStoryCard` cocok dipakai sebagai notifikasi visual otomatis:
|
|
1037
|
+
**Event:**
|
|
2602
1038
|
|
|
2603
1039
|
```js
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
}
|
|
1040
|
+
await sock.sendMessage(jid, {
|
|
1041
|
+
eventMessage: {
|
|
1042
|
+
name: "Community Meetup",
|
|
1043
|
+
description: "Join us for the monthly meetup!",
|
|
1044
|
+
startTime: Date.now() + 86400000,
|
|
1045
|
+
endTime: Date.now() + 90000000,
|
|
1046
|
+
location: {
|
|
1047
|
+
name: "Jakarta",
|
|
1048
|
+
degreesLatitude: -6.2,
|
|
1049
|
+
degreesLongitude: 106.8,
|
|
1050
|
+
},
|
|
1051
|
+
},
|
|
1052
|
+
});
|
|
2617
1053
|
```
|
|
2618
1054
|
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
Untuk `rpg-perusahaan.js` yang menampilkan daftar aset/saham:
|
|
1055
|
+
**Poll Result:**
|
|
2622
1056
|
|
|
2623
1057
|
```js
|
|
2624
1058
|
await sock.sendMessage(jid, {
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
]
|
|
2635
|
-
}))
|
|
2636
|
-
})
|
|
1059
|
+
pollResultMessage: {
|
|
1060
|
+
name: "Favorite Color?",
|
|
1061
|
+
pollVotes: [
|
|
1062
|
+
{ optionName: "Red", optionVoteCount: 42 },
|
|
1063
|
+
{ optionName: "Blue", optionVoteCount: 38 },
|
|
1064
|
+
{ optionName: "Green", optionVoteCount: 25 },
|
|
1065
|
+
],
|
|
1066
|
+
},
|
|
1067
|
+
});
|
|
2637
1068
|
```
|
|
2638
1069
|
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
Untuk `rpg-teknologi.js` dengan arsitektur chipset/GPU berjenjang (kategori → sub-kategori → item):
|
|
1070
|
+
**Status with Mentions:**
|
|
2642
1071
|
|
|
2643
1072
|
```js
|
|
2644
|
-
await sock.
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
footer: 'Sistem Teknologi Harps-MD',
|
|
2649
|
-
sections: [
|
|
2650
|
-
{
|
|
2651
|
-
title: '⚡ Chipset Tier 1',
|
|
2652
|
-
rows: [
|
|
2653
|
-
{ rowId: 'chip_a1', title: 'NeoCore X1', description: '3.2 GHz, 8 core' },
|
|
2654
|
-
{
|
|
2655
|
-
title: '🎮 GPU Sub-Kategori',
|
|
2656
|
-
rows: [
|
|
2657
|
-
{ rowId: 'gpu_x1', title: 'VoltEdge RTX-Z', description: '16GB VRAM' }
|
|
2658
|
-
]
|
|
2659
|
-
}
|
|
2660
|
-
]
|
|
2661
|
-
}
|
|
2662
|
-
]
|
|
2663
|
-
}
|
|
2664
|
-
}, { quoted: msg })
|
|
1073
|
+
await sock.sendStatusMention({ text: "Big update coming!" }, [
|
|
1074
|
+
"628xxx@s.whatsapp.net",
|
|
1075
|
+
"groupid@g.us",
|
|
1076
|
+
]);
|
|
2665
1077
|
```
|
|
2666
1078
|
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
Menggabungkan `buildTagAllText` dengan notifikasi pasar saham NPC whale:
|
|
1079
|
+
**Product Message:**
|
|
2670
1080
|
|
|
2671
1081
|
```js
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
}
|
|
2682
|
-
|
|
1082
|
+
await sock.sendMessage(jid, {
|
|
1083
|
+
productMessage: {
|
|
1084
|
+
title: "Wireless Headphones",
|
|
1085
|
+
description: "High quality bluetooth headphones",
|
|
1086
|
+
productId: "WH-001",
|
|
1087
|
+
retailerId: "ourin-shop",
|
|
1088
|
+
url: "https://example.com/product",
|
|
1089
|
+
priceAmount1000: 299000,
|
|
1090
|
+
currencyCode: "IDR",
|
|
1091
|
+
thumbnail: { url: "https://example.com/product.jpg" },
|
|
1092
|
+
body: "Check out this product!",
|
|
1093
|
+
footer: "Ourin Shop",
|
|
1094
|
+
buttons: [
|
|
1095
|
+
{
|
|
1096
|
+
name: "quick_reply",
|
|
1097
|
+
buttonParamsJson: JSON.stringify({
|
|
1098
|
+
display_text: "Buy Now",
|
|
1099
|
+
id: "buy_wh001",
|
|
1100
|
+
}),
|
|
1101
|
+
},
|
|
1102
|
+
],
|
|
1103
|
+
},
|
|
1104
|
+
});
|
|
1105
|
+
```
|
|
1106
|
+
|
|
1107
|
+
**Mixed Rich Message (custom submessages):**
|
|
1108
|
+
|
|
1109
|
+
```js
|
|
1110
|
+
await sock.sendRichMessage(
|
|
1111
|
+
jid,
|
|
1112
|
+
[
|
|
1113
|
+
{ messageType: 2, messageText: "Here is some info:" },
|
|
1114
|
+
{
|
|
1115
|
+
messageType: 4,
|
|
1116
|
+
tableMetadata: {
|
|
1117
|
+
title: "Stats",
|
|
1118
|
+
rows: [
|
|
1119
|
+
{ items: ["Metric", "Value"], isHeading: true },
|
|
1120
|
+
{ items: ["Users", "1000"] },
|
|
1121
|
+
{ items: ["Uptime", "99.9%"] },
|
|
1122
|
+
],
|
|
1123
|
+
},
|
|
1124
|
+
},
|
|
1125
|
+
{ messageType: 2, messageText: "And some code:" },
|
|
1126
|
+
{
|
|
1127
|
+
messageType: 5,
|
|
1128
|
+
codeMetadata: {
|
|
1129
|
+
codeLanguage: "javascript",
|
|
1130
|
+
codeBlocks: [{ highlightType: 0, codeContent: 'console.log("OK")' }],
|
|
1131
|
+
},
|
|
1132
|
+
},
|
|
1133
|
+
],
|
|
1134
|
+
quoted,
|
|
1135
|
+
);
|
|
1136
|
+
```
|
|
1137
|
+
|
|
1138
|
+
**SubMessage Types:**
|
|
1139
|
+
|
|
1140
|
+
| messageType | Name | Payload Field |
|
|
1141
|
+
| ----------- | ------------- | ---------------------- |
|
|
1142
|
+
| 0 | UNKNOWN | — |
|
|
1143
|
+
| 1 | GRID_IMAGE | `gridImageMetadata` |
|
|
1144
|
+
| 2 | TEXT | `messageText` |
|
|
1145
|
+
| 3 | INLINE_IMAGE | `imageMetadata` |
|
|
1146
|
+
| 4 | TABLE | `tableMetadata` |
|
|
1147
|
+
| 5 | CODE | `codeMetadata` |
|
|
1148
|
+
| 6 | DYNAMIC | `dynamicMetadata` |
|
|
1149
|
+
| 7 | MAP | `mapMetadata` |
|
|
1150
|
+
| 8 | LATEX | `latexMetadata` |
|
|
1151
|
+
| 9 | CONTENT_ITEMS | `contentItemsMetadata` |
|
|
2683
1152
|
|
|
2684
1153
|
---
|
|
2685
1154
|
|
|
2686
|
-
|
|
1155
|
+
### Newsletter Methods
|
|
2687
1156
|
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
- **Batasi `logger` ke level `warn`/`error`** di produksi (`pino({ level: 'warn' })`) — logging level `debug` sangat verbose dan bisa memperlambat proses I/O pada bot dengan traffic tinggi.
|
|
2693
|
-
- **Gunakan `sock.ev.buffer()` / `sock.ev.flush()`** saat melakukan operasi massal (mis. restore ratusan kontak) agar handler event Anda tidak terpanggil berkali-kali secara terpisah.
|
|
2694
|
-
- **Hindari memanggil `groupMetadata()` di dalam loop** untuk banyak grup sekaligus — gunakan `groupFetchAllParticipating()` sekali saja lalu simpan hasilnya ke cache.
|
|
2695
|
-
- **Batasi concurrency saat broadcast** (lihat contoh `p-queue` di bagian FAQ) untuk menghindari flag spam dari WhatsApp sekaligus menjaga stabilitas koneksi socket.
|
|
2696
|
-
- **Gunakan `viewOnce: true` secukupnya** — media view-once tetap perlu diunggah penuh ke server WA seperti media biasa, tidak ada penghematan bandwidth dari sisi pengiriman.
|
|
1157
|
+
```js
|
|
1158
|
+
// Resolve channel URL to metadata
|
|
1159
|
+
const info = await sock.cekIDSaluran("https://whatsapp.com/channel/xxxxx");
|
|
1160
|
+
console.log(info.name, info.subscribers);
|
|
2697
1161
|
|
|
2698
|
-
|
|
1162
|
+
// Bulk follow multiple channels
|
|
1163
|
+
await sock.newsletterMultipleFollow("id1@newsletter id2@newsletter");
|
|
2699
1164
|
|
|
2700
|
-
|
|
1165
|
+
// Fetch all subscribed channels
|
|
1166
|
+
const channels = await sock.newsletterFetchAllSubscribe();
|
|
2701
1167
|
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
- **Validasi input dari pengguna** sebelum diteruskan ke `sendMessage` (mis. `jid` tujuan) untuk mencegah bot disalahgunakan mengirim pesan ke JID yang tidak dimaksud.
|
|
2705
|
-
- **Batasi command sensitif** (broadcast massal, kick anggota, hapus data) hanya untuk JID admin yang sudah diverifikasi — jangan hanya mengandalkan prefix command tanpa pengecekan pengirim.
|
|
2706
|
-
- **Gunakan `shouldIgnoreJid`** di config untuk secara eksplisit mengabaikan JID tertentu (mis. broadcast list, JID yang diketahui sebagai sumber spam) sebelum diproses lebih jauh oleh event handler Anda.
|
|
2707
|
-
- **Selalu bungkus handler pesan dengan `try/catch`** — satu error tak tertangani di handler tidak boleh sampai membuat seluruh proses bot crash.
|
|
2708
|
-
- **Perhatikan rate limit WhatsApp** — pengiriman pesan dalam volume sangat tinggi dalam waktu singkat berisiko membuat akun terkena flag spam atau bahkan banned permanen. Ini bukan batasan dari Harps-Baileys, melainkan kebijakan WhatsApp di level protokol/server.
|
|
2709
|
-
- **Update library secara berkala** — WhatsApp cukup sering mengubah detail protokol level rendah; versi Harps-Baileys yang usang berisiko berhenti berfungsi tanpa peringatan (mis. `version` di config perlu disesuaikan dengan rilis WA Web terbaru).
|
|
1168
|
+
// Generic action (follow/unfollow/mute/unmute)
|
|
1169
|
+
await sock.newsletterAction("id@newsletter", "follow");
|
|
2710
1170
|
|
|
2711
|
-
|
|
1171
|
+
// Create newsletter
|
|
1172
|
+
const nl = await sock.newsletterCreate("My Channel", "Description");
|
|
2712
1173
|
|
|
2713
|
-
|
|
1174
|
+
// Update newsletter
|
|
1175
|
+
await sock.newsletterUpdate("id@newsletter", { name: "New Name" });
|
|
2714
1176
|
|
|
2715
|
-
|
|
1177
|
+
// Get subscriber count
|
|
1178
|
+
const { subscribers } = await sock.newsletterSubscribers("id@newsletter");
|
|
2716
1179
|
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
| Kirim teks, media dasar, kontak, lokasi, reaksi, poll | ✅ | ✅ |
|
|
2720
|
-
| Native Flow buttons (`quick_reply`, `cta_url`, dll) | ✅ (manual, perlu tahu shape proto) | ✅ + shorthand `buttons`/`templateButtons` yang lebih ringkas |
|
|
2721
|
-
| List message | ✅ | ✅ + `nestedListMessage` dengan auto-flatten section bersarang |
|
|
2722
|
-
| Carousel (`cards`) | Tergantung versi, sering perlu payload manual | ✅ shorthand `cards` siap pakai |
|
|
2723
|
-
| Multi-dropdown dalam satu pesan | ❌ tidak ada bawaan | ✅ `multiSelectMessage` |
|
|
2724
|
-
| Story/status ke grup tertentu | ❌ tidak ada bawaan | ✅ `groupStatusMessage` (Group Status V2), semua tipe media |
|
|
2725
|
-
| Generator gambar story otomatis | ❌ | ✅ `renderStoryCard()` berbasis Jimp |
|
|
2726
|
-
| `additionalNodes` otomatis untuk semua pesan interaktif | Tergantung versi & implementasi pengguna | ✅ otomatis via `buildInteractiveAdditionalNodes` di semua jalur pengiriman relevan |
|
|
2727
|
-
| Payment request message | Tergantung versi | ✅ `requestPaymentMessage` shorthand |
|
|
2728
|
-
| Product message tunggal | Tergantung versi | ✅ `productMessage` shorthand |
|
|
2729
|
-
| Album (grup foto/video) | Tergantung versi | ✅ `albumMessage` shorthand |
|
|
2730
|
-
| Poll result snapshot | ❌ | ✅ `pollResultMessage` |
|
|
2731
|
-
| Dokumen dengan thumbnail preview | Tergantung versi | ✅ dipatch agar konsisten menampilkan `jpegThumbnail` |
|
|
1180
|
+
// Get metadata
|
|
1181
|
+
const meta = await sock.newsletterMetadata("jid", "id@newsletter");
|
|
2732
1182
|
|
|
2733
|
-
|
|
1183
|
+
// Follow / Unfollow
|
|
1184
|
+
await sock.newsletterFollow("id@newsletter");
|
|
1185
|
+
await sock.newsletterUnfollow("id@newsletter");
|
|
2734
1186
|
|
|
2735
|
-
|
|
1187
|
+
// Mute / Unmute
|
|
1188
|
+
await sock.newsletterMute("id@newsletter");
|
|
1189
|
+
await sock.newsletterUnmute("id@newsletter");
|
|
2736
1190
|
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
| **LID** | *Linked Identity* — JID tersamar (`@lid`) yang menggantikan nomor telepon asli demi privasi, terutama di grup besar. |
|
|
2743
|
-
| **PN** | *Phone Number* — JID berbasis nomor telepon asli (`@s.whatsapp.net`), lawan dari LID. |
|
|
2744
|
-
| **Native Flow** | Sistem tombol/interaktif modern WhatsApp (`interactiveMessage.nativeFlowMessage`), pengganti `buttonsMessage`/`templateMessage` legacy. |
|
|
2745
|
-
| **NF V7** | Istilah internal fork ini untuk generasi ke-7 builder Native Flow yang mencakup 13 jenis tombol (URL, call, copy, reminder, dst). |
|
|
2746
|
-
| **Additional Nodes** | Node XML biner tambahan yang dikirim bersamaan dengan payload pesan lewat `relayMessage()`, memberi hint ke client cara merender pesan tersebut. |
|
|
2747
|
-
| **Relay Message** | Proses inti mengenkripsi & mengirim sebuah pesan ke satu/banyak device tujuan lewat protokol Signal. |
|
|
2748
|
-
| **App-State** | Data tersinkronisasi lintas device (kontak, chat, label, pengaturan) yang disimpan sebagai *patch* terenkripsi di server WhatsApp. |
|
|
2749
|
-
| **Pre-Key** | Kunci kriptografi sekali pakai (Signal Protocol) yang perlu selalu tersedia agar device lain bisa memulai sesi terenkripsi baru dengan Anda. |
|
|
2750
|
-
| **Sender Key** | Kunci untuk enkripsi pesan grup (agar tidak perlu enkripsi 1-1 ke tiap anggota). |
|
|
2751
|
-
| **Stub Message** | Pesan sistem tanpa konten asli (`message: null`), merepresentasikan event seperti "X mengubah nama grup" — dibaca dari `messageStubType`. |
|
|
2752
|
-
| **Ephemeral** | Pesan sekali lihat (*disappearing message*) — otomatis terhapus setelah durasi tertentu. |
|
|
2753
|
-
| **PTT** | *Push To Talk* — voice note (pesan suara), lawan dari audio musik biasa. |
|
|
2754
|
-
| **PTV** | *Push To Video* — video pesan bulat gaya voice note. |
|
|
2755
|
-
| **Boom** | Kelas error dari `@hapi/boom`, membawa `output.statusCode` mirip kode status HTTP. |
|
|
2756
|
-
| **Noise Protocol** | Protokol handshake kriptografi yang dipakai WhatsApp Web untuk membangun koneksi WebSocket aman sebelum otentikasi Signal berlangsung. |
|
|
2757
|
-
| **USync** | Protokol WhatsApp untuk query status banyak user/device sekaligus (dipakai untuk cek siapa yang online di WhatsApp sebelum mengirim pesan). |
|
|
2758
|
-
| **WAM** | *WhatsApp Analytics/Metrics* — encoder biner untuk data telemetri internal client (bukan untuk data pengguna). |
|
|
1191
|
+
// Update name / description / picture
|
|
1192
|
+
await sock.newsletterUpdateName("id@newsletter", "New Name");
|
|
1193
|
+
await sock.newsletterUpdateDescription("id@newsletter", "New Desc");
|
|
1194
|
+
await sock.newsletterUpdatePicture("id@newsletter", mediaUpload);
|
|
1195
|
+
await sock.newsletterRemovePicture("id@newsletter");
|
|
2759
1196
|
|
|
2760
|
-
|
|
1197
|
+
// React to message
|
|
1198
|
+
await sock.newsletterReactMessage("id@newsletter", serverId, "👍");
|
|
2761
1199
|
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
Parameter ketiga (`options`) bersifat opsional dan memengaruhi bagaimana pesan dibangun & dikirim:
|
|
2765
|
-
|
|
2766
|
-
| Opsi | Tipe | Keterangan |
|
|
2767
|
-
|---|---|---|
|
|
2768
|
-
| `quoted` | `WAMessage` | Pesan yang ingin di-reply/kutip. |
|
|
2769
|
-
| `messageId` | `string` | Override ID pesan (default: digenerate otomatis, format `3EB0` + random hex). |
|
|
2770
|
-
| `timestamp` | `Date` | Override waktu pesan (default: `new Date()` saat ini). |
|
|
2771
|
-
| `ephemeralExpiration` | `number` | Durasi pesan sekali lihat dalam detik (default: `WA_DEFAULT_EPHEMERAL` jika chat sedang ephemeral). |
|
|
2772
|
-
| `mediaCache` | objek cache | Cache upload media agar file yang sama tidak diunggah ulang (mengurangi request upload berulang). |
|
|
2773
|
-
| `mediaUploadTimeoutMs` | `number` | Timeout khusus untuk proses upload media. |
|
|
2774
|
-
| `backgroundColor` | `string`/`number` | Warna latar untuk teks bergaya atau audio dengan visual (lihat bagian [Teks & Link Preview](#teks--link-preview)). |
|
|
2775
|
-
| `font` | `number` | Indeks font (0-5) untuk teks bergaya. |
|
|
2776
|
-
| `getUrlInfo` | `function` | Override resolver link preview kustom (default memakai `link-preview-js`). |
|
|
2777
|
-
| `getProfilePicUrl` | `function` | Dipakai saat mengirim `groupInvite` agar bisa menampilkan foto profil grup di pesan undangan. |
|
|
2778
|
-
| `getCallLink` | `function` | Resolver untuk membuat link panggilan otomatis pada `event.call`. |
|
|
2779
|
-
| `useCachedGroupMetadata` | `boolean` | Paksa pakai/lewati cache `cachedGroupMetadata` khusus untuk pengiriman ini. |
|
|
2780
|
-
| `statusJidList` | `string[]` | Daftar JID penerima khusus untuk pesan status (`status@broadcast`) — hanya JID ini yang akan melihat status Anda. |
|
|
2781
|
-
| `broadcast` | `boolean` | Tandai pesan sebagai broadcast list. |
|
|
2782
|
-
| `additionalNodes` | `BinaryNode[]` | Node binari tambahan manual (lihat [`buildInteractiveAdditionalNodes`](#buildinteractiveadditionalnodes--kenapa-wajib-ada)) — jarang perlu diisi manual karena sudah otomatis. |
|
|
2783
|
-
| `forceForward` | `boolean` | Paksa tandai pesan sebagai "diteruskan" walau baru pertama kali diteruskan. |
|
|
2784
|
-
| `logger` | pino logger | Override logger khusus untuk pengiriman pesan ini saja. |
|
|
2785
|
-
|
|
2786
|
-
### Contoh Menggabungkan Beberapa Opsi Sekaligus
|
|
1200
|
+
// Fetch messages
|
|
1201
|
+
const msgs = await sock.newsletterFetchMessages("id@newsletter", 50, 0, 0);
|
|
2787
1202
|
|
|
2788
|
-
|
|
2789
|
-
await sock.
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
ephemeralExpiration: 3600,
|
|
2794
|
-
messageId: `CUSTOM-${Date.now()}`,
|
|
2795
|
-
logger: sock.logger.child({ feature: 'reminder' })
|
|
2796
|
-
})
|
|
1203
|
+
// Admin operations
|
|
1204
|
+
const count = await sock.newsletterAdminCount("id@newsletter");
|
|
1205
|
+
await sock.newsletterChangeOwner("id@newsletter", newOwnerJid);
|
|
1206
|
+
await sock.newsletterDemote("id@newsletter", userJid);
|
|
1207
|
+
await sock.newsletterDelete("id@newsletter");
|
|
2797
1208
|
```
|
|
2798
1209
|
|
|
2799
1210
|
---
|
|
2800
1211
|
|
|
2801
|
-
|
|
1212
|
+
### Group Methods
|
|
2802
1213
|
|
|
2803
|
-
|
|
1214
|
+
```js
|
|
1215
|
+
// Fetch group metadata
|
|
1216
|
+
const meta = await sock.groupMetadata("id@g.us");
|
|
2804
1217
|
|
|
2805
|
-
|
|
1218
|
+
// Create group
|
|
1219
|
+
const group = await sock.groupCreate("My Group", ["628xxx@s.whatsapp.net"]);
|
|
2806
1220
|
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
pm2 start index.js --name harps-md --time
|
|
2810
|
-
pm2 save
|
|
2811
|
-
pm2 startup # ikuti instruksi agar bot auto-start saat server reboot
|
|
2812
|
-
```
|
|
1221
|
+
// Leave group
|
|
1222
|
+
await sock.groupLeave("id@g.us");
|
|
2813
1223
|
|
|
2814
|
-
|
|
1224
|
+
// Update subject / description
|
|
1225
|
+
await sock.groupUpdateSubject("id@g.us", "New Subject");
|
|
1226
|
+
await sock.groupUpdateDescription("id@g.us", "New Description");
|
|
2815
1227
|
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
autorestart: true,
|
|
2823
|
-
max_restarts: 20,
|
|
2824
|
-
restart_delay: 3000,
|
|
2825
|
-
env: {
|
|
2826
|
-
NODE_ENV: 'production'
|
|
2827
|
-
}
|
|
2828
|
-
}]
|
|
2829
|
-
}
|
|
2830
|
-
```
|
|
1228
|
+
// Participant actions: add, remove, promote, demote
|
|
1229
|
+
const result = await sock.groupParticipantsUpdate(
|
|
1230
|
+
"id@g.us",
|
|
1231
|
+
["628xxx@s.whatsapp.net"],
|
|
1232
|
+
"add", // 'remove' | 'promote' | 'demote'
|
|
1233
|
+
);
|
|
2831
1234
|
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
1235
|
+
// Handle join requests
|
|
1236
|
+
const requests = await sock.groupRequestParticipantsList("id@g.us");
|
|
1237
|
+
await sock.groupRequestParticipantsUpdate(
|
|
1238
|
+
"id@g.us",
|
|
1239
|
+
["628xxx@s.whatsapp.net"],
|
|
1240
|
+
"approve",
|
|
1241
|
+
);
|
|
2835
1242
|
|
|
2836
|
-
|
|
1243
|
+
// Invite code
|
|
1244
|
+
const code = await sock.groupInviteCode("id@g.us");
|
|
1245
|
+
await sock.groupRevokeInvite("id@g.us");
|
|
1246
|
+
await sock.groupAcceptInvite("ABCDE12345");
|
|
1247
|
+
const info = await sock.groupGetInviteInfo("ABCDE12345");
|
|
2837
1248
|
|
|
2838
|
-
|
|
2839
|
-
|
|
1249
|
+
// Settings: announcement, not_announcement, locked, unlocked
|
|
1250
|
+
await sock.groupSettingUpdate("id@g.us", "announcement");
|
|
1251
|
+
await sock.groupSettingUpdate("id@g.us", "locked");
|
|
2840
1252
|
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
1253
|
+
// Member add mode / Join approval
|
|
1254
|
+
await sock.groupMemberAddMode("id@g.us", "admin_add");
|
|
1255
|
+
await sock.groupJoinApprovalMode("id@g.us", "on");
|
|
2844
1256
|
|
|
2845
|
-
|
|
1257
|
+
// Toggle disappearing messages
|
|
1258
|
+
await sock.groupToggleEphemeral("id@g.us", 86400); // 24h
|
|
2846
1259
|
|
|
2847
|
-
|
|
2848
|
-
|
|
1260
|
+
// Fetch all participating groups
|
|
1261
|
+
const groups = await sock.groupFetchAllParticipating();
|
|
2849
1262
|
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
docker run -d --name harps-md -v $(pwd)/sesi_auth:/app/sesi_auth harps-md
|
|
1263
|
+
// Update member label
|
|
1264
|
+
await sock.updateMemberLabel("id@g.us", "VIP");
|
|
2853
1265
|
```
|
|
2854
1266
|
|
|
2855
|
-
|
|
1267
|
+
---
|
|
1268
|
+
|
|
1269
|
+
### Community Methods
|
|
1270
|
+
|
|
1271
|
+
```js
|
|
1272
|
+
// Fetch community metadata
|
|
1273
|
+
const meta = await sock.communityMetadata("communityid@g.us");
|
|
1274
|
+
|
|
1275
|
+
// Create community
|
|
1276
|
+
const community = await sock.communityCreate(
|
|
1277
|
+
"Our Community",
|
|
1278
|
+
"Community description",
|
|
1279
|
+
);
|
|
1280
|
+
|
|
1281
|
+
// Create a subgroup under a community
|
|
1282
|
+
const subgroup = await sock.communityCreateGroup(
|
|
1283
|
+
"Announcements",
|
|
1284
|
+
["628xxx@s.whatsapp.net"],
|
|
1285
|
+
"communityid@g.us",
|
|
1286
|
+
);
|
|
1287
|
+
|
|
1288
|
+
// Link / unlink an existing group
|
|
1289
|
+
await sock.communityLinkGroup("groupid@g.us", "communityid@g.us");
|
|
1290
|
+
await sock.communityUnlinkGroup("groupid@g.us", "communityid@g.us");
|
|
1291
|
+
|
|
1292
|
+
// Fetch linked groups
|
|
1293
|
+
const linked = await sock.communityFetchLinkedGroups("communityid@g.us");
|
|
1294
|
+
|
|
1295
|
+
// Invite handling
|
|
1296
|
+
const code = await sock.communityInviteCode("communityid@g.us");
|
|
1297
|
+
await sock.communityRevokeInvite("communityid@g.us");
|
|
1298
|
+
await sock.communityAcceptInvite(code);
|
|
1299
|
+
const inviteInfo = await sock.communityGetInviteInfo(code);
|
|
1300
|
+
|
|
1301
|
+
// Requests / participants
|
|
1302
|
+
const requests =
|
|
1303
|
+
await sock.communityRequestParticipantsList("communityid@g.us");
|
|
1304
|
+
await sock.communityRequestParticipantsUpdate(
|
|
1305
|
+
"communityid@g.us",
|
|
1306
|
+
["628xxx@s.whatsapp.net"],
|
|
1307
|
+
"approve",
|
|
1308
|
+
);
|
|
1309
|
+
await sock.communityParticipantsUpdate(
|
|
1310
|
+
"communityid@g.us",
|
|
1311
|
+
["628xxx@s.whatsapp.net"],
|
|
1312
|
+
"add",
|
|
1313
|
+
);
|
|
1314
|
+
|
|
1315
|
+
// Settings
|
|
1316
|
+
await sock.communityUpdateSubject("communityid@g.us", "New Subject");
|
|
1317
|
+
await sock.communityUpdateDescription("communityid@g.us", "New Description");
|
|
1318
|
+
await sock.communityToggleEphemeral("communityid@g.us", 86400);
|
|
1319
|
+
await sock.communitySettingUpdate("communityid@g.us", "announcement");
|
|
1320
|
+
await sock.communityMemberAddMode("communityid@g.us", "admin_add");
|
|
1321
|
+
await sock.communityJoinApprovalMode("communityid@g.us", "on");
|
|
1322
|
+
|
|
1323
|
+
// Leave / list all
|
|
1324
|
+
await sock.communityLeave("communityid@g.us");
|
|
1325
|
+
const communities = await sock.communityFetchAllParticipating();
|
|
1326
|
+
```
|
|
2856
1327
|
|
|
2857
|
-
|
|
1328
|
+
---
|
|
2858
1329
|
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
1330
|
+
### Business Methods
|
|
1331
|
+
|
|
1332
|
+
```js
|
|
1333
|
+
// Catalog
|
|
1334
|
+
const { products, nextPageCursor } = await sock.getCatalog({
|
|
1335
|
+
jid: "628xxx@s.whatsapp.net",
|
|
1336
|
+
limit: 10,
|
|
1337
|
+
});
|
|
1338
|
+
|
|
1339
|
+
const { collections } = await sock.getCollections("628xxx@s.whatsapp.net", 10);
|
|
1340
|
+
|
|
1341
|
+
// Orders
|
|
1342
|
+
const order = await sock.getOrderDetails(orderId, tokenBase64);
|
|
1343
|
+
|
|
1344
|
+
// Product CRUD
|
|
1345
|
+
const product = await sock.productCreate({
|
|
1346
|
+
name: "Premium Package",
|
|
1347
|
+
description: "Official premium plan",
|
|
1348
|
+
price: 150000,
|
|
1349
|
+
currency: "IDR",
|
|
1350
|
+
originCountryCode: "ID",
|
|
1351
|
+
images: [mediaUpload],
|
|
1352
|
+
});
|
|
1353
|
+
|
|
1354
|
+
await sock.productUpdate(product.id, {
|
|
1355
|
+
name: "Premium Package Plus",
|
|
1356
|
+
description: "Official premium plan plus",
|
|
1357
|
+
price: 175000,
|
|
1358
|
+
currency: "IDR",
|
|
1359
|
+
images: [mediaUpload],
|
|
1360
|
+
});
|
|
1361
|
+
|
|
1362
|
+
await sock.productDelete([product.id]);
|
|
1363
|
+
|
|
1364
|
+
// Business profile
|
|
1365
|
+
await sock.updateBusinessProfile({
|
|
1366
|
+
address: "Jakarta, Indonesia",
|
|
1367
|
+
description: "Official store",
|
|
1368
|
+
websites: ["https://example.com"],
|
|
1369
|
+
email: "hello@example.com",
|
|
1370
|
+
hours: {
|
|
1371
|
+
timezone: "Asia/Jakarta",
|
|
1372
|
+
days: [{ day: "mon", mode: "open_24h" }],
|
|
1373
|
+
},
|
|
1374
|
+
});
|
|
1375
|
+
|
|
1376
|
+
// Legacy alias is still available for backward compatibility
|
|
1377
|
+
await sock.updateBussinesProfile({
|
|
1378
|
+
description: "Legacy alias still works",
|
|
1379
|
+
});
|
|
1380
|
+
|
|
1381
|
+
await sock.updateCoverPhoto(mediaUpload);
|
|
1382
|
+
await sock.removeCoverPhoto(coverId);
|
|
1383
|
+
|
|
1384
|
+
// Quick replies
|
|
1385
|
+
await sock.addOrEditQuickReply({
|
|
1386
|
+
shortcut: "hello",
|
|
1387
|
+
message: "Hello from business account",
|
|
1388
|
+
});
|
|
1389
|
+
|
|
1390
|
+
await sock.removeQuickReply(timestamp);
|
|
2865
1391
|
```
|
|
2866
1392
|
|
|
2867
1393
|
---
|
|
2868
1394
|
|
|
2869
|
-
|
|
1395
|
+
### Chat & Profile Methods
|
|
2870
1396
|
|
|
2871
|
-
|
|
1397
|
+
```js
|
|
1398
|
+
// Profile picture
|
|
1399
|
+
const url = await sock.profilePictureUrl(jid, "image");
|
|
1400
|
+
await sock.updateProfilePicture(jid, mediaUpload);
|
|
1401
|
+
await sock.removeProfilePicture(jid);
|
|
1402
|
+
|
|
1403
|
+
// Profile name / status
|
|
1404
|
+
await sock.updateProfileName("My Name");
|
|
1405
|
+
await sock.updateProfileStatus("Available");
|
|
2872
1406
|
|
|
2873
|
-
|
|
1407
|
+
// Presence
|
|
1408
|
+
await sock.sendPresenceUpdate("available", jid);
|
|
1409
|
+
await sock.presenceSubscribe(jid);
|
|
2874
1410
|
|
|
2875
|
-
|
|
1411
|
+
// Read receipts
|
|
1412
|
+
await sock.readMessages([msg.key]);
|
|
1413
|
+
await sock.sendReceipt(jid, participant, [msgId], "read");
|
|
2876
1414
|
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
1415
|
+
// Block / Unblock
|
|
1416
|
+
await sock.updateBlockStatus(jid, "block");
|
|
1417
|
+
await sock.updateBlockStatus(jid, "unblock");
|
|
2880
1418
|
|
|
2881
|
-
|
|
1419
|
+
// Fetch blocklist
|
|
1420
|
+
const list = await sock.fetchBlocklist();
|
|
2882
1421
|
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
1422
|
+
// Chat modifications
|
|
1423
|
+
await sock.chatModify(
|
|
1424
|
+
{
|
|
1425
|
+
archive: true,
|
|
1426
|
+
lastMessageOrig: msg,
|
|
1427
|
+
lastMessage: msg,
|
|
1428
|
+
},
|
|
1429
|
+
jid,
|
|
1430
|
+
);
|
|
2886
1431
|
|
|
2887
|
-
|
|
1432
|
+
// Star messages
|
|
1433
|
+
await sock.star(jid, [{ id: msgId, fromMe: true }], true);
|
|
2888
1434
|
|
|
2889
|
-
|
|
1435
|
+
// Contact management
|
|
1436
|
+
await sock.addOrEditContact(jid, { displayName: "Name" });
|
|
1437
|
+
await sock.removeContact(jid);
|
|
2890
1438
|
|
|
2891
|
-
|
|
1439
|
+
// Labels
|
|
1440
|
+
await sock.addChatLabel(jid, labelId);
|
|
1441
|
+
await sock.removeChatLabel(jid, labelId);
|
|
1442
|
+
await sock.addMessageLabel(jid, messageId, labelId);
|
|
2892
1443
|
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
- `Utils/story-card.js` (baru) — `renderStoryCard()`, generator visual story/status berbasis Jimp.
|
|
2896
|
-
- `handleGroupStory` mode baru `card` — kirim story langsung dari `renderStoryCard()` tanpa buffer manual.
|
|
2897
|
-
- `handleGroupStory`: dukungan semua tipe media dengan caption (`text`, `image`, `video`, `audio`, `sticker`, `document`, `message`, `raw`).
|
|
2898
|
-
- `multiSelectMessage` — satu pesan dengan beberapa `single_select` buttons terpisah.
|
|
2899
|
-
- `nestedListMessage` — `listMessage` dengan auto-flatten nested rows.
|
|
2900
|
-
- Ekspor semua NF V7 builders: `nfButtonUrl`, `nfButtonCall`, `nfButtonCopy`, `nfButtonReminder`, `nfButtonCancelReminder`, `nfButtonAddress`, `nfButtonLocation`, `nfButtonQuickReply`, `nfButtonSingleSelect`, `nfButtonMultiSelect`, `nfButtonReviewPay`, `nfButtonReviewOrder`, `nfButtonMPM`.
|
|
2901
|
-
- Ekspor `buildNestedListMessage()` sebagai helper standalone.
|
|
2902
|
-
- `messages-send.js`: wiring case `NESTED_LIST` dan `MULTI_SELECT`.
|
|
2903
|
-
- `buildInteractiveAdditionalNodes` menambah dukungan `groupStatusMessageV2` → inject `<meta is_vsn2="1">` di dalam grup.
|
|
1444
|
+
// App state sync
|
|
1445
|
+
await sock.resyncAppState(["regular", "critical_block"], true);
|
|
2904
1446
|
|
|
2905
|
-
|
|
1447
|
+
// Business profile
|
|
1448
|
+
const biz = await sock.getBusinessProfile(jid);
|
|
1449
|
+
```
|
|
2906
1450
|
|
|
2907
1451
|
---
|
|
2908
1452
|
|
|
2909
|
-
|
|
1453
|
+
### Privacy Settings
|
|
1454
|
+
|
|
1455
|
+
```js
|
|
1456
|
+
await sock.updateLastSeenPrivacy("all"); // 'all' | 'contacts' | 'contact_blacklist' | 'nobody'
|
|
1457
|
+
await sock.updateOnlinePrivacy("all"); // 'all' | 'match_last_seen'
|
|
1458
|
+
await sock.updateProfilePicturePrivacy("contacts");
|
|
1459
|
+
await sock.updateStatusPrivacy("contacts");
|
|
1460
|
+
await sock.updateReadReceiptsPrivacy("all"); // 'all' | 'none'
|
|
1461
|
+
await sock.updateGroupsAddPrivacy("all"); // 'all' | 'contacts'
|
|
1462
|
+
await sock.updateMessagesPrivacy("all"); // 'all' | 'contacts' | 'nobody'
|
|
1463
|
+
await sock.updateCallPrivacy("everyone");
|
|
1464
|
+
await sock.updateDefaultDisappearingMode(86400);
|
|
1465
|
+
await sock.updateDisableLinkPreviewsPrivacy(true);
|
|
1466
|
+
```
|
|
1467
|
+
|
|
1468
|
+
---
|
|
2910
1469
|
|
|
2911
|
-
|
|
1470
|
+
## 📡 Event Reference
|
|
1471
|
+
|
|
1472
|
+
```js
|
|
1473
|
+
sock.ev.on('connection.update', ({ connection, lastDisconnect, qr, isNewLogin, receivedPendingNotifications, isOnline }) => {})
|
|
1474
|
+
sock.ev.on('creds.update', (update) => {})
|
|
1475
|
+
sock.ev.on('messaging-history.set', ({ chats, contacts, messages, isLatest }) => {})
|
|
1476
|
+
sock.ev.on('chats.upsert', (chats) => {})
|
|
1477
|
+
sock.ev.on('chats.update', (updates) => {})
|
|
1478
|
+
sock.ev.on('chats.delete', (jids) => {})
|
|
1479
|
+
sock.ev.on('contacts.upsert', (contacts) => {})
|
|
1480
|
+
sock.ev.on('contacts.update', (updates) => {})
|
|
1481
|
+
sock.ev.on('messages.upsert', ({ messages, type }) => {})
|
|
1482
|
+
sock.ev.on('messages.update', (updates) => {})
|
|
1483
|
+
sock.ev.on('messages.delete', (keys) => {})
|
|
1484
|
+
sock.ev.on('messages.reaction', (reactions) => {})
|
|
1485
|
+
sock.ev.on('message-receipt.update', (updates) => {})
|
|
1486
|
+
sock.ev.on('groups.update', (updates) => {})
|
|
1487
|
+
sock.ev.on('group-participants.update', (update) => {})
|
|
1488
|
+
sock.ev.on('group.join-request', (update) => {})
|
|
1489
|
+
sock.ev.on('call', (calls) => {})
|
|
1490
|
+
sock.ev.on('labels.edit', (label) => {})
|
|
1491
|
+
sock.ev.on('labels.associations', ({ associated, label, type }) => {})
|
|
1492
|
+
sock.ev.on('newsletter.update', (updates) => {})
|
|
1493
|
+
sock.ev.on('newsletter.follow', (jid) => {})
|
|
1494
|
+
sock.ev.on('newsletter.unfollow', (jid) => {})
|
|
1495
|
+
sock.ev.on('settings.update', ({ isAutoEmojiEnabled, isReadReceiptsEnabled, ... }) => {})
|
|
1496
|
+
```
|
|
2912
1497
|
|
|
2913
|
-
|
|
1498
|
+
---
|
|
2914
1499
|
|
|
2915
|
-
|
|
1500
|
+
## 🔧 Utility Exports
|
|
2916
1501
|
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
1502
|
+
```js
|
|
1503
|
+
import {
|
|
1504
|
+
// Auth
|
|
1505
|
+
useMultiFileAuthState,
|
|
1506
|
+
makeCacheableSignalKeyStore,
|
|
1507
|
+
initAuthCreds,
|
|
1508
|
+
BufferJSON,
|
|
1509
|
+
fetchLatestBaileysVersion,
|
|
1510
|
+
|
|
1511
|
+
// Code tokenization
|
|
1512
|
+
tokenizeCode,
|
|
1513
|
+
tokenizeCodeV2,
|
|
1514
|
+
CodeHighlightType,
|
|
1515
|
+
RichSubMessageType,
|
|
1516
|
+
|
|
1517
|
+
// Rich message generators
|
|
1518
|
+
generateTableContent,
|
|
1519
|
+
generateTableContentV2,
|
|
1520
|
+
toTableMetadataV2,
|
|
1521
|
+
generateListContent,
|
|
1522
|
+
generateCodeBlockContent,
|
|
1523
|
+
generateCodeBlockContentV2,
|
|
1524
|
+
generateLinkContent,
|
|
1525
|
+
generateLinkContentV2,
|
|
1526
|
+
generateRichMessageContent,
|
|
1527
|
+
generateLatexContent,
|
|
1528
|
+
generateLatexImageContent,
|
|
1529
|
+
generateLatexInlineImageContent,
|
|
1530
|
+
generateUnifiedResponseContent,
|
|
1531
|
+
captureUnifiedResponse,
|
|
1532
|
+
|
|
1533
|
+
// Rich message builders
|
|
1534
|
+
buildRichContextInfo,
|
|
1535
|
+
buildBotForwardedMessage,
|
|
1536
|
+
|
|
1537
|
+
// Sticker pack helper
|
|
1538
|
+
makeStickerPack,
|
|
1539
|
+
|
|
1540
|
+
// Language keyword sets
|
|
1541
|
+
JS_KEYWORDS,
|
|
1542
|
+
PYTHON_KEYWORDS,
|
|
1543
|
+
GO_KEYWORDS,
|
|
1544
|
+
LUA_KEYWORDS,
|
|
1545
|
+
BASH_KEYWORDS,
|
|
1546
|
+
LANGUAGE_KEYWORDS,
|
|
1547
|
+
|
|
1548
|
+
// Crypto
|
|
1549
|
+
Curve,
|
|
1550
|
+
signedKeyPair,
|
|
1551
|
+
aesEncryptGCM,
|
|
1552
|
+
aesDecryptGCM,
|
|
1553
|
+
|
|
1554
|
+
// JID utilities
|
|
1555
|
+
jidEncode,
|
|
1556
|
+
jidDecode,
|
|
1557
|
+
jidNormalizedUser,
|
|
1558
|
+
areJidsSameUser,
|
|
1559
|
+
isJidGroup,
|
|
1560
|
+
isJidNewsletter,
|
|
1561
|
+
isLidUser,
|
|
1562
|
+
isPnUser,
|
|
1563
|
+
isJidBot,
|
|
1564
|
+
isJidMetaAI,
|
|
1565
|
+
isJidBroadcast,
|
|
1566
|
+
isJidStatusBroadcast,
|
|
1567
|
+
|
|
1568
|
+
// Connection
|
|
1569
|
+
DisconnectReason,
|
|
1570
|
+
Browsers,
|
|
1571
|
+
|
|
1572
|
+
// Dugong (advanced message types)
|
|
1573
|
+
Dugong,
|
|
1574
|
+
|
|
1575
|
+
// Types
|
|
1576
|
+
WASocket,
|
|
1577
|
+
} from "ourin-baileys";
|
|
1578
|
+
```
|
|
1579
|
+
|
|
1580
|
+
> [!NOTE]
|
|
1581
|
+
> In this build, some advanced helper typings may appear first in `lib/Socket/messages-send.d.ts` before they are reflected everywhere else in aggregated socket declarations. If your editor autocomplete lags behind runtime behavior, inspect `lib/Socket/messages-send.js` and `lib/Utils/rich-messages.d.ts` for the most complete helper surface.
|
|
2926
1582
|
|
|
2927
|
-
|
|
1583
|
+
---
|
|
2928
1584
|
|
|
2929
|
-
|
|
2930
|
-
- Versi `@vinzsocket/baileys` yang dipakai (`npm ls @vinzsocket/baileys`).
|
|
2931
|
-
- Versi Node.js (`node -v`).
|
|
2932
|
-
- Cuplikan kode minimal yang memicu masalah.
|
|
2933
|
-
- Perilaku yang diharapkan vs. yang benar-benar terjadi.
|
|
2934
|
-
- Log error lengkap (`logger` level `debug` jika memungkinkan, dengan data sensitif disensor).
|
|
1585
|
+
## 🏗️ Building This Package
|
|
2935
1586
|
|
|
2936
|
-
|
|
1587
|
+
This repository ships compiled files, but it still includes the build script used to emit/update `lib/`.
|
|
2937
1588
|
|
|
2938
1589
|
```bash
|
|
2939
|
-
git clone https://github.com/VinzSocket/Baileys.git
|
|
2940
|
-
cd Baileys
|
|
2941
1590
|
npm install
|
|
2942
|
-
npm run build
|
|
2943
|
-
npm run build:docs # generate dokumentasi API (typedoc)
|
|
2944
|
-
npm test # unit test
|
|
1591
|
+
npm run build
|
|
2945
1592
|
```
|
|
2946
1593
|
|
|
2947
|
-
|
|
1594
|
+
What the build does:
|
|
1595
|
+
|
|
1596
|
+
- runs TypeScript with `tsconfig.build.json`
|
|
1597
|
+
- emits JavaScript and declaration files into `lib/`
|
|
1598
|
+
- runs `tsc-esm-fix` so generated ESM imports resolve cleanly
|
|
1599
|
+
|
|
1600
|
+
Important build notes:
|
|
2948
1601
|
|
|
2949
|
-
|
|
1602
|
+
- `tsconfig.json` is authoring-oriented and uses `noEmit: true`
|
|
1603
|
+
- `tsconfig.build.json` flips emit back on and excludes test files
|
|
1604
|
+
- published package files are limited to `lib/**/*` and `WAProto/**/*`
|
|
2950
1605
|
|
|
2951
|
-
|
|
1606
|
+
---
|
|
2952
1607
|
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
1608
|
+
## 🔀 Differences from Official Baileys
|
|
1609
|
+
|
|
1610
|
+
| Area | Official Baileys v7 | ourin-baileys |
|
|
1611
|
+
| -------------------- | ------------------- | ---------------------------------------- |
|
|
1612
|
+
| Interactive messages | No native support | Full support via Dugong |
|
|
1613
|
+
| Album messages | Not supported | Multi-media albums |
|
|
1614
|
+
| AI Rich Response | Not available | Table, code block, rich text |
|
|
1615
|
+
| Table V1 | Not available | Basic table with headers |
|
|
1616
|
+
| Table V2 | Not available | Unified response + GenATableUXPrimitive |
|
|
1617
|
+
| Code Block V1 | Not available | Syntax highlighting (JS/TS/Python) |
|
|
1618
|
+
| Code Block V2 | Not available | Unified response + 6 languages |
|
|
1619
|
+
| Link Message | Not available | Inline embeds + citations + verification |
|
|
1620
|
+
| Business nodes | Manual injection | Auto-inject on relay |
|
|
1621
|
+
| Newsletter extras | Basic only | Auto-follow, bulk follow, URL resolve |
|
|
1622
|
+
| Button detection | Not available | `getButtonType()` auto-detect |
|
|
1623
|
+
| Payment messages | Not supported | Full support |
|
|
1624
|
+
| Event messages | Basic | Enhanced all fields |
|
|
1625
|
+
| Status mentions | Not available | `sendStatusMention()` |
|
|
1626
|
+
| Product messages | Not supported | Catalog + buttons |
|
|
1627
|
+
| LID support | Basic | Full LID↔PN mapping + session migration |
|
|
1628
|
+
| Identity changes | No handling | Debounced session refresh |
|
|
1629
|
+
| Message retry | Basic | `MessageRetryManager` with cache |
|
|
2957
1630
|
|
|
2958
|
-
|
|
1631
|
+
---
|
|
2959
1632
|
|
|
2960
|
-
|
|
2961
|
-
- Baileys upstream (referensi protokol dasar): **https://github.com/WhiskeySockets/Baileys**
|
|
2962
|
-
- Dokumentasi Protocol Buffers (untuk memahami `WAProto`): **https://protobuf.dev**
|
|
2963
|
-
- `@hapi/boom` (struktur error yang dipakai di seluruh library): **https://hapi.dev/module/boom**
|
|
2964
|
-
- Jimp (dependency opsional untuk `renderStoryCard`): **https://github.com/jimp-dev/jimp**
|
|
1633
|
+
## 🤝 Contributing
|
|
2965
1634
|
|
|
2966
|
-
|
|
1635
|
+
1. Fork this repo
|
|
1636
|
+
2. Create a branch (`git checkout -b feature/name`)
|
|
1637
|
+
3. Commit changes (`git commit -m 'feat: add feature'`)
|
|
1638
|
+
4. Push to branch (`git push origin feature/name`)
|
|
1639
|
+
5. Open a Pull Request
|
|
2967
1640
|
|
|
2968
1641
|
---
|
|
2969
1642
|
|
|
2970
|
-
## 📄
|
|
1643
|
+
## 📄 License
|
|
2971
1644
|
|
|
2972
|
-
|
|
1645
|
+
MIT © [LuckyArch](https://github.com/LuckyArch)
|
|
2973
1646
|
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
Copyright (c) Alvin-B2T / VinzSocket
|
|
2978
|
-
|
|
2979
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
2980
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
2981
|
-
in the Software without restriction, including without limitation the rights
|
|
2982
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
2983
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
2984
|
-
furnished to do so, subject to the following conditions:
|
|
2985
|
-
|
|
2986
|
-
The above copyright notice and this permission notice shall be included in all
|
|
2987
|
-
copies or substantial portions of the Software.
|
|
2988
|
-
|
|
2989
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
2990
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
2991
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
2992
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
2993
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
2994
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
2995
|
-
SOFTWARE.
|
|
2996
|
-
```
|
|
1647
|
+
> [!CAUTION]
|
|
1648
|
+
> This library is for **educational purposes**. Ensure compliance with WhatsApp Terms of Service.
|
|
2997
1649
|
|
|
2998
1650
|
---
|
|
2999
1651
|
|
|
3000
1652
|
<div align="center">
|
|
3001
1653
|
|
|
3002
|
-
**
|
|
1654
|
+
**Made with 💚 by Zann**
|
|
3003
1655
|
|
|
3004
|
-
|
|
1656
|
+
[⭐ Star this repo](https://github.com/LuckyArch/ourin-baileys) · [🐛 Report Bug](https://github.com/LuckyArch/ourin-baileys/issues) · [💡 Request Feature](https://github.com/LuckyArch/ourin-baileys/issues)
|
|
3005
1657
|
|
|
3006
1658
|
</div>
|