@boruto_vk7/baileys 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1383 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,1388 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# 🌱 @itsliaaa/baileys
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@itsliaaa/baileys)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
Enhanced Baileys v7 with fixed newsletter media upload, plus support for interactive messages, albums, and more message types.
|
|
7
|
+
<br><br>
|
|
8
|
+
<a href="https://www.npmjs.com/package/@itsliaaa/baileys">
|
|
9
|
+
<img src="https://img.shields.io/npm/v/@itsliaaa/baileys?style=for-the-badge&logo=npm"/>
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@itsliaaa/baileys">
|
|
12
|
+
<img src="https://img.shields.io/npm/dm/@itsliaaa/baileys?style=for-the-badge&logo=npm"/>
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://github.com/itsliaaa/baileys">
|
|
15
|
+
<img src="https://img.shields.io/github/stars/itsliaaa/baileys?style=for-the-badge&logo=github"/>
|
|
16
|
+
</a>
|
|
17
|
+
<a href="LICENSE">
|
|
18
|
+
<img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge"/>
|
|
19
|
+
</a>
|
|
20
|
+
<a href="https://nodejs.org">
|
|
21
|
+
<img src="https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&labelColor=green&logoColor=white&style=for-the-badge"/>
|
|
22
|
+
</a>
|
|
23
|
+
<a href="#">
|
|
24
|
+
<img src="https://img.shields.io/badge/ESM-only?logo=javascript&labelColor=yellow&logoColor=black&style=for-the-badge"/>
|
|
25
|
+
</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
☕ For donation: [Saweria](https://saweria.co/itsliaaa)
|
|
29
|
+
|
|
30
|
+
### ✨ Highlights
|
|
31
|
+
|
|
32
|
+
This fork designed for production use with a focus on clarity and safety:
|
|
33
|
+
|
|
34
|
+
- 🚫 No obfuscation. Easy to read and audit.
|
|
35
|
+
- 🚫 No auto-follow channel (newsletter) behavior.
|
|
36
|
+
|
|
37
|
+
> [!IMPORTANT]
|
|
38
|
+
Hi everyone,
|
|
39
|
+
>
|
|
40
|
+
> I want to share something that’s been weighing on me a bit.
|
|
41
|
+
>
|
|
42
|
+
> Recently, I found a few packages published on npm that are essentially just **renamed** versions of a fork I personally worked on:
|
|
43
|
+
>
|
|
44
|
+
> - https://www.npmjs.com/package/@noya4u_27/baileys
|
|
45
|
+
> - https://www.npmjs.com/package/@phrolovaa/baileys
|
|
46
|
+
> - https://www.npmjs.com/package/@dnuzi/baileys
|
|
47
|
+
> - https://www.npmjs.com/package/@crysnovax/baileys
|
|
48
|
+
>
|
|
49
|
+
> To be clear, I’m **not** the original maintainer of Baileys all respect goes to the amazing work behind [@boruto_vk7/baileys](https://github.com/WhiskeySockets/Baileys). I only created and maintained my own fork ([@itsliaaa/baileys](https://www.npmjs.com/package/@itsliaaa/baileys)) where I spent a **lot** of time improving and adapting things on my own.
|
|
50
|
+
>
|
|
51
|
+
> **It’s honestly a bit disheartening to see my fork being republished under different names without any acknowledgment or credit.** I put a lot of late nights and personal effort into it, so seeing it circulate like this feels… quietly painful.
|
|
52
|
+
>
|
|
53
|
+
> If you come across these packages, I’d really appreciate it if you could take a closer look and, if appropriate, **help report them to npm.** More than anything, I just hope for a bit of fairness and proper recognition for the work that people put in.
|
|
54
|
+
>
|
|
55
|
+
> Thank you for taking the time to read this 🤍
|
|
56
|
+
|
|
57
|
+
### 🛠️ Internal Adjustments
|
|
58
|
+
- 🖼️ Fixed an issue where media could not be sent to newsletters due to an upstream issue.
|
|
59
|
+
- 📁 Reintroduced [`makeInMemoryStore`](#%EF%B8%8F-implementing-a-data-store) with a minimal ESM adaptation and small adjustments for Baileys v7.
|
|
60
|
+
- 📦 Switched FFmpeg execution from `exec` to `spawn` for safer process handling.
|
|
61
|
+
- 🗃️ Added [`@napi-rs/image`](https://www.npmjs.com/package/@napi-rs/image) as a supported image processing backend in [`getImageProcessingLibrary()`](#%EF%B8%8F-image-processing), offering a balance between performance and compatibility.
|
|
62
|
+
|
|
63
|
+
### 📨 Message Handling & Compatibility
|
|
64
|
+
- 📩 Expanded message support for:
|
|
65
|
+
- 🖼️ [Album Message](#%EF%B8%8F-album-image--video)
|
|
66
|
+
- 👤 [Group Status Message](#4%EF%B8%8F⃣-group-status)
|
|
67
|
+
- 👉🏻 [Interactive Message](#-sending-interactive-messages) (buttons, lists, native flows, templates, carousels).
|
|
68
|
+
- 🎞️ [Status Mention Message](#%EF%B8%8F-status-mention)
|
|
69
|
+
- 📦 [Sticker Pack Message](#-sticker-pack)
|
|
70
|
+
- ✨ [Rich Response Message](#-rich-response) **[NEW]**
|
|
71
|
+
- 🧾 [Message with Code Blocks](#-message-with-code-block) **[NEW]**
|
|
72
|
+
- 📋 [Message with Table](#-message-with-table) **[NEW]**
|
|
73
|
+
- 💳 [Payment-related Message](#-sending-payment-messages) (payment requests, invites, orders, invoices).
|
|
74
|
+
- 📰 Simplified sending messages with ad thumbnail using [`externalAdReply`](#3%EF%B8%8F⃣-external-ad-reply), without requiring manual `contextInfo`.
|
|
75
|
+
- 💭 Added support for quoting messages inside channel (newsletter). **[NEW]**
|
|
76
|
+
- 🎀 Added support for [custom button icon](#3%EF%B8%8F⃣-interactive). **[NEW]**
|
|
77
|
+
|
|
78
|
+
### 🧩 Additional Message Options
|
|
79
|
+
- 👁️ Added optional boolean flags for message handling:
|
|
80
|
+
- 🤖 [`ai`](#1%EF%B8%8F⃣-ai-icon) - AI icon on message
|
|
81
|
+
- 📣 [`mentionAll`](#-mention) - Mention all group participants without requiring their JIDs in `mentions` or `mentionedJid` **[NEW]**
|
|
82
|
+
- 🔧 [`ephemeral`](#2%EF%B8%8F⃣-ephemeral), [`groupStatus`](#4%EF%B8%8F⃣-group-status), [`viewOnceV2`](#8%EF%B8%8F⃣-view-once-v2), [`viewOnceV2Extension`](#9%EF%B8%8F⃣-view-once-v2-extension), [`interactiveAsTemplate`](#3%EF%B8%8F⃣-interactive) - Message wrappers
|
|
83
|
+
- 🔒 [`secureMetaServiceLabel`](#6%EF%B8%8F⃣-secure-meta-service-label) - Secure meta service label on message **[NEW]**
|
|
84
|
+
- 📄 [`raw`](#5%EF%B8%8F⃣-raw) - Build your message manually **(DO NOT USE FOR EXPLOITATION)**
|
|
85
|
+
|
|
86
|
+
> [!NOTE]
|
|
87
|
+
📄 This project is maintained with limited scope and is not intended to replace upstream Baileys.
|
|
88
|
+
>
|
|
89
|
+
> 😞 And, really sorry for my bad english.
|
|
90
|
+
|
|
91
|
+
### 📥 Installation
|
|
92
|
+
|
|
93
|
+
- 📄 Via `package.json`
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
# NPM
|
|
97
|
+
"dependencies": {
|
|
98
|
+
"@itsliaaa/baileys": "latest"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# GitHub
|
|
102
|
+
"dependencies": {
|
|
103
|
+
"@itsliaaa/baileys": "github:itsliaaa/baileys"
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- ⌨️ Via terminal
|
|
8
108
|
|
|
9
|
-
## Instalação
|
|
10
109
|
```bash
|
|
11
|
-
|
|
110
|
+
# NPM
|
|
111
|
+
npm i @itsliaaa/baileys@latest
|
|
112
|
+
|
|
113
|
+
# GitHub
|
|
114
|
+
npm i github:itsliaaa/baileys
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### 🧩 Import (ESM & CJS)
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
// --- ESM
|
|
121
|
+
import { makeWASocket } from '@itsliaaa/baileys'
|
|
122
|
+
|
|
123
|
+
// --- CJS (tested and working on Node.js 24 ✅)
|
|
124
|
+
const { makeWASocket } = require('@itsliaaa/baileys')
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 🌐 Connect to WhatsApp (Quick Step)
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from '@itsliaaa/baileys'
|
|
131
|
+
import { Boom } from '@hapi/boom'
|
|
132
|
+
import pino from 'pino'
|
|
133
|
+
|
|
134
|
+
// --- Connect with pairing code
|
|
135
|
+
const myPhoneNumber = '6288888888888'
|
|
136
|
+
|
|
137
|
+
const logger = pino({ level: 'silent' })
|
|
138
|
+
|
|
139
|
+
const connectToWhatsApp = async () => {
|
|
140
|
+
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
141
|
+
|
|
142
|
+
const sock = makeWASocket({
|
|
143
|
+
logger,
|
|
144
|
+
auth: state
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
sock.ev.on('creds.update', saveCreds)
|
|
148
|
+
|
|
149
|
+
sock.ev.on('connection.update', (update) => {
|
|
150
|
+
const { connection, lastDisconnect } = update
|
|
151
|
+
if (connection === 'connecting' && !sock.authState.creds.registered) {
|
|
152
|
+
await delay(1500)
|
|
153
|
+
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
154
|
+
console.log('🔗 Pairing code', ':', code)
|
|
155
|
+
}
|
|
156
|
+
else if (connection === 'close') {
|
|
157
|
+
const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
158
|
+
console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
|
|
159
|
+
if (shouldReconnect) {
|
|
160
|
+
connectToWhatsApp()
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else if (connection === 'open') {
|
|
164
|
+
console.log('✅ Successfully connected to WhatsApp')
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
169
|
+
for (const message of messages) {
|
|
170
|
+
if (!message.message) continue
|
|
171
|
+
|
|
172
|
+
console.log('🔔 Got new message', ':', message)
|
|
173
|
+
await sock.sendMessage(message.key.remoteJid, {
|
|
174
|
+
text: '👋🏻 Hello world'
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
connectToWhatsApp()
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 🗄️ Implementing Data Store
|
|
184
|
+
|
|
185
|
+
> [!CAUTION]
|
|
186
|
+
I highly recommend building your own data store, as keeping an entire chat history in memory can lead to excessive RAM usage.
|
|
187
|
+
|
|
188
|
+
```javascript
|
|
189
|
+
import { makeWASocket, makeInMemoryStore, delay, DisconnectReason, useMultiFileAuthState } from '@itsliaaa/baileys'
|
|
190
|
+
import { Boom } from '@hapi/boom'
|
|
191
|
+
import pino from 'pino'
|
|
192
|
+
|
|
193
|
+
const myPhoneNumber = '6288888888888'
|
|
194
|
+
|
|
195
|
+
// --- Create your store path
|
|
196
|
+
const storePath = './store.json'
|
|
197
|
+
|
|
198
|
+
const logger = pino({ level: 'silent' })
|
|
199
|
+
|
|
200
|
+
const connectToWhatsApp = async () => {
|
|
201
|
+
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
202
|
+
|
|
203
|
+
const sock = makeWASocket({
|
|
204
|
+
logger,
|
|
205
|
+
auth: state
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
const store = makeInMemoryStore({
|
|
209
|
+
logger,
|
|
210
|
+
socket: sock
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
store.bind(sock.ev)
|
|
214
|
+
|
|
215
|
+
sock.ev.on('creds.update', saveCreds)
|
|
216
|
+
|
|
217
|
+
sock.ev.on('connection.update', (update) => {
|
|
218
|
+
const { connection, lastDisconnect } = update
|
|
219
|
+
if (connection === 'connecting' && !sock.authState.creds.registered) {
|
|
220
|
+
await delay(1500)
|
|
221
|
+
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
222
|
+
console.log('🔗 Pairing code', ':', code)
|
|
223
|
+
}
|
|
224
|
+
else if (connection === 'close') {
|
|
225
|
+
const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
226
|
+
console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
|
|
227
|
+
if (shouldReconnect) {
|
|
228
|
+
connectToWhatsApp()
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else if (connection === 'open') {
|
|
232
|
+
console.log('✅ Successfully connected to WhatsApp')
|
|
233
|
+
}
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
sock.ev.on('chats.upsert', () => {
|
|
237
|
+
console.log('✉️ Got chats', store.chats.all())
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
sock.ev.on('contacts.upsert', () => {
|
|
241
|
+
console.log('👥 Got contacts', Object.values(store.contacts))
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
// --- Read store from file
|
|
245
|
+
store.readFromFile(storePath)
|
|
246
|
+
|
|
247
|
+
// --- Save store every 3 minutes
|
|
248
|
+
setInterval(() => {
|
|
249
|
+
store.writeToFile(storePath)
|
|
250
|
+
}, 180000)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
connectToWhatsApp()
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 🪪 WhatsApp IDs Explain
|
|
257
|
+
|
|
258
|
+
`id` is the WhatsApp ID, called `jid` and `lid` too, of the person or group you're sending the message to.
|
|
259
|
+
- It must be in the format `[country code][phone number]@s.whatsapp.net`
|
|
260
|
+
- Example for people: `19999999999@s.whatsapp.net` and `12699999999@lid`.
|
|
261
|
+
- For groups, it must be in the format `123456789-123345@g.us`.
|
|
262
|
+
- For Meta AI, it's `11111111111@bot`.
|
|
263
|
+
- For broadcast lists, it's `[timestamp of creation]@broadcast`.
|
|
264
|
+
- For stories, the ID is `status@broadcast`.
|
|
265
|
+
|
|
266
|
+
### ✉️ Sending Messages
|
|
267
|
+
|
|
268
|
+
> [!NOTE]
|
|
269
|
+
You can get the `jid` from `message.key.remoteJid` in the first example.
|
|
270
|
+
|
|
271
|
+
#### 🔠 Text
|
|
272
|
+
|
|
273
|
+
```javascript
|
|
274
|
+
sock.sendMessage(jid, {
|
|
275
|
+
text: '👋🏻 Hello'
|
|
276
|
+
}, {
|
|
277
|
+
quoted: message
|
|
278
|
+
})
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
#### 🔔 Mention
|
|
282
|
+
|
|
283
|
+
```javascript
|
|
284
|
+
// --- Regular mention
|
|
285
|
+
sock.sendMessage(jid, {
|
|
286
|
+
text: '👋🏻 Hello @628123456789',
|
|
287
|
+
mentions: ['628123456789@s.whatsapp.net']
|
|
288
|
+
}, {
|
|
289
|
+
quoted: message
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
// --- Mention all
|
|
293
|
+
sock.sendMessage(jid, {
|
|
294
|
+
text: '👋🏻 Hello @all',
|
|
295
|
+
mentionAll: true
|
|
296
|
+
}, {
|
|
297
|
+
quoted: message
|
|
298
|
+
})
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
#### 😁 Reaction
|
|
302
|
+
|
|
303
|
+
```javascript
|
|
304
|
+
sock.sendMessage(jid, {
|
|
305
|
+
react: {
|
|
306
|
+
key: message.key,
|
|
307
|
+
text: '✨'
|
|
308
|
+
}
|
|
309
|
+
}, {
|
|
310
|
+
quoted: message
|
|
311
|
+
})
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
#### 📌 Pin Message
|
|
315
|
+
|
|
316
|
+
```javascript
|
|
317
|
+
sock.sendMessage(jid, {
|
|
318
|
+
pin: message.key,
|
|
319
|
+
time: 86400, // --- Set the value in seconds: 86400 (1d), 604800 (7d), or 2592000 (30d)
|
|
320
|
+
type: 1 // --- Or 0 to remove
|
|
321
|
+
}, {
|
|
322
|
+
quoted: message
|
|
323
|
+
})
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
#### 👤 Contact
|
|
327
|
+
|
|
328
|
+
```javascript
|
|
329
|
+
const vcard = 'BEGIN:VCARD\n'
|
|
330
|
+
+ 'VERSION:3.0\n'
|
|
331
|
+
+ 'FN:Lia Wynn\n'
|
|
332
|
+
+ 'ORG:Waitress;\n'
|
|
333
|
+
+ 'TEL;type=CELL;type=VOICE;waid=628123456789:+62 8123 4567 89\n'
|
|
334
|
+
+ 'END:VCARD'
|
|
335
|
+
|
|
336
|
+
sock.sendMessage(jid, {
|
|
337
|
+
contacts: {
|
|
338
|
+
displayName: 'Lia Wynn',
|
|
339
|
+
contacts: [
|
|
340
|
+
{ vcard }
|
|
341
|
+
]
|
|
342
|
+
}
|
|
343
|
+
}, {
|
|
344
|
+
quoted: message
|
|
345
|
+
})
|
|
12
346
|
```
|
|
347
|
+
|
|
348
|
+
#### 📍 Location
|
|
349
|
+
|
|
350
|
+
```javascript
|
|
351
|
+
sock.sendMessage(jid, {
|
|
352
|
+
location: {
|
|
353
|
+
degreesLatitude: 24.121231,
|
|
354
|
+
degreesLongitude: 55.1121221,
|
|
355
|
+
name: '👋🏻 I am here'
|
|
356
|
+
}
|
|
357
|
+
}, {
|
|
358
|
+
quoted: message
|
|
359
|
+
})
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
#### 🗓️ Event
|
|
363
|
+
|
|
364
|
+
```javascript
|
|
365
|
+
sock.sendMessage(jid, {
|
|
366
|
+
event: {
|
|
367
|
+
name: '🎶 Meet & Mingle Party',
|
|
368
|
+
description: 'Meet & Mingle Party is a fun, casual gathering to connect, chat, and build new relationships within the community.',
|
|
369
|
+
call: 'audio', // --- Or "video", this field is optional
|
|
370
|
+
startDate: new Date(Date.now() + 3600000),
|
|
371
|
+
endDate: new Date(Date.now() + 28800000),
|
|
372
|
+
isCancelled: false, // --- Optional
|
|
373
|
+
isScheduleCall: false, // --- Optional
|
|
374
|
+
extraGuestsAllowed: false, // --- Optional
|
|
375
|
+
location: {
|
|
376
|
+
name: 'Jakarta',
|
|
377
|
+
degreesLatitude: -6.2,
|
|
378
|
+
degreesLongitude: 106.8
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}, {
|
|
382
|
+
quoted: message
|
|
383
|
+
})
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
#### 📊 Poll
|
|
387
|
+
|
|
388
|
+
```javascript
|
|
389
|
+
// --- Regular poll message
|
|
390
|
+
sock.sendMessage(jid, {
|
|
391
|
+
poll: {
|
|
392
|
+
name: '🔥 Voting time',
|
|
393
|
+
values: ['Yes', 'No'],
|
|
394
|
+
selectableCount: 1,
|
|
395
|
+
toAnnouncementGroup: false
|
|
396
|
+
}
|
|
397
|
+
}, {
|
|
398
|
+
quoted: message
|
|
399
|
+
})
|
|
400
|
+
|
|
401
|
+
// --- Quiz (only for newsletter)
|
|
402
|
+
sock.sendMessage('1211111111111@newsletter', {
|
|
403
|
+
poll: {
|
|
404
|
+
name: '🔥 Quiz',
|
|
405
|
+
values: ['Yes', 'No'],
|
|
406
|
+
correctAnswer: 'Yes',
|
|
407
|
+
pollType: 1
|
|
408
|
+
}
|
|
409
|
+
}, {
|
|
410
|
+
quoted: message
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
// --- Poll result
|
|
414
|
+
sock.sendMessage(jid, {
|
|
415
|
+
pollResult: {
|
|
416
|
+
name: '📝 Poll Result',
|
|
417
|
+
votes: [{
|
|
418
|
+
name: 'Nice',
|
|
419
|
+
voteCount: 10
|
|
420
|
+
}, {
|
|
421
|
+
name: 'Nah',
|
|
422
|
+
voteCount: 2
|
|
423
|
+
}],
|
|
424
|
+
pollType: 0 // Or 1 for quiz
|
|
425
|
+
}
|
|
426
|
+
}, {
|
|
427
|
+
quoted: message
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
// --- Poll update
|
|
431
|
+
sock.sendMessage(jid, {
|
|
432
|
+
pollUpdate: {
|
|
433
|
+
metadata: {},
|
|
434
|
+
key: message.key,
|
|
435
|
+
vote: {
|
|
436
|
+
enclv: /* <Buffer> */,
|
|
437
|
+
encPayload: /* <Buffer> */
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}, {
|
|
441
|
+
quoted: message
|
|
442
|
+
})
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
#### 💭 Response
|
|
446
|
+
|
|
447
|
+
```javascript
|
|
448
|
+
// --- Using buttonsResponseMessage
|
|
449
|
+
sock.sendMessage(jid, {
|
|
450
|
+
type: 'plain',
|
|
451
|
+
buttonReply: {
|
|
452
|
+
id: '#Menu',
|
|
453
|
+
displayText: '✨ Interesting Menu'
|
|
454
|
+
}
|
|
455
|
+
}, {
|
|
456
|
+
quoted: message
|
|
457
|
+
})
|
|
458
|
+
|
|
459
|
+
// --- Using interactiveResponseMessage
|
|
460
|
+
sock.sendMessage(jid, {
|
|
461
|
+
flowReply: {
|
|
462
|
+
format: 0,
|
|
463
|
+
text: '💭 Response',
|
|
464
|
+
name: 'menu_options',
|
|
465
|
+
paramsJson: JSON.stringify({
|
|
466
|
+
id: '#Menu',
|
|
467
|
+
description: '✨ Interesting Menu'
|
|
468
|
+
})
|
|
469
|
+
}
|
|
470
|
+
}, {
|
|
471
|
+
quoted: message
|
|
472
|
+
})
|
|
473
|
+
|
|
474
|
+
// --- Using listResponseMessage
|
|
475
|
+
sock.sendMessage(jid, {
|
|
476
|
+
listReply: {
|
|
477
|
+
title: '📄 See More',
|
|
478
|
+
description: '✨ Interesting Menu',
|
|
479
|
+
id: '#Menu'
|
|
480
|
+
}
|
|
481
|
+
}, {
|
|
482
|
+
quoted: message
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
// --- Using templateButtonReplyMessage
|
|
486
|
+
sock.sendMessage(jid, {
|
|
487
|
+
type: 'template',
|
|
488
|
+
buttonReply: {
|
|
489
|
+
id: '#Menu',
|
|
490
|
+
displayText: '✨ Interesting Menu',
|
|
491
|
+
index: 1
|
|
492
|
+
}
|
|
493
|
+
}, {
|
|
494
|
+
quoted: message
|
|
495
|
+
})
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
#### ✨ Rich Response
|
|
499
|
+
|
|
500
|
+
> [!NOTE]
|
|
501
|
+
`richResponse[]` is a representation of [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) inside `richResponseMessage`.
|
|
502
|
+
|
|
503
|
+
> [!TIP]
|
|
504
|
+
You can still use the original [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) field directly.
|
|
505
|
+
> The code example below is just an implementation using a helper, not a required structure.
|
|
506
|
+
|
|
507
|
+
```javascript
|
|
508
|
+
sock.sendMessage(jid, {
|
|
509
|
+
richResponse: [{
|
|
510
|
+
text: 'Example Usage',
|
|
511
|
+
}, {
|
|
512
|
+
language: 'javascript',
|
|
513
|
+
code: [{
|
|
514
|
+
highlightType: 0,
|
|
515
|
+
codeContent: 'console.log("Hello, World!")'
|
|
516
|
+
}]
|
|
517
|
+
}, {
|
|
518
|
+
text: 'Pretty simple, right?\n'
|
|
519
|
+
}, {
|
|
520
|
+
text: 'Comparison between Node.js, Bun, and Deno',
|
|
521
|
+
}, {
|
|
522
|
+
title: 'Runtime Comparison',
|
|
523
|
+
table: [{
|
|
524
|
+
isHeading: true,
|
|
525
|
+
items: ['', 'Node.js', 'Bun', 'Deno']
|
|
526
|
+
}, {
|
|
527
|
+
isHeading: false,
|
|
528
|
+
items: ['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)']
|
|
529
|
+
}, {
|
|
530
|
+
isHeading: false,
|
|
531
|
+
items: ['Performance', '4/5', '5/5', '4/5']
|
|
532
|
+
}]
|
|
533
|
+
}, {
|
|
534
|
+
text: 'Does this help clarify the differences?'
|
|
535
|
+
}]
|
|
536
|
+
})
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
> [!TIP]
|
|
540
|
+
You can easily add syntax highlighting by importing `tokenizeCode` directly from Baileys.
|
|
541
|
+
|
|
542
|
+
```javascript
|
|
543
|
+
import { tokenizeCode } from '@itsliaaa/baileys'
|
|
544
|
+
|
|
545
|
+
const language = 'javascript'
|
|
546
|
+
const code = 'console.log("Hello, World!")'
|
|
547
|
+
|
|
548
|
+
sock.sendMessage(jid, {
|
|
549
|
+
richResponse: [{
|
|
550
|
+
text: 'Example Usage',
|
|
551
|
+
}, {
|
|
552
|
+
language,
|
|
553
|
+
code: tokenizeCode(code, language)
|
|
554
|
+
}, {
|
|
555
|
+
text: 'Pretty simple, right?'
|
|
556
|
+
}]
|
|
557
|
+
})
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
#### 🧾 Message with Code Block
|
|
561
|
+
|
|
562
|
+
> [!NOTE]
|
|
563
|
+
This feature already includes a built-in tokenizer.
|
|
564
|
+
|
|
565
|
+
```javascript
|
|
566
|
+
sock.sendMessage(jid, {
|
|
567
|
+
headerText: '## Example Usage',
|
|
568
|
+
contentText: '---',
|
|
569
|
+
code: 'console.log("Hello, World!")',
|
|
570
|
+
language: 'javascript',
|
|
571
|
+
footerText: 'Pretty simple, right?'
|
|
572
|
+
})
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
#### 📋 Message with Table
|
|
576
|
+
|
|
577
|
+
```javascript
|
|
578
|
+
sock.sendMessage(jid, {
|
|
579
|
+
headerText: '## Comparison between Node.js, Bun, and Deno',
|
|
580
|
+
contentText: '---',
|
|
581
|
+
title: 'Runtime Comparison',
|
|
582
|
+
table: [
|
|
583
|
+
['', 'Node.js', 'Bun', 'Deno'],
|
|
584
|
+
['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)'],
|
|
585
|
+
['Performance', '4/5', '5/5', '4/5']
|
|
586
|
+
],
|
|
587
|
+
footerText: 'Does this help clarify the differences?'
|
|
588
|
+
})
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
#### 🎞️ Status Mention
|
|
592
|
+
|
|
593
|
+
```javascript
|
|
594
|
+
sock.sendMessage([jidA, jidB, jidC], {
|
|
595
|
+
text: 'Hello! 👋🏻'
|
|
596
|
+
})
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
### 📁 Sending Media Messages
|
|
600
|
+
|
|
601
|
+
> [!NOTE]
|
|
602
|
+
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).
|
|
603
|
+
|
|
604
|
+
#### 🖼️ Image
|
|
605
|
+
|
|
606
|
+
```javascript
|
|
607
|
+
sock.sendMessage(jid, {
|
|
608
|
+
image: {
|
|
609
|
+
url: './path/to/image.jpg'
|
|
610
|
+
},
|
|
611
|
+
caption: '🔥 Superb'
|
|
612
|
+
}, {
|
|
613
|
+
quoted: message
|
|
614
|
+
})
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
#### 🎥 Video
|
|
618
|
+
|
|
619
|
+
```javascript
|
|
620
|
+
sock.sendMessage(jid, {
|
|
621
|
+
video: {
|
|
622
|
+
url: './path/to/video.mp4'
|
|
623
|
+
},
|
|
624
|
+
gifPlayback: false, // --- Set true if you want to send video as GIF
|
|
625
|
+
ptv: false, // --- Set true if you want to send video as PTV
|
|
626
|
+
caption: '🔥 Superb'
|
|
627
|
+
}, {
|
|
628
|
+
quoted: message
|
|
629
|
+
})
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
#### 📃 Sticker
|
|
633
|
+
|
|
634
|
+
```javascript
|
|
635
|
+
sock.sendMessage(jid, {
|
|
636
|
+
sticker: {
|
|
637
|
+
url: './path/to/sticker.webp'
|
|
638
|
+
}
|
|
639
|
+
}, {
|
|
640
|
+
quoted: message
|
|
641
|
+
})
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
#### 💽 Audio
|
|
645
|
+
|
|
646
|
+
```javascript
|
|
647
|
+
sock.sendMessage(jid, {
|
|
648
|
+
audio: {
|
|
649
|
+
url: './path/to/audio.mp3'
|
|
650
|
+
},
|
|
651
|
+
ptt: false, // --- Set true if you want to send audio as Voice Note
|
|
652
|
+
}, {
|
|
653
|
+
quoted: message
|
|
654
|
+
})
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
#### 🖼️ Album (Image & Video)
|
|
658
|
+
|
|
659
|
+
```javascript
|
|
660
|
+
sock.sendMessage(jid, {
|
|
661
|
+
album: [{
|
|
662
|
+
image: {
|
|
663
|
+
url: './path/to/image.jpg'
|
|
664
|
+
},
|
|
665
|
+
caption: '1st image'
|
|
666
|
+
}, {
|
|
667
|
+
video: {
|
|
668
|
+
url: './path/to/video.mp4'
|
|
669
|
+
},
|
|
670
|
+
caption: '1st video'
|
|
671
|
+
}, {
|
|
672
|
+
image: {
|
|
673
|
+
url: './path/to/image.jpg'
|
|
674
|
+
},
|
|
675
|
+
caption: '2nd image'
|
|
676
|
+
}, {
|
|
677
|
+
video: {
|
|
678
|
+
url: './path/to/video.mp4'
|
|
679
|
+
},
|
|
680
|
+
caption: '2nd video'
|
|
681
|
+
}]
|
|
682
|
+
}, {
|
|
683
|
+
quoted: message
|
|
684
|
+
})
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
#### 📦 Sticker Pack
|
|
688
|
+
|
|
689
|
+
> [!IMPORTANT]
|
|
690
|
+
If `sharp` or `@napi-rs/image` is not installed, the `cover` and `stickers` must already be in WebP format.
|
|
691
|
+
|
|
692
|
+
```javascript
|
|
693
|
+
sock.sendMessage(jid, {
|
|
694
|
+
cover: {
|
|
695
|
+
url: './path/to/image.webp'
|
|
696
|
+
},
|
|
697
|
+
stickers: [{
|
|
698
|
+
data: {
|
|
699
|
+
url: './path/to/image.webp'
|
|
700
|
+
}
|
|
701
|
+
}, {
|
|
702
|
+
data: {
|
|
703
|
+
url: './path/to/image.webp'
|
|
704
|
+
}
|
|
705
|
+
}, {
|
|
706
|
+
data: {
|
|
707
|
+
url: './path/to/image.webp'
|
|
708
|
+
}
|
|
709
|
+
}],
|
|
710
|
+
name: '📦 My Sticker Pack',
|
|
711
|
+
publisher: '🌟 Lia Wynn',
|
|
712
|
+
description: '@itsliaaa/baileys'
|
|
713
|
+
}, {
|
|
714
|
+
quoted: message
|
|
715
|
+
})
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
### 👉🏻 Sending Interactive Messages
|
|
719
|
+
|
|
720
|
+
#### 1️⃣ Buttons
|
|
721
|
+
|
|
722
|
+
```javascript
|
|
723
|
+
// --- Regular buttons message
|
|
724
|
+
sock.sendMessage(jid, {
|
|
725
|
+
text: '👆🏻 Buttons!',
|
|
726
|
+
footer: '@itsliaaa/baileys',
|
|
727
|
+
buttons: [{
|
|
728
|
+
text: '👋🏻 SignUp',
|
|
729
|
+
id: '#SignUp'
|
|
730
|
+
}]
|
|
731
|
+
}, {
|
|
732
|
+
quoted: message
|
|
733
|
+
})
|
|
734
|
+
|
|
735
|
+
// --- Buttons with Media & Native Flow
|
|
736
|
+
sock.sendMessage(jid, {
|
|
737
|
+
image: {
|
|
738
|
+
url: './path/to/image.jpg'
|
|
739
|
+
},
|
|
740
|
+
caption: '👆🏻 Buttons and Native Flow!',
|
|
741
|
+
footer: '@itsliaaa/baileys',
|
|
742
|
+
buttons: [{
|
|
743
|
+
text: '👋🏻 Rating',
|
|
744
|
+
id: '#Rating'
|
|
745
|
+
}, {
|
|
746
|
+
text: '📋 Select',
|
|
747
|
+
sections: [{
|
|
748
|
+
title: '✨ Section 1',
|
|
749
|
+
rows: [{
|
|
750
|
+
header: '',
|
|
751
|
+
title: '💭 Secret Ingredient',
|
|
752
|
+
description: '',
|
|
753
|
+
id: '#SecretIngredient'
|
|
754
|
+
}]
|
|
755
|
+
}, {
|
|
756
|
+
title: '✨ Section 2',
|
|
757
|
+
highlight_label: '🔥 Popular',
|
|
758
|
+
rows: [{
|
|
759
|
+
header: '',
|
|
760
|
+
title: '🏷️ Coupon',
|
|
761
|
+
description: '',
|
|
762
|
+
id: '#CouponCode'
|
|
763
|
+
}]
|
|
764
|
+
}]
|
|
765
|
+
}]
|
|
766
|
+
}, {
|
|
767
|
+
quoted: message
|
|
768
|
+
})
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
#### 2️⃣ List
|
|
772
|
+
|
|
773
|
+
> [!NOTE]
|
|
774
|
+
It only works in private chat (`@s.whatsapp.net`).
|
|
775
|
+
|
|
776
|
+
```javascript
|
|
777
|
+
sock.sendMessage(jid, {
|
|
778
|
+
text: '📋 List!',
|
|
779
|
+
footer: '@itsliaaa/baileys',
|
|
780
|
+
buttonText: '📋 Select',
|
|
781
|
+
title: '👋🏻 Hello',
|
|
782
|
+
sections: [{
|
|
783
|
+
title: '🚀 Menu 1',
|
|
784
|
+
rows: [{
|
|
785
|
+
title: '✨ AI',
|
|
786
|
+
description: '',
|
|
787
|
+
rowId: '#AI'
|
|
788
|
+
}]
|
|
789
|
+
}, {
|
|
790
|
+
title: '🌱 Menu 2',
|
|
791
|
+
rows: [{
|
|
792
|
+
title: '🔍 Search',
|
|
793
|
+
description: '',
|
|
794
|
+
rowId: '#Search'
|
|
795
|
+
}]
|
|
796
|
+
}]
|
|
797
|
+
}, {
|
|
798
|
+
quoted: message
|
|
799
|
+
})
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
#### 3️⃣ Interactive
|
|
803
|
+
|
|
804
|
+
```javascript
|
|
805
|
+
// --- Native Flow
|
|
806
|
+
sock.sendMessage(jid, {
|
|
807
|
+
image: {
|
|
808
|
+
url: './path/to/image.jpg'
|
|
809
|
+
},
|
|
810
|
+
caption: '🗄️ Interactive!',
|
|
811
|
+
footer: '@itsliaaa/baileys',
|
|
812
|
+
optionText: '👉🏻 Select Options', // --- Optional, wrap all native flow into a single list
|
|
813
|
+
optionTitle: '📄 Select Options', // --- Optional
|
|
814
|
+
offerText: '🏷️ Newest Coupon!', // --- Optional, add an offer into message
|
|
815
|
+
offerCode: '@itsliaaa/baileys', // --- Optional
|
|
816
|
+
offerUrl: 'https://www.npmjs.com/package/@itsliaaa/baileys', // --- Optional
|
|
817
|
+
offerExpiration: Date.now() + 3_600_000, // --- Optional
|
|
818
|
+
nativeFlow: [{
|
|
819
|
+
text: '👋🏻 Greeting',
|
|
820
|
+
id: '#Greeting',
|
|
821
|
+
icon: 'review' // --- Optional
|
|
822
|
+
}, {
|
|
823
|
+
text: '📞 Call',
|
|
824
|
+
call: '628123456789'
|
|
825
|
+
}, {
|
|
826
|
+
text: '📋 Copy',
|
|
827
|
+
copy: '@itsliaaa/baileys'
|
|
828
|
+
}, {
|
|
829
|
+
text: '🌐 Source',
|
|
830
|
+
url: 'https://www.npmjs.com/package/@itsliaaa/baileys'
|
|
831
|
+
}, {
|
|
832
|
+
text: '📋 Select',
|
|
833
|
+
sections: [{
|
|
834
|
+
title: '✨ Section 1',
|
|
835
|
+
rows: [{
|
|
836
|
+
header: '',
|
|
837
|
+
title: '🏷️ Coupon',
|
|
838
|
+
description: '',
|
|
839
|
+
id: '#CouponCode'
|
|
840
|
+
}]
|
|
841
|
+
}, {
|
|
842
|
+
title: '✨ Section 2',
|
|
843
|
+
highlight_label: '🔥 Popular',
|
|
844
|
+
rows: [{
|
|
845
|
+
header: '',
|
|
846
|
+
title: '💭 Secret Ingredient',
|
|
847
|
+
description: '',
|
|
848
|
+
id: '#SecretIngredient'
|
|
849
|
+
}]
|
|
850
|
+
}],
|
|
851
|
+
icon: 'default' // --- Optional
|
|
852
|
+
}],
|
|
853
|
+
interactiveAsTemplate: false, // --- Optional, wrap the interactive message into a template
|
|
854
|
+
}, {
|
|
855
|
+
quoted: message
|
|
856
|
+
})
|
|
857
|
+
|
|
858
|
+
// --- Carousel & Native Flow
|
|
859
|
+
sock.sendMessage(jid, {
|
|
860
|
+
text: '🗂️ Interactive with Carousel!',
|
|
861
|
+
footer: '@itsliaaa/baileys',
|
|
862
|
+
cards: [{
|
|
863
|
+
image: {
|
|
864
|
+
url: './path/to/image.jpg'
|
|
865
|
+
},
|
|
866
|
+
caption: '🖼️ Image 1',
|
|
867
|
+
footer: '🏷️️ Pinterest',
|
|
868
|
+
nativeFlow: [{
|
|
869
|
+
text: '🌐 Source',
|
|
870
|
+
url: 'https://www.npmjs.com/package/@itsliaaa/baileys'
|
|
871
|
+
}]
|
|
872
|
+
}, {
|
|
873
|
+
image: {
|
|
874
|
+
url: './path/to/image.jpg'
|
|
875
|
+
},
|
|
876
|
+
caption: '🖼️ Image 2',
|
|
877
|
+
footer: '🏷️ Pinterest',
|
|
878
|
+
offerText: '🏷️ New Coupon!',
|
|
879
|
+
offerCode: '@itsliaaa/baileys',
|
|
880
|
+
offerUrl: 'https://www.npmjs.com/package/@itsliaaa/baileys',
|
|
881
|
+
offerExpiration: Date.now() + 3_600_000,
|
|
882
|
+
nativeFlow: [{
|
|
883
|
+
text: '🌐 Source',
|
|
884
|
+
url: 'https://www.npmjs.com/package/@itsliaaa/baileys'
|
|
885
|
+
}]
|
|
886
|
+
}, {
|
|
887
|
+
image: {
|
|
888
|
+
url: './path/to/image.jpg'
|
|
889
|
+
},
|
|
890
|
+
caption: '🖼️ Image 3',
|
|
891
|
+
footer: '🏷️ Pinterest',
|
|
892
|
+
optionText: '👉🏻 Select Options',
|
|
893
|
+
optionTitle: '👉🏻 Select Options',
|
|
894
|
+
offerText: '🏷️ New Coupon!',
|
|
895
|
+
offerCode: '@itsliaaa/baileys',
|
|
896
|
+
offerUrl: 'https://www.npmjs.com/package/@itsliaaa/baileys',
|
|
897
|
+
offerExpiration: Date.now() + 3_600_000,
|
|
898
|
+
nativeFlow: [{
|
|
899
|
+
text: '🛒 Product',
|
|
900
|
+
id: '#Product'
|
|
901
|
+
}, {
|
|
902
|
+
text: '🌐 Source',
|
|
903
|
+
url: 'https://www.npmjs.com/package/@itsliaaa/baileys'
|
|
904
|
+
}]
|
|
905
|
+
}]
|
|
906
|
+
}, {
|
|
907
|
+
quoted: message
|
|
908
|
+
})
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
#### 4️⃣ Hydrated Template
|
|
912
|
+
|
|
913
|
+
```javascript
|
|
914
|
+
sock.sendMessage(jid, {
|
|
915
|
+
title: '👋🏻 Hello',
|
|
916
|
+
image: {
|
|
917
|
+
url: './path/to/image.jpg'
|
|
918
|
+
},
|
|
919
|
+
caption: '🫙 Template!',
|
|
920
|
+
footer: '@itsliaaa/baileys',
|
|
921
|
+
templateButtons: [{
|
|
922
|
+
text: '👉🏻 Tap Here',
|
|
923
|
+
id: '#Order'
|
|
924
|
+
}, {
|
|
925
|
+
text: '🌐 Source',
|
|
926
|
+
url: 'https://www.npmjs.com/package/@itsliaaa/baileys'
|
|
927
|
+
}, {
|
|
928
|
+
text: '📞 Call',
|
|
929
|
+
call: '628123456789'
|
|
930
|
+
}]
|
|
931
|
+
}, {
|
|
932
|
+
quoted: message
|
|
933
|
+
})
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
### 💳 Sending Payment Messages
|
|
937
|
+
|
|
938
|
+
#### 1️⃣ Invite Payment
|
|
939
|
+
|
|
940
|
+
```javascript
|
|
941
|
+
sock.sendMessage(jid, {
|
|
942
|
+
paymentInviteServiceType: 3 // 1, 2, or 3
|
|
943
|
+
})
|
|
944
|
+
```
|
|
945
|
+
|
|
946
|
+
#### 2️⃣ Invoice
|
|
947
|
+
|
|
948
|
+
> [!NOTE]
|
|
949
|
+
Invoice message are not supported yet.
|
|
950
|
+
|
|
951
|
+
```javascript
|
|
952
|
+
sock.sendMessage(jid, {
|
|
953
|
+
image: {
|
|
954
|
+
url: './path/to/image.jpg'
|
|
955
|
+
},
|
|
956
|
+
invoiceNote: '🏷️ Invoice'
|
|
957
|
+
})
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
#### 3️⃣ Order
|
|
961
|
+
|
|
962
|
+
```javascript
|
|
963
|
+
sock.sendMessage(chat, {
|
|
964
|
+
orderText: '🛍️ Order',
|
|
965
|
+
thumbnail: fs.readFileSync('./path/to/image.jpg') // --- Must in buffer format
|
|
966
|
+
}, {
|
|
967
|
+
quoted: message
|
|
968
|
+
})
|
|
969
|
+
```
|
|
970
|
+
|
|
971
|
+
#### 4️⃣ Product
|
|
972
|
+
|
|
973
|
+
```javascript
|
|
974
|
+
sock.sendMessage(jid, {
|
|
975
|
+
image: {
|
|
976
|
+
url: './path/to/image.jpg'
|
|
977
|
+
},
|
|
978
|
+
product: {
|
|
979
|
+
title: '🛒 My Product'
|
|
980
|
+
},
|
|
981
|
+
businessOwnerJid: '0@s.whatsapp.net' // --- Must included
|
|
982
|
+
}, {
|
|
983
|
+
quoted: message
|
|
984
|
+
})
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
#### 5️⃣ Request Payment
|
|
988
|
+
|
|
989
|
+
```javascript
|
|
990
|
+
sock.sendMessage(jid, {
|
|
991
|
+
text: '💳 Request Payment',
|
|
992
|
+
requestPaymentFrom: '0@s.whatsapp.net'
|
|
993
|
+
})
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
### 👁️ Other Message Options
|
|
997
|
+
|
|
998
|
+
#### 1️⃣ AI Icon
|
|
999
|
+
|
|
1000
|
+
> [!NOTE]
|
|
1001
|
+
It only works in private chat (`@s.whatsapp.net`).
|
|
1002
|
+
|
|
1003
|
+
```javascript
|
|
1004
|
+
sock.sendMessage(jid, {
|
|
1005
|
+
image: {
|
|
1006
|
+
url: './path/to/image.jpg'
|
|
1007
|
+
},
|
|
1008
|
+
caption: '🤖 With AI icon!',
|
|
1009
|
+
ai: true
|
|
1010
|
+
}, {
|
|
1011
|
+
quoted: message
|
|
1012
|
+
})
|
|
1013
|
+
```
|
|
1014
|
+
|
|
1015
|
+
#### 2️⃣ Ephemeral
|
|
1016
|
+
|
|
1017
|
+
> [!NOTE]
|
|
1018
|
+
Wrap message into `ephemeralMessage`
|
|
1019
|
+
|
|
1020
|
+
```javascript
|
|
1021
|
+
sock.sendMessage(jid, {
|
|
1022
|
+
image: {
|
|
1023
|
+
url: './path/to/image.jpg'
|
|
1024
|
+
},
|
|
1025
|
+
caption: '👁️ Ephemeral',
|
|
1026
|
+
ephemeral: true
|
|
1027
|
+
})
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
#### 3️⃣ External Ad Reply
|
|
1031
|
+
|
|
1032
|
+
> [!NOTE]
|
|
1033
|
+
Add an ad thumbnail to messages (may not be displayed on some WhatsApp versions).
|
|
1034
|
+
|
|
1035
|
+
```javascript
|
|
1036
|
+
sock.sendMessage(jid, {
|
|
1037
|
+
text: '📰 External Ad Reply',
|
|
1038
|
+
externalAdReply: {
|
|
1039
|
+
title: '📝 Did you know?',
|
|
1040
|
+
body: '❓ I dont know',
|
|
1041
|
+
thumbnail: fs.readFileSync('./path/to/image.jpg'), // --- Must in buffer format
|
|
1042
|
+
largeThumbnail: false, // --- Or true for bigger thumbnail
|
|
1043
|
+
url: 'https://www.npmjs.com/package/@itsliaaa/baileys' // --- Optional, used for WhatsApp internal thumbnail caching and direct URL
|
|
1044
|
+
}
|
|
1045
|
+
}, {
|
|
1046
|
+
quoted: message
|
|
1047
|
+
})
|
|
1048
|
+
```
|
|
1049
|
+
|
|
1050
|
+
#### 4️⃣ Group Status
|
|
1051
|
+
|
|
1052
|
+
> [!NOTE]
|
|
1053
|
+
It only works in group chat (`@g.us`)
|
|
1054
|
+
|
|
1055
|
+
```javascript
|
|
1056
|
+
sock.sendMessage(jid, {
|
|
1057
|
+
image: {
|
|
1058
|
+
url: './path/to/image.jpg'
|
|
1059
|
+
},
|
|
1060
|
+
caption: '👥 Group Status!',
|
|
1061
|
+
groupStatus: true
|
|
1062
|
+
})
|
|
1063
|
+
```
|
|
1064
|
+
|
|
1065
|
+
#### 5️⃣ Raw
|
|
1066
|
+
|
|
1067
|
+
```javascript
|
|
1068
|
+
sock.sendMessage(jid, {
|
|
1069
|
+
extendedTextMessage: {
|
|
1070
|
+
text: '📃 Built manually from scratch using the raw WhatsApp proto structure',
|
|
1071
|
+
contextInfo: {
|
|
1072
|
+
externalAdReply: {
|
|
1073
|
+
title: '@itsliaaa/baileys',
|
|
1074
|
+
thumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
1075
|
+
sourceApp: 'whatsapp',
|
|
1076
|
+
showAdAttribution: true,
|
|
1077
|
+
mediaType: 1
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
},
|
|
1081
|
+
raw: true
|
|
1082
|
+
}, {
|
|
1083
|
+
quoted: message
|
|
1084
|
+
})
|
|
1085
|
+
```
|
|
1086
|
+
|
|
1087
|
+
#### 6️⃣ Secure Meta Service Label
|
|
1088
|
+
|
|
1089
|
+
```javascript
|
|
1090
|
+
sock.sendMessage(jid, {
|
|
1091
|
+
text: '🏷️ Just a label!',
|
|
1092
|
+
secureMetaServiceLabel: true
|
|
1093
|
+
})
|
|
1094
|
+
```
|
|
1095
|
+
|
|
1096
|
+
#### 7️⃣ View Once
|
|
1097
|
+
|
|
1098
|
+
> [!NOTE]
|
|
1099
|
+
Wrap message into `viewOnceMessage`
|
|
1100
|
+
|
|
1101
|
+
```javascript
|
|
1102
|
+
sock.sendMessage(jid, {
|
|
1103
|
+
image: {
|
|
1104
|
+
url: './path/to/image.jpg'
|
|
1105
|
+
},
|
|
1106
|
+
caption: '👁️ View Once',
|
|
1107
|
+
viewOnce: true
|
|
1108
|
+
})
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
#### 8️⃣ View Once V2
|
|
1112
|
+
|
|
1113
|
+
> [!NOTE]
|
|
1114
|
+
Wrap message into `viewOnceMessageV2`
|
|
1115
|
+
|
|
1116
|
+
```javascript
|
|
1117
|
+
sock.sendMessage(jid, {
|
|
1118
|
+
image: {
|
|
1119
|
+
url: './path/to/image.jpg'
|
|
1120
|
+
},
|
|
1121
|
+
caption: '👁️ View Once V2',
|
|
1122
|
+
viewOnceV2: true
|
|
1123
|
+
})
|
|
1124
|
+
```
|
|
1125
|
+
|
|
1126
|
+
#### 9️⃣ View Once V2 Extension
|
|
1127
|
+
|
|
1128
|
+
> [!NOTE]
|
|
1129
|
+
Wrap message into `viewOnceMessageV2Extension`
|
|
1130
|
+
|
|
1131
|
+
```javascript
|
|
1132
|
+
sock.sendMessage(jid, {
|
|
1133
|
+
image: {
|
|
1134
|
+
url: './path/to/image.jpg'
|
|
1135
|
+
},
|
|
1136
|
+
caption: '👁️ View Once V2 Extension',
|
|
1137
|
+
viewOnceV2Extension: true
|
|
1138
|
+
})
|
|
1139
|
+
```
|
|
1140
|
+
|
|
1141
|
+
### 🧰 Additional Contents
|
|
1142
|
+
|
|
1143
|
+
#### 🏷️ Find User ID (JID|PN/LID)
|
|
1144
|
+
|
|
1145
|
+
> [!NOTE]
|
|
1146
|
+
The ID must contain numbers only (no +, (), or -) and must include the country code with WhatsApp ID format.
|
|
1147
|
+
|
|
1148
|
+
```javascript
|
|
1149
|
+
// --- PN (Phone Number)
|
|
1150
|
+
const phoneNumber = '6281111111111@s.whatsapp.net'
|
|
1151
|
+
|
|
1152
|
+
const ids = await sock.findUserId(phoneNumber)
|
|
1153
|
+
|
|
1154
|
+
console.log('🏷️ Got user ID', ':', ids)
|
|
1155
|
+
|
|
1156
|
+
// --- LID (Local Identifier)
|
|
1157
|
+
const lid = '43411111111111@lid'
|
|
1158
|
+
|
|
1159
|
+
const ids = await sock.findUserId(lid)
|
|
1160
|
+
|
|
1161
|
+
console.log('🏷️ Got user ID', ':', ids)
|
|
1162
|
+
|
|
1163
|
+
// --- Output
|
|
1164
|
+
// {
|
|
1165
|
+
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
1166
|
+
// lid: '43411111111111@lid'
|
|
1167
|
+
// }
|
|
1168
|
+
// --- Output when failed
|
|
1169
|
+
// {
|
|
1170
|
+
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
1171
|
+
// lid: 'id-not-found'
|
|
1172
|
+
// }
|
|
1173
|
+
// --- Same output shape regardless of input type
|
|
1174
|
+
```
|
|
1175
|
+
|
|
1176
|
+
#### 🔑 Request Custom Pairing Code
|
|
1177
|
+
|
|
1178
|
+
> [!NOTE]
|
|
1179
|
+
The phone number must contain numbers only (no +, (), or -) and must include the country code.
|
|
1180
|
+
|
|
1181
|
+
```javascript
|
|
1182
|
+
const phoneNumber = '6281111111111'
|
|
1183
|
+
const customPairingCode = 'STARFALL'
|
|
1184
|
+
|
|
1185
|
+
await sock.requestPairingCode(phoneNumber, customPairingCode)
|
|
1186
|
+
|
|
1187
|
+
console.log('🔗 Pairing code', ':', customPairingCode)
|
|
1188
|
+
```
|
|
1189
|
+
|
|
1190
|
+
#### 🖼️ Image Processing
|
|
1191
|
+
|
|
1192
|
+
> [!NOTE]
|
|
1193
|
+
Automatically use available image processing library: `sharp`, `@napi-rs/image`, or `jimp`
|
|
1194
|
+
|
|
1195
|
+
```javascript
|
|
1196
|
+
import { getImageProcessingLibrary } from '@itsliaaa/baileys'
|
|
1197
|
+
import { readFile } from 'fs/promises'
|
|
1198
|
+
|
|
1199
|
+
const lib = await getImageProcessingLibrary()
|
|
1200
|
+
|
|
1201
|
+
const bufferOrFilePath = './path/to/image.jpg'
|
|
1202
|
+
const width = 512
|
|
1203
|
+
|
|
1204
|
+
let output
|
|
1205
|
+
|
|
1206
|
+
// --- If sharp installed
|
|
1207
|
+
if (lib.sharp?.default) {
|
|
1208
|
+
const img = lib.sharp.default(bufferOrFilePath)
|
|
1209
|
+
|
|
1210
|
+
output = await img.resize(width)
|
|
1211
|
+
.jpeg({ quality: 80 })
|
|
1212
|
+
.toBuffer()
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
// --- If @napi-rs/image installed
|
|
1216
|
+
else if (lib.image?.Transformer) {
|
|
1217
|
+
// --- Must in buffer format
|
|
1218
|
+
const inputBuffer = Buffer.isBuffer(bufferOrFilePath)
|
|
1219
|
+
? bufferOrFilePath
|
|
1220
|
+
: await readFile(bufferOrFilePath)
|
|
1221
|
+
|
|
1222
|
+
const img = new lib.image.Transformer(inputBuffer)
|
|
1223
|
+
|
|
1224
|
+
output = await img.resize(width, undefined, 0)
|
|
1225
|
+
.jpeg(50)
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
// --- If jimp installed
|
|
1229
|
+
else if (lib.jimp?.Jimp) {
|
|
1230
|
+
const img = await lib.jimp.Jimp.read(bufferOrFilePath)
|
|
1231
|
+
|
|
1232
|
+
output = await img
|
|
1233
|
+
.resize({ w: width, mode: lib.jimp.ResizeStrategy.BILINEAR })
|
|
1234
|
+
.getBuffer('image/jpeg', { quality: 50 });
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
// --- Fallback
|
|
1238
|
+
else {
|
|
1239
|
+
throw new Error('No image processing available')
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
console.log('✅ Process completed!')
|
|
1243
|
+
console.dir(output, { depth: null })
|
|
1244
|
+
```
|
|
1245
|
+
|
|
1246
|
+
#### 📣 Newsletter Management
|
|
1247
|
+
|
|
1248
|
+
```javascript
|
|
1249
|
+
// --- Create a new one
|
|
1250
|
+
sock.newsletterCreate('@itsliaaa/baileys')
|
|
1251
|
+
|
|
1252
|
+
// --- Get info
|
|
1253
|
+
sock.newsletterMetadata('1231111111111@newsletter')
|
|
1254
|
+
|
|
1255
|
+
// --- Demote admin
|
|
1256
|
+
sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
1257
|
+
|
|
1258
|
+
// --- Change owner
|
|
1259
|
+
sock.newsletterChangeOwner('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
1260
|
+
|
|
1261
|
+
// --- Change name
|
|
1262
|
+
sock.newsletterUpdateName('1231111111111@newsletter', '📦 @itsliaaa/baileys')
|
|
1263
|
+
|
|
1264
|
+
// --- Change description
|
|
1265
|
+
sock.newsletterUpdateDescription('1231111111111@newsletter', '📣 Fresh updates weekly')
|
|
1266
|
+
|
|
1267
|
+
// --- Change photo
|
|
1268
|
+
sock.newsletterUpdatePicture('1231111111111@newsletter', {
|
|
1269
|
+
url: 'path/to/image.jpg'
|
|
1270
|
+
})
|
|
1271
|
+
|
|
1272
|
+
// --- Remove photo
|
|
1273
|
+
sock.newsletterRemovePicture('1231111111111@newsletter')
|
|
1274
|
+
|
|
1275
|
+
// --- React to a message
|
|
1276
|
+
sock.newsletterReactMessage('1231111111111@newsletter', '100', '💛')
|
|
1277
|
+
|
|
1278
|
+
// --- Get all subscribed newsletters
|
|
1279
|
+
const newsletters = await sock.newsletterSubscribed()
|
|
1280
|
+
|
|
1281
|
+
console.dir(newsletters, { depth: null })
|
|
1282
|
+
```
|
|
1283
|
+
|
|
1284
|
+
#### 👥 Group Management
|
|
1285
|
+
|
|
1286
|
+
```javascript
|
|
1287
|
+
// --- Create a new one and add participants using their JIDs
|
|
1288
|
+
sock.groupCreate('@itsliaaa/baileys', ['628123456789@s.whatsapp.net'])
|
|
1289
|
+
|
|
1290
|
+
// --- Get info
|
|
1291
|
+
sock.groupMetadata(jid)
|
|
1292
|
+
|
|
1293
|
+
// --- Get invite code
|
|
1294
|
+
sock.groupInviteCode(jid)
|
|
1295
|
+
|
|
1296
|
+
// --- Revoke invite link
|
|
1297
|
+
sock.groupRevokeInvite(jid)
|
|
1298
|
+
|
|
1299
|
+
// --- Leave group
|
|
1300
|
+
sock.groupLeave(jid)
|
|
1301
|
+
|
|
1302
|
+
// --- Add participants
|
|
1303
|
+
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'add')
|
|
1304
|
+
|
|
1305
|
+
// --- Remove participants
|
|
1306
|
+
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'remove')
|
|
1307
|
+
|
|
1308
|
+
// --- Promote to admin
|
|
1309
|
+
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'promote')
|
|
1310
|
+
|
|
1311
|
+
// --- Demote from admin
|
|
1312
|
+
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'demote')
|
|
1313
|
+
|
|
1314
|
+
// --- Change name
|
|
1315
|
+
sock.groupUpdateSubject(jid, '📦 @itsliaaa/baileys')
|
|
1316
|
+
|
|
1317
|
+
// --- Change description
|
|
1318
|
+
sock.groupUpdateDescription(jid, 'Updated description')
|
|
1319
|
+
|
|
1320
|
+
// --- Change photo
|
|
1321
|
+
sock.updateProfilePicture(jid, {
|
|
1322
|
+
url: 'path/to/image.jpg'
|
|
1323
|
+
})
|
|
1324
|
+
|
|
1325
|
+
// --- Remove photo
|
|
1326
|
+
sock.removeProfilePicture(jid)
|
|
1327
|
+
|
|
1328
|
+
// --- Set group as admin only for chatting
|
|
1329
|
+
sock.groupSettingUpdate(jid, 'announcement')
|
|
1330
|
+
|
|
1331
|
+
// --- Set group as open to all for chatting
|
|
1332
|
+
sock.groupSettingUpdate(jid, 'not_announcement')
|
|
1333
|
+
|
|
1334
|
+
// --- Set admin only can edit group info
|
|
1335
|
+
sock.groupSettingUpdate(jid, 'locked')
|
|
1336
|
+
|
|
1337
|
+
// --- Set all participants can edit group info
|
|
1338
|
+
sock.groupSettingUpdate(jid, 'unlocked')
|
|
1339
|
+
|
|
1340
|
+
// --- Set admin only can add participants
|
|
1341
|
+
sock.groupMemberAddMode(jid, 'admin_add')
|
|
1342
|
+
|
|
1343
|
+
// --- Set all participants can add participants
|
|
1344
|
+
sock.groupMemberAddMode(jid, 'all_member_add')
|
|
1345
|
+
|
|
1346
|
+
// --- Enable or disable temporary messages with seconds format
|
|
1347
|
+
sock.groupToggleEphemeral(jid, 86400)
|
|
1348
|
+
|
|
1349
|
+
// --- Disable temporary messages
|
|
1350
|
+
sock.groupToggleEphemeral(jid, 0)
|
|
1351
|
+
|
|
1352
|
+
// --- Enable or disable membership approval mode
|
|
1353
|
+
sock.groupJoinApprovalMode(jid, 'on')
|
|
1354
|
+
sock.groupJoinApprovalMode(jid, 'off')
|
|
1355
|
+
|
|
1356
|
+
// --- Get all groups metadata
|
|
1357
|
+
const groups = await sock.groupFetchAllParticipating()
|
|
1358
|
+
|
|
1359
|
+
console.dir(groups, { depth: null })
|
|
1360
|
+
|
|
1361
|
+
// --- Get pending invites
|
|
1362
|
+
const invites = await sock.groupGetInviteInfo(code)
|
|
1363
|
+
|
|
1364
|
+
console.dir(invites, { depth: null })
|
|
1365
|
+
|
|
1366
|
+
// --- Accept group invite
|
|
1367
|
+
sock.groupAcceptInvite(code)
|
|
1368
|
+
|
|
1369
|
+
// --- Get group info from link
|
|
1370
|
+
const group = await sock.groupGetInviteInfo('https://chat.whatsapp.com/ABC123')
|
|
1371
|
+
|
|
1372
|
+
console.log('👥 Got group info from link', ':', group)
|
|
1373
|
+
```
|
|
1374
|
+
|
|
1375
|
+
## 📦 Fork Base
|
|
1376
|
+
> [!NOTE]
|
|
1377
|
+
This fork is based on [Baileys (GitHub)](https://github.com/WhiskeySockets/Baileys)
|
|
1378
|
+
|
|
1379
|
+
## 📣 Credits
|
|
1380
|
+
> [!IMPORTANT]
|
|
1381
|
+
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)
|
|
1382
|
+
>
|
|
1383
|
+
> Full credit goes to the original Baileys maintainers and contributors:
|
|
1384
|
+
> - [purpshell](https://github.com/purpshell)
|
|
1385
|
+
> - [jlucaso1](https://github.com/jlucaso1)
|
|
1386
|
+
> - [adiwajshing](https://github.com/adiwajshing)
|
|
1387
|
+
>
|
|
1388
|
+
> This fork includes additional enhancements and modifications by [Lia Wynn](https://github.com/itsliaaa)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boruto_vk7/baileys",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Enhanced Baileys v7 with fixed newsletter media upload, plus support for interactive messages, albums, and more message types.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|