violetics 7.0.1-alpha → 7.0.3-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/LICENSE +3 -2
  2. package/README.md +1001 -232
  3. package/WAProto/index.js +75379 -142631
  4. package/engine-requirements.js +11 -8
  5. package/lib/Defaults/index.js +132 -146
  6. package/lib/Signal/Group/ciphertext-message.js +2 -6
  7. package/lib/Signal/Group/group-session-builder.js +7 -42
  8. package/lib/Signal/Group/group_cipher.js +37 -52
  9. package/lib/Signal/Group/index.js +11 -57
  10. package/lib/Signal/Group/keyhelper.js +7 -45
  11. package/lib/Signal/Group/sender-chain-key.js +7 -16
  12. package/lib/Signal/Group/sender-key-distribution-message.js +8 -12
  13. package/lib/Signal/Group/sender-key-message.js +9 -13
  14. package/lib/Signal/Group/sender-key-name.js +2 -6
  15. package/lib/Signal/Group/sender-key-record.js +9 -22
  16. package/lib/Signal/Group/sender-key-state.js +27 -43
  17. package/lib/Signal/Group/sender-message-key.js +4 -8
  18. package/lib/Signal/libsignal.js +319 -94
  19. package/lib/Signal/lid-mapping.js +224 -139
  20. package/lib/Socket/Client/index.js +2 -19
  21. package/lib/Socket/Client/types.js +10 -0
  22. package/lib/Socket/Client/websocket.js +53 -0
  23. package/lib/Socket/business.js +162 -44
  24. package/lib/Socket/chats.js +477 -418
  25. package/lib/Socket/communities.js +430 -0
  26. package/lib/Socket/groups.js +110 -99
  27. package/lib/Socket/index.js +10 -10
  28. package/lib/Socket/messages-recv.js +884 -561
  29. package/lib/Socket/messages-send.js +859 -428
  30. package/lib/Socket/mex.js +41 -0
  31. package/lib/Socket/newsletter.js +195 -390
  32. package/lib/Socket/socket.js +465 -315
  33. package/lib/Store/index.js +3 -10
  34. package/lib/Store/make-in-memory-store.js +73 -79
  35. package/lib/Store/make-ordered-dictionary.js +4 -7
  36. package/lib/Store/object-repository.js +2 -6
  37. package/lib/Types/Auth.js +1 -2
  38. package/lib/Types/Bussines.js +1 -0
  39. package/lib/Types/Call.js +1 -2
  40. package/lib/Types/Chat.js +7 -4
  41. package/lib/Types/Contact.js +1 -2
  42. package/lib/Types/Events.js +1 -2
  43. package/lib/Types/GroupMetadata.js +1 -2
  44. package/lib/Types/Label.js +2 -5
  45. package/lib/Types/LabelAssociation.js +2 -5
  46. package/lib/Types/Message.js +17 -9
  47. package/lib/Types/Newsletter.js +33 -38
  48. package/lib/Types/Product.js +1 -2
  49. package/lib/Types/Signal.js +1 -2
  50. package/lib/Types/Socket.js +2 -2
  51. package/lib/Types/State.js +12 -2
  52. package/lib/Types/USync.js +1 -2
  53. package/lib/Types/index.js +14 -31
  54. package/lib/Utils/auth-utils.js +228 -152
  55. package/lib/Utils/browser-utils.js +28 -0
  56. package/lib/Utils/business.js +66 -70
  57. package/lib/Utils/chat-utils.js +331 -249
  58. package/lib/Utils/crypto.js +57 -91
  59. package/lib/Utils/decode-wa-message.js +168 -84
  60. package/lib/Utils/event-buffer.js +138 -80
  61. package/lib/Utils/generics.js +180 -297
  62. package/lib/Utils/history.js +83 -49
  63. package/lib/Utils/identity-change-handler.js +48 -0
  64. package/lib/Utils/index.js +19 -33
  65. package/lib/Utils/link-preview.js +14 -23
  66. package/lib/Utils/logger.js +2 -7
  67. package/lib/Utils/lt-hash.js +2 -46
  68. package/lib/Utils/make-mutex.js +24 -47
  69. package/lib/Utils/message-retry-manager.js +224 -0
  70. package/lib/Utils/messages-media.js +501 -496
  71. package/lib/Utils/messages.js +1428 -362
  72. package/lib/Utils/noise-handler.js +145 -100
  73. package/lib/Utils/pre-key-manager.js +105 -0
  74. package/lib/Utils/process-message.js +356 -150
  75. package/lib/Utils/reporting-utils.js +257 -0
  76. package/lib/Utils/signal.js +78 -73
  77. package/lib/Utils/sync-action-utils.js +47 -0
  78. package/lib/Utils/tc-token-utils.js +17 -0
  79. package/lib/Utils/use-multi-file-auth-state.js +35 -45
  80. package/lib/Utils/validate-connection.js +91 -107
  81. package/lib/WABinary/constants.js +1300 -1304
  82. package/lib/WABinary/decode.js +26 -48
  83. package/lib/WABinary/encode.js +109 -155
  84. package/lib/WABinary/generic-utils.js +161 -149
  85. package/lib/WABinary/index.js +5 -21
  86. package/lib/WABinary/jid-utils.js +73 -40
  87. package/lib/WABinary/types.js +1 -2
  88. package/lib/WAM/BinaryInfo.js +2 -6
  89. package/lib/WAM/constants.js +19070 -11568
  90. package/lib/WAM/encode.js +17 -23
  91. package/lib/WAM/index.js +3 -19
  92. package/lib/WAUSync/Protocols/USyncContactProtocol.js +8 -12
  93. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -15
  94. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -13
  95. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -14
  96. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -23
  97. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +13 -9
  98. package/lib/WAUSync/Protocols/index.js +4 -20
  99. package/lib/WAUSync/USyncQuery.js +40 -36
  100. package/lib/WAUSync/USyncUser.js +2 -6
  101. package/lib/WAUSync/index.js +3 -19
  102. package/lib/index.js +11 -44
  103. package/package.json +74 -107
  104. package/lib/Defaults/baileys-version.json +0 -3
  105. package/lib/Defaults/phonenumber-mcc.json +0 -223
  106. package/lib/Signal/Group/queue-job.js +0 -57
  107. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  108. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  109. package/lib/Socket/Client/web-socket-client.js +0 -118
  110. package/lib/Socket/groupStatus.js +0 -637
  111. package/lib/Socket/registration.js +0 -166
  112. package/lib/Socket/usync.js +0 -70
  113. package/lib/Store/make-cache-manager-store.js +0 -83
  114. package/lib/Utils/baileys-event-stream.js +0 -63
package/README.md CHANGED
@@ -1,318 +1,1087 @@
1
- <div align="center">
2
- <h1>🌟 Violetics Baileys</h1>
3
- <p><i>A professionally enhanced, feature-rich version of the Baileys WhatsApp Web API</i></p>
1
+ # 🌱 Violetics
4
2
 
5
- [![npm version](https://img.shields.io/npm/v/violetics.svg?style=for-the-badge)](https://www.npmjs.com/package/violetics)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](LICENSE)
7
- </div>
3
+ ![Logo](https://files.catbox.moe/c5s9g0.jpg)
8
4
 
9
- <br/>
5
+ A lightweight fork of Baileys with a few fixes and a small adjustment.
10
6
 
11
- Built for developers requiring robust WhatsApp automation with modern tooling, enhanced stability, and comprehensive documentation to handle **Hundreds of Sessions (Multi-Device)** concurrently using **SQLite**.
7
+ ### ⚙️ Changes
12
8
 
13
- ---
9
+ #### 🛠️ Internal Adjustments
10
+ - 🖼️ Fixed an issue where media could not be sent to newsletters due to an upstream issue.
11
+ - 📁 Reintroduced [`makeInMemoryStore`](#%EF%B8%8F-implementing-a-data-store) with a minimal ESM adaptation and small adjustments for Baileys v7.
12
+ - 📦 Switched FFmpeg execution from `exec` to `spawn` for safer process handling.
13
+ - 🗃️ Added `@napi-rs/image` as a supported image processing backend in `getImageProcessingLibrary()`, offering a balance between performance and compatibility.
14
14
 
15
- ## 📋 Table of Contents
15
+ #### 📨 Message Handling & Compatibility
16
+ - 👉🏻 Added support for sending [interactive message](#-sending-interactive-messages) types (button, list, interactive, template, carousel).
17
+ - 📩 Added support for [album messages](#%EF%B8%8F-album-image--video), [group status messages](#4%EF%B8%8F⃣-group-status), [status mention messages](#%EF%B8%8F-status-mention), [sticker pack messages](#-sticker-pack), and several [payment-related messages](#-sending-payment-messages) (request payment, payment invite, order, invoice).
18
+ - 📰 Simplified sending messages with ad thumbnails via [`externalAdReply`](#3%EF%B8%8F⃣-external-ad-reply) without requiring manual `contextInfo`.
16
19
 
17
- - [✨ Features](#-features)
18
- - [📦 Installation](#-installation)
19
- - [🚀 Quick Start](#-quick-start)
20
- - [🔌 Connection & Configuration](#-connection--configuration)
21
- - [💾 Handling Hundreds of Sessions (SQLite)](#-handling-hundreds-of-sessions-sqlite)
22
- - [📥 Core Features (Messages, Groups, Profile)](#-core-features)
23
- - [⚖️ Legal Notice](#️-legal-notice)
20
+ #### 🧩 Additional Message Options
21
+ - 👁️ Added optional boolean flags for message handling:
22
+ - [`ai`](#1%EF%B8%8F⃣-ai-label) - AI label on message
23
+ - [`mentionAll`](#-mention) - Mentions all group participants without requiring their JIDs in `mentions` or `mentionedJid`
24
+ - [`ephemeral`](#2%EF%B8%8F⃣-ephemeral), [`groupStatus`](#4%EF%B8%8F⃣-group-status), [`viewOnceV2`](#7%EF%B8%8F⃣-view-once-v2), [`viewOnceV2Extension`](#8%EF%B8%8F⃣-view-once-v2-extension), [`interactiveAsTemplate`](#3%EF%B8%8F⃣-interactive) - Message wrappers
25
+ - [`raw`](#5%EF%B8%8F⃣-raw) - Build your message manually **(DO NOT USE FOR EXPLOITATION)**
24
26
 
25
- ---
27
+ > [!NOTE]
28
+ 📄 This project is maintained with limited scope and is not intended to replace upstream Baileys.
29
+ >
30
+ > 😞 And, really sorry for my bad english.
26
31
 
27
- ## Features
32
+ ### 📥 Installation
28
33
 
29
- - 🚀 **Modern & Fast** – Built with TypeScript and latest technologies.
30
- - 🔧 **Production Ready Stability** – Modified Web Socket client configurations, custom ping/pong keep-alives, and connection limits removed to prevent random logouts.
31
- - 📱 **Multi-Device Support** – Full support for WhatsApp's multi-device protocol.
32
- - 🔐 **End-to-End Encryption** – Secure communication using Signal Protocol.
33
- - 📨 **All Message Types** – Support for text, media, documents, contacts, locations, polls, reactions, and more.
34
- - 👥 **Advanced Group Management** – Comprehensive controls including unique group status support.
35
- - 🛠️ **Developer Friendly** – Clean API, extensive examples, and detailed documentation.
34
+ - 📄 Via `package.json`
36
35
 
37
- ---
36
+ ```json
37
+ # NPM
38
+ "dependencies": {
39
+ "violetics": "latest"
40
+ }
41
+
42
+ # GitHub
43
+ "dependencies": {
44
+ "violetics": "github:cv3inx/violetics"
45
+ }
46
+ ```
38
47
 
39
- ## 📦 Installation
48
+ - ⌨️ Via terminal
40
49
 
41
- ### Via NPM
42
50
  ```bash
43
- npm install violetics
51
+ # NPM
52
+ npm i violetics@latest
53
+
54
+ # GitHub
55
+ npm i github:cv3inx/violetics
44
56
  ```
45
57
 
46
- ### Via GitHub
47
- ```bash
48
- npm install github:cv3inx/violetics.git
58
+ #### 🧩 Import (ESM & CJS)
59
+
60
+ ```javascript
61
+ // --- ESM
62
+ import { makeWASocket } from 'violetics'
63
+
64
+ // --- CJS (tested and working on Node.js 24 ✅)
65
+ const { makeWASocket } = require('violetics')
49
66
  ```
50
67
 
51
- ---
68
+ ### 🔧 Usage
69
+
70
+ #### 🌐 Connect to WhatsApp (Quick Step)
71
+
72
+ ```javascript
73
+ import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from 'violetics'
74
+ import { Boom } from '@hapi/boom'
75
+ import pino from 'pino'
76
+
77
+ // --- Connect with pairing code
78
+ const myPhoneNumber = '6288888888888'
79
+
80
+ const logger = pino({ level: 'silent' })
52
81
 
53
- ## 🚀 Quick Start
82
+ const connectToWhatsApp = async () => {
83
+ const { state, saveCreds } = await useMultiFileAuthState('session')
84
+
85
+ const sock = makeWASocket({
86
+ logger,
87
+ auth: state
88
+ })
89
+
90
+ sock.ev.on('creds.update', saveCreds)
91
+
92
+ sock.ev.on('connection.update', (update) => {
93
+ const { connection, lastDisconnect } = update
94
+ if (connection === 'connecting' && !sock.authState.creds.registered) {
95
+ await delay(1500)
96
+ const code = await sock.requestPairingCode(myPhoneNumber)
97
+ console.log('🔗 Pairing code', ':', code)
98
+ }
99
+ else if (connection === 'close') {
100
+ const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
101
+ console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
102
+ if (shouldReconnect) {
103
+ connectToWhatsApp()
104
+ }
105
+ }
106
+ else if (connection === 'open') {
107
+ console.log('✅ Successfully connected to WhatsApp')
108
+ }
109
+ })
110
+
111
+ sock.ev.on('messages.upsert', async ({ messages }) => {
112
+ for (const message of messages) {
113
+ if (!message.message) continue
114
+
115
+ console.log('🔔 Got new message', ':', message)
116
+ await sock.sendMessage(message.key.remoteJid, {
117
+ text: '👋🏻 Hello world'
118
+ })
119
+ }
120
+ })
121
+ }
54
122
 
55
- Here is a basic example to get you connected and listening to messages using standard File Authentication.
123
+ connectToWhatsApp()
124
+ ```
125
+
126
+ #### 🗄️ Implementing a Data Store
127
+
128
+ > [!CAUTION]
129
+ I highly recommend building your own data store, as keeping an entire chat history in memory can lead to excessive RAM usage.
56
130
 
57
131
  ```javascript
58
- const { makeWASocket, useMultiFileAuthState, DisconnectReason } = require('violetics');
59
- const { Boom } = require('@hapi/boom');
132
+ import { makeWASocket, makeInMemoryStore, delay, DisconnectReason, useMultiFileAuthState } from 'violetics'
133
+ import { Boom } from '@hapi/boom'
134
+ import pino from 'pino'
135
+
136
+ const myPhoneNumber = '6288888888888'
137
+
138
+ // --- Create your store path
139
+ const storePath = './store.json'
140
+
141
+ const logger = pino({ level: 'silent' })
60
142
 
61
- async function connectToWhatsApp() {
62
- const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys');
143
+ const connectToWhatsApp = async () => {
144
+ const { state, saveCreds } = await useMultiFileAuthState('session')
63
145
 
64
- const sock = makeWASocket({
65
- auth: state,
66
- printQRInTerminal: true,
67
- browser: ["Ubuntu", "Chrome", "125"],
68
- });
69
-
70
- sock.ev.on('connection.update', (update) => {
71
- const { connection, lastDisconnect } = update;
72
- if (connection === 'close') {
73
- const shouldReconnect = (lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut;
74
- console.log('Connection closed. Reconnecting:', shouldReconnect);
75
- if (shouldReconnect) connectToWhatsApp();
76
- } else if (connection === 'open') {
77
- console.log('✅ Successfully connected to WhatsApp!');
78
- }
79
- });
80
-
81
- sock.ev.on('messages.upsert', async ({ messages }) => {
82
- const m = messages[0];
83
- if (!m.message || m.key.fromMe) return;
84
-
85
- // Auto-reply example
86
- if (m.message.conversation === 'ping') {
87
- await sock.sendMessage(m.key.remoteJid, { text: 'pong!' });
88
- }
89
- });
90
-
91
- // Save credentials when updated (debounced by default in this library)
92
- sock.ev.on('creds.update', saveCreds);
146
+ const sock = makeWASocket({
147
+ logger,
148
+ auth: state
149
+ })
150
+
151
+ const store = makeInMemoryStore({
152
+ logger,
153
+ socket: sock
154
+ })
155
+
156
+ store.bind(sock.ev)
157
+
158
+ sock.ev.on('creds.update', saveCreds)
159
+
160
+ sock.ev.on('connection.update', (update) => {
161
+ const { connection, lastDisconnect } = update
162
+ if (connection === 'connecting' && !sock.authState.creds.registered) {
163
+ await delay(1500)
164
+ const code = await sock.requestPairingCode(myPhoneNumber)
165
+ console.log('🔗 Pairing code', ':', code)
166
+ }
167
+ else if (connection === 'close') {
168
+ const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
169
+ console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
170
+ if (shouldReconnect) {
171
+ connectToWhatsApp()
172
+ }
173
+ }
174
+ else if (connection === 'open') {
175
+ console.log('✅ Successfully connected to WhatsApp')
176
+ }
177
+ })
178
+
179
+ sock.ev.on('chats.upsert', () => {
180
+ console.log('✉️ Got chats', store.chats.all())
181
+ })
182
+
183
+ sock.ev.on('contacts.upsert', () => {
184
+ console.log('👥 Got contacts', Object.values(store.contacts))
185
+ })
186
+
187
+ // --- Read store from file
188
+ store.readFromFile(storePath)
189
+
190
+ // --- Save store every 3 minutes
191
+ setInterval(() => {
192
+ store.writeToFile(storePath)
193
+ }, 180000)
93
194
  }
94
195
 
95
- connectToWhatsApp();
196
+ connectToWhatsApp()
96
197
  ```
97
198
 
98
- ---
199
+ #### 🪪 WhatsApp IDs Explain
99
200
 
100
- ## 🔌 Connection & Configuration
201
+ `id` is the WhatsApp ID, called `jid` and `lid` too, of the person or group you're sending the message to.
202
+ - It must be in the format `[country code][phone number]@s.whatsapp.net`
203
+ - Example for people: `19999999999@s.whatsapp.net` and `12699999999@lid`.
204
+ - For groups, it must be in the format `123456789-123345@g.us`.
205
+ - For Meta AI, it's `11111111111@bot`.
206
+ - For broadcast lists, it's `[timestamp of creation]@broadcast`.
207
+ - For stories, the ID is `status@broadcast`.
101
208
 
102
- ### Connect via Pairing Code (No QR)
209
+ #### ✉️ Sending Messages
103
210
 
104
- If you're running the bot on a remote server without a terminal, you can pair using an 8-digit code instead of scanning a QR code.
211
+ > [!NOTE]
212
+ You can get the `jid` from `message.key.remoteJid` in the first example.
213
+
214
+ ##### 🔠 Text
105
215
 
106
216
  ```javascript
107
- const sock = makeWASocket({ printQRInTerminal: false });
217
+ sock.sendMessage(jid, {
218
+ text: '👋🏻 Hello'
219
+ }, {
220
+ quoted: message
221
+ })
222
+ ```
108
223
 
109
- if (!sock.authState.creds.registered) {
110
- const phoneNumber = '1234567890'; // Include country code, no symbols
111
- const pairingCode = await sock.requestPairingCode(phoneNumber);
112
- console.log('🔑 Your Pairing Code:', pairingCode);
113
- }
224
+ ##### 🔔 Mention
225
+
226
+ ```javascript
227
+ // --- Regular mention
228
+ sock.sendMessage(jid, {
229
+ text: '👋🏻 Hello @628123456789',
230
+ mentions: ['628123456789@s.whatsapp.net']
231
+ }, {
232
+ quoted: message
233
+ })
234
+
235
+ // --- Mention all
236
+ sock.sendMessage(jid, {
237
+ text: '👋🏻 Hello @all',
238
+ mentionAll: true
239
+ }, {
240
+ quoted: message
241
+ })
114
242
  ```
115
243
 
116
- ---
244
+ ##### 😁 Reaction
245
+
246
+ ```javascript
247
+ sock.sendMessage(jid, {
248
+ react: {
249
+ key: message.key,
250
+ text: '✨'
251
+ }
252
+ }, {
253
+ quoted: message
254
+ })
255
+ ```
256
+
257
+ ##### 📌 Pin Message
258
+
259
+ ```javascript
260
+ sock.sendMessage(jid, {
261
+ pin: message.key,
262
+ time: 86400, // --- Set the value in seconds: 86400 (1d), 604800 (7d), or 2592000 (30d)
263
+ type: 1 // --- Or 0 to remove
264
+ }, {
265
+ quoted: message
266
+ })
267
+ ```
117
268
 
118
- ## 💾 Handling Hundreds of Sessions (SQLite)
269
+ ##### 👤 Contact
119
270
 
120
- Jika target Anda adalah merender **Ratusan Bot secara bersamaan** dalam 1 Node.js Process, **file JSON biasa sangat tidak dianjurkan** karena rentan lock-file race condition dan limitasi sinkronisasi disk I/O, yang memicu masalah `Connection Closed` atau `DisconnectReason.loggedOut` tiba-tiba karena Socket API kehabisan waktu memanggil Event Emitter.
271
+ ```javascript
272
+ const vcard = 'BEGIN:VCARD\n'
273
+ + 'VERSION:3.0\n'
274
+ + 'FN:Lia Wynn\n'
275
+ + 'ORG:Waiters;\n'
276
+ + 'TEL;type=CELL;type=VOICE;waid=628123456789:+62 8123 4567 89\n'
277
+ + 'END:VCARD'
278
+
279
+ sock.sendMessage(jid, {
280
+ contacts: {
281
+ displayName: 'Lia',
282
+ contacts: [
283
+ { vcard }
284
+ ]
285
+ }
286
+ }, {
287
+ quoted: message
288
+ })
289
+ ```
121
290
 
122
- Gunakan **SQLite** untuk auth *Multi-Session* dengan tiga aturan vital:
291
+ ##### 📍 Location
123
292
 
124
- ### 1. Gunakan Mode SQLite `WAL`
125
- SQLite biasanya mengunci database saat sedang diproses (*Database is locked*). Untuk mematikan lock tersebut, pastikan perintah ini selalu berjalan di koneksi pertama inisialisasi SQLite Anda:
126
- ```sql
127
- PRAGMA journal_mode=WAL;
128
- PRAGMA synchronous=NORMAL;
129
- PRAGMA cache_size=-64000;
293
+ ```javascript
294
+ sock.sendMessage(jid, {
295
+ location: {
296
+ degreesLatitude: 24.121231,
297
+ degreesLongitude: 55.1121221,
298
+ name: '👋🏻 I am here'
299
+ }
300
+ }, {
301
+ quoted: message
302
+ })
130
303
  ```
131
304
 
132
- ### 2. Hindari `Sync` Database Queries
133
- Menggunakan fungsi bawaan `better-sqlite3` dengan eksekusi *sync* (seperti `db.prepare(query).run()`) dapat mem-blok *event loop* Node.js untuk mengeksekusi *callback* dari lib WhatsApp, menyebabkan ping-pong timeout.
134
- Gunakan pendekatan koneksi SQLite *asynchronous* (`async/await`) atau *Worker Threads*.
305
+ ##### 📊 Poll
135
306
 
136
- ### 3. Gunakan `addTransactionCapability`
137
- Ratusan WhatsApp session menghasilkan jutaan Signal Keys selama pertukaran PreKey login. Menyimpan data satu-per-satu ke SQLite secara harfiah akan merusak login sinkronisasi Anda! Anda diwajibkan menggunakan pembungkus Native `addTransactionCapability` yang terdapat dalam library ini.
307
+ ```javascript
308
+ // --- Regular poll message
309
+ sock.sendMessage(jid, {
310
+ poll: {
311
+ name: '🔥 Voting time',
312
+ values: ['Yes', 'No'],
313
+ selectableCount: 1,
314
+ toAnnouncementGroup: false
315
+ }
316
+ }, {
317
+ quoted: message
318
+ })
319
+
320
+ // --- Quiz (only for newsletter)
321
+ sock.sendMessage('1211111111111@newsletter', {
322
+ poll: {
323
+ name: '🔥 Quiz',
324
+ values: ['Yes', 'No'],
325
+ correctAnswer: 'Yes',
326
+ pollType: 1
327
+ }
328
+ }, {
329
+ quoted: message
330
+ })
331
+
332
+ // --- Poll result
333
+ sock.sendMessage(jid, {
334
+ pollResult: {
335
+ name: '📝 Poll Result',
336
+ votes: [{
337
+ name: 'Nice',
338
+ voteCount: 10
339
+ }, {
340
+ name: 'Nah',
341
+ voteCount: 2
342
+ }],
343
+ pollType: 0 // Or 1 for quiz
344
+ }
345
+ }, {
346
+ quoted: message
347
+ })
348
+
349
+ // --- Poll update
350
+ sock.sendMessage(jid, {
351
+ pollUpdate: {
352
+ metadata: {},
353
+ key: message.key,
354
+ vote: {
355
+ enclv: /* <Buffer> */,
356
+ encPayload: /* <Buffer> */
357
+ }
358
+ }
359
+ }, {
360
+ quoted: message
361
+ })
362
+ ```
363
+
364
+ ##### 🎞️ Status Mention
138
365
 
139
- **Contoh Template Asinkron Auth Bot SQLite:**
140
366
  ```javascript
141
- const { addTransactionCapability, initAuthCreds } = require('violetics');
367
+ sock.sendMessage([jidA, jidB, jidC], {
368
+ text: 'Hello! 👋🏻'
369
+ })
370
+ ```
142
371
 
143
- // Membungkus Database Custom Anda ke Session Bot
144
- function makeSqliteAuthState(dbConnection, sessionId) {
145
- const state = {
146
- get: async (type, ids) => {
147
- // TODO: Ambil row dari tabel session secara `async`
148
- // return dict { [id]: data }
149
- },
150
- set: async (data) => {
151
- // TODO: Insert/Update row ke tabel SQLite secara `async`
152
- }
153
- };
372
+ #### 📁 Sending Media Messages
154
373
 
155
- // WAJIB: Membungkus transaksi Anda agar dieksekusi dalam bentuk 'Batch'
156
- // Setiap transaksi Signal WhatsApp akan disimpan 100 sekaligus tanpa spam query DB
157
- const keys = addTransactionCapability(state, console, {
158
- maxCommitRetries: 10,
159
- delayBetweenTriesMs: 3000
160
- });
374
+ > [!NOTE]
375
+ For media messages, you can pass a `Buffer` directly, or an object with either `{ stream: Readable }` or `{ url: string }` (local file path or HTTP/HTTPS URL).
161
376
 
162
- return {
163
- state: {
164
- creds: /* creds dari database dbConnection */,
165
- keys
166
- },
167
- saveCreds: () => {
168
- // Simpan perubahan kredensial
169
- // Sebaiknya Anda buat fungsi "Debounce" disini selama 2 detik
170
- // agar tidak menyebabkan CPU Spike saat Login Pertama Kali
171
- }
172
- }
173
- }
377
+ ##### 🖼️ Image
378
+
379
+ ```javascript
380
+ sock.sendMessage(jid, {
381
+ image: {
382
+ url: './path/to/image.jpg'
383
+ },
384
+ caption: '🔥 Superb'
385
+ }, {
386
+ quoted: message
387
+ })
174
388
  ```
175
389
 
176
- ---
390
+ ##### 🎥 Video
177
391
 
178
- ## 📥 Core Features
392
+ ```javascript
393
+ sock.sendMessage(jid, {
394
+ video: {
395
+ url: './path/to/video.mp4'
396
+ },
397
+ gifPlayback: false, // --- Set true if you want to send video as GIF
398
+ ptv: false, // --- Set true if you want to send video as PTV
399
+ caption: '🔥 Superb'
400
+ }, {
401
+ quoted: message
402
+ })
403
+ ```
179
404
 
180
- <details>
181
- <summary><b>📤 Sending Messages</b></summary>
182
- <br>
405
+ ##### 📃 Sticker
183
406
 
184
407
  ```javascript
185
- // 1. Text message
186
- await sock.sendMessage(jid, { text: 'Hello World!' });
408
+ sock.sendMessage(jid, {
409
+ sticker: {
410
+ url: './path/to/sticker.webp'
411
+ }
412
+ }, {
413
+ quoted: message
414
+ })
415
+ ```
187
416
 
188
- // 2. Mention users
189
- await sock.sendMessage(jid, {
190
- text: 'Hello @12345678901!',
191
- mentions: ['12345678901@s.whatsapp.net']
192
- });
417
+ ##### 💽 Audio
418
+
419
+ ```javascript
420
+ sock.sendMessage(jid, {
421
+ audio: {
422
+ url: './path/to/audio.mp3'
423
+ },
424
+ ptt: false, // --- Set true if you want to send audio as Voice Note
425
+ }, {
426
+ quoted: message
427
+ })
428
+ ```
193
429
 
194
- // 3. Send Media (Image)
195
- await sock.sendMessage(jid, {
196
- image: { url: './path/to/image.jpg' },
197
- caption: 'Check out this image!'
198
- });
430
+ ##### 🖼️ Album (Image & Video)
199
431
 
200
- // 4. Send Poll
201
- await sock.sendMessage(jid, {
202
- poll: {
203
- name: 'Favorite Language?',
204
- values: ['TypeScript', 'Python', 'Go'],
205
- selectableCount: 1
206
- }
207
- });
432
+ ```javascript
433
+ sock.sendMessage(jid, {
434
+ album: [{
435
+ image: {
436
+ url: './path/to/image.jpg'
437
+ },
438
+ caption: '1st image'
439
+ }, {
440
+ video: {
441
+ url: './path/to/video.mp4'
442
+ },
443
+ caption: '1st video'
444
+ }, {
445
+ image: {
446
+ url: './path/to/image.jpg'
447
+ },
448
+ caption: '2nd image'
449
+ }, {
450
+ video: {
451
+ url: './path/to/video.mp4'
452
+ },
453
+ caption: '2nd video'
454
+ }]
455
+ }, {
456
+ quoted: message
457
+ })
208
458
  ```
209
- </details>
210
459
 
211
- <details>
212
- <summary><b>👥 Group Management</b></summary>
213
- <br>
460
+ ##### 📦 Sticker Pack
461
+
462
+ > [!IMPORTANT]
463
+ If `sharp` or `@napi-rs/image` is not installed, the `cover` and `stickers` must already be in WebP format.
214
464
 
215
465
  ```javascript
216
- // 1. Create a group
217
- const group = await sock.groupCreate('My Developer Group', ['123...@s.whatsapp.net']);
466
+ sock.sendMessage(jid, {
467
+ cover: {
468
+ url: './path/to/image.webp'
469
+ },
470
+ stickers: [{
471
+ data: {
472
+ url: './path/to/image.webp'
473
+ }
474
+ }, {
475
+ data: {
476
+ url: './path/to/image.webp'
477
+ }
478
+ }, {
479
+ data: {
480
+ url: './path/to/image.webp'
481
+ }
482
+ }],
483
+ name: '📦 My Sticker Pack',
484
+ publisher: '🌟 Lia Wynn',
485
+ description: 'violetics'
486
+ }, {
487
+ quoted: message
488
+ })
489
+ ```
218
490
 
219
- // 2. Modify participants (Add, Remove, Promote)
220
- await sock.groupParticipantsUpdate(groupJid, ['123...@s.whatsapp.net'], 'add');
491
+ #### 👉🏻 Sending Interactive Messages
221
492
 
222
- // 3. Update Group Info
223
- await sock.groupUpdateSubject(groupJid, 'New Amazing Name');
224
- await sock.groupUpdateDescription(groupJid, 'New description for the group');
493
+ ##### 1️⃣ Buttons
494
+
495
+ ```javascript
496
+ // --- Regular buttons message
497
+ sock.sendMessage(jid, {
498
+ text: '👆🏻 Buttons!',
499
+ footer: 'violetics',
500
+ buttons: [{
501
+ text: '👋🏻 SignUp',
502
+ id: '#SignUp'
503
+ }]
504
+ }, {
505
+ quoted: message
506
+ })
507
+
508
+ // --- Buttons with Media & Native Flow
509
+ sock.sendMessage(jid, {
510
+ image: {
511
+ url: './path/to/image.jpg'
512
+ },
513
+ caption: '👆🏻 Buttons and Native Flow!',
514
+ footer: 'violetics',
515
+ buttons: [{
516
+ text: '👋🏻 Rating',
517
+ id: '#Rating'
518
+ }, {
519
+ text: '📋 Select',
520
+ sections: [{
521
+ title: '✨ Section 1',
522
+ rows: [{
523
+ header: '',
524
+ title: '💭 Secret Ingredient',
525
+ description: '',
526
+ id: '#SecretIngredient'
527
+ }]
528
+ }, {
529
+ title: '✨ Section 2',
530
+ highlight_label: '🔥 Popular',
531
+ rows: [{
532
+ header: '',
533
+ title: '🏷️ Coupon',
534
+ description: '',
535
+ id: '#CouponCode'
536
+ }]
537
+ }]
538
+ }]
539
+ }, {
540
+ quoted: message
541
+ })
225
542
  ```
226
- </details>
227
543
 
228
- <details>
229
- <summary><b>📢 Newsletter (Channels) API</b></summary>
230
- <br>
544
+ ##### 2️⃣ List
231
545
 
232
- Full support for WhatsApp Newsletters (Channels). Manage, fetch, and react to channel updates!
546
+ > [!NOTE]
547
+ It only works in private chat (`@s.whatsapp.net`).
233
548
 
234
549
  ```javascript
235
- // 1. Fetch Newsletter by Invitelink/URL
236
- const channelData = await sock.newsletterFromUrl('https://whatsapp.com/channel/0029...');
550
+ sock.sendMessage(jid, {
551
+ text: '📋 List!',
552
+ footer: 'violetics',
553
+ buttonText: '📋 Select',
554
+ title: '👋🏻 Hello',
555
+ sections: [{
556
+ title: '🚀 Menu 1',
557
+ rows: [{
558
+ title: '✨ AI',
559
+ description: '',
560
+ rowId: '#AI'
561
+ }]
562
+ }, {
563
+ title: '🌱 Menu 2',
564
+ rows: [{
565
+ title: '🔍 Search',
566
+ description: '',
567
+ rowId: '#Search'
568
+ }]
569
+ }]
570
+ }, {
571
+ quoted: message
572
+ })
573
+ ```
574
+
575
+ ##### 3️⃣ Interactive
237
576
 
238
- // 2. Follow / Unfollow a Channel
239
- await sock.newsletterFollow(channelJid);
240
- await sock.newsletterUnfollow(channelJid);
577
+ ```javascript
578
+ // --- Native Flow
579
+ sock.sendMessage(jid, {
580
+ image: {
581
+ url: './path/to/image.jpg'
582
+ },
583
+ caption: '🗄️ Interactive!',
584
+ footer: 'violetics',
585
+ optionText: '👉🏻 Select Options', // --- Optional, wrap all native flow into a single list
586
+ optionTitle: '📄 Select Options', // --- Optional
587
+ couponText: '🏷️ Newest Coupon!', // --- Optional, add coupon into message
588
+ couponCode: 'violetics', // --- Optional
589
+ nativeFlow: [{
590
+ text: '👋🏻 Greeting',
591
+ id: '#Greeting'
592
+ }, {
593
+ text: '📞 Call',
594
+ call: '628123456789'
595
+ }, {
596
+ text: '📋 Copy',
597
+ copy: 'violetics'
598
+ }, {
599
+ text: '🌐 Source',
600
+ url: 'https://www.npmjs.com/package/baileys'
601
+ }, {
602
+ text: '📋 Select',
603
+ sections: [{
604
+ title: '✨ Section 1',
605
+ rows: [{
606
+ header: '',
607
+ title: '🏷️ Coupon',
608
+ description: '',
609
+ id: '#CouponCode'
610
+ }]
611
+ }, {
612
+ title: '✨ Section 2',
613
+ highlight_label: '🔥 Popular',
614
+ rows: [{
615
+ header: '',
616
+ title: '💭 Secret Ingredient',
617
+ description: '',
618
+ id: '#SecretIngredient'
619
+ }]
620
+ }]
621
+ }],
622
+ interactiveAsTemplate: false, // --- Optional, wrap the interactive message into a template
623
+ }, {
624
+ quoted: message
625
+ })
626
+
627
+ // --- Carousel & Native Flow
628
+ sock.sendMessage(jid, {
629
+ text: '🗂️ Interactive with Carousel!',
630
+ footer: 'violetics',
631
+ cards: [{
632
+ image: {
633
+ url: './path/to/image.jpg'
634
+ },
635
+ caption: '🖼️ Image 1',
636
+ footer: '🏷️️ Pinterest',
637
+ nativeFlow: [{
638
+ text: '🌐 Source',
639
+ url: 'https://www.npmjs.com/package/baileys'
640
+ }]
641
+ }, {
642
+ image: {
643
+ url: './path/to/image.jpg'
644
+ },
645
+ caption: '🖼️ Image 2',
646
+ footer: '🏷️ Pinterest',
647
+ couponText: '🏷️ New Coupon!',
648
+ couponCode: 'violetics',
649
+ nativeFlow: [{
650
+ text: '🌐 Source',
651
+ url: 'https://www.npmjs.com/package/baileys'
652
+ }]
653
+ }, {
654
+ image: {
655
+ url: './path/to/image.jpg'
656
+ },
657
+ caption: '🖼️ Image 3',
658
+ footer: '🏷️ Pinterest',
659
+ optionText: '👉🏻 Select Options',
660
+ optionTitle: '📄 Select Options',
661
+ couponText: '🏷️ New Coupon!',
662
+ couponCode: 'violetics',
663
+ nativeFlow: [{
664
+ text: '🛒 Product',
665
+ id: '#Product'
666
+ }, {
667
+ text: '🌐 Source',
668
+ url: 'https://www.npmjs.com/package/baileys'
669
+ }]
670
+ }]
671
+ }, {
672
+ quoted: message
673
+ })
674
+ ```
241
675
 
242
- // 3. Mute / Unmute
243
- await sock.newsletterMute(channelJid);
244
- await sock.newsletterUnmute(channelJid);
676
+ ##### 4️⃣ Hydrated Template
245
677
 
246
- // 4. Create a new Channel
247
- const newChannel = await sock.newsletterCreate('My Channel', 'Description here', 'ALL');
678
+ ```javascript
679
+ sock.sendMessage(jid, {
680
+ title: '👋🏻 Hello',
681
+ image: {
682
+ url: './path/to/image.jpg'
683
+ },
684
+ caption: '🫙 Template!',
685
+ footer: 'violetics',
686
+ templateButtons: [{
687
+ text: '👉🏻 Tap Here',
688
+ id: '#Order'
689
+ }, {
690
+ text: '🌐 Source',
691
+ url: 'https://www.npmjs.com/package/baileys'
692
+ }, {
693
+ text: '📞 Call',
694
+ call: '628123456789'
695
+ }]
696
+ }, {
697
+ quoted: message
698
+ })
699
+ ```
248
700
 
249
- // 5. Fetch Subscribed Channels & Messages
250
- const mySubscriptions = await sock.newsletterFetchAllSubscribe();
251
- console.log(mySubscriptions); // List of your followed newsletters
701
+ #### 💳 Sending Payment Messages
252
702
 
253
- const messages = await sock.newsletterFetchMessages('get', channelJid, 50);
703
+ ##### 1️⃣ Invite Payment
254
704
 
255
- // 6. Update Channel Info
256
- await sock.newsletterUpdateName(channelJid, 'New Name');
257
- await sock.newsletterUpdateDescription(channelJid, 'New Description');
258
- await sock.newsletterUpdatePicture(channelJid, buffer);
705
+ ```javascript
706
+ sock.sendMessage(jid, {
707
+ paymentInviteServiceType: 3 // 1, 2, or 3
708
+ })
259
709
  ```
260
- </details>
261
710
 
262
- <details>
263
- <summary><b>✨ Advanced Messages (Violetics)</b></summary>
264
- <br>
711
+ ##### 2️⃣ Invoice
265
712
 
266
- Violetics implements advanced parsing and sending for native flow menus, albums, events, and unique status interactions directly through the `sock` instance!
713
+ > [!NOTE]
714
+ Invoice message are not supported yet.
267
715
 
268
716
  ```javascript
269
- // 1. Send Interactive Message (Buttons & Media)
270
- const interactive = await sock.handleInteractive(jid, {
271
- interactiveMessage: {
272
- title: "Main Menu",
273
- footer: "Powered by Violetics",
274
- header: "Select an option",
275
- buttons: [
276
- { name: 'quick_reply', buttonParamsJson: '{"display_text":"Option 1","id":"opt1"}' },
277
- { name: 'cta_url', buttonParamsJson: '{"display_text":"Visit Site","url":"https://example.com"}' }
278
- ]
279
- }
280
- }, { quoted: messageObject }); // Pass quoting using the `options` object
717
+ sock.sendMessage(jid, {
718
+ image: {
719
+ url: './path/to/image.jpg'
720
+ },
721
+ invoiceNote: '🏷️ Invoice'
722
+ })
723
+ ```
281
724
 
282
- await sock.relayMessage(jid, interactive.interactiveMessage, {});
725
+ ##### 3️⃣ Order
283
726
 
284
- // 2. Send Album (Multiple Media)
285
- await sock.handleAlbum(jid, [
286
- { image: { url: './image1.jpg' } },
287
- { video: { url: './video1.mp4' } }
288
- ]);
727
+ ```javascript
728
+ sock.sendMessage(chat, {
729
+ orderText: '🛍️ Order',
730
+ thumbnail: fs.readFileSync('./path/to/image.jpg') // --- Must in buffer format
731
+ }, {
732
+ quoted: message
733
+ })
734
+ ```
289
735
 
290
- // 3. Send Group / Private WhatsApp Status with Mentions
291
- await sock.sendStatusWhatsApp(['12345678901@s.whatsapp.net', '12345678902-1234@g.us'], {
292
- text: "Check out this status!",
293
- backgroundColor: "#ff0000",
294
- font: 1
295
- });
736
+ ##### 4️⃣ Product
296
737
 
297
- // 4. Handle External Ad Replies, Payments, and Events natively!
298
- await sock.handleEvent(jid, {
299
- eventMessage: {
300
- name: "Developer Meetup",
301
- description: "Join us for coding!",
302
- joinLink: "https://zoom.us/...",
303
- startTime: Date.now(),
304
- endTime: Date.now() + 3600000
305
- }
306
- });
738
+ ```javascript
739
+ sock.sendMessage(jid, {
740
+ image: {
741
+ url: './path/to/image.jpg'
742
+ },
743
+ product: {
744
+ title: '🛒 My Product'
745
+ },
746
+ businessOwnerJid: '0@s.whatsapp.net' // --- Must included
747
+ }, {
748
+ quoted: message
749
+ })
307
750
  ```
308
- </details>
309
751
 
310
- ---
752
+ ##### 5️⃣ Request Payment
753
+
754
+ ```javascript
755
+ sock.sendMessage(jid, {
756
+ text: '💳 Request Payment',
757
+ requestPaymentFrom: '0@s.whatsapp.net'
758
+ })
759
+ ```
760
+
761
+ #### 👁️ Other Message Options
762
+
763
+ ##### 1️⃣ AI Label
764
+
765
+ > [!NOTE]
766
+ It only works in private chat (`@s.whatsapp.net`).
767
+
768
+ ```javascript
769
+ sock.sendMessage(jid, {
770
+ image: {
771
+ url: './path/to/image.jpg'
772
+ },
773
+ caption: '🤖 AI Labeled!',
774
+ ai: true
775
+ }, {
776
+ quoted: message
777
+ })
778
+ ```
779
+
780
+ ##### 2️⃣ Ephemeral
781
+
782
+ > [!NOTE]
783
+ Wrap message into `ephemeralMessage`
784
+
785
+ ```javascript
786
+ sock.sendMessage(jid, {
787
+ image: {
788
+ url: './path/to/image.jpg'
789
+ },
790
+ caption: '👁️ Ephemeral',
791
+ ephemeral: true
792
+ })
793
+ ```
794
+
795
+ ##### 3️⃣ External Ad Reply
796
+
797
+ > [!NOTE]
798
+ Add an ad thumbnail to messages (may not be displayed on some WhatsApp versions).
799
+
800
+ ```javascript
801
+ sock.sendMessage(jid, {
802
+ text: '📰 External Ad Reply',
803
+ externalAdReply: {
804
+ title: '📝 Did you know?',
805
+ body: '❓ I dont know',
806
+ thumbnail: fs.readFileSync('./path/to/image.jpg'), // --- Must in buffer format
807
+ largeThumbnail: false, // --- Or true for bigger thumbnail
808
+ url: 'https://www.npmjs.com/package/baileys' // --- Optional, used for WhatsApp internal thumbnail caching and direct URL
809
+ }
810
+ }, {
811
+ quoted: message
812
+ })
813
+ ```
814
+
815
+ ##### 4️⃣ Group Status
816
+
817
+ > [!NOTE]
818
+ It only works in group chat (`@g.us`)
311
819
 
312
- ## ⚖️ Legal Notice
820
+ ```javascript
821
+ sock.sendMessage(jid, {
822
+ image: {
823
+ url: './path/to/image.jpg'
824
+ },
825
+ caption: '👥 Group Status!',
826
+ groupStatus: true
827
+ })
828
+ ```
829
+
830
+ ##### 5️⃣ Raw
831
+
832
+ ```javascript
833
+ sock.sendMessage(jid, {
834
+ extendedTextMessage: {
835
+ text: '📃 Built manually from scratch using the raw WhatsApp proto structure',
836
+ contextInfo: {
837
+ externalAdReply: {
838
+ title: 'violetics',
839
+ thumbnail: fs.readFileSync('./path/to/image.jpg'),
840
+ sourceApp: 'whatsapp',
841
+ showAdAttribution: true,
842
+ mediaType: 1
843
+ }
844
+ }
845
+ },
846
+ raw: true
847
+ }, {
848
+ quoted: message
849
+ })
850
+ ```
851
+
852
+ ##### 6️⃣ View Once
853
+
854
+ > [!NOTE]
855
+ Wrap message into `viewOnceMessage`
856
+
857
+ ```javascript
858
+ sock.sendMessage(jid, {
859
+ image: {
860
+ url: './path/to/image.jpg'
861
+ },
862
+ caption: '👁️ View Once',
863
+ viewOnce: true
864
+ })
865
+ ```
866
+
867
+ ##### 7️⃣ View Once V2
868
+
869
+ > [!NOTE]
870
+ Wrap message into `viewOnceMessageV2`
871
+
872
+ ```javascript
873
+ sock.sendMessage(jid, {
874
+ image: {
875
+ url: './path/to/image.jpg'
876
+ },
877
+ caption: '👁️ View Once V2',
878
+ viewOnceV2: true
879
+ })
880
+ ```
881
+
882
+ ##### 8️⃣ View Once V2 Extension
883
+
884
+ > [!NOTE]
885
+ Wrap message into `viewOnceMessageV2Extension`
886
+
887
+ ```javascript
888
+ sock.sendMessage(jid, {
889
+ image: {
890
+ url: './path/to/image.jpg'
891
+ },
892
+ caption: '👁️ View Once V2 Extension',
893
+ viewOnceV2Extension: true
894
+ })
895
+ ```
896
+
897
+ #### 🧰 Additional Contents
898
+
899
+ ##### 🏷️ Find User ID (JID|PN/LID)
900
+
901
+ > [!NOTE]
902
+ The ID must contain numbers only (no +, (), or -) and must include the country code with WhatsApp ID format.
903
+
904
+ ```javascript
905
+ // --- PN (Phone Number)
906
+ const phoneNumber = '6281111111111@s.whatsapp.net'
907
+
908
+ const ids = await sock.findUserId(phoneNumber)
909
+
910
+ console.log('🏷️ Got user ID', ':', ids)
911
+
912
+ // --- LID (Local Identifier)
913
+ const lid = '43411111111111@lid'
914
+
915
+ const ids = await sock.findUserId(lid)
916
+
917
+ console.log('🏷️ Got user ID', ':', ids)
918
+
919
+ // --- Output
920
+ // {
921
+ // phoneNumber: '6281111111111@s.whatsapp.net',
922
+ // lid: '43411111111111@lid'
923
+ // }
924
+ // --- Output when failed
925
+ // {
926
+ // phoneNumber: '6281111111111@s.whatsapp.net',
927
+ // lid: 'id-not-found'
928
+ // }
929
+ // --- Same output shape regardless of input type
930
+ ```
931
+
932
+ ##### 🔑 Request Custom Pairing Code
933
+
934
+ > [!NOTE]
935
+ The phone number must contain numbers only (no +, (), or -) and must include the country code.
936
+
937
+ ```javascript
938
+ const phoneNumber = '6281111111111'
939
+ const customPairingCode = 'STARFALL'
940
+
941
+ await sock.requestPairingCode(phoneNumber, customPairingCode)
942
+
943
+ console.log('🔗 Pairing code', ':', customPairingCode)
944
+ ```
945
+
946
+ ##### 📣 Newsletter Management
947
+
948
+ ```javascript
949
+ // --- Create a new one
950
+ sock.newsletterCreate('violetics')
951
+
952
+ // --- Get info
953
+ sock.newsletterMetadata('1231111111111@newsletter')
954
+
955
+ // --- Demote admin
956
+ sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
957
+
958
+ // --- Change owner
959
+ sock.newsletterChangeOwner('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
960
+
961
+ // --- Change name
962
+ sock.newsletterUpdateName('1231111111111@newsletter', '📦 violetics')
963
+
964
+ // --- Change description
965
+ sock.newsletterUpdateDescription('1231111111111@newsletter', '📣 Fresh updates weekly')
966
+
967
+ // --- Change photo
968
+ sock.newsletterUpdatePicture('1231111111111@newsletter', {
969
+ url: 'path/to/image.jpg'
970
+ })
971
+
972
+ // --- Remove photo
973
+ sock.newsletterRemovePicture('1231111111111@newsletter')
974
+
975
+ // --- React to a message
976
+ sock.newsletterReactMessage('1231111111111@newsletter', '100', '💛')
977
+
978
+ // --- Get all subscribed newsletters
979
+ const newsletters = await sock.newsletterSubscribed()
980
+
981
+ console.dir(newsletters, { depth: null })
982
+ ```
983
+
984
+ ##### 👥 Group Management
985
+
986
+ ```javascript
987
+ // --- Create a new one and add participants using their JIDs
988
+ sock.groupCreate('violetics', ['628123456789@s.whatsapp.net'])
989
+
990
+ // --- Get info
991
+ sock.groupMetadata(jid)
992
+
993
+ // --- Get invite code
994
+ sock.groupInviteCode(jid)
995
+
996
+ // --- Revoke invite link
997
+ sock.groupRevokeInvite(jid)
998
+
999
+ // --- Leave group
1000
+ sock.groupLeave(jid)
1001
+
1002
+ // --- Add participants
1003
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'add')
1004
+
1005
+ // --- Remove participants
1006
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'remove')
1007
+
1008
+ // --- Promote to admin
1009
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'promote')
1010
+
1011
+ // --- Demote from admin
1012
+ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'demote')
1013
+
1014
+ // --- Change name
1015
+ sock.groupUpdateSubject(jid, '📦 violetics')
1016
+
1017
+ // --- Change description
1018
+ sock.groupUpdateDescription(jid, 'Updated description')
1019
+
1020
+ // --- Change photo
1021
+ sock.updateProfilePicture(jid, {
1022
+ url: 'path/to/image.jpg'
1023
+ })
1024
+
1025
+ // --- Remove photo
1026
+ sock.removeProfilePicture(jid)
1027
+
1028
+ // --- Set group as admin only for chatting
1029
+ sock.groupSettingUpdate(jid, 'announcement')
1030
+
1031
+ // --- Set group as open to all for chatting
1032
+ sock.groupSettingUpdate(jid, 'not_announcement')
1033
+
1034
+ // --- Set admin only can edit group info
1035
+ sock.groupSettingUpdate(jid, 'locked')
1036
+
1037
+ // --- Set all participants can edit group info
1038
+ sock.groupSettingUpdate(jid, 'unlocked')
1039
+
1040
+ // --- Set admin only can add participants
1041
+ sock.groupMemberAddMode(jid, 'admin_add')
1042
+
1043
+ // --- Set all participants can add participants
1044
+ sock.groupMemberAddMode(jid, 'all_member_add')
1045
+
1046
+ // --- Enable or disable temporary messages with seconds format
1047
+ sock.groupToggleEphemeral(jid, 86400)
1048
+
1049
+ // --- Disable temporary messages
1050
+ sock.groupToggleEphemeral(jid, 0)
1051
+
1052
+ // --- Enable or disable membership approval mode
1053
+ sock.groupJoinApprovalMode(jid, 'on')
1054
+ sock.groupJoinApprovalMode(jid, 'off')
1055
+
1056
+ // --- Get all groups metadata
1057
+ const groups = await sock.groupFetchAllParticipating()
1058
+
1059
+ console.dir(groups, { depth: null })
1060
+
1061
+ // --- Get pending invites
1062
+ const invites = await sock.groupGetInviteInfo(code)
1063
+
1064
+ console.dir(invites, { depth: null })
1065
+
1066
+ // --- Accept group invite
1067
+ sock.groupAcceptInvite(code)
1068
+
1069
+ // --- Get group info from link
1070
+ const group = await sock.groupGetInviteInfo('https://chat.whatsapp.com/ABC123')
1071
+
1072
+ console.log('👥 Got group info from link', ':', group)
1073
+ ```
313
1074
 
314
- **Disclaimer**: This project is **NOT** affiliated with, authorized, maintained, sponsored, or endorsed by WhatsApp LLC or any of its affiliates.
315
- - This library is intended for strictly legitimate automation purposes.
316
- - Do **NOT** use it for spamming, bulk reporting, or harassment.
317
- - Users are solely responsible for compliance with WhatsApp's Terms of Service.
318
- - The maintainers assume **NO** liability for any damages, legal actions, or account bans caused by the use of this software.
1075
+ ## 📦 Fork Base
1076
+ > [!NOTE]
1077
+ This fork is based on [Baileys (GitHub)](https://github.com/WhiskeySockets/Baileys)
1078
+
1079
+ ## 📣 Credits
1080
+ > [!IMPORTANT]
1081
+ This fork uses Protocol Buffer definitions maintained by [WPP Connect](https://github.com/wppconnect-team) via [`wa-proto`](https://github.com/wppconnect-team/wa-proto)
1082
+ >
1083
+ > All rights belong to the original Baileys maintainers and contributors:
1084
+ > - [WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)
1085
+ > - [purpshell](https://github.com/purpshell)
1086
+ > - [jlucaso1](https://github.com/jlucaso1)
1087
+ > - [adiwajshing](https://github.com/adiwajshing)