@lordmega/baileys 0.3.24 โ 0.3.25
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 +19 -1529
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,77 +31,6 @@
|
|
|
31
31
|
- [๐ ๏ธ Internal Adjustments](#%EF%B8%8F-internal-adjustments)
|
|
32
32
|
- [๐จ Messages Handling & Compatibility](#-messages-handling--compatibility)
|
|
33
33
|
- [๐งฉ Additional Message Options](#-additional-message-options)
|
|
34
|
-
- [๐ฅ Installation](#-installation)
|
|
35
|
-
- [๐งฉ Import (ESM & CJS)](#-import-esm--cjs)
|
|
36
|
-
- [๐ Quick Start](#-quick-start)
|
|
37
|
-
- [๐ Connect to WhatsApp (Quick Step)](#-connect-to-whatsapp-quick-step)
|
|
38
|
-
- [๐ Auth State](#-auth-state)
|
|
39
|
-
- [๐๏ธ Implementing Data Store](#%EF%B8%8F-implementing-data-store)
|
|
40
|
-
- [๐ชช WhatsApp IDs Explain](#-whatsapp-ids-explain)
|
|
41
|
-
- [โ๏ธ Sending Messages](#%EF%B8%8F-sending-messages)
|
|
42
|
-
- [๐ Text](#-text)
|
|
43
|
-
- [๐ Mention](#-mention)
|
|
44
|
-
- [๐ Reaction](#-reaction)
|
|
45
|
-
- [๐ Pin Message](#-pin-message)
|
|
46
|
-
- [๐ Keep Chat](#-keep-chat)
|
|
47
|
-
- [โก๏ธ Forward Message](#%EF%B8%8F-forward-message)
|
|
48
|
-
- [๐ค Contact](#-contact)
|
|
49
|
-
- [๐ Location](#-location)
|
|
50
|
-
- [๐๏ธ Event](#%EF%B8%8F-event)
|
|
51
|
-
- [๐ฅ Group Invite](#-group-invite)
|
|
52
|
-
- [๐๏ธ Product](#%EF%B8%8F-product)
|
|
53
|
-
- [๐ Poll](#-poll)
|
|
54
|
-
- [๐ญ Button Response](#-button-response)
|
|
55
|
-
- [โจ Rich Response](#-rich-response)
|
|
56
|
-
- [๐งพ Message with Code Block](#-message-with-code-block)
|
|
57
|
-
- [๐ Message with Inline Entities](#-message-with-inline-entities)
|
|
58
|
-
- [๐ Message with Table](#-message-with-table)
|
|
59
|
-
- [๐๏ธ Status Mention](#%EF%B8%8F-status-mention)
|
|
60
|
-
- [๐ Sending Media Messages](#-sending-media-messages)
|
|
61
|
-
- [๐ผ๏ธ Image](#%EF%B8%8F-image)
|
|
62
|
-
- [๐ฅ Video](#-video)
|
|
63
|
-
- [๐ Sticker](#-sticker)
|
|
64
|
-
- [๐ฝ Audio](#-audio)
|
|
65
|
-
- [๐๏ธ Document](#%EF%B8%8F-document)
|
|
66
|
-
- [๐ผ๏ธ Album (Image & Video)](#%EF%B8%8F-album-image--video)
|
|
67
|
-
- [๐ฆ Sticker Pack](#-sticker-pack)
|
|
68
|
-
- [๐๏ธ Reveal View-Once](#%EF%B8%8F-reveal-view-once)
|
|
69
|
-
- [๐๐ป Sending Interactive Messages](#-sending-interactive-messages)
|
|
70
|
-
- [๐ Buttons](#-buttons)
|
|
71
|
-
- [๐ List](#-list)
|
|
72
|
-
- [๐๏ธ Interactive](#%EF%B8%8F-interactive)
|
|
73
|
-
- [๐ซ Hydrated Template](#-hydrated-template)
|
|
74
|
-
- [๐ณ Sending Payment Messages](#-sending-payment-messages)
|
|
75
|
-
- [โ Invite Payment](#-invite-payment)
|
|
76
|
-
- [๐งพ Invoice](#-invoice)
|
|
77
|
-
- [๐๏ธ Order](#%EF%B8%8F-order)
|
|
78
|
-
- [๐ณ Request Payment](#-request-payment)
|
|
79
|
-
- [๐๏ธ Other Message Options](#%EF%B8%8F-other-message-options)
|
|
80
|
-
- [๐ค AI Icon](#-ai-icon)
|
|
81
|
-
- [๐ Ephemeral](#-ephemeral)
|
|
82
|
-
- [๐ฐ External Ad Reply](#-external-ad-reply)
|
|
83
|
-
- [๐งโ๐งโ๐ง Group Status](#%E2%80%8D%E2%80%8D-group-status)
|
|
84
|
-
- [๐ฑ Lottie Sticker](#-lottie-sticker)
|
|
85
|
-
- [๐งฉ Raw](#-raw)
|
|
86
|
-
- [๐ท๏ธ Secure Meta Service Label](#%EF%B8%8F-secure-meta-service-label)
|
|
87
|
-
- [๐ Spoiler](#-spoiler)
|
|
88
|
-
- [๐๏ธ View Once](#%EF%B8%8F-view-once)
|
|
89
|
-
- [๐๏ธ View Once V2](#%EF%B8%8F-view-once-v2)
|
|
90
|
-
- [๐๏ธ View Once V2 Extension](#%EF%B8%8F-view-once-v2-extension)
|
|
91
|
-
- [โป๏ธ Modify Messages](#%EF%B8%8F-modify-messages)
|
|
92
|
-
- [๐๏ธ Delete Messages](#%EF%B8%8F-delete-messages)
|
|
93
|
-
- [โ๏ธ Edit Messages](#%EF%B8%8F-edit-messages)
|
|
94
|
-
- [๐งฐ Additional Contents](#-additional-contents)
|
|
95
|
-
- [๐ท๏ธ Find User ID (JID|PN/LID)](#%EF%B8%8F-find-user-id-jidpnlid)
|
|
96
|
-
- [๐ Request Custom Pairing Code](#-request-custom-pairing-code)
|
|
97
|
-
- [๐ผ๏ธ Image Processing](#%EF%B8%8F-image-processing)
|
|
98
|
-
- [๐ฃ Newsletter Management](#-newsletter-management)
|
|
99
|
-
- [๐ฅ Group Management](#-group-management)
|
|
100
|
-
- [๐ฅ Community Management](#-community-management)
|
|
101
|
-
- [๐ค Profile Management](#-profile-management)
|
|
102
|
-
- [๐ Business Management](#-business-management)
|
|
103
|
-
- [๐ Privacy Management](#-privacy-management)
|
|
104
|
-
- [๐ก Events](#-events)
|
|
105
34
|
- [๐ Try the Bot](#-try-the-bot)
|
|
106
35
|
- [๐ฆ Fork Base](#-fork-base)
|
|
107
36
|
|
|
@@ -123,1478 +52,39 @@ Built for production with an emphasis on readability and reliability:
|
|
|
123
52
|
- ๐ผ๏ธ Fixed newsletter media upload failures caused by an upstream bug.
|
|
124
53
|
- ๐ Restored `makeInMemoryStore` with a lightweight ESM adaptation and minor compatibility tweaks for Baileys v7.
|
|
125
54
|
- ๐ฆ Replaced FFmpeg `exec` calls with `spawn` for more reliable process management.
|
|
126
|
-
- ๐๏ธ Added [`@napi-rs/image`](https://www.npmjs.com/package/@napi-rs/image) as a supported backend in
|
|
55
|
+
- ๐๏ธ Added [`@napi-rs/image`](https://www.npmjs.com/package/@napi-rs/image) as a supported backend in `getImageProcessingLibrary()`, providing a solid balance between speed and compatibility.
|
|
127
56
|
- ๐ Spoofing guards on self-only protocol messages.
|
|
128
57
|
|
|
129
58
|
### ๐จ Messages Handling & Compatibility
|
|
130
59
|
|
|
131
60
|
- ๐ฉ Extended message type support for:
|
|
132
|
-
- ๐ผ๏ธ
|
|
133
|
-
- ๐ค
|
|
134
|
-
- ๐๐ป
|
|
135
|
-
- ๐๏ธ
|
|
136
|
-
- ๐ฆ
|
|
137
|
-
- โจ
|
|
138
|
-
- ๐งพ
|
|
139
|
-
- ๐
|
|
140
|
-
- ๐
|
|
141
|
-
- ๐ณ
|
|
142
|
-
- ๐ฐ Simplified ad thumbnail sending via
|
|
61
|
+
- ๐ผ๏ธ Album Message
|
|
62
|
+
- ๐ค Group Status Message
|
|
63
|
+
- ๐๐ป Interactive Message (buttons, lists, native flows, templates, carousels)
|
|
64
|
+
- ๐๏ธ Status Mention Message
|
|
65
|
+
- ๐ฆ Sticker Pack Message
|
|
66
|
+
- โจ Rich Response Message **[NEW]**
|
|
67
|
+
- ๐งพ Message with Code Blocks **[NEW]**
|
|
68
|
+
- ๐ Message with Inline Entities **[NEW]**
|
|
69
|
+
- ๐ Message with Table **[NEW]**
|
|
70
|
+
- ๐ณ Payment-related Messages (requests, invites, orders, invoices)
|
|
71
|
+
- ๐ฐ Simplified ad thumbnail sending via `externalAdReply` โ no manual `contextInfo` required.
|
|
143
72
|
- ๐ญ Added support for quoting messages inside newsletters. **[NEW]**
|
|
144
|
-
- ๐ Added support for
|
|
145
|
-
- ๐๏ธ Reveal view-once messages and resend as normal media via
|
|
73
|
+
- ๐ Added support for custom button icons. **[NEW]**
|
|
74
|
+
- ๐๏ธ Reveal view-once messages and resend as normal media via `sock.rvo()`. **[NEW]**
|
|
146
75
|
|
|
147
76
|
### ๐งฉ Additional Message Options
|
|
148
77
|
|
|
149
78
|
- ๐๏ธ Optional boolean flags for message behavior:
|
|
150
|
-
- ๐ค
|
|
151
|
-
- ๐ฃ
|
|
152
|
-
- ๐ง
|
|
153
|
-
- ๐
|
|
154
|
-
- ๐
|
|
79
|
+
- ๐ค `ai` โ AI icon on message
|
|
80
|
+
- ๐ฃ `mentionAll` โ Mention all group participants without specifying individual JIDs **[NEW]**
|
|
81
|
+
- ๐ง `ephemeral`, `groupStatus`, `isLottie`, `spoiler`, `viewOnce`, `viewOnceV2`, `viewOnceV2Extension`, `interactiveAsTemplate` โ Message wrappers
|
|
82
|
+
- ๐ `secureMetaServiceLabel` โ Secure meta service label **[NEW]**
|
|
83
|
+
- ๐ `raw` โ Build message proto manually **(DO NOT USE FOR EXPLOITATION)**
|
|
155
84
|
- ๐ Pass a custom 32-byte `messageSecret` on any message type via send options.
|
|
156
85
|
|
|
157
86
|
---
|
|
158
87
|
|
|
159
|
-
### ๐ฅ Installation
|
|
160
|
-
|
|
161
|
-
- ๐ Via `package.json`
|
|
162
|
-
|
|
163
|
-
```json
|
|
164
|
-
# NPM
|
|
165
|
-
"dependencies": {
|
|
166
|
-
"@lordmega/baileys": "latest"
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
# GitHub
|
|
170
|
-
"dependencies": {
|
|
171
|
-
"@lordmega/baileys": "github:lordmega/baileys"
|
|
172
|
-
}
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
- โจ๏ธ Via terminal
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
# NPM
|
|
179
|
-
npm i @lordmega/baileys@latest
|
|
180
|
-
|
|
181
|
-
# GitHub
|
|
182
|
-
npm i github:lordmega/baileys
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
#### ๐งฉ Import (ESM & CJS)
|
|
186
|
-
|
|
187
|
-
```javascript
|
|
188
|
-
// --- ESM
|
|
189
|
-
import { makeWASocket } from '@lordmega/baileys'
|
|
190
|
-
|
|
191
|
-
// --- CJS (tested and working on Node.js 24 โ
)
|
|
192
|
-
const { makeWASocket } = require('@lordmega/baileys')
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
---
|
|
196
|
-
|
|
197
|
-
### ๐ Quick Start
|
|
198
|
-
|
|
199
|
-
```javascript
|
|
200
|
-
import { makeWASocket, useMultiFileAuthState, DisconnectReason } from '@lordmega/baileys'
|
|
201
|
-
import { Boom } from '@hapi/boom'
|
|
202
|
-
|
|
203
|
-
const { state, saveCreds } = await useMultiFileAuthState('auth')
|
|
204
|
-
|
|
205
|
-
const sock = makeWASocket({ auth: state, printQRInTerminal: true })
|
|
206
|
-
|
|
207
|
-
sock.ev.on('creds.update', saveCreds)
|
|
208
|
-
|
|
209
|
-
sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
|
|
210
|
-
if (connection === 'close') {
|
|
211
|
-
const reconnect = lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut
|
|
212
|
-
if (reconnect) makeWASocket({ auth: state })
|
|
213
|
-
}
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
217
|
-
const msg = messages[0]
|
|
218
|
-
if (!msg.key.fromMe && msg.message?.conversation) {
|
|
219
|
-
await sock.sendMessage(msg.key.remoteJid, { text: 'pong' })
|
|
220
|
-
}
|
|
221
|
-
})
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
---
|
|
225
|
-
|
|
226
|
-
### ๐ Connect to WhatsApp (Quick Step)
|
|
227
|
-
|
|
228
|
-
```javascript
|
|
229
|
-
import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from '@lordmega/baileys'
|
|
230
|
-
import { Boom } from '@hapi/boom'
|
|
231
|
-
import pino from 'pino'
|
|
232
|
-
|
|
233
|
-
const myPhoneNumber = '2560000000'
|
|
234
|
-
|
|
235
|
-
const logger = pino({ level: 'silent' })
|
|
236
|
-
|
|
237
|
-
const connectToWhatsApp = async () => {
|
|
238
|
-
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
239
|
-
|
|
240
|
-
const sock = makeWASocket({
|
|
241
|
-
logger,
|
|
242
|
-
auth: state
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
sock.ev.on('creds.update', saveCreds)
|
|
246
|
-
|
|
247
|
-
sock.ev.on('connection.update', (update) => {
|
|
248
|
-
const { connection, lastDisconnect } = update
|
|
249
|
-
if (connection === 'connecting' && !sock.authState.creds.registered) {
|
|
250
|
-
await delay(1500)
|
|
251
|
-
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
252
|
-
console.log('๐ Pairing code', ':', code)
|
|
253
|
-
}
|
|
254
|
-
else if (connection === 'close') {
|
|
255
|
-
const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
256
|
-
console.log('โ ๏ธ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
|
|
257
|
-
if (shouldReconnect) {
|
|
258
|
-
connectToWhatsApp()
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
else if (connection === 'open') {
|
|
262
|
-
console.log('โ
Successfully connected to WhatsApp')
|
|
263
|
-
}
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
267
|
-
for (const message of messages) {
|
|
268
|
-
if (!message.message) continue
|
|
269
|
-
|
|
270
|
-
console.log('๐ Got new message', ':', message)
|
|
271
|
-
await sock.sendMessage(message.key.remoteJid, {
|
|
272
|
-
text: '๐๐ป Hello world'
|
|
273
|
-
})
|
|
274
|
-
}
|
|
275
|
-
})
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
connectToWhatsApp()
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
#### ๐ Auth State
|
|
282
|
-
|
|
283
|
-
> [!NOTE]
|
|
284
|
-
> You can use the experimental `useSingleFileAuthState` and `useSqliteAuthState` as alternatives to `useMultiFileAuthState`. Note that `useSingleFileAuthState` has built-in caching, so wrapping `state.keys` with `makeCacheableSignalKeyStore` is unnecessary.
|
|
285
|
-
|
|
286
|
-
#### ๐ฑ Android Browser (receive view-once)
|
|
287
|
-
|
|
288
|
-
Connect as an Android client to receive view-once messages natively:
|
|
289
|
-
|
|
290
|
-
```javascript
|
|
291
|
-
import { makeWASocket, Browsers } from '@lordmega/baileys'
|
|
292
|
-
|
|
293
|
-
const sock = makeWASocket({ auth: state, browser: Browsers.android('Chrome') })
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
---
|
|
297
|
-
|
|
298
|
-
### ๐๏ธ Implementing Data Store
|
|
299
|
-
|
|
300
|
-
> [!CAUTION]
|
|
301
|
-
> Building your own data store is strongly recommended โ keeping full chat history in memory can cause excessive RAM usage.
|
|
302
|
-
|
|
303
|
-
```javascript
|
|
304
|
-
import { makeWASocket, makeInMemoryStore, delay, DisconnectReason, useMultiFileAuthState } from '@lordmega/baileys'
|
|
305
|
-
import { Boom } from '@hapi/boom'
|
|
306
|
-
import pino from 'pino'
|
|
307
|
-
|
|
308
|
-
const myPhoneNumber = '6288888888888'
|
|
309
|
-
const storePath = './store.json'
|
|
310
|
-
const logger = pino({ level: 'silent' })
|
|
311
|
-
|
|
312
|
-
const connectToWhatsApp = async () => {
|
|
313
|
-
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
314
|
-
|
|
315
|
-
const sock = makeWASocket({
|
|
316
|
-
logger,
|
|
317
|
-
auth: state
|
|
318
|
-
})
|
|
319
|
-
|
|
320
|
-
const store = makeInMemoryStore({
|
|
321
|
-
logger,
|
|
322
|
-
socket: sock
|
|
323
|
-
})
|
|
324
|
-
|
|
325
|
-
store.bind(sock.ev)
|
|
326
|
-
|
|
327
|
-
sock.ev.on('creds.update', saveCreds)
|
|
328
|
-
|
|
329
|
-
sock.ev.on('connection.update', (update) => {
|
|
330
|
-
const { connection, lastDisconnect } = update
|
|
331
|
-
if (connection === 'connecting' && !sock.authState.creds.registered) {
|
|
332
|
-
await delay(1500)
|
|
333
|
-
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
334
|
-
console.log('๐ Pairing code', ':', code)
|
|
335
|
-
}
|
|
336
|
-
else if (connection === 'close') {
|
|
337
|
-
const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
338
|
-
console.log('โ ๏ธ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
|
|
339
|
-
if (shouldReconnect) {
|
|
340
|
-
connectToWhatsApp()
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
else if (connection === 'open') {
|
|
344
|
-
console.log('โ
Successfully connected to WhatsApp')
|
|
345
|
-
}
|
|
346
|
-
})
|
|
347
|
-
|
|
348
|
-
sock.ev.on('chats.upsert', () => {
|
|
349
|
-
console.log('โ๏ธ Got chats', store.chats.all())
|
|
350
|
-
})
|
|
351
|
-
|
|
352
|
-
sock.ev.on('contacts.upsert', () => {
|
|
353
|
-
console.log('๐ฅ Got contacts', Object.values(store.contacts))
|
|
354
|
-
})
|
|
355
|
-
|
|
356
|
-
store.readFromFile(storePath)
|
|
357
|
-
|
|
358
|
-
setInterval(() => {
|
|
359
|
-
store.writeToFile(storePath)
|
|
360
|
-
}, 180000)
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
connectToWhatsApp()
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
---
|
|
367
|
-
|
|
368
|
-
### ๐ชช WhatsApp IDs Explain
|
|
369
|
-
|
|
370
|
-
`id` is the WhatsApp ID (also referred to as `jid` or `lid`) of the person or group you're messaging.
|
|
371
|
-
- Format: `[country code][phone number]@s.whatsapp.net`
|
|
372
|
-
- Individual: `19999999999@s.whatsapp.net` or `12699999999@lid`
|
|
373
|
-
- Group: `123456789-123345@g.us`
|
|
374
|
-
- Meta AI: `11111111111@bot`
|
|
375
|
-
- Broadcast lists: `[timestamp]@broadcast`
|
|
376
|
-
- Stories: `status@broadcast`
|
|
377
|
-
|
|
378
|
-
---
|
|
379
|
-
|
|
380
|
-
### โ๏ธ Sending Messages
|
|
381
|
-
|
|
382
|
-
#### ๐ Text
|
|
383
|
-
|
|
384
|
-
```javascript
|
|
385
|
-
// --- Regular text
|
|
386
|
-
sock.sendMessage(jid, {
|
|
387
|
-
text: '๐๐ป Hello'
|
|
388
|
-
}, {
|
|
389
|
-
quoted: message
|
|
390
|
-
})
|
|
391
|
-
|
|
392
|
-
// --- With link preview
|
|
393
|
-
const urlA = 'https://www.npmjs.com/package/@lordmega/baileys'
|
|
394
|
-
|
|
395
|
-
sock.sendMessage(jid, {
|
|
396
|
-
text: urlA + ' ๐๐ป Check it out!',
|
|
397
|
-
linkPreview: {
|
|
398
|
-
'matched-text': urlA,
|
|
399
|
-
title: '๐ฑ @lordmega/baileys',
|
|
400
|
-
description: 'Underrated Baileys Fork',
|
|
401
|
-
previewType: 0,
|
|
402
|
-
jpegThumbnail: fs.readFileSync('./path/to/image.jpg')
|
|
403
|
-
}
|
|
404
|
-
})
|
|
405
|
-
|
|
406
|
-
// --- Large link preview with favicon
|
|
407
|
-
import { prepareWAMessageMedia } from '@lordmega/baileys'
|
|
408
|
-
|
|
409
|
-
const urlB = 'https://www.npmjs.com/package/@lordmega/baileys#readme'
|
|
410
|
-
|
|
411
|
-
const { imageMessage: image } = await prepareWAMessageMedia({
|
|
412
|
-
image: { url: './path/to/image.jpg' }
|
|
413
|
-
}, {
|
|
414
|
-
upload: sock.waUploadToServer,
|
|
415
|
-
mediaTypeOverride: 'thumbnail-link'
|
|
416
|
-
})
|
|
417
|
-
|
|
418
|
-
image.height = 720
|
|
419
|
-
image.width = 480
|
|
420
|
-
|
|
421
|
-
sock.sendMessage(jid, {
|
|
422
|
-
text: urlB + ' ๐๐ป Check it out!',
|
|
423
|
-
linkPreview: {
|
|
424
|
-
'matched-text': urlB,
|
|
425
|
-
title: '๐ฑ @lordmega/baileys',
|
|
426
|
-
description: 'Underrated Baileys Fork',
|
|
427
|
-
previewType: 0,
|
|
428
|
-
jpegThumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
429
|
-
highQualityThumbnail: image,
|
|
430
|
-
linkPreviewMetadata: {
|
|
431
|
-
linkMediaDuration: 0,
|
|
432
|
-
socialMediaPostType: 1,
|
|
433
|
-
}
|
|
434
|
-
},
|
|
435
|
-
favicon: { url: './path/to/tiny-image.ico' }
|
|
436
|
-
})
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
#### ๐ Mention
|
|
440
|
-
|
|
441
|
-
```javascript
|
|
442
|
-
// --- Specific mention
|
|
443
|
-
sock.sendMessage(jid, {
|
|
444
|
-
text: '๐๐ป Hello @628123456789',
|
|
445
|
-
mentions: ['628123456789@s.whatsapp.net']
|
|
446
|
-
}, {
|
|
447
|
-
quoted: message
|
|
448
|
-
})
|
|
449
|
-
|
|
450
|
-
// --- Mention all
|
|
451
|
-
sock.sendMessage(jid, {
|
|
452
|
-
text: '๐๐ป Hello @all',
|
|
453
|
-
mentionAll: true
|
|
454
|
-
}, {
|
|
455
|
-
quoted: message
|
|
456
|
-
})
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
#### ๐ Reaction
|
|
460
|
-
|
|
461
|
-
```javascript
|
|
462
|
-
sock.sendMessage(jid, {
|
|
463
|
-
react: {
|
|
464
|
-
key: message.key,
|
|
465
|
-
text: 'โจ'
|
|
466
|
-
}
|
|
467
|
-
})
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
#### ๐ Pin Message
|
|
471
|
-
|
|
472
|
-
```javascript
|
|
473
|
-
sock.sendMessage(jid, {
|
|
474
|
-
pin: message.key,
|
|
475
|
-
time: 86400, // 86400 (1d), 604800 (7d), 2592000 (30d)
|
|
476
|
-
type: 1 // 2 to unpin
|
|
477
|
-
})
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
#### ๐ Keep Chat
|
|
481
|
-
|
|
482
|
-
> [!NOTE]
|
|
483
|
-
> Only works in chats or groups with disappearing messages enabled.
|
|
484
|
-
|
|
485
|
-
```javascript
|
|
486
|
-
sock.sendMessage(jid, {
|
|
487
|
-
keep: message.key,
|
|
488
|
-
type: 1 // 2 to remove
|
|
489
|
-
})
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
#### โก๏ธ Forward Message
|
|
493
|
-
|
|
494
|
-
```javascript
|
|
495
|
-
sock.sendMessage(jid, {
|
|
496
|
-
forward: message,
|
|
497
|
-
force: true // Optional
|
|
498
|
-
})
|
|
499
|
-
```
|
|
500
|
-
|
|
501
|
-
#### ๐ค Contact
|
|
502
|
-
|
|
503
|
-
```javascript
|
|
504
|
-
const vcard = 'BEGIN:VCARD\n'
|
|
505
|
-
+ 'VERSION:3.0\n'
|
|
506
|
-
+ 'FN:John Doe\n'
|
|
507
|
-
+ 'ORG:Example;\n'
|
|
508
|
-
+ 'TEL;type=CELL;type=VOICE;waid=628123456789:+62 8123 4567 89\n'
|
|
509
|
-
+ 'END:VCARD'
|
|
510
|
-
|
|
511
|
-
sock.sendMessage(jid, {
|
|
512
|
-
contacts: {
|
|
513
|
-
displayName: 'John Doe',
|
|
514
|
-
contacts: [{ vcard }]
|
|
515
|
-
}
|
|
516
|
-
}, {
|
|
517
|
-
quoted: message
|
|
518
|
-
})
|
|
519
|
-
```
|
|
520
|
-
|
|
521
|
-
#### ๐ Location
|
|
522
|
-
|
|
523
|
-
```javascript
|
|
524
|
-
sock.sendMessage(jid, {
|
|
525
|
-
location: {
|
|
526
|
-
degreesLatitude: 24.121231,
|
|
527
|
-
degreesLongitude: 55.1121221,
|
|
528
|
-
name: '๐๐ป I am here'
|
|
529
|
-
}
|
|
530
|
-
}, {
|
|
531
|
-
quoted: message
|
|
532
|
-
})
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
#### ๐๏ธ Event
|
|
536
|
-
|
|
537
|
-
```javascript
|
|
538
|
-
sock.sendMessage(jid, {
|
|
539
|
-
event: {
|
|
540
|
-
name: '๐ถ Meet & Mingle Party',
|
|
541
|
-
description: 'A casual gathering to connect and build new relationships.',
|
|
542
|
-
call: 'audio', // or "video", optional
|
|
543
|
-
startDate: new Date(Date.now() + 3600000),
|
|
544
|
-
endDate: new Date(Date.now() + 28800000),
|
|
545
|
-
isCancelled: false,
|
|
546
|
-
isScheduleCall: false,
|
|
547
|
-
extraGuestsAllowed: false,
|
|
548
|
-
location: {
|
|
549
|
-
name: 'Jakarta',
|
|
550
|
-
degreesLatitude: -6.2,
|
|
551
|
-
degreesLongitude: 106.8
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}, {
|
|
555
|
-
quoted: message
|
|
556
|
-
})
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
#### ๐ฅ Group Invite
|
|
560
|
-
|
|
561
|
-
```javascript
|
|
562
|
-
const inviteCode = groupUrl
|
|
563
|
-
.split('chat.whatsapp.com/')[1]
|
|
564
|
-
?.split('?')[0]
|
|
565
|
-
|
|
566
|
-
sock.sendMessage(jid, {
|
|
567
|
-
groupInvite: {
|
|
568
|
-
inviteCode,
|
|
569
|
-
inviteExpiration: Date.now() + 86400000,
|
|
570
|
-
text: '๐๐ป You are invited to join our group.',
|
|
571
|
-
jid: '1201111111111@g.us',
|
|
572
|
-
subject: 'Group Name',
|
|
573
|
-
}
|
|
574
|
-
}, {
|
|
575
|
-
quoted: message
|
|
576
|
-
})
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
#### ๐๏ธ Product
|
|
580
|
-
|
|
581
|
-
```javascript
|
|
582
|
-
import { randomUUID } from 'crypto'
|
|
583
|
-
|
|
584
|
-
sock.sendMessage(jid, {
|
|
585
|
-
image: { url: './path/to/image.jpg' },
|
|
586
|
-
body: '๐๐ป Check this out!',
|
|
587
|
-
footer: 'MegaBot',
|
|
588
|
-
product: {
|
|
589
|
-
currencyCode: 'IDR',
|
|
590
|
-
description: '๐๏ธ Great product!',
|
|
591
|
-
priceAmount1000: 70_000_000,
|
|
592
|
-
productId: randomUUID(),
|
|
593
|
-
productImageCount: 1,
|
|
594
|
-
salePriceAmount1000: 65_000_000,
|
|
595
|
-
signedUrl: 'https://example.com',
|
|
596
|
-
title: '๐ฆ Product Name',
|
|
597
|
-
url: 'https://example.com'
|
|
598
|
-
},
|
|
599
|
-
businessOwnerJid: '0@s.whatsapp.net'
|
|
600
|
-
})
|
|
601
|
-
```
|
|
602
|
-
|
|
603
|
-
#### ๐ Poll
|
|
604
|
-
|
|
605
|
-
```javascript
|
|
606
|
-
// --- Standard poll
|
|
607
|
-
sock.sendMessage(jid, {
|
|
608
|
-
poll: {
|
|
609
|
-
name: '๐ฅ Quick vote',
|
|
610
|
-
values: ['Yes', 'No'],
|
|
611
|
-
selectableCount: 1,
|
|
612
|
-
toAnnouncementGroup: false,
|
|
613
|
-
endDate: new Date(Date.now() + 28800000),
|
|
614
|
-
hideVoter: false,
|
|
615
|
-
canAddOption: false
|
|
616
|
-
}
|
|
617
|
-
}, {
|
|
618
|
-
quoted: message
|
|
619
|
-
})
|
|
620
|
-
|
|
621
|
-
// --- Quiz (newsletters only)
|
|
622
|
-
sock.sendMessage('1211111111111@newsletter', {
|
|
623
|
-
poll: {
|
|
624
|
-
name: '๐ฅ Quiz',
|
|
625
|
-
values: ['Yes', 'No'],
|
|
626
|
-
correctAnswer: 'Yes',
|
|
627
|
-
pollType: 1
|
|
628
|
-
}
|
|
629
|
-
})
|
|
630
|
-
|
|
631
|
-
// --- Poll result
|
|
632
|
-
sock.sendMessage(jid, {
|
|
633
|
-
pollResult: {
|
|
634
|
-
name: '๐ Poll Result',
|
|
635
|
-
votes: [{
|
|
636
|
-
name: 'Nice',
|
|
637
|
-
voteCount: 10
|
|
638
|
-
}, {
|
|
639
|
-
name: 'Nah',
|
|
640
|
-
voteCount: 2
|
|
641
|
-
}],
|
|
642
|
-
pollType: 0
|
|
643
|
-
}
|
|
644
|
-
})
|
|
645
|
-
|
|
646
|
-
// --- Poll update
|
|
647
|
-
sock.sendMessage(jid, {
|
|
648
|
-
pollUpdate: {
|
|
649
|
-
metadata: {},
|
|
650
|
-
key: message.key,
|
|
651
|
-
vote: {
|
|
652
|
-
enclv: /* <Buffer> */,
|
|
653
|
-
encPayload: /* <Buffer> */
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
})
|
|
657
|
-
```
|
|
658
|
-
|
|
659
|
-
#### ๐ญ Button Response
|
|
660
|
-
|
|
661
|
-
```javascript
|
|
662
|
-
// --- buttonsResponseMessage
|
|
663
|
-
sock.sendMessage(jid, {
|
|
664
|
-
type: 'plain',
|
|
665
|
-
buttonReply: {
|
|
666
|
-
id: '#Menu',
|
|
667
|
-
displayText: 'โจ Menu'
|
|
668
|
-
}
|
|
669
|
-
}, { quoted: message })
|
|
670
|
-
|
|
671
|
-
// --- interactiveResponseMessage
|
|
672
|
-
sock.sendMessage(jid, {
|
|
673
|
-
flowReply: {
|
|
674
|
-
format: 0,
|
|
675
|
-
text: '๐ญ Response',
|
|
676
|
-
name: 'menu_options',
|
|
677
|
-
paramsJson: JSON.stringify({
|
|
678
|
-
id: '#Menu',
|
|
679
|
-
description: 'โจ Menu'
|
|
680
|
-
})
|
|
681
|
-
}
|
|
682
|
-
}, { quoted: message })
|
|
683
|
-
|
|
684
|
-
// --- listResponseMessage
|
|
685
|
-
sock.sendMessage(jid, {
|
|
686
|
-
listReply: {
|
|
687
|
-
title: '๐ See More',
|
|
688
|
-
description: 'โจ Menu',
|
|
689
|
-
id: '#Menu'
|
|
690
|
-
}
|
|
691
|
-
}, { quoted: message })
|
|
692
|
-
|
|
693
|
-
// --- templateButtonReplyMessage
|
|
694
|
-
sock.sendMessage(jid, {
|
|
695
|
-
type: 'template',
|
|
696
|
-
buttonReply: {
|
|
697
|
-
id: '#Menu',
|
|
698
|
-
displayText: 'โจ Menu',
|
|
699
|
-
index: 1
|
|
700
|
-
}
|
|
701
|
-
}, { quoted: message })
|
|
702
|
-
```
|
|
703
|
-
|
|
704
|
-
#### โจ Rich Response
|
|
705
|
-
|
|
706
|
-
> [!NOTE]
|
|
707
|
-
> `richResponse[]` maps to `submessages[]` inside `richResponseMessage`.
|
|
708
|
-
|
|
709
|
-
```javascript
|
|
710
|
-
sock.sendMessage(jid, {
|
|
711
|
-
disclaimerText: 'RAW submessages structure example',
|
|
712
|
-
richResponse: [{
|
|
713
|
-
text: 'Example Usage',
|
|
714
|
-
}, {
|
|
715
|
-
language: 'javascript',
|
|
716
|
-
code: [{
|
|
717
|
-
highlightType: 0,
|
|
718
|
-
codeContent: 'console.log("Hello, World!")'
|
|
719
|
-
}]
|
|
720
|
-
}, {
|
|
721
|
-
text: 'Pretty simple, right?\n'
|
|
722
|
-
}, {
|
|
723
|
-
text: 'Runtime Comparison',
|
|
724
|
-
}, {
|
|
725
|
-
title: 'Runtime Comparison',
|
|
726
|
-
table: [{
|
|
727
|
-
isHeading: true,
|
|
728
|
-
items: ['', 'Node.js', 'Bun', 'Deno']
|
|
729
|
-
}, {
|
|
730
|
-
isHeading: false,
|
|
731
|
-
items: ['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)']
|
|
732
|
-
}, {
|
|
733
|
-
isHeading: false,
|
|
734
|
-
items: ['Performance', '4/5', '5/5', '4/5']
|
|
735
|
-
}]
|
|
736
|
-
}, {
|
|
737
|
-
text: 'Does this help clarify the differences?'
|
|
738
|
-
}]
|
|
739
|
-
})
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
> [!TIP]
|
|
743
|
-
> Use `tokenizeCode` for syntax highlighting:
|
|
744
|
-
|
|
745
|
-
```javascript
|
|
746
|
-
import { tokenizeCode } from '@lordmega/baileys'
|
|
747
|
-
|
|
748
|
-
const language = 'javascript'
|
|
749
|
-
const code = 'console.log("Hello, World!")'
|
|
750
|
-
|
|
751
|
-
sock.sendMessage(jid, {
|
|
752
|
-
disclaimerText: 'Tokenized Code Block',
|
|
753
|
-
richResponse: [{
|
|
754
|
-
text: 'Example',
|
|
755
|
-
}, {
|
|
756
|
-
language,
|
|
757
|
-
code: tokenizeCode(code, language)
|
|
758
|
-
}, {
|
|
759
|
-
text: 'Clean and simple.'
|
|
760
|
-
}]
|
|
761
|
-
})
|
|
762
|
-
```
|
|
763
|
-
|
|
764
|
-
> ๐ก Supported languages: `css`, `html`, `javascript`, `typescript`, `python`, `golang`, `rust`, `c`, `c#`, `c++`, `bash`, `bat`, `powershell`
|
|
765
|
-
|
|
766
|
-
#### ๐งพ Message with Code Block
|
|
767
|
-
|
|
768
|
-
```javascript
|
|
769
|
-
sock.sendMessage(jid, {
|
|
770
|
-
disclaimerText: 'Code Block',
|
|
771
|
-
headerText: '## Example Usage',
|
|
772
|
-
contentText: '---',
|
|
773
|
-
code: 'console.log("Hello, World!")',
|
|
774
|
-
language: 'javascript',
|
|
775
|
-
footerText: 'Pretty simple, right?'
|
|
776
|
-
})
|
|
777
|
-
```
|
|
778
|
-
|
|
779
|
-
#### ๐ Message with Inline Entities
|
|
780
|
-
|
|
781
|
-
```javascript
|
|
782
|
-
sock.sendMessage(jid, {
|
|
783
|
-
disclaimerText: 'Inline Entities',
|
|
784
|
-
headerText: '## Check Out!',
|
|
785
|
-
contentText: '---',
|
|
786
|
-
links: [{
|
|
787
|
-
text: '1. Google',
|
|
788
|
-
title: 'Popular Search Engine',
|
|
789
|
-
url: 'https://www.google.com/'
|
|
790
|
-
}, {
|
|
791
|
-
text: '2. YouTube',
|
|
792
|
-
title: 'Popular Streaming Platform',
|
|
793
|
-
url: 'https://www.youtube.com/'
|
|
794
|
-
}],
|
|
795
|
-
footerText: '---'
|
|
796
|
-
})
|
|
797
|
-
```
|
|
798
|
-
|
|
799
|
-
#### ๐ Message with Table
|
|
800
|
-
|
|
801
|
-
```javascript
|
|
802
|
-
sock.sendMessage(jid, {
|
|
803
|
-
disclaimerText: 'Table',
|
|
804
|
-
headerText: '## Runtime Comparison',
|
|
805
|
-
contentText: '---',
|
|
806
|
-
title: 'Node.js vs Bun vs Deno',
|
|
807
|
-
table: [
|
|
808
|
-
['', 'Node.js', 'Bun', 'Deno'],
|
|
809
|
-
['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)'],
|
|
810
|
-
['Performance', '4/5', '5/5', '4/5']
|
|
811
|
-
],
|
|
812
|
-
noHeading: false,
|
|
813
|
-
footerText: 'Does this help clarify things?'
|
|
814
|
-
})
|
|
815
|
-
```
|
|
816
|
-
|
|
817
|
-
#### ๐๏ธ Status Mention
|
|
818
|
-
|
|
819
|
-
```javascript
|
|
820
|
-
sock.sendMessage([jidA, jidB, jidC], {
|
|
821
|
-
text: 'Hello! ๐๐ป'
|
|
822
|
-
})
|
|
823
|
-
```
|
|
824
|
-
|
|
825
|
-
---
|
|
826
|
-
|
|
827
|
-
### ๐ Sending Media Messages
|
|
828
|
-
|
|
829
|
-
> [!NOTE]
|
|
830
|
-
> Media can be passed as a `Buffer`, `{ stream: Readable }`, or `{ url: string }` (local path or HTTP/HTTPS URL).
|
|
831
|
-
|
|
832
|
-
#### ๐ผ๏ธ Image
|
|
833
|
-
|
|
834
|
-
```javascript
|
|
835
|
-
sock.sendMessage(jid, {
|
|
836
|
-
image: { url: './path/to/image.jpg' },
|
|
837
|
-
caption: '๐ฅ Check this out'
|
|
838
|
-
}, { quoted: message })
|
|
839
|
-
```
|
|
840
|
-
|
|
841
|
-
#### ๐ฅ Video
|
|
842
|
-
|
|
843
|
-
```javascript
|
|
844
|
-
sock.sendMessage(jid, {
|
|
845
|
-
video: { url: './path/to/video.mp4' },
|
|
846
|
-
gifPlayback: false,
|
|
847
|
-
ptv: false,
|
|
848
|
-
caption: '๐ฅ Check this out'
|
|
849
|
-
}, { quoted: message })
|
|
850
|
-
```
|
|
851
|
-
|
|
852
|
-
#### ๐ Sticker
|
|
853
|
-
|
|
854
|
-
```javascript
|
|
855
|
-
sock.sendMessage(jid, {
|
|
856
|
-
sticker: { url: './path/to/sticker.webp' }
|
|
857
|
-
}, { quoted: message })
|
|
858
|
-
```
|
|
859
|
-
|
|
860
|
-
#### ๐ฝ Audio
|
|
861
|
-
|
|
862
|
-
```javascript
|
|
863
|
-
sock.sendMessage(jid, {
|
|
864
|
-
audio: { url: './path/to/audio.mp3' },
|
|
865
|
-
ptt: false // true for voice note
|
|
866
|
-
}, { quoted: message })
|
|
867
|
-
```
|
|
868
|
-
|
|
869
|
-
#### ๐๏ธ Document
|
|
870
|
-
|
|
871
|
-
```javascript
|
|
872
|
-
sock.sendMessage(jid, {
|
|
873
|
-
document: { url: './path/to/document.pdf' },
|
|
874
|
-
mimetype: 'application/pdf',
|
|
875
|
-
caption: 'โจ Document'
|
|
876
|
-
}, { quoted: message })
|
|
877
|
-
```
|
|
878
|
-
|
|
879
|
-
#### ๐ผ๏ธ Album (Image & Video)
|
|
880
|
-
|
|
881
|
-
```javascript
|
|
882
|
-
sock.sendMessage(jid, {
|
|
883
|
-
album: [{
|
|
884
|
-
image: { url: './path/to/image.jpg' },
|
|
885
|
-
caption: '1st image'
|
|
886
|
-
}, {
|
|
887
|
-
video: { url: './path/to/video.mp4' },
|
|
888
|
-
caption: '1st video'
|
|
889
|
-
}, {
|
|
890
|
-
image: { url: './path/to/image.jpg' },
|
|
891
|
-
caption: '2nd image'
|
|
892
|
-
}, {
|
|
893
|
-
video: { url: './path/to/video.mp4' },
|
|
894
|
-
caption: '2nd video'
|
|
895
|
-
}]
|
|
896
|
-
}, { quoted: message })
|
|
897
|
-
```
|
|
898
|
-
|
|
899
|
-
#### ๐ฆ Sticker Pack
|
|
900
|
-
|
|
901
|
-
> [!IMPORTANT]
|
|
902
|
-
> Without `sharp` or `@napi-rs/image` installed, all sticker files must already be in WebP format.
|
|
903
|
-
|
|
904
|
-
```javascript
|
|
905
|
-
sock.sendMessage(jid, {
|
|
906
|
-
cover: { url: './path/to/image.webp' },
|
|
907
|
-
stickers: [{
|
|
908
|
-
data: { url: './path/to/image.webp' }
|
|
909
|
-
}, {
|
|
910
|
-
data: { url: './path/to/image.webp' }
|
|
911
|
-
}],
|
|
912
|
-
name: '๐ฆ My Sticker Pack',
|
|
913
|
-
publisher: 'MegaBot',
|
|
914
|
-
description: 'Custom sticker pack'
|
|
915
|
-
}, { quoted: message })
|
|
916
|
-
```
|
|
917
|
-
|
|
918
|
-
---
|
|
919
|
-
|
|
920
|
-
### ๐๏ธ Reveal View-Once
|
|
921
|
-
|
|
922
|
-
Download a view-once message and resend it as normal media. Works for image, video, audio, document, and sticker. Downloads and re-uploads so it stays valid even after the original was opened.
|
|
923
|
-
|
|
924
|
-
```javascript
|
|
925
|
-
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
926
|
-
for (const m of messages) {
|
|
927
|
-
const vo = m.message?.viewOnceMessage
|
|
928
|
-
|| m.message?.viewOnceMessageV2
|
|
929
|
-
|| m.message?.viewOnceMessageV2Extension
|
|
930
|
-
if (vo) {
|
|
931
|
-
await sock.rvo(m) // resend to the original chat
|
|
932
|
-
// await sock.rvo(m, jid) // or to a specific jid
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
})
|
|
936
|
-
```
|
|
937
|
-
|
|
938
|
-
---
|
|
939
|
-
|
|
940
|
-
### ๐๐ป Sending Interactive Messages
|
|
941
|
-
|
|
942
|
-
#### ๐ Buttons
|
|
943
|
-
|
|
944
|
-
```javascript
|
|
945
|
-
// --- Basic buttons
|
|
946
|
-
sock.sendMessage(jid, {
|
|
947
|
-
text: '๐๐ป Buttons!',
|
|
948
|
-
footer: 'MegaBot',
|
|
949
|
-
buttons: [{
|
|
950
|
-
text: '๐๐ป Sign Up',
|
|
951
|
-
id: '#SignUp'
|
|
952
|
-
}]
|
|
953
|
-
}, { quoted: message })
|
|
954
|
-
|
|
955
|
-
// --- Buttons with media and native flow
|
|
956
|
-
sock.sendMessage(jid, {
|
|
957
|
-
image: { url: './path/to/image.jpg' },
|
|
958
|
-
caption: '๐๐ป Buttons with Native Flow!',
|
|
959
|
-
footer: 'MegaBot',
|
|
960
|
-
buttons: [{
|
|
961
|
-
text: '๐๐ป Rating',
|
|
962
|
-
id: '#Rating'
|
|
963
|
-
}, {
|
|
964
|
-
text: '๐ Select',
|
|
965
|
-
sections: [{
|
|
966
|
-
title: 'โจ Section 1',
|
|
967
|
-
rows: [{
|
|
968
|
-
header: '',
|
|
969
|
-
title: '๐ญ Secret Ingredient',
|
|
970
|
-
description: '',
|
|
971
|
-
id: '#SecretIngredient'
|
|
972
|
-
}]
|
|
973
|
-
}]
|
|
974
|
-
}]
|
|
975
|
-
}, { quoted: message })
|
|
976
|
-
```
|
|
977
|
-
|
|
978
|
-
#### ๐ List
|
|
979
|
-
|
|
980
|
-
> [!NOTE]
|
|
981
|
-
> Only works in private chats (`@s.whatsapp.net`).
|
|
982
|
-
|
|
983
|
-
```javascript
|
|
984
|
-
sock.sendMessage(jid, {
|
|
985
|
-
text: '๐ Pick an option',
|
|
986
|
-
footer: 'MegaBot',
|
|
987
|
-
buttonText: '๐ Select',
|
|
988
|
-
title: '๐๐ป Hello',
|
|
989
|
-
sections: [{
|
|
990
|
-
title: '๐ Menu 1',
|
|
991
|
-
rows: [{
|
|
992
|
-
title: 'โจ AI',
|
|
993
|
-
description: '',
|
|
994
|
-
rowId: '#AI'
|
|
995
|
-
}]
|
|
996
|
-
}, {
|
|
997
|
-
title: '๐ฑ Menu 2',
|
|
998
|
-
rows: [{
|
|
999
|
-
title: '๐ Search',
|
|
1000
|
-
description: '',
|
|
1001
|
-
rowId: '#Search'
|
|
1002
|
-
}]
|
|
1003
|
-
}]
|
|
1004
|
-
}, { quoted: message })
|
|
1005
|
-
```
|
|
1006
|
-
|
|
1007
|
-
#### ๐๏ธ Interactive
|
|
1008
|
-
|
|
1009
|
-
```javascript
|
|
1010
|
-
// --- Native flow
|
|
1011
|
-
sock.sendMessage(jid, {
|
|
1012
|
-
image: { url: './path/to/image.jpg' },
|
|
1013
|
-
caption: '๐๏ธ Interactive!',
|
|
1014
|
-
footer: 'MegaBot',
|
|
1015
|
-
optionText: '๐๐ป Select Options',
|
|
1016
|
-
optionTitle: '๐ Options',
|
|
1017
|
-
offerText: '๐ท๏ธ Latest Deal!',
|
|
1018
|
-
offerCode: 'MEGA2024',
|
|
1019
|
-
offerUrl: 'https://example.com',
|
|
1020
|
-
offerExpiration: Date.now() + 3_600_000,
|
|
1021
|
-
nativeFlow: [{
|
|
1022
|
-
text: '๐๐ป Greeting',
|
|
1023
|
-
id: '#Greeting',
|
|
1024
|
-
icon: 'review'
|
|
1025
|
-
}, {
|
|
1026
|
-
text: '๐ Call',
|
|
1027
|
-
call: '628123456789'
|
|
1028
|
-
}, {
|
|
1029
|
-
text: '๐ Copy',
|
|
1030
|
-
copy: 'some-text'
|
|
1031
|
-
}, {
|
|
1032
|
-
text: '๐ Visit',
|
|
1033
|
-
url: 'https://example.com',
|
|
1034
|
-
useWebview: true
|
|
1035
|
-
}, {
|
|
1036
|
-
text: '๐ Select',
|
|
1037
|
-
sections: [{
|
|
1038
|
-
title: 'โจ Section 1',
|
|
1039
|
-
rows: [{
|
|
1040
|
-
header: '',
|
|
1041
|
-
title: '๐ท๏ธ Option A',
|
|
1042
|
-
description: '',
|
|
1043
|
-
id: '#OptionA'
|
|
1044
|
-
}]
|
|
1045
|
-
}],
|
|
1046
|
-
icon: 'default'
|
|
1047
|
-
}],
|
|
1048
|
-
interactiveAsTemplate: false // Optional, wrap into templateMessage
|
|
1049
|
-
}, { quoted: message })
|
|
1050
|
-
|
|
1051
|
-
// --- Carousel with native flow
|
|
1052
|
-
sock.sendMessage(jid, {
|
|
1053
|
-
text: '๐๏ธ Carousel!',
|
|
1054
|
-
footer: 'MegaBot',
|
|
1055
|
-
cards: [{
|
|
1056
|
-
image: { url: './path/to/image.jpg' },
|
|
1057
|
-
caption: '๐ผ๏ธ Slide 1',
|
|
1058
|
-
footer: '๐ท๏ธ Tag',
|
|
1059
|
-
nativeFlow: [{
|
|
1060
|
-
text: '๐ Visit',
|
|
1061
|
-
url: 'https://example.com',
|
|
1062
|
-
useWebview: true
|
|
1063
|
-
}]
|
|
1064
|
-
}, {
|
|
1065
|
-
image: { url: './path/to/image.jpg' },
|
|
1066
|
-
caption: '๐ผ๏ธ Slide 2',
|
|
1067
|
-
footer: '๐ท๏ธ Tag',
|
|
1068
|
-
nativeFlow: [{
|
|
1069
|
-
text: '๐ Visit',
|
|
1070
|
-
url: 'https://example.com'
|
|
1071
|
-
}]
|
|
1072
|
-
}]
|
|
1073
|
-
}, { quoted: message })
|
|
1074
|
-
|
|
1075
|
-
// --- Native flow with audio footer
|
|
1076
|
-
sock.sendMessage(jid, {
|
|
1077
|
-
text: '๐ Audio in footer!',
|
|
1078
|
-
audioFooter: { url: './path/to/audio.mp3' },
|
|
1079
|
-
nativeFlow: [{
|
|
1080
|
-
text: '๐๐ป Next',
|
|
1081
|
-
id: '#Next',
|
|
1082
|
-
icon: 'review'
|
|
1083
|
-
}, {
|
|
1084
|
-
text: '๐๐ป Skip',
|
|
1085
|
-
id: '#Skip',
|
|
1086
|
-
icon: 'default'
|
|
1087
|
-
}]
|
|
1088
|
-
}, { quoted: message })
|
|
1089
|
-
```
|
|
1090
|
-
|
|
1091
|
-
#### ๐ซ Hydrated Template
|
|
1092
|
-
|
|
1093
|
-
```javascript
|
|
1094
|
-
sock.sendMessage(jid, {
|
|
1095
|
-
title: '๐๐ป Hello',
|
|
1096
|
-
image: { url: './path/to/image.jpg' },
|
|
1097
|
-
caption: '๐ซ Template!',
|
|
1098
|
-
footer: 'MegaBot',
|
|
1099
|
-
templateButtons: [{
|
|
1100
|
-
text: '๐๐ป Tap Here',
|
|
1101
|
-
id: '#Order'
|
|
1102
|
-
}, {
|
|
1103
|
-
text: '๐ Visit',
|
|
1104
|
-
url: 'https://example.com'
|
|
1105
|
-
}, {
|
|
1106
|
-
text: '๐ Call',
|
|
1107
|
-
call: '628123456789'
|
|
1108
|
-
}]
|
|
1109
|
-
}, { quoted: message })
|
|
1110
|
-
```
|
|
1111
|
-
|
|
1112
|
-
---
|
|
1113
|
-
|
|
1114
|
-
### ๐ณ Sending Payment Messages
|
|
1115
|
-
|
|
1116
|
-
#### โ Invite Payment
|
|
1117
|
-
|
|
1118
|
-
```javascript
|
|
1119
|
-
sock.sendMessage(jid, {
|
|
1120
|
-
paymentInviteServiceType: 3 // 1, 2, or 3
|
|
1121
|
-
})
|
|
1122
|
-
```
|
|
1123
|
-
|
|
1124
|
-
#### ๐งพ Invoice
|
|
1125
|
-
|
|
1126
|
-
> [!NOTE]
|
|
1127
|
-
> Invoice messages are not fully supported yet.
|
|
1128
|
-
|
|
1129
|
-
```javascript
|
|
1130
|
-
sock.sendMessage(jid, {
|
|
1131
|
-
image: { url: './path/to/image.jpg' },
|
|
1132
|
-
invoiceNote: '๐ท๏ธ Invoice'
|
|
1133
|
-
})
|
|
1134
|
-
```
|
|
1135
|
-
|
|
1136
|
-
#### ๐๏ธ Order
|
|
1137
|
-
|
|
1138
|
-
```javascript
|
|
1139
|
-
sock.sendMessage(jid, {
|
|
1140
|
-
orderText: '๐๏ธ Your Order',
|
|
1141
|
-
thumbnail: fs.readFileSync('./path/to/image.jpg') // Must be a Buffer
|
|
1142
|
-
}, { quoted: message })
|
|
1143
|
-
```
|
|
1144
|
-
|
|
1145
|
-
#### ๐ณ Request Payment
|
|
1146
|
-
|
|
1147
|
-
```javascript
|
|
1148
|
-
sock.sendMessage(jid, {
|
|
1149
|
-
text: '๐ณ Payment Request',
|
|
1150
|
-
requestPaymentFrom: '0@s.whatsapp.net'
|
|
1151
|
-
})
|
|
1152
|
-
```
|
|
1153
|
-
|
|
1154
|
-
---
|
|
1155
|
-
|
|
1156
|
-
### ๐๏ธ Other Message Options
|
|
1157
|
-
|
|
1158
|
-
#### ๐ค AI Icon
|
|
1159
|
-
|
|
1160
|
-
> [!NOTE]
|
|
1161
|
-
> Only works in private chats (`@s.whatsapp.net`).
|
|
1162
|
-
|
|
1163
|
-
```javascript
|
|
1164
|
-
sock.sendMessage(jid, {
|
|
1165
|
-
image: { url: './path/to/image.jpg' },
|
|
1166
|
-
caption: '๐ค AI-tagged message',
|
|
1167
|
-
ai: true
|
|
1168
|
-
}, { quoted: message })
|
|
1169
|
-
```
|
|
1170
|
-
|
|
1171
|
-
#### ๐ Ephemeral
|
|
1172
|
-
|
|
1173
|
-
```javascript
|
|
1174
|
-
sock.sendMessage(jid, {
|
|
1175
|
-
image: { url: './path/to/image.jpg' },
|
|
1176
|
-
caption: '๐๏ธ Ephemeral',
|
|
1177
|
-
ephemeral: true
|
|
1178
|
-
})
|
|
1179
|
-
```
|
|
1180
|
-
|
|
1181
|
-
#### ๐ฐ External Ad Reply
|
|
1182
|
-
|
|
1183
|
-
```javascript
|
|
1184
|
-
sock.sendMessage(jid, {
|
|
1185
|
-
text: '๐ฐ Ad Reply',
|
|
1186
|
-
externalAdReply: {
|
|
1187
|
-
title: '๐ Did you know?',
|
|
1188
|
-
body: 'โ Interesting fact',
|
|
1189
|
-
thumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
1190
|
-
largeThumbnail: false,
|
|
1191
|
-
url: 'https://example.com'
|
|
1192
|
-
}
|
|
1193
|
-
}, { quoted: message })
|
|
1194
|
-
```
|
|
1195
|
-
|
|
1196
|
-
#### ๐งโ๐งโ๐ง Group Status
|
|
1197
|
-
|
|
1198
|
-
> [!NOTE]
|
|
1199
|
-
> Only works in group chats (`@g.us`).
|
|
1200
|
-
|
|
1201
|
-
```javascript
|
|
1202
|
-
sock.sendMessage(jid, {
|
|
1203
|
-
image: { url: './path/to/image.jpg' },
|
|
1204
|
-
caption: '๐ฅ Group Status',
|
|
1205
|
-
groupStatus: true
|
|
1206
|
-
})
|
|
1207
|
-
```
|
|
1208
|
-
|
|
1209
|
-
#### ๐ฑ Lottie Sticker
|
|
1210
|
-
|
|
1211
|
-
```javascript
|
|
1212
|
-
sock.sendMessage(jid, {
|
|
1213
|
-
sticker: { url: './path/to/sticker.webp' },
|
|
1214
|
-
isLottie: true
|
|
1215
|
-
})
|
|
1216
|
-
```
|
|
1217
|
-
|
|
1218
|
-
#### ๐งฉ Raw
|
|
1219
|
-
|
|
1220
|
-
```javascript
|
|
1221
|
-
sock.sendMessage(jid, {
|
|
1222
|
-
extendedTextMessage: {
|
|
1223
|
-
text: '๐ Manually constructed proto message',
|
|
1224
|
-
contextInfo: {
|
|
1225
|
-
externalAdReply: {
|
|
1226
|
-
title: 'MegaBot',
|
|
1227
|
-
thumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
1228
|
-
sourceApp: 'whatsapp',
|
|
1229
|
-
showAdAttribution: true,
|
|
1230
|
-
mediaType: 1
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
},
|
|
1234
|
-
raw: true
|
|
1235
|
-
}, { quoted: message })
|
|
1236
|
-
```
|
|
1237
|
-
|
|
1238
|
-
#### ๐ท๏ธ Secure Meta Service Label
|
|
1239
|
-
|
|
1240
|
-
```javascript
|
|
1241
|
-
sock.sendMessage(jid, {
|
|
1242
|
-
text: '๐ท๏ธ Labeled message',
|
|
1243
|
-
secureMetaServiceLabel: true
|
|
1244
|
-
})
|
|
1245
|
-
```
|
|
1246
|
-
|
|
1247
|
-
#### ๐ Spoiler
|
|
1248
|
-
|
|
1249
|
-
```javascript
|
|
1250
|
-
sock.sendMessage(jid, {
|
|
1251
|
-
image: { url: './path/to/image.jpg' },
|
|
1252
|
-
caption: 'โ Spoiler',
|
|
1253
|
-
spoiler: true
|
|
1254
|
-
})
|
|
1255
|
-
```
|
|
1256
|
-
|
|
1257
|
-
#### ๐๏ธ View Once
|
|
1258
|
-
|
|
1259
|
-
```javascript
|
|
1260
|
-
sock.sendMessage(jid, {
|
|
1261
|
-
image: { url: './path/to/image.jpg' },
|
|
1262
|
-
caption: '๐๏ธ View Once',
|
|
1263
|
-
viewOnce: true
|
|
1264
|
-
})
|
|
1265
|
-
```
|
|
1266
|
-
|
|
1267
|
-
#### ๐๏ธ View Once V2
|
|
1268
|
-
|
|
1269
|
-
```javascript
|
|
1270
|
-
sock.sendMessage(jid, {
|
|
1271
|
-
image: { url: './path/to/image.jpg' },
|
|
1272
|
-
caption: '๐๏ธ View Once V2',
|
|
1273
|
-
viewOnceV2: true
|
|
1274
|
-
})
|
|
1275
|
-
```
|
|
1276
|
-
|
|
1277
|
-
#### ๐๏ธ View Once V2 Extension
|
|
1278
|
-
|
|
1279
|
-
```javascript
|
|
1280
|
-
sock.sendMessage(jid, {
|
|
1281
|
-
image: { url: './path/to/image.jpg' },
|
|
1282
|
-
caption: '๐๏ธ View Once V2 Extension',
|
|
1283
|
-
viewOnceV2Extension: true
|
|
1284
|
-
})
|
|
1285
|
-
```
|
|
1286
|
-
|
|
1287
|
-
#### ๐ Caller-Supplied messageSecret
|
|
1288
|
-
|
|
1289
|
-
Pass your own 32-byte `messageSecret` on any message type:
|
|
1290
|
-
|
|
1291
|
-
```javascript
|
|
1292
|
-
import { randomBytes } from 'crypto'
|
|
1293
|
-
|
|
1294
|
-
await sock.sendMessage(jid, { text: 'hi' }, { messageSecret: randomBytes(32) })
|
|
1295
|
-
```
|
|
1296
|
-
|
|
1297
|
-
---
|
|
1298
|
-
|
|
1299
|
-
### โป๏ธ Modify Messages
|
|
1300
|
-
|
|
1301
|
-
#### ๐๏ธ Delete Messages
|
|
1302
|
-
|
|
1303
|
-
```javascript
|
|
1304
|
-
sock.sendMessage(jid, {
|
|
1305
|
-
delete: message.key
|
|
1306
|
-
})
|
|
1307
|
-
```
|
|
1308
|
-
|
|
1309
|
-
#### โ๏ธ Edit Messages
|
|
1310
|
-
|
|
1311
|
-
```javascript
|
|
1312
|
-
// --- Edit text
|
|
1313
|
-
sock.sendMessage(jid, {
|
|
1314
|
-
text: 'โจ Corrected message',
|
|
1315
|
-
edit: message.key
|
|
1316
|
-
})
|
|
1317
|
-
|
|
1318
|
-
// --- Edit media caption
|
|
1319
|
-
sock.sendMessage(jid, {
|
|
1320
|
-
caption: 'โจ Updated caption',
|
|
1321
|
-
edit: message.key
|
|
1322
|
-
})
|
|
1323
|
-
```
|
|
1324
|
-
|
|
1325
|
-
> [!NOTE]
|
|
1326
|
-
> Encrypted E2EE message edits (May 2026+) are automatically decrypted โ edited messages arrive via the normal `protocolMessage.editedMessage` path.
|
|
1327
|
-
|
|
1328
|
-
---
|
|
1329
|
-
|
|
1330
|
-
### ๐งฐ Additional Contents
|
|
1331
|
-
|
|
1332
|
-
#### ๐ท๏ธ Find User ID (JID|PN/LID)
|
|
1333
|
-
|
|
1334
|
-
> [!NOTE]
|
|
1335
|
-
> Numbers only โ no `+`, `()`, or `-`. Must include country code.
|
|
1336
|
-
|
|
1337
|
-
```javascript
|
|
1338
|
-
const ids = await sock.findUserId('6281111111111@s.whatsapp.net')
|
|
1339
|
-
console.log('๐ท๏ธ User ID:', ids)
|
|
1340
|
-
|
|
1341
|
-
// Output:
|
|
1342
|
-
// { phoneNumber: '6281111111111@s.whatsapp.net', lid: '43411111111111@lid' }
|
|
1343
|
-
// On failure:
|
|
1344
|
-
// { phoneNumber: '6281111111111@s.whatsapp.net', lid: undefined }
|
|
1345
|
-
```
|
|
1346
|
-
|
|
1347
|
-
#### ๐ Request Custom Pairing Code
|
|
1348
|
-
|
|
1349
|
-
```javascript
|
|
1350
|
-
await sock.requestPairingCode('6281111111111', 'MYCODE')
|
|
1351
|
-
console.log('๐ Pairing code: MYCODE')
|
|
1352
|
-
```
|
|
1353
|
-
|
|
1354
|
-
#### ๐ผ๏ธ Image Processing
|
|
1355
|
-
|
|
1356
|
-
```javascript
|
|
1357
|
-
import { getImageProcessingLibrary } from '@lordmega/baileys'
|
|
1358
|
-
import { readFile } from 'fs/promises'
|
|
1359
|
-
|
|
1360
|
-
const lib = await getImageProcessingLibrary()
|
|
1361
|
-
const input = './path/to/image.jpg'
|
|
1362
|
-
const width = 512
|
|
1363
|
-
let output
|
|
1364
|
-
|
|
1365
|
-
if (lib.sharp?.default) {
|
|
1366
|
-
output = await lib.sharp.default(input)
|
|
1367
|
-
.resize(width)
|
|
1368
|
-
.jpeg({ quality: 80 })
|
|
1369
|
-
.toBuffer()
|
|
1370
|
-
}
|
|
1371
|
-
else if (lib.image?.Transformer) {
|
|
1372
|
-
const buf = Buffer.isBuffer(input) ? input : await readFile(input)
|
|
1373
|
-
output = await new lib.image.Transformer(buf)
|
|
1374
|
-
.resize(width, undefined, 0)
|
|
1375
|
-
.jpeg(50)
|
|
1376
|
-
}
|
|
1377
|
-
else if (lib.jimp?.Jimp) {
|
|
1378
|
-
output = await (await lib.jimp.Jimp.read(input))
|
|
1379
|
-
.resize({ w: width, mode: lib.jimp.ResizeStrategy.BILINEAR })
|
|
1380
|
-
.getBuffer('image/jpeg', { quality: 50 })
|
|
1381
|
-
}
|
|
1382
|
-
else {
|
|
1383
|
-
throw new Error('No image processing library available')
|
|
1384
|
-
}
|
|
1385
|
-
```
|
|
1386
|
-
|
|
1387
|
-
#### ๐ฃ Newsletter Management
|
|
1388
|
-
|
|
1389
|
-
```javascript
|
|
1390
|
-
sock.newsletterCreate('Name', 'Description')
|
|
1391
|
-
const metadata = sock.newsletterMetadata('1231111111111@newsletter')
|
|
1392
|
-
const subscribers = await sock.newsletterSubscribers('1231111111111@newsletter')
|
|
1393
|
-
sock.newsletterFollow('1231111111111@newsletter')
|
|
1394
|
-
sock.newsletterUnfollow('1231111111111@newsletter')
|
|
1395
|
-
sock.newsletterMute('1231111111111@newsletter')
|
|
1396
|
-
sock.newsletterUnmute('1231111111111@newsletter')
|
|
1397
|
-
sock.newsletterDemote('1231111111111@newsletter', '628...@s.whatsapp.net')
|
|
1398
|
-
sock.newsletterChangeOwner('1231111111111@newsletter', '628...@s.whatsapp.net')
|
|
1399
|
-
sock.newsletterUpdate('1231111111111@newsletter', { name: 'New Name' })
|
|
1400
|
-
sock.newsletterUpdateName('1231111111111@newsletter', 'New Name')
|
|
1401
|
-
sock.newsletterUpdateDescription('1231111111111@newsletter', 'New description')
|
|
1402
|
-
sock.newsletterUpdatePicture('1231111111111@newsletter', { url: 'path/to/image.jpg' })
|
|
1403
|
-
sock.newsletterRemovePicture('1231111111111@newsletter')
|
|
1404
|
-
sock.newsletterReactMessage('1231111111111@newsletter', '100', '๐')
|
|
1405
|
-
const count = await sock.newsletterAdminCount('1231111111111@newsletter')
|
|
1406
|
-
const newsletters = await sock.newsletterSubscribed()
|
|
1407
|
-
const messages = sock.newsletterFetchMessages('jid', '1231111111111@newsletter', 50, 0, 0)
|
|
1408
|
-
sock.newsletterDelete('1231111111111@newsletter')
|
|
1409
|
-
```
|
|
1410
|
-
|
|
1411
|
-
#### ๐ฅ Group Management
|
|
1412
|
-
|
|
1413
|
-
```javascript
|
|
1414
|
-
const group = sock.groupCreate('Group Name', ['628...@s.whatsapp.net'])
|
|
1415
|
-
const metadata = await sock.groupMetadata(jid)
|
|
1416
|
-
const inviteCode = await sock.groupInviteCode(jid)
|
|
1417
|
-
sock.groupRevokeInvite(jid)
|
|
1418
|
-
sock.groupAcceptInvite(inviteCode)
|
|
1419
|
-
sock.groupLeave(jid)
|
|
1420
|
-
sock.groupParticipantsUpdate(jid, ['628...@s.whatsapp.net'], 'add')
|
|
1421
|
-
sock.groupParticipantsUpdate(jid, ['628...@s.whatsapp.net'], 'remove')
|
|
1422
|
-
sock.groupParticipantsUpdate(jid, ['628...@s.whatsapp.net'], 'promote')
|
|
1423
|
-
sock.groupParticipantsUpdate(jid, ['628...@s.whatsapp.net'], 'demote')
|
|
1424
|
-
sock.groupRequestParticipantsUpdate(jid, ['628...@s.whatsapp.net'], 'approve')
|
|
1425
|
-
sock.groupUpdateSubject(jid, 'New Name')
|
|
1426
|
-
sock.groupUpdateDescription(jid, 'New description')
|
|
1427
|
-
sock.updateProfilePicture(jid, { url: 'path/to/image.jpg' })
|
|
1428
|
-
sock.removeProfilePicture(jid)
|
|
1429
|
-
sock.groupSettingUpdate(jid, 'announcement') // admin-only chat
|
|
1430
|
-
sock.groupSettingUpdate(jid, 'not_announcement') // open chat
|
|
1431
|
-
sock.groupSettingUpdate(jid, 'locked') // admin-only edits
|
|
1432
|
-
sock.groupSettingUpdate(jid, 'unlocked') // open edits
|
|
1433
|
-
sock.groupMemberAddMode(jid, 'admin_add')
|
|
1434
|
-
sock.groupMemberAddMode(jid, 'all_member_add')
|
|
1435
|
-
sock.groupToggleEphemeral(jid, 86400)
|
|
1436
|
-
sock.groupToggleEphemeral(jid, 0) // disable
|
|
1437
|
-
sock.groupJoinApprovalMode(jid, 'on')
|
|
1438
|
-
sock.groupJoinApprovalMode(jid, 'off')
|
|
1439
|
-
const groups = await sock.groupFetchAllParticipating()
|
|
1440
|
-
const requests = await sock.groupRequestParticipantsList(jid)
|
|
1441
|
-
const groupInfo = await sock.groupGetInviteInfo('ABC123456789')
|
|
1442
|
-
sock.updateMemberLabel(jid, 'label')
|
|
1443
|
-
```
|
|
1444
|
-
|
|
1445
|
-
#### ๐ฅ Community Management
|
|
1446
|
-
|
|
1447
|
-
```javascript
|
|
1448
|
-
const community = await sock.communityCreate('Name', 'Description')
|
|
1449
|
-
const group = await sock.communityCreateGroup('Announcements', ['628...@s.whatsapp.net'], communityJid)
|
|
1450
|
-
sock.communityLinkGroup(groupJid, communityJid)
|
|
1451
|
-
sock.communityUnlinkGroup(groupJid, communityJid)
|
|
1452
|
-
const metadata = await sock.communityMetadata(jid)
|
|
1453
|
-
const inviteCode = await sock.communityInviteCode(jid)
|
|
1454
|
-
sock.communityRevokeInvite(jid)
|
|
1455
|
-
sock.communityAcceptInvite(inviteCode)
|
|
1456
|
-
sock.communityLeave(jid)
|
|
1457
|
-
sock.communityRequestParticipantsUpdate(jid, ['628...@s.whatsapp.net'], 'approve')
|
|
1458
|
-
sock.communityUpdateSubject(jid, 'New Name')
|
|
1459
|
-
sock.communityUpdateDescription(jid, 'New description')
|
|
1460
|
-
sock.communitySettingUpdate(jid, 'announcement')
|
|
1461
|
-
sock.communitySettingUpdate(jid, 'locked')
|
|
1462
|
-
sock.communityMemberAddMode(jid, 'admin_add')
|
|
1463
|
-
sock.communityToggleEphemeral(jid, 86400)
|
|
1464
|
-
sock.communityJoinApprovalMode(jid, 'on')
|
|
1465
|
-
const communities = await sock.communityFetchAllParticipating()
|
|
1466
|
-
const linked = await sock.communityFetchLinkedGroups(jid)
|
|
1467
|
-
const requests = await sock.communityRequestParticipantsList(jid)
|
|
1468
|
-
const info = await sock.communityGetInviteInfo('ABC123456789')
|
|
1469
|
-
```
|
|
1470
|
-
|
|
1471
|
-
#### ๐ค Profile Management
|
|
1472
|
-
|
|
1473
|
-
```javascript
|
|
1474
|
-
const url = await sock.profilePictureUrl(jid, 'image')
|
|
1475
|
-
sock.updateProfilePicture(jid, buffer)
|
|
1476
|
-
sock.removeProfilePicture(jid)
|
|
1477
|
-
sock.updateProfileName('My Name')
|
|
1478
|
-
sock.updateProfileStatus('Available')
|
|
1479
|
-
sock.sendPresenceUpdate('available', jid)
|
|
1480
|
-
sock.presenceSubscribe(jid)
|
|
1481
|
-
sock.readMessages([message.key])
|
|
1482
|
-
sock.sendReceipt(jid, participant, [messageId], 'read')
|
|
1483
|
-
sock.updateBlockStatus(jid, 'block')
|
|
1484
|
-
sock.updateBlockStatus(jid, 'unblock')
|
|
1485
|
-
const blocked = await sock.fetchBlocklist()
|
|
1486
|
-
sock.chatModify({ archive: true, lastMessageOrig: message, lastMessage: message }, jid)
|
|
1487
|
-
sock.star(jid, [{ id: messageId, fromMe: true }], true)
|
|
1488
|
-
sock.addOrEditContact(jid, { displayName: 'Name' })
|
|
1489
|
-
sock.removeContact(jid)
|
|
1490
|
-
sock.addChatLabel(jid, labelId)
|
|
1491
|
-
sock.removeChatLabel(jid, labelId)
|
|
1492
|
-
sock.addMessageLabel(jid, messageId, labelId)
|
|
1493
|
-
sock.resyncAppState(['regular', 'critical_block'], true)
|
|
1494
|
-
const profile = await sock.getBusinessProfile(jid)
|
|
1495
|
-
```
|
|
1496
|
-
|
|
1497
|
-
#### ๐ Business Management
|
|
1498
|
-
|
|
1499
|
-
```javascript
|
|
1500
|
-
const product = await sock.productCreate({
|
|
1501
|
-
name: 'Product Name',
|
|
1502
|
-
description: 'Description',
|
|
1503
|
-
price: 100000,
|
|
1504
|
-
currency: 'IDR',
|
|
1505
|
-
originCountryCode: 'ID',
|
|
1506
|
-
images: [bufferImage, { url: './path/to/image.jpg' }]
|
|
1507
|
-
})
|
|
1508
|
-
|
|
1509
|
-
await sock.productUpdate(productId, {
|
|
1510
|
-
name: 'Updated Name',
|
|
1511
|
-
price: 75000,
|
|
1512
|
-
currency: 'IDR',
|
|
1513
|
-
images: [{ url: './path/to/image.jpg' }]
|
|
1514
|
-
})
|
|
1515
|
-
|
|
1516
|
-
sock.productDelete([productId])
|
|
1517
|
-
|
|
1518
|
-
const { products, nextPageCursor } = await sock.getCatalog({
|
|
1519
|
-
jid: '628...@s.whatsapp.net',
|
|
1520
|
-
limit: 10
|
|
1521
|
-
})
|
|
1522
|
-
|
|
1523
|
-
const collections = await sock.getCollections('628...@s.whatsapp.net', 10)
|
|
1524
|
-
const order = await sock.getOrderDetails(orderId, tokenBase64)
|
|
1525
|
-
|
|
1526
|
-
await sock.updateBusinessProfile({
|
|
1527
|
-
address: 'Jakarta, Indonesia',
|
|
1528
|
-
description: 'Official Store',
|
|
1529
|
-
websites: ['https://example.com'],
|
|
1530
|
-
email: 'contact@example.com',
|
|
1531
|
-
hours: {
|
|
1532
|
-
timezone: 'Asia/Jakarta',
|
|
1533
|
-
days: [{ day: 'mon', mode: 'open_24h' }]
|
|
1534
|
-
}
|
|
1535
|
-
})
|
|
1536
|
-
|
|
1537
|
-
sock.updateCoverPhoto({ url: './path/to/image.jpg' })
|
|
1538
|
-
sock.removeCoverPhoto(coverId)
|
|
1539
|
-
sock.addOrEditQuickReply({ shortcut: 'hello', message: 'Hello!' })
|
|
1540
|
-
sock.removeQuickReply(timestamp)
|
|
1541
|
-
```
|
|
1542
|
-
|
|
1543
|
-
#### ๐ Privacy Management
|
|
1544
|
-
|
|
1545
|
-
```javascript
|
|
1546
|
-
sock.updateLastSeenPrivacy('all' | 'contacts' | 'contact_blacklist' | 'nobody')
|
|
1547
|
-
sock.updateOnlinePrivacy('all' | 'match_last_seen')
|
|
1548
|
-
sock.updateProfilePicturePrivacy('contacts')
|
|
1549
|
-
sock.updateStatusPrivacy('contacts')
|
|
1550
|
-
sock.updateReadReceiptsPrivacy('all' | 'none')
|
|
1551
|
-
sock.updateGroupsAddPrivacy('all' | 'contacts')
|
|
1552
|
-
sock.updateMessagesPrivacy('all' | 'contacts' | 'nobody')
|
|
1553
|
-
sock.updateCallPrivacy('everyone')
|
|
1554
|
-
sock.updateDefaultDisappearingMode(86400)
|
|
1555
|
-
sock.updateDisableLinkPreviewsPrivacy(true)
|
|
1556
|
-
```
|
|
1557
|
-
|
|
1558
|
-
#### ๐ก Events
|
|
1559
|
-
|
|
1560
|
-
```javascript
|
|
1561
|
-
sock.ev.on('connection.update', (update) => {})
|
|
1562
|
-
sock.ev.on('creds.update', (update) => {})
|
|
1563
|
-
sock.ev.on('messaging-history.set', (update) => {})
|
|
1564
|
-
sock.ev.on('messaging-history.status', (update) => {})
|
|
1565
|
-
sock.ev.on('chats.upsert', (update) => {})
|
|
1566
|
-
sock.ev.on('chats.update', (update) => {})
|
|
1567
|
-
sock.ev.on('chats.delete', (update) => {})
|
|
1568
|
-
sock.ev.on('chats.lock', (update) => {})
|
|
1569
|
-
sock.ev.on('lid-mapping.update', (update) => {})
|
|
1570
|
-
sock.ev.on('presence.update', (update) => {})
|
|
1571
|
-
sock.ev.on('contacts.upsert', (update) => {})
|
|
1572
|
-
sock.ev.on('contacts.update', (update) => {})
|
|
1573
|
-
sock.ev.on('messages.delete', (update) => {})
|
|
1574
|
-
sock.ev.on('messages.update', (update) => {})
|
|
1575
|
-
sock.ev.on('messages.media-update', (update) => {})
|
|
1576
|
-
sock.ev.on('messages.upsert', (update) => {})
|
|
1577
|
-
sock.ev.on('messages.reaction', (update) => {})
|
|
1578
|
-
sock.ev.on('message-receipt.update', (update) => {})
|
|
1579
|
-
sock.ev.on('groups.upsert', (update) => {})
|
|
1580
|
-
sock.ev.on('groups.update', (update) => {})
|
|
1581
|
-
sock.ev.on('group-participants.update', (update) => {})
|
|
1582
|
-
sock.ev.on('group.join-request', (update) => {})
|
|
1583
|
-
sock.ev.on('group.member-tag.update', (update) => {})
|
|
1584
|
-
sock.ev.on('blocklist.set', (update) => {})
|
|
1585
|
-
sock.ev.on('blocklist.update', (update) => {})
|
|
1586
|
-
sock.ev.on('call', (update) => {})
|
|
1587
|
-
sock.ev.on('labels.edit', (update) => {})
|
|
1588
|
-
sock.ev.on('labels.association', (update) => {})
|
|
1589
|
-
sock.ev.on('newsletter.reaction', (update) => {})
|
|
1590
|
-
sock.ev.on('newsletter.view', (update) => {})
|
|
1591
|
-
sock.ev.on('newsletter-participants.update', (update) => {})
|
|
1592
|
-
sock.ev.on('newsletter-settings.update', (update) => {})
|
|
1593
|
-
sock.ev.on('settings.update', (update) => {})
|
|
1594
|
-
```
|
|
1595
|
-
|
|
1596
|
-
---
|
|
1597
|
-
|
|
1598
88
|
### ๐ Try the Bot
|
|
1599
89
|
|
|
1600
90
|
A lightweight, modular WhatsApp bot built on this library โ includes group management, moderation, quiz games, and utility tools.
|