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.
- package/LICENSE +3 -2
- package/README.md +1001 -232
- package/WAProto/index.js +75379 -142631
- package/engine-requirements.js +11 -8
- package/lib/Defaults/index.js +132 -146
- package/lib/Signal/Group/ciphertext-message.js +2 -6
- package/lib/Signal/Group/group-session-builder.js +7 -42
- package/lib/Signal/Group/group_cipher.js +37 -52
- package/lib/Signal/Group/index.js +11 -57
- package/lib/Signal/Group/keyhelper.js +7 -45
- package/lib/Signal/Group/sender-chain-key.js +7 -16
- package/lib/Signal/Group/sender-key-distribution-message.js +8 -12
- package/lib/Signal/Group/sender-key-message.js +9 -13
- package/lib/Signal/Group/sender-key-name.js +2 -6
- package/lib/Signal/Group/sender-key-record.js +9 -22
- package/lib/Signal/Group/sender-key-state.js +27 -43
- package/lib/Signal/Group/sender-message-key.js +4 -8
- package/lib/Signal/libsignal.js +319 -94
- package/lib/Signal/lid-mapping.js +224 -139
- package/lib/Socket/Client/index.js +2 -19
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.js +162 -44
- package/lib/Socket/chats.js +477 -418
- package/lib/Socket/communities.js +430 -0
- package/lib/Socket/groups.js +110 -99
- package/lib/Socket/index.js +10 -10
- package/lib/Socket/messages-recv.js +884 -561
- package/lib/Socket/messages-send.js +859 -428
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.js +195 -390
- package/lib/Socket/socket.js +465 -315
- package/lib/Store/index.js +3 -10
- package/lib/Store/make-in-memory-store.js +73 -79
- package/lib/Store/make-ordered-dictionary.js +4 -7
- package/lib/Store/object-repository.js +2 -6
- package/lib/Types/Auth.js +1 -2
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.js +1 -2
- package/lib/Types/Chat.js +7 -4
- package/lib/Types/Contact.js +1 -2
- package/lib/Types/Events.js +1 -2
- package/lib/Types/GroupMetadata.js +1 -2
- package/lib/Types/Label.js +2 -5
- package/lib/Types/LabelAssociation.js +2 -5
- package/lib/Types/Message.js +17 -9
- package/lib/Types/Newsletter.js +33 -38
- package/lib/Types/Product.js +1 -2
- package/lib/Types/Signal.js +1 -2
- package/lib/Types/Socket.js +2 -2
- package/lib/Types/State.js +12 -2
- package/lib/Types/USync.js +1 -2
- package/lib/Types/index.js +14 -31
- package/lib/Utils/auth-utils.js +228 -152
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/business.js +66 -70
- package/lib/Utils/chat-utils.js +331 -249
- package/lib/Utils/crypto.js +57 -91
- package/lib/Utils/decode-wa-message.js +168 -84
- package/lib/Utils/event-buffer.js +138 -80
- package/lib/Utils/generics.js +180 -297
- package/lib/Utils/history.js +83 -49
- package/lib/Utils/identity-change-handler.js +48 -0
- package/lib/Utils/index.js +19 -33
- package/lib/Utils/link-preview.js +14 -23
- package/lib/Utils/logger.js +2 -7
- package/lib/Utils/lt-hash.js +2 -46
- package/lib/Utils/make-mutex.js +24 -47
- package/lib/Utils/message-retry-manager.js +224 -0
- package/lib/Utils/messages-media.js +501 -496
- package/lib/Utils/messages.js +1428 -362
- package/lib/Utils/noise-handler.js +145 -100
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.js +356 -150
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/signal.js +78 -73
- package/lib/Utils/sync-action-utils.js +47 -0
- package/lib/Utils/tc-token-utils.js +17 -0
- package/lib/Utils/use-multi-file-auth-state.js +35 -45
- package/lib/Utils/validate-connection.js +91 -107
- package/lib/WABinary/constants.js +1300 -1304
- package/lib/WABinary/decode.js +26 -48
- package/lib/WABinary/encode.js +109 -155
- package/lib/WABinary/generic-utils.js +161 -149
- package/lib/WABinary/index.js +5 -21
- package/lib/WABinary/jid-utils.js +73 -40
- package/lib/WABinary/types.js +1 -2
- package/lib/WAM/BinaryInfo.js +2 -6
- package/lib/WAM/constants.js +19070 -11568
- package/lib/WAM/encode.js +17 -23
- package/lib/WAM/index.js +3 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +8 -12
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -15
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -13
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -14
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -23
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +13 -9
- package/lib/WAUSync/Protocols/index.js +4 -20
- package/lib/WAUSync/USyncQuery.js +40 -36
- package/lib/WAUSync/USyncUser.js +2 -6
- package/lib/WAUSync/index.js +3 -19
- package/lib/index.js +11 -44
- package/package.json +74 -107
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.js +0 -118
- package/lib/Socket/groupStatus.js +0 -637
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Utils/baileys-event-stream.js +0 -63
package/README.md
CHANGED
|
@@ -1,318 +1,1087 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
6
|
-
[](LICENSE)
|
|
7
|
-
</div>
|
|
3
|
+

|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
A lightweight fork of Baileys with a few fixes and a small adjustment.
|
|
10
6
|
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
18
|
-
-
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
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
|
-
|
|
32
|
+
### 📥 Installation
|
|
28
33
|
|
|
29
|
-
-
|
|
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
|
-
|
|
48
|
+
- ⌨️ Via terminal
|
|
40
49
|
|
|
41
|
-
### Via NPM
|
|
42
50
|
```bash
|
|
43
|
-
|
|
51
|
+
# NPM
|
|
52
|
+
npm i violetics@latest
|
|
53
|
+
|
|
54
|
+
# GitHub
|
|
55
|
+
npm i github:cv3inx/violetics
|
|
44
56
|
```
|
|
45
57
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
59
|
-
|
|
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
|
|
62
|
-
|
|
143
|
+
const connectToWhatsApp = async () => {
|
|
144
|
+
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
63
145
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
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
|
-
|
|
209
|
+
#### ✉️ Sending Messages
|
|
103
210
|
|
|
104
|
-
|
|
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
|
-
|
|
217
|
+
sock.sendMessage(jid, {
|
|
218
|
+
text: '👋🏻 Hello'
|
|
219
|
+
}, {
|
|
220
|
+
quoted: message
|
|
221
|
+
})
|
|
222
|
+
```
|
|
108
223
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
269
|
+
##### 👤 Contact
|
|
119
270
|
|
|
120
|
-
|
|
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
|
-
|
|
291
|
+
##### 📍 Location
|
|
123
292
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
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
|
-
|
|
137
|
-
|
|
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
|
-
|
|
367
|
+
sock.sendMessage([jidA, jidB, jidC], {
|
|
368
|
+
text: 'Hello! 👋🏻'
|
|
369
|
+
})
|
|
370
|
+
```
|
|
142
371
|
|
|
143
|
-
|
|
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
|
-
|
|
156
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
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
|
-
|
|
181
|
-
<summary><b>📤 Sending Messages</b></summary>
|
|
182
|
-
<br>
|
|
405
|
+
##### 📃 Sticker
|
|
183
406
|
|
|
184
407
|
```javascript
|
|
185
|
-
|
|
186
|
-
|
|
408
|
+
sock.sendMessage(jid, {
|
|
409
|
+
sticker: {
|
|
410
|
+
url: './path/to/sticker.webp'
|
|
411
|
+
}
|
|
412
|
+
}, {
|
|
413
|
+
quoted: message
|
|
414
|
+
})
|
|
415
|
+
```
|
|
187
416
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
217
|
-
|
|
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
|
-
|
|
220
|
-
await sock.groupParticipantsUpdate(groupJid, ['123...@s.whatsapp.net'], 'add');
|
|
491
|
+
#### 👉🏻 Sending Interactive Messages
|
|
221
492
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
229
|
-
<summary><b>📢 Newsletter (Channels) API</b></summary>
|
|
230
|
-
<br>
|
|
544
|
+
##### 2️⃣ List
|
|
231
545
|
|
|
232
|
-
|
|
546
|
+
> [!NOTE]
|
|
547
|
+
It only works in private chat (`@s.whatsapp.net`).
|
|
233
548
|
|
|
234
549
|
```javascript
|
|
235
|
-
|
|
236
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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
|
-
|
|
243
|
-
await sock.newsletterMute(channelJid);
|
|
244
|
-
await sock.newsletterUnmute(channelJid);
|
|
676
|
+
##### 4️⃣ Hydrated Template
|
|
245
677
|
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
250
|
-
const mySubscriptions = await sock.newsletterFetchAllSubscribe();
|
|
251
|
-
console.log(mySubscriptions); // List of your followed newsletters
|
|
701
|
+
#### 💳 Sending Payment Messages
|
|
252
702
|
|
|
253
|
-
|
|
703
|
+
##### 1️⃣ Invite Payment
|
|
254
704
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
705
|
+
```javascript
|
|
706
|
+
sock.sendMessage(jid, {
|
|
707
|
+
paymentInviteServiceType: 3 // 1, 2, or 3
|
|
708
|
+
})
|
|
259
709
|
```
|
|
260
|
-
</details>
|
|
261
710
|
|
|
262
|
-
|
|
263
|
-
<summary><b>✨ Advanced Messages (Violetics)</b></summary>
|
|
264
|
-
<br>
|
|
711
|
+
##### 2️⃣ Invoice
|
|
265
712
|
|
|
266
|
-
|
|
713
|
+
> [!NOTE]
|
|
714
|
+
Invoice message are not supported yet.
|
|
267
715
|
|
|
268
716
|
```javascript
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
-
|
|
725
|
+
##### 3️⃣ Order
|
|
283
726
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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
|
-
|
|
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
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
|
|
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
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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)
|