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