@itsliaaa/baileys 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +1078 -0
- package/WAProto/index.js +100441 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.js +144 -0
- package/lib/Signal/Group/ciphertext-message.js +11 -0
- package/lib/Signal/Group/group-session-builder.js +29 -0
- package/lib/Signal/Group/group_cipher.js +81 -0
- package/lib/Signal/Group/index.js +11 -0
- package/lib/Signal/Group/keyhelper.js +17 -0
- package/lib/Signal/Group/sender-chain-key.js +25 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
- package/lib/Signal/Group/sender-key-message.js +65 -0
- package/lib/Signal/Group/sender-key-name.js +47 -0
- package/lib/Signal/Group/sender-key-record.js +40 -0
- package/lib/Signal/Group/sender-key-state.js +83 -0
- package/lib/Signal/Group/sender-message-key.js +25 -0
- package/lib/Signal/libsignal.js +402 -0
- package/lib/Signal/lid-mapping.js +270 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.js +378 -0
- package/lib/Socket/chats.js +1048 -0
- package/lib/Socket/communities.js +430 -0
- package/lib/Socket/groups.js +328 -0
- package/lib/Socket/index.js +11 -0
- package/lib/Socket/messages-recv.js +1442 -0
- package/lib/Socket/messages-send.js +1153 -0
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.js +227 -0
- package/lib/Socket/socket.js +936 -0
- package/lib/Store/index.js +3 -0
- package/lib/Store/make-in-memory-store.js +421 -0
- package/lib/Store/make-ordered-dictionary.js +78 -0
- package/lib/Store/object-repository.js +23 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.js +24 -0
- package/lib/Types/LabelAssociation.js +6 -0
- package/lib/Types/Message.js +17 -0
- package/lib/Types/Newsletter.js +33 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +12 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.js +25 -0
- package/lib/Utils/auth-utils.js +289 -0
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/business.js +230 -0
- package/lib/Utils/chat-utils.js +811 -0
- package/lib/Utils/crypto.js +117 -0
- package/lib/Utils/decode-wa-message.js +282 -0
- package/lib/Utils/event-buffer.js +573 -0
- package/lib/Utils/generics.js +385 -0
- package/lib/Utils/history.js +130 -0
- package/lib/Utils/identity-change-handler.js +48 -0
- package/lib/Utils/index.js +19 -0
- package/lib/Utils/link-preview.js +84 -0
- package/lib/Utils/logger.js +2 -0
- package/lib/Utils/lt-hash.js +7 -0
- package/lib/Utils/make-mutex.js +32 -0
- package/lib/Utils/message-retry-manager.js +224 -0
- package/lib/Utils/messages-media.js +789 -0
- package/lib/Utils/messages.js +1832 -0
- package/lib/Utils/noise-handler.js +200 -0
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.js +527 -0
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/signal.js +158 -0
- package/lib/Utils/sync-action-utils.js +47 -0
- package/lib/Utils/tc-token-utils.js +17 -0
- package/lib/Utils/use-multi-file-auth-state.js +120 -0
- package/lib/Utils/validate-connection.js +206 -0
- package/lib/WABinary/constants.js +1300 -0
- package/lib/WABinary/decode.js +261 -0
- package/lib/WABinary/encode.js +219 -0
- package/lib/WABinary/generic-utils.js +197 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.js +95 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.js +9 -0
- package/lib/WAM/constants.js +22852 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
- package/lib/WAUSync/Protocols/index.js +4 -0
- package/lib/WAUSync/USyncQuery.js +93 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/index.js +11 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,1078 @@
|
|
|
1
|
+
# 🌱 @itsliaaa/baileys
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
A lightweight fork of Baileys with a few fixes and a small adjustment.
|
|
6
|
+
|
|
7
|
+
### ⚙️ **Changes**
|
|
8
|
+
|
|
9
|
+
#### 🛠️ Internal Adjustments
|
|
10
|
+
- 🖼️ Fixed an issue where media could not be sent to newsletters due to an upstream issue.
|
|
11
|
+
- 📁 Reintroduced `makeInMemoryStore` with a minimal ESM adaptation and small adjustments for Baileys v7.
|
|
12
|
+
- 📦 Switched FFmpeg execution from `exec` to `spawn` for safer process handling.
|
|
13
|
+
|
|
14
|
+
#### 📨 Message Handling & Compatibility
|
|
15
|
+
- 👉🏻 Added support for sending interactive message types (button, list, interactive, template, carousel).
|
|
16
|
+
- 📩 Added support for album messages, group status messages, sticker pack messages, and several payment-related messages (request payment, payment invite, order, invoice).
|
|
17
|
+
- 📰 Simplified sending messages with ad thumbnails via `externalAdReply` without requiring manual `contextInfo`.
|
|
18
|
+
|
|
19
|
+
#### 🧩 Additional Message Options
|
|
20
|
+
- 👁️ Added optional boolean flags for message handling:
|
|
21
|
+
- `ai` - AI label on message
|
|
22
|
+
- `ephemeral`, `groupStatus`, `viewOnceV2`, `viewOnceV2Extension`, `interactiveAsTemplate` - Message wrappers
|
|
23
|
+
- `raw` - Build your message manually **(DO NOT USE FOR EXPLOITATION)**
|
|
24
|
+
|
|
25
|
+
> [!NOTE]
|
|
26
|
+
📄 This project is maintained with limited scope and is not intended to replace upstream Baileys.
|
|
27
|
+
>
|
|
28
|
+
> 😞 And, really sorry for my bad english.
|
|
29
|
+
|
|
30
|
+
### 📥 **Installation**
|
|
31
|
+
|
|
32
|
+
- 📄 Via `package.json`
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
# NPM
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@itsliaaa/baileys": "latest"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# GitHub
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@itsliaaa/baileys": "github:itsliaaa/baileys"
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- ⌨️ Via terminal
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# NPM
|
|
50
|
+
npm i @itsliaaa/baileys@latest
|
|
51
|
+
|
|
52
|
+
# GitHub
|
|
53
|
+
npm i github:itsliaaa/baileys
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### 🧩 Import (ESM & CJS)
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
// --- ESM
|
|
60
|
+
import { makeWASocket } from '@itsliaaa/baileys'
|
|
61
|
+
|
|
62
|
+
// --- CJS (tested and working on Node.js 24 ✅)
|
|
63
|
+
const { makeWASocket } = require('@itsliaaa/baileys')
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 🔧 **Usage**
|
|
67
|
+
|
|
68
|
+
#### 🌐 Connect to WhatsApp (Quick Step)
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from '@itsliaaa/baileys'
|
|
72
|
+
import { Boom } from '@hapi/boom'
|
|
73
|
+
import pino from 'pino'
|
|
74
|
+
|
|
75
|
+
// --- Connect with pairing code
|
|
76
|
+
const myPhoneNumber = '6288888888888'
|
|
77
|
+
|
|
78
|
+
const logger = pino({ level: 'silent' })
|
|
79
|
+
|
|
80
|
+
const connectToWhatsApp = async () => {
|
|
81
|
+
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
82
|
+
|
|
83
|
+
const sock = makeWASocket({
|
|
84
|
+
logger,
|
|
85
|
+
auth: state
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
sock.ev.on('creds.update', saveCreds)
|
|
89
|
+
|
|
90
|
+
sock.ev.on('connection.update', (update) => {
|
|
91
|
+
const { connection, lastDisconnect } = update
|
|
92
|
+
if (connection === 'connecting' && !sock.authState.creds.registered) {
|
|
93
|
+
await delay(1500)
|
|
94
|
+
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
95
|
+
console.log('🔗 Pairing code', ':', code)
|
|
96
|
+
}
|
|
97
|
+
else if (connection === 'close') {
|
|
98
|
+
const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
99
|
+
console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
|
|
100
|
+
if (shouldReconnect) {
|
|
101
|
+
connectToWhatsApp()
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else if (connection === 'open') {
|
|
105
|
+
console.log('✅ Successfully connected to WhatsApp')
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
110
|
+
for (const message of messages) {
|
|
111
|
+
if (!message.message) continue
|
|
112
|
+
|
|
113
|
+
console.log('🔔 Got new message', ':', message)
|
|
114
|
+
await sock.sendMessage(message.key.remoteJid, {
|
|
115
|
+
text: '👋🏻 Hello world'
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
connectToWhatsApp()
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### 🗄️ Implementing a Data Store
|
|
125
|
+
|
|
126
|
+
> [!CAUTION]
|
|
127
|
+
I highly recommend building your own data store, as keeping an entire chat history in memory can lead to excessive RAM usage.
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
import { makeWASocket, makeInMemoryStore, delay, DisconnectReason, useMultiFileAuthState } from '@itsliaaa/baileys'
|
|
131
|
+
import { Boom } from '@hapi/boom'
|
|
132
|
+
import pino from 'pino'
|
|
133
|
+
|
|
134
|
+
const myPhoneNumber = '6288888888888'
|
|
135
|
+
|
|
136
|
+
// --- Create your store path
|
|
137
|
+
const storePath = './store.json'
|
|
138
|
+
|
|
139
|
+
const logger = pino({ level: 'silent' })
|
|
140
|
+
|
|
141
|
+
const connectToWhatsApp = async () => {
|
|
142
|
+
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
143
|
+
|
|
144
|
+
const sock = makeWASocket({
|
|
145
|
+
logger,
|
|
146
|
+
auth: state
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
const store = makeInMemoryStore({
|
|
150
|
+
logger,
|
|
151
|
+
socket: sock
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
store.bind(sock.ev)
|
|
155
|
+
|
|
156
|
+
sock.ev.on('creds.update', saveCreds)
|
|
157
|
+
|
|
158
|
+
sock.ev.on('connection.update', (update) => {
|
|
159
|
+
const { connection, lastDisconnect } = update
|
|
160
|
+
if (connection === 'connecting' && !sock.authState.creds.registered) {
|
|
161
|
+
await delay(1500)
|
|
162
|
+
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
163
|
+
console.log('🔗 Pairing code', ':', code)
|
|
164
|
+
}
|
|
165
|
+
else if (connection === 'close') {
|
|
166
|
+
const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
167
|
+
console.log('⚠️ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
|
|
168
|
+
if (shouldReconnect) {
|
|
169
|
+
connectToWhatsApp()
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else if (connection === 'open') {
|
|
173
|
+
console.log('✅ Successfully connected to WhatsApp')
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
sock.ev.on('chats.upsert', () => {
|
|
178
|
+
console.log('✉️ Got chats', store.chats.all())
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
sock.ev.on('contacts.upsert', () => {
|
|
182
|
+
console.log('👥 Got contacts', Object.values(store.contacts))
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
// --- Read store from file
|
|
186
|
+
store.readFromFile(storePath)
|
|
187
|
+
|
|
188
|
+
// --- Save store every 3 minutes
|
|
189
|
+
setInterval(() => {
|
|
190
|
+
store.writeToFile(storePath)
|
|
191
|
+
}, 180000)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
connectToWhatsApp()
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
#### 🪪 WhatsApp IDs Explain
|
|
198
|
+
|
|
199
|
+
`id` is the WhatsApp ID, called `jid` and `lid` too, of the person or group you're sending the message to.
|
|
200
|
+
- It must be in the format `[country code][phone number]@s.whatsapp.net`
|
|
201
|
+
- Example for people: `19999999999@s.whatsapp.net` and `12699999999@lid`.
|
|
202
|
+
- For groups, it must be in the format `123456789-123345@g.us`.
|
|
203
|
+
- For Meta AI, it's `11111111111@bot`.
|
|
204
|
+
- For broadcast lists, it's `[timestamp of creation]@broadcast`.
|
|
205
|
+
- For stories, the ID is `status@broadcast`.
|
|
206
|
+
|
|
207
|
+
#### ✉️ Sending Messages
|
|
208
|
+
|
|
209
|
+
> [!NOTE]
|
|
210
|
+
You can get the `jid` from `message.key.remoteJid` in the first example.
|
|
211
|
+
|
|
212
|
+
##### 🔠 Text
|
|
213
|
+
|
|
214
|
+
```javascript
|
|
215
|
+
sock.sendMessage(jid, {
|
|
216
|
+
text: '👋🏻 Hello'
|
|
217
|
+
}, {
|
|
218
|
+
quoted: message
|
|
219
|
+
})
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
##### 🔔 Mention
|
|
223
|
+
|
|
224
|
+
```javascript
|
|
225
|
+
sock.sendMessage(jid, {
|
|
226
|
+
text: '👋🏻 Hello @628123456789',
|
|
227
|
+
mentions: ['628123456789@s.whatsapp.net']
|
|
228
|
+
}, {
|
|
229
|
+
quoted: message
|
|
230
|
+
})
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
##### 😁 Reaction
|
|
234
|
+
|
|
235
|
+
```javascript
|
|
236
|
+
sock.sendMessage(jid, {
|
|
237
|
+
react: {
|
|
238
|
+
key: message.key,
|
|
239
|
+
text: '✨'
|
|
240
|
+
}
|
|
241
|
+
}, {
|
|
242
|
+
quoted: message
|
|
243
|
+
})
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
##### 📌 Pin Message
|
|
247
|
+
|
|
248
|
+
```javascript
|
|
249
|
+
sock.sendMessage(jid, {
|
|
250
|
+
pin: message.key,
|
|
251
|
+
time: 86400, // --- Set the value in seconds: 86400 (1d), 604800 (7d), or 2592000 (30d)
|
|
252
|
+
type: 1 // --- Or 0 to remove
|
|
253
|
+
}, {
|
|
254
|
+
quoted: message
|
|
255
|
+
})
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
##### 👤 Contact
|
|
259
|
+
|
|
260
|
+
```javascript
|
|
261
|
+
const vcard = 'BEGIN:VCARD\n'
|
|
262
|
+
+ 'VERSION:3.0\n'
|
|
263
|
+
+ 'FN:Elia Wynn\n'
|
|
264
|
+
+ 'ORG:Waiters;\n'
|
|
265
|
+
+ 'TEL;type=CELL;type=VOICE;waid=628123456789:+62 8123 4567 89\n'
|
|
266
|
+
+ 'END:VCARD'
|
|
267
|
+
|
|
268
|
+
sock.sendMessage(jid, {
|
|
269
|
+
contacts: {
|
|
270
|
+
displayName: 'Elia',
|
|
271
|
+
contacts: [
|
|
272
|
+
{ vcard }
|
|
273
|
+
]
|
|
274
|
+
}
|
|
275
|
+
}, {
|
|
276
|
+
quoted: message
|
|
277
|
+
})
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
##### 📍 Location
|
|
281
|
+
|
|
282
|
+
```javascript
|
|
283
|
+
sock.sendMessage(jid, {
|
|
284
|
+
location: {
|
|
285
|
+
degreesLatitude: 24.121231,
|
|
286
|
+
degreesLongitude: 55.1121221,
|
|
287
|
+
name: '👋🏻 I am here'
|
|
288
|
+
}
|
|
289
|
+
}, {
|
|
290
|
+
quoted: message
|
|
291
|
+
})
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
##### 📊 Poll
|
|
295
|
+
|
|
296
|
+
```javascript
|
|
297
|
+
// --- Regular poll message
|
|
298
|
+
sock.sendMessage(jid, {
|
|
299
|
+
poll: {
|
|
300
|
+
name: '🔥 Voting time',
|
|
301
|
+
values: ['Yes', 'No'],
|
|
302
|
+
selectableCount: 1,
|
|
303
|
+
toAnnouncementGroup: false
|
|
304
|
+
}
|
|
305
|
+
}, {
|
|
306
|
+
quoted: message
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
// --- Quiz (only for newsletter)
|
|
310
|
+
sock.sendMessage('1211111111111@newsletter', {
|
|
311
|
+
poll: {
|
|
312
|
+
name: '🔥 Quiz',
|
|
313
|
+
values: ['Yes', 'No'],
|
|
314
|
+
correctAnswer: 'Yes',
|
|
315
|
+
pollType: 1
|
|
316
|
+
}
|
|
317
|
+
}, {
|
|
318
|
+
quoted: message
|
|
319
|
+
})
|
|
320
|
+
|
|
321
|
+
// Poll result
|
|
322
|
+
sock.sendMessage(jid, {
|
|
323
|
+
pollResult: {
|
|
324
|
+
name: '📝 Poll Result',
|
|
325
|
+
votes: [{
|
|
326
|
+
name: 'Nice',
|
|
327
|
+
voteCount: 10
|
|
328
|
+
}, {
|
|
329
|
+
name: 'Nah',
|
|
330
|
+
voteCount: 2
|
|
331
|
+
}],
|
|
332
|
+
pollType: 0 // Or 1 for quiz
|
|
333
|
+
}
|
|
334
|
+
}, {
|
|
335
|
+
quoted: message
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
// Poll update
|
|
339
|
+
sock.sendMessage(jid, {
|
|
340
|
+
pollUpdate: {
|
|
341
|
+
metadata: {},
|
|
342
|
+
key: message.key,
|
|
343
|
+
vote: {
|
|
344
|
+
enclv: /* <Buffer> */,
|
|
345
|
+
encPayload: /* <Buffer> */
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}, {
|
|
349
|
+
quoted: message
|
|
350
|
+
})
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
#### 📁 Sending Media Messages
|
|
354
|
+
|
|
355
|
+
> [!NOTE]
|
|
356
|
+
For media messages, you can pass a `Buffer` directly, or an object with either `{ stream: Readable }` or `{ url: string }` (local file path or HTTP/HTTPS URL).
|
|
357
|
+
|
|
358
|
+
##### 🖼️ Image
|
|
359
|
+
|
|
360
|
+
```javascript
|
|
361
|
+
sock.sendMessage(jid, {
|
|
362
|
+
image: {
|
|
363
|
+
url: './path/to/image.jpg'
|
|
364
|
+
},
|
|
365
|
+
caption: '🔥 Superb'
|
|
366
|
+
}, {
|
|
367
|
+
quoted: message
|
|
368
|
+
})
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
##### 🎥 Video
|
|
372
|
+
|
|
373
|
+
```javascript
|
|
374
|
+
sock.sendMessage(jid, {
|
|
375
|
+
video: {
|
|
376
|
+
url: './path/to/video.mp4'
|
|
377
|
+
},
|
|
378
|
+
gifPlayback: false, // --- Set true if you want to send video as GIF
|
|
379
|
+
ptv: false, // --- Set true if you want to send video as PTV
|
|
380
|
+
caption: '🔥 Superb'
|
|
381
|
+
}, {
|
|
382
|
+
quoted: message
|
|
383
|
+
})
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
##### 📃 Sticker
|
|
387
|
+
|
|
388
|
+
```javascript
|
|
389
|
+
sock.sendMessage(jid, {
|
|
390
|
+
sticker: {
|
|
391
|
+
url: './path/to/sticker.webp'
|
|
392
|
+
}
|
|
393
|
+
}, {
|
|
394
|
+
quoted: message
|
|
395
|
+
})
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
##### 💽 Audio
|
|
399
|
+
|
|
400
|
+
```javascript
|
|
401
|
+
sock.sendMessage(jid, {
|
|
402
|
+
audio: {
|
|
403
|
+
url: './path/to/audio.mp3'
|
|
404
|
+
},
|
|
405
|
+
ptt: false, // --- Set true if you want to send audio as Voice Note
|
|
406
|
+
}, {
|
|
407
|
+
quoted: message
|
|
408
|
+
})
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
##### 🖼️ Album (Image & Video)
|
|
412
|
+
|
|
413
|
+
```javascript
|
|
414
|
+
sock.sendMessage(jid, {
|
|
415
|
+
album: [{
|
|
416
|
+
image: {
|
|
417
|
+
url: './path/to/image.jpg'
|
|
418
|
+
},
|
|
419
|
+
caption: '1st image'
|
|
420
|
+
}, {
|
|
421
|
+
video: {
|
|
422
|
+
url: './path/to/video.mp4'
|
|
423
|
+
},
|
|
424
|
+
caption: '1st video'
|
|
425
|
+
}, {
|
|
426
|
+
image: {
|
|
427
|
+
url: './path/to/image.jpg'
|
|
428
|
+
},
|
|
429
|
+
caption: '2nd image'
|
|
430
|
+
}, {
|
|
431
|
+
video: {
|
|
432
|
+
url: './path/to/video.mp4'
|
|
433
|
+
},
|
|
434
|
+
caption: '2nd video'
|
|
435
|
+
}]
|
|
436
|
+
}, {
|
|
437
|
+
quoted: message
|
|
438
|
+
})
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
##### 📦 Sticker Pack
|
|
442
|
+
|
|
443
|
+
> [!IMPORTANT]
|
|
444
|
+
If Sharp is not installed, the `cover` and `stickers` must already be in WebP format.
|
|
445
|
+
|
|
446
|
+
```javascript
|
|
447
|
+
sock.sendMessage(jid, {
|
|
448
|
+
cover: {
|
|
449
|
+
url: './path/to/image.webp'
|
|
450
|
+
},
|
|
451
|
+
stickers: [{
|
|
452
|
+
data: {
|
|
453
|
+
url: './path/to/image.webp'
|
|
454
|
+
}
|
|
455
|
+
}, {
|
|
456
|
+
data: {
|
|
457
|
+
url: './path/to/image.webp'
|
|
458
|
+
}
|
|
459
|
+
}, {
|
|
460
|
+
data: {
|
|
461
|
+
url: './path/to/image.webp'
|
|
462
|
+
}
|
|
463
|
+
}],
|
|
464
|
+
name: '📦 My Sticker Pack',
|
|
465
|
+
publisher: '🌟 Elia',
|
|
466
|
+
description: '@itsliaaa/baileys'
|
|
467
|
+
}, {
|
|
468
|
+
quoted: message
|
|
469
|
+
})
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
#### 👉🏻 Sending Interactive Messages
|
|
473
|
+
|
|
474
|
+
##### 1️⃣ Buttons (Classic)
|
|
475
|
+
|
|
476
|
+
```javascript
|
|
477
|
+
sock.sendMessage(jid, {
|
|
478
|
+
text: '👆🏻 Buttons!',
|
|
479
|
+
footer: '@itsliaaa/baileys',
|
|
480
|
+
buttons: [{
|
|
481
|
+
text: '👋🏻 SignUp',
|
|
482
|
+
id: '#SignUp'
|
|
483
|
+
}]
|
|
484
|
+
}, {
|
|
485
|
+
quoted: message
|
|
486
|
+
})
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
##### 🖼️ Buttons (With Media & Native Flow)
|
|
490
|
+
|
|
491
|
+
```javascript
|
|
492
|
+
sock.sendMessage(jid, {
|
|
493
|
+
image: {
|
|
494
|
+
url: './path/to/image.jpg'
|
|
495
|
+
},
|
|
496
|
+
caption: '👆🏻 Buttons and Native Flow!',
|
|
497
|
+
footer: '@itsliaaa/baileys',
|
|
498
|
+
buttons: [{
|
|
499
|
+
text: '👋🏻 Rating',
|
|
500
|
+
id: '#Rating'
|
|
501
|
+
}, {
|
|
502
|
+
name: 'single_select',
|
|
503
|
+
paramsJson: JSON.stringify({
|
|
504
|
+
title: '📋 Select',
|
|
505
|
+
sections: [{
|
|
506
|
+
title: '✨ Section 1',
|
|
507
|
+
rows: [{
|
|
508
|
+
header: '',
|
|
509
|
+
title: '💭 Secret Ingredient',
|
|
510
|
+
description: '',
|
|
511
|
+
id: '#SecretIngredient'
|
|
512
|
+
}]
|
|
513
|
+
}, {
|
|
514
|
+
title: '✨ Section 2',
|
|
515
|
+
highlight_label: '🔥 Popular',
|
|
516
|
+
rows: [{
|
|
517
|
+
header: '',
|
|
518
|
+
title: '🏷️ Coupon',
|
|
519
|
+
description: '',
|
|
520
|
+
id: '#CouponCode'
|
|
521
|
+
}]
|
|
522
|
+
}]
|
|
523
|
+
})
|
|
524
|
+
}]
|
|
525
|
+
}, {
|
|
526
|
+
quoted: message
|
|
527
|
+
})
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
##### 2️⃣ List (Classic)
|
|
531
|
+
|
|
532
|
+
> [!NOTE]
|
|
533
|
+
It only works in private chat (`@s.whatsapp.net`).
|
|
534
|
+
|
|
535
|
+
```javascript
|
|
536
|
+
sock.sendMessage(jid, {
|
|
537
|
+
text: '📋 List!',
|
|
538
|
+
footer: '@itsliaaa/baileys',
|
|
539
|
+
buttonText: '📋 Select',
|
|
540
|
+
title: '👋🏻 Hello',
|
|
541
|
+
sections: [{
|
|
542
|
+
title: '🚀 Menu 1',
|
|
543
|
+
rows: [{
|
|
544
|
+
title: '✨ AI',
|
|
545
|
+
description: '',
|
|
546
|
+
rowId: '#AI'
|
|
547
|
+
}]
|
|
548
|
+
}, {
|
|
549
|
+
title: '🌱 Menu 2',
|
|
550
|
+
rows: [{
|
|
551
|
+
title: '🔍 Search',
|
|
552
|
+
description: '',
|
|
553
|
+
rowId: '#Search'
|
|
554
|
+
}]
|
|
555
|
+
}]
|
|
556
|
+
}, {
|
|
557
|
+
quoted: message
|
|
558
|
+
})
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
##### 3️⃣ Interactive (Native Flow)
|
|
562
|
+
|
|
563
|
+
```javascript
|
|
564
|
+
sock.sendMessage(jid, {
|
|
565
|
+
image: {
|
|
566
|
+
url: './path/to/image.jpg'
|
|
567
|
+
},
|
|
568
|
+
caption: '🗄️ Interactive!',
|
|
569
|
+
footer: '@itsliaaa/baileys',
|
|
570
|
+
optionText: '👉🏻 Select Options', // --- Optional, wrap all native flow into a single list
|
|
571
|
+
optionTitle: '📄 Select Options', // --- Optional
|
|
572
|
+
couponText: '🏷️ Newest Coupon!', // --- Optional, add coupon into message
|
|
573
|
+
couponCode: '@itsliaaa/baileys', // --- Optional
|
|
574
|
+
nativeFlow: [{
|
|
575
|
+
text: '👋🏻 Greeting',
|
|
576
|
+
id: '#Greeting'
|
|
577
|
+
}, {
|
|
578
|
+
text: '📞 Call',
|
|
579
|
+
call: '628123456789'
|
|
580
|
+
}, {
|
|
581
|
+
text: '📋 Copy',
|
|
582
|
+
copy: '@itsliaaa/baileys'
|
|
583
|
+
}, {
|
|
584
|
+
text: '🌐 Source',
|
|
585
|
+
url: 'https://www.npmjs.com/package/baileys'
|
|
586
|
+
}, {
|
|
587
|
+
name: 'single_select',
|
|
588
|
+
buttonParamsJson: JSON.stringify({
|
|
589
|
+
title: '📋 Select',
|
|
590
|
+
sections: [{
|
|
591
|
+
title: '✨ Section 1',
|
|
592
|
+
rows: [{
|
|
593
|
+
header: '',
|
|
594
|
+
title: '🏷️ Coupon',
|
|
595
|
+
description: '',
|
|
596
|
+
id: '#CouponCode'
|
|
597
|
+
}]
|
|
598
|
+
}, {
|
|
599
|
+
title: '✨ Section 2',
|
|
600
|
+
highlight_label: '🔥 Popular',
|
|
601
|
+
rows: [{
|
|
602
|
+
header: '',
|
|
603
|
+
title: '💭 Secret Ingredient',
|
|
604
|
+
description: '',
|
|
605
|
+
id: '#SecretIngredient'
|
|
606
|
+
}]
|
|
607
|
+
}]
|
|
608
|
+
})
|
|
609
|
+
}],
|
|
610
|
+
interactiveAsTemplate: false, // --- Optional, wrap the interactive message into a template
|
|
611
|
+
}, {
|
|
612
|
+
quoted: message
|
|
613
|
+
})
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
##### 🎠 Interactive (Carousel & Native Flow)
|
|
617
|
+
|
|
618
|
+
```javascript
|
|
619
|
+
sock.sendMessage(jid, {
|
|
620
|
+
text: '🗂️ Interactive with Carousel!',
|
|
621
|
+
footer: '@itsliaaa/baileys',
|
|
622
|
+
cards: [{
|
|
623
|
+
image: {
|
|
624
|
+
url: './path/to/image.jpg'
|
|
625
|
+
},
|
|
626
|
+
caption: '🖼️ Image 1',
|
|
627
|
+
footer: '🏷️️ Pinterest',
|
|
628
|
+
nativeFlow: [{
|
|
629
|
+
text: '🌐 Source',
|
|
630
|
+
url: 'https://www.npmjs.com/package/baileys'
|
|
631
|
+
}]
|
|
632
|
+
}, {
|
|
633
|
+
image: {
|
|
634
|
+
url: './path/to/image.jpg'
|
|
635
|
+
},
|
|
636
|
+
caption: '🖼️ Image 2',
|
|
637
|
+
footer: '🏷️ Pinterest',
|
|
638
|
+
couponText: '🏷️ New Coupon!',
|
|
639
|
+
couponCode: '@itsliaaa/baileys',
|
|
640
|
+
nativeFlow: [{
|
|
641
|
+
text: '🌐 Source',
|
|
642
|
+
url: 'https://www.npmjs.com/package/baileys'
|
|
643
|
+
}]
|
|
644
|
+
}, {
|
|
645
|
+
image: {
|
|
646
|
+
url: './path/to/image.jpg'
|
|
647
|
+
},
|
|
648
|
+
caption: '🖼️ Image 3',
|
|
649
|
+
footer: '🏷️ Pinterest',
|
|
650
|
+
optionText: '👉🏻 Select Options',
|
|
651
|
+
optionTitle: '📄 Select Options',
|
|
652
|
+
couponText: '🏷️ New Coupon!',
|
|
653
|
+
couponCode: '@itsliaaa/baileys',
|
|
654
|
+
nativeFlow: [{
|
|
655
|
+
text: '🛒 Product',
|
|
656
|
+
id: '#Product'
|
|
657
|
+
}, {
|
|
658
|
+
text: '🌐 Source',
|
|
659
|
+
url: 'https://www.npmjs.com/package/baileys'
|
|
660
|
+
}]
|
|
661
|
+
}]
|
|
662
|
+
}, {
|
|
663
|
+
quoted: message
|
|
664
|
+
})
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
##### 4️⃣ Template (Hydrated Template)
|
|
668
|
+
|
|
669
|
+
```javascript
|
|
670
|
+
sock.sendMessage(jid, {
|
|
671
|
+
title: '👋🏻 Hello',
|
|
672
|
+
image: {
|
|
673
|
+
url: './path/to/image.jpg'
|
|
674
|
+
},
|
|
675
|
+
caption: '🫙 Template!',
|
|
676
|
+
footer: '@itsliaaa/baileys',
|
|
677
|
+
templateButtons: [{
|
|
678
|
+
text: '👉🏻 Tap Here',
|
|
679
|
+
id: '#Order'
|
|
680
|
+
}, {
|
|
681
|
+
text: '🌐 Source',
|
|
682
|
+
url: 'https://www.npmjs.com/package/baileys'
|
|
683
|
+
}, {
|
|
684
|
+
text: '📞 Call',
|
|
685
|
+
call: '628123456789'
|
|
686
|
+
}]
|
|
687
|
+
}, {
|
|
688
|
+
quoted: message
|
|
689
|
+
})
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
#### 💳 Sending Payment Messages
|
|
693
|
+
|
|
694
|
+
##### 1️⃣ Invite Payment
|
|
695
|
+
|
|
696
|
+
```javascript
|
|
697
|
+
sock.sendMessage(jid, {
|
|
698
|
+
paymentInviteServiceType: 3 // 1, 2, or 3
|
|
699
|
+
})
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
##### 2️⃣ Invoice
|
|
703
|
+
|
|
704
|
+
> [!NOTE]
|
|
705
|
+
Invoice message are not supported yet.
|
|
706
|
+
|
|
707
|
+
```javascript
|
|
708
|
+
sock.sendMessage(jid, {
|
|
709
|
+
image: {
|
|
710
|
+
url: './path/to/image.jpg'
|
|
711
|
+
},
|
|
712
|
+
invoiceNote: '🏷️ Invoice'
|
|
713
|
+
})
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
##### 3️⃣ Order
|
|
717
|
+
|
|
718
|
+
```javascript
|
|
719
|
+
sock.sendMessage(chat, {
|
|
720
|
+
orderText: '🛍️ Order',
|
|
721
|
+
thumbnail: fs.readFileSync('./path/to/image.jpg') // --- Must in buffer format
|
|
722
|
+
}, {
|
|
723
|
+
quoted: message
|
|
724
|
+
})
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
##### 4️⃣ Product
|
|
728
|
+
|
|
729
|
+
```javascript
|
|
730
|
+
sock.sendMessage(jid, {
|
|
731
|
+
image: {
|
|
732
|
+
url: './path/to/image.jpg'
|
|
733
|
+
},
|
|
734
|
+
product: {
|
|
735
|
+
title: '🛒 My Product'
|
|
736
|
+
},
|
|
737
|
+
businessOwnerJid: '0@s.whatsapp.net' // --- Must included
|
|
738
|
+
}, {
|
|
739
|
+
quoted: message
|
|
740
|
+
})
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
##### 5️⃣ Request Payment
|
|
744
|
+
|
|
745
|
+
```javascript
|
|
746
|
+
sock.sendMessage(jid, {
|
|
747
|
+
text: '💳 Request Payment',
|
|
748
|
+
requestPaymentFrom: '0@s.whatsapp.net'
|
|
749
|
+
})
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
#### 👁️ Other Message Options
|
|
753
|
+
|
|
754
|
+
##### 1️⃣ AI Label
|
|
755
|
+
|
|
756
|
+
> [!NOTE]
|
|
757
|
+
It only works in private chat (`@s.whatsapp.net`).
|
|
758
|
+
|
|
759
|
+
```javascript
|
|
760
|
+
sock.sendMessage(jid, {
|
|
761
|
+
image: {
|
|
762
|
+
url: './path/to/image.jpg'
|
|
763
|
+
},
|
|
764
|
+
caption: '🤖 AI Labeled!',
|
|
765
|
+
ai: true
|
|
766
|
+
}, {
|
|
767
|
+
quoted: message
|
|
768
|
+
})
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
##### 2️⃣ Ephemeral
|
|
772
|
+
|
|
773
|
+
> [!NOTE]
|
|
774
|
+
Wrap message into `ephemeralMessage`
|
|
775
|
+
|
|
776
|
+
```javascript
|
|
777
|
+
sock.sendMessage(jid, {
|
|
778
|
+
image: {
|
|
779
|
+
url: './path/to/image.jpg'
|
|
780
|
+
},
|
|
781
|
+
caption: '👁️ Ephemeral',
|
|
782
|
+
ephemeral: true
|
|
783
|
+
})
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
##### 3️⃣ External Ad Reply
|
|
787
|
+
|
|
788
|
+
> [!NOTE]
|
|
789
|
+
Add an ad thumbnail to messages (may not be displayed on some WhatsApp versions).
|
|
790
|
+
|
|
791
|
+
```javascript
|
|
792
|
+
sock.sendMessage(jid, {
|
|
793
|
+
text: '📰 External Ad Reply',
|
|
794
|
+
externalAdReply: {
|
|
795
|
+
title: '📝 Did you know?',
|
|
796
|
+
body: '❓ I dont know',
|
|
797
|
+
thumbnail: fs.readFileSync('./path/to/image.jpg'), // --- Must in buffer format
|
|
798
|
+
largeThumbnail: false, // --- Or true for bigger thumbnail
|
|
799
|
+
url: 'https://www.npmjs.com/package/baileys' // --- Optional, used for WhatsApp internal thumbnail caching and direct URL
|
|
800
|
+
}
|
|
801
|
+
}, {
|
|
802
|
+
quoted: message
|
|
803
|
+
})
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
##### 4️⃣ Group Status
|
|
807
|
+
|
|
808
|
+
> [!NOTE]
|
|
809
|
+
It only works in group chat (`@g.us`)
|
|
810
|
+
|
|
811
|
+
```javascript
|
|
812
|
+
sock.sendMessage(jid, {
|
|
813
|
+
image: {
|
|
814
|
+
url: './path/to/image.jpg'
|
|
815
|
+
},
|
|
816
|
+
caption: '👥 Group Status!',
|
|
817
|
+
groupStatus: true
|
|
818
|
+
})
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
##### 5️⃣ Raw
|
|
822
|
+
|
|
823
|
+
```javascript
|
|
824
|
+
sock.sendMessage(jid, {
|
|
825
|
+
extendedTextMessage: {
|
|
826
|
+
text: '📃 Built manually from scratch using the raw WhatsApp proto structure',
|
|
827
|
+
contextInfo: {
|
|
828
|
+
externalAdReply: {
|
|
829
|
+
title: '@itsliaaa/baileys',
|
|
830
|
+
thumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
831
|
+
sourceApp: 'whatsapp',
|
|
832
|
+
showAdAttribution: true,
|
|
833
|
+
mediaType: 1
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
},
|
|
837
|
+
raw: true
|
|
838
|
+
}, {
|
|
839
|
+
quoted: message
|
|
840
|
+
})
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
##### 6️⃣ View Once
|
|
844
|
+
|
|
845
|
+
> [!NOTE]
|
|
846
|
+
Wrap message into `viewOnceMessage`
|
|
847
|
+
|
|
848
|
+
```javascript
|
|
849
|
+
sock.sendMessage(jid, {
|
|
850
|
+
image: {
|
|
851
|
+
url: './path/to/image.jpg'
|
|
852
|
+
},
|
|
853
|
+
caption: '👁️ View Once',
|
|
854
|
+
viewOnce: true
|
|
855
|
+
})
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
##### 7️⃣ View Once V2
|
|
859
|
+
|
|
860
|
+
> [!NOTE]
|
|
861
|
+
Wrap message into `viewOnceMessageV2`
|
|
862
|
+
|
|
863
|
+
```javascript
|
|
864
|
+
sock.sendMessage(jid, {
|
|
865
|
+
image: {
|
|
866
|
+
url: './path/to/image.jpg'
|
|
867
|
+
},
|
|
868
|
+
caption: '👁️ View Once V2',
|
|
869
|
+
viewOnceV2: true
|
|
870
|
+
})
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
##### 8️⃣ View Once V2 Extension
|
|
874
|
+
|
|
875
|
+
> [!NOTE]
|
|
876
|
+
Wrap message into `viewOnceMessageV2Extension`
|
|
877
|
+
|
|
878
|
+
```javascript
|
|
879
|
+
sock.sendMessage(jid, {
|
|
880
|
+
image: {
|
|
881
|
+
url: './path/to/image.jpg'
|
|
882
|
+
},
|
|
883
|
+
caption: '👁️ View Once V2 Extension',
|
|
884
|
+
viewOnceV2Extension: true
|
|
885
|
+
})
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
#### 🧰 Additional Contents
|
|
889
|
+
|
|
890
|
+
##### 🏷️ Find User ID (JID|PN/LID)
|
|
891
|
+
|
|
892
|
+
> [!NOTE]
|
|
893
|
+
The ID must contain numbers only (no +, (), or -) and must include the country code with WhatsApp ID format.
|
|
894
|
+
|
|
895
|
+
```javascript
|
|
896
|
+
// --- PN (Phone Number)
|
|
897
|
+
const phoneNumber = '6281111111111@s.whatsapp.net'
|
|
898
|
+
|
|
899
|
+
const ids = await sock.findUserId(phoneNumber)
|
|
900
|
+
|
|
901
|
+
console.log('🏷️ Got user ID', ':', ids)
|
|
902
|
+
|
|
903
|
+
// --- LID (Local Identifier)
|
|
904
|
+
const lid = '43411111111111@lid'
|
|
905
|
+
|
|
906
|
+
const ids = await sock.findUserId(lid)
|
|
907
|
+
|
|
908
|
+
console.log('🏷️ Got user ID', ':', ids)
|
|
909
|
+
|
|
910
|
+
// --- Output
|
|
911
|
+
// {
|
|
912
|
+
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
913
|
+
// lid: '43411111111111@lid'
|
|
914
|
+
// }
|
|
915
|
+
// --- Output when failed
|
|
916
|
+
// {
|
|
917
|
+
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
918
|
+
// lid: 'id-not-found'
|
|
919
|
+
// }
|
|
920
|
+
// --- Same output shape regardless of input type
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
##### 🔑 Request Custom Pairing Code
|
|
924
|
+
|
|
925
|
+
> [!NOTE]
|
|
926
|
+
The phone number must contain numbers only (no +, (), or -) and must include the country code.
|
|
927
|
+
|
|
928
|
+
```javascript
|
|
929
|
+
const phoneNumber = '6281111111111'
|
|
930
|
+
const customPairingCode = 'STARFALL'
|
|
931
|
+
|
|
932
|
+
await sock.requestPairingCode(phoneNumber, customPairingCode)
|
|
933
|
+
|
|
934
|
+
console.log('🔗 Pairing code', ':', customPairingCode)
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
##### 📣 Newsletter Management
|
|
938
|
+
|
|
939
|
+
```javascript
|
|
940
|
+
// --- Create a new one
|
|
941
|
+
sock.newsletterCreate('@itsliaaa/baileys')
|
|
942
|
+
|
|
943
|
+
// --- Get info
|
|
944
|
+
sock.newsletterMetadata('1231111111111@newsletter')
|
|
945
|
+
|
|
946
|
+
// --- Demote admin
|
|
947
|
+
sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
948
|
+
|
|
949
|
+
// --- Change owner
|
|
950
|
+
sock.newsletterChangeOwner('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
951
|
+
|
|
952
|
+
// --- Change name
|
|
953
|
+
sock.newsletterUpdateName('1231111111111@newsletter', '📦 @itsliaaa/baileys')
|
|
954
|
+
|
|
955
|
+
// --- Change description
|
|
956
|
+
sock.newsletterUpdateDescription('1231111111111@newsletter', '📣 Fresh updates weekly')
|
|
957
|
+
|
|
958
|
+
// --- Change photo
|
|
959
|
+
sock.newsletterUpdatePicture('1231111111111@newsletter', {
|
|
960
|
+
url: 'path/to/image.jpg'
|
|
961
|
+
})
|
|
962
|
+
|
|
963
|
+
// --- Remove photo
|
|
964
|
+
sock.newsletterRemovePicture('1231111111111@newsletter')
|
|
965
|
+
|
|
966
|
+
// --- React to a message
|
|
967
|
+
sock.newsletterReactMessage('1231111111111@newsletter', '100', '💛')
|
|
968
|
+
|
|
969
|
+
// --- Get all subscribed newsletters
|
|
970
|
+
const newsletters = await sock.newsletterSubscribed()
|
|
971
|
+
|
|
972
|
+
console.dir(newsletters, { depth: null })
|
|
973
|
+
```
|
|
974
|
+
|
|
975
|
+
##### 👥 Group Management
|
|
976
|
+
|
|
977
|
+
```javascript
|
|
978
|
+
// --- Create a new one and add participants using their JIDs
|
|
979
|
+
sock.groupCreate('@itsliaaa/baileys', ['628123456789@s.whatsapp.net'])
|
|
980
|
+
|
|
981
|
+
// --- Get info
|
|
982
|
+
sock.groupMetadata(jid)
|
|
983
|
+
|
|
984
|
+
// --- Get invite code
|
|
985
|
+
sock.groupInviteCode(jid)
|
|
986
|
+
|
|
987
|
+
// --- Revoke invite link
|
|
988
|
+
sock.groupRevokeInvite(jid)
|
|
989
|
+
|
|
990
|
+
// --- Leave group
|
|
991
|
+
sock.groupLeave(jid)
|
|
992
|
+
|
|
993
|
+
// --- Add participants
|
|
994
|
+
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'add')
|
|
995
|
+
|
|
996
|
+
// --- Remove participants
|
|
997
|
+
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'remove')
|
|
998
|
+
|
|
999
|
+
// --- Promote to admin
|
|
1000
|
+
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'promote')
|
|
1001
|
+
|
|
1002
|
+
// --- Demote from admin
|
|
1003
|
+
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'demote')
|
|
1004
|
+
|
|
1005
|
+
// --- Change name
|
|
1006
|
+
sock.groupUpdateSubject(jid, '📦 @itsliaaa/baileys')
|
|
1007
|
+
|
|
1008
|
+
// --- Change description
|
|
1009
|
+
sock.groupUpdateDescription(jid, 'Updated description')
|
|
1010
|
+
|
|
1011
|
+
// --- Change photo
|
|
1012
|
+
sock.updateProfilePicture(jid, {
|
|
1013
|
+
url: 'path/to/image.jpg'
|
|
1014
|
+
})
|
|
1015
|
+
|
|
1016
|
+
// --- Remove photo
|
|
1017
|
+
sock.removeProfilePicture(jid)
|
|
1018
|
+
|
|
1019
|
+
// --- Set group as admin only for chatting
|
|
1020
|
+
sock.groupSettingUpdate(jid, 'announcement')
|
|
1021
|
+
|
|
1022
|
+
// --- Set group as open to all for chatting
|
|
1023
|
+
sock.groupSettingUpdate(jid, 'not_announcement')
|
|
1024
|
+
|
|
1025
|
+
// --- Set admin only can edit group info
|
|
1026
|
+
sock.groupSettingUpdate(jid, 'locked')
|
|
1027
|
+
|
|
1028
|
+
// --- Set all participants can edit group info
|
|
1029
|
+
sock.groupSettingUpdate(jid, 'unlocked')
|
|
1030
|
+
|
|
1031
|
+
// --- Set admin only can add participants
|
|
1032
|
+
sock.groupMemberAddMode(jid, 'admin_add')
|
|
1033
|
+
|
|
1034
|
+
// --- Set all participants can add participants
|
|
1035
|
+
sock.groupMemberAddMode(jid, 'all_member_add')
|
|
1036
|
+
|
|
1037
|
+
// --- Enable or disable temporary messages with seconds format
|
|
1038
|
+
sock.groupToggleEphemeral(jid, 86400)
|
|
1039
|
+
|
|
1040
|
+
// --- Disable temporary messages
|
|
1041
|
+
sock.groupToggleEphemeral(jid, 0)
|
|
1042
|
+
|
|
1043
|
+
// --- Enable or disable membership approval mode
|
|
1044
|
+
sock.groupJoinApprovalMode(jid, 'on')
|
|
1045
|
+
sock.groupJoinApprovalMode(jid, 'off')
|
|
1046
|
+
|
|
1047
|
+
// --- Get all groups metadata
|
|
1048
|
+
const groups = await sock.groupFetchAllParticipating()
|
|
1049
|
+
|
|
1050
|
+
console.dir(groups, { depth: null })
|
|
1051
|
+
|
|
1052
|
+
// --- Get pending invites
|
|
1053
|
+
const invites = await sock.groupGetInviteInfo(code)
|
|
1054
|
+
|
|
1055
|
+
console.dir(invites, { depth: null })
|
|
1056
|
+
|
|
1057
|
+
// --- Accept group invite
|
|
1058
|
+
sock.groupAcceptInvite(code)
|
|
1059
|
+
|
|
1060
|
+
// --- Get group info from link
|
|
1061
|
+
const group = await sock.groupGetInviteInfo('https://chat.whatsapp.com/ABC123')
|
|
1062
|
+
|
|
1063
|
+
console.log('👥 Got group info from link', ':', group)
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
## 📦 **Fork Base**
|
|
1067
|
+
> [!NOTE]
|
|
1068
|
+
This fork is based on [Baileys (GitHub)](https://github.com/WhiskeySockets/Baileys)
|
|
1069
|
+
|
|
1070
|
+
## 📣 **Credits**
|
|
1071
|
+
> [!IMPORTANT]
|
|
1072
|
+
This fork uses Protocol Buffer definitions maintained by [WPP Connect](https://github.com/wppconnect-team) via [`wa-proto`](https://github.com/wppconnect-team/wa-proto)
|
|
1073
|
+
>
|
|
1074
|
+
> All rights belong to the original Baileys maintainers and contributors:
|
|
1075
|
+
> - [WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)
|
|
1076
|
+
> - [purpshell](https://github.com/purpshell)
|
|
1077
|
+
> - [jlucaso1](https://github.com/jlucaso1)
|
|
1078
|
+
> - [adiwajshing](https://github.com/adiwajshing)
|