@mihiranga_mihiranga/mezuka-baileys 1.0.2
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 +201 -0
- package/README.md +651 -0
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +4775 -0
- package/WAProto/index.js +169661 -0
- package/WAProto//342/235/244/357/270/217 +1 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.js +112 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Defaults//360/237/222/226 +1 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.js +29 -0
- package/lib/Signal/Group//342/235/244/357/270/217 +1 -0
- package/lib/Signal/libsignal.js +174 -0
- package/lib/Signal//360/237/222/226 +1 -0
- package/lib/Socket/Client/index.js +18 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +72 -0
- package/lib/Socket/Client//342/235/244/357/270/217 +1 -0
- package/lib/Socket/business.js +260 -0
- package/lib/Socket/chats.js +890 -0
- package/lib/Socket/groups.js +332 -0
- package/lib/Socket/index.js +10 -0
- package/lib/Socket/messages-recv.js +1142 -0
- package/lib/Socket/messages-send.js +1068 -0
- package/lib/Socket/newsletter.js +250 -0
- package/lib/Socket/socket.js +654 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Socket//360/237/222/236 +1 -0
- package/lib/Store/index.js +8 -0
- package/lib/Store/make-in-memory-store.js +429 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Store//342/235/244/357/270/217 +1 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.js +7 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +42 -0
- package/lib/Types//360/237/222/236 +1 -0
- package/lib/Utils/auth-utils.js +199 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/browser-utils.js +35 -0
- package/lib/Utils/business.js +234 -0
- package/lib/Utils/chat-utils.js +730 -0
- package/lib/Utils/crypto.js +193 -0
- package/lib/Utils/decode-wa-message.js +207 -0
- package/lib/Utils/event-buffer.js +518 -0
- package/lib/Utils/generics.js +473 -0
- package/lib/Utils/history.js +95 -0
- package/lib/Utils/index.js +33 -0
- package/lib/Utils/link-preview.js +126 -0
- package/lib/Utils/logger.js +7 -0
- package/lib/Utils/lt-hash.js +51 -0
- package/lib/Utils/make-mutex.js +43 -0
- package/lib/Utils/messages-media.js +880 -0
- package/lib/Utils/messages.js +1154 -0
- package/lib/Utils/noise-handler.js +150 -0
- package/lib/Utils/process-message.js +372 -0
- package/lib/Utils/signal.js +153 -0
- package/lib/Utils/use-multi-file-auth-state.js +125 -0
- package/lib/Utils/validate-connection.js +199 -0
- package/lib/Utils//342/235/244/357/270/217 +1 -0
- package/lib/WABinary/constants.js +1303 -0
- package/lib/WABinary/decode.js +265 -0
- package/lib/WABinary/encode.js +250 -0
- package/lib/WABinary/generic-utils.js +130 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.js +83 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WABinary//360/237/222/226 +1 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAM//360/237/222/226 +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/Protocols//342/235/244/357/270/217 +1 -0
- package/lib/WAUSync/USyncQuery.js +89 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/WAUSync//360/237/222/226 +1 -0
- package/lib/index.js +45 -0
- package/lib//360/237/222/226 +1 -0
- package/package.json +121 -0
package/README.md
ADDED
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 🚀 @mezuka/baileys
|
|
4
|
+
|
|
5
|
+
### *Advanced WhatsApp Web API - Modified by Black Cat OFC*
|
|
6
|
+
|
|
7
|
+
<img src="https://files.catbox.moe/fhuqe1.jpg" width="400" alt="Mezuka Baileys Banner" />
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/@mezuka/baileys)
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
[](https://www.npmjs.com/package/@mezuka/baileys)
|
|
12
|
+
[](https://nodejs.org)
|
|
13
|
+
[](https://whatsapp.com)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
### 👨💻 **Owner:** Nimeshka Mihiran | **Team:** Black Cat OFC
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 📑 Table of Contents
|
|
24
|
+
|
|
25
|
+
- [✨ Features](#-features)
|
|
26
|
+
- [📦 Installation](#-installation)
|
|
27
|
+
- [🚀 Quick Start](#-quick-start)
|
|
28
|
+
- [🔐 Authentication Methods](#-authentication-methods)
|
|
29
|
+
- [📨 Sending Messages](#-sending-messages)
|
|
30
|
+
- [🎨 Advanced Features](#-advanced-features)
|
|
31
|
+
- [👥 Group Management](#-group-management)
|
|
32
|
+
- [🔒 Privacy & Security](#-privacy--security)
|
|
33
|
+
- [📞 Contact & Support](#-contact--support)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## ✨ Features
|
|
38
|
+
|
|
39
|
+
<div align="center">
|
|
40
|
+
|
|
41
|
+
| Feature | Status | Feature | Status |
|
|
42
|
+
|---------|--------|---------|--------|
|
|
43
|
+
| 🔐 **QR Code Auth** | ✅ | 📱 **Pairing Code** | ✅ |
|
|
44
|
+
| 💬 **All Message Types** | ✅ | 🖼️ **Media Support** | ✅ |
|
|
45
|
+
| 👥 **Group Management** | ✅ | 📊 **Polls & Events** | ✅ |
|
|
46
|
+
| 🔒 **Privacy Controls** | ✅ | 🎨 **Interactive Buttons** | ✅ |
|
|
47
|
+
| 📦 **Product Messages** | ✅ | 💳 **Payment Messages** | ✅ |
|
|
48
|
+
| 🤖 **AI Integration** | ✅ | 🌐 **Multi-Device** | ✅ |
|
|
49
|
+
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 📦 Installation
|
|
55
|
+
|
|
56
|
+
### NPM Installation
|
|
57
|
+
```bash
|
|
58
|
+
npm install @mezuka/baileys
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Yarn Installation
|
|
62
|
+
```bash
|
|
63
|
+
yarn add @mezuka/baileys
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Using as Baileys Fork
|
|
67
|
+
Add to your `package.json`:
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"baileys": "npm:@mezuka/baileys"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 🚀 Quick Start
|
|
79
|
+
|
|
80
|
+
### Basic Setup with QR Code
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@mezuka/baileys'
|
|
84
|
+
import { Boom } from '@hapi/boom'
|
|
85
|
+
|
|
86
|
+
async function connectToWhatsApp() {
|
|
87
|
+
const { state, saveCreds } = await useMultiFileAuthState('./auth_info_baileys')
|
|
88
|
+
|
|
89
|
+
const sock = makeWASocket({
|
|
90
|
+
auth: state,
|
|
91
|
+
printQRInTerminal: true,
|
|
92
|
+
browser: ['Black Cat Bot', 'Chrome', '1.0.0']
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
sock.ev.on('connection.update', (update) => {
|
|
96
|
+
const { connection, lastDisconnect } = update
|
|
97
|
+
|
|
98
|
+
if(connection === 'close') {
|
|
99
|
+
const shouldReconnect = (lastDisconnect?.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
100
|
+
console.log('Connection closed, reconnecting:', shouldReconnect)
|
|
101
|
+
|
|
102
|
+
if(shouldReconnect) {
|
|
103
|
+
connectToWhatsApp()
|
|
104
|
+
}
|
|
105
|
+
} else if(connection === 'open') {
|
|
106
|
+
console.log('✅ Connected successfully!')
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
111
|
+
for (const m of messages) {
|
|
112
|
+
console.log('📨 New message:', m)
|
|
113
|
+
|
|
114
|
+
if(m.message) {
|
|
115
|
+
await sock.sendMessage(m.key.remoteJid!, {
|
|
116
|
+
text: '👋 Hello from @mezuka/baileys!'
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
sock.ev.on('creds.update', saveCreds)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
connectToWhatsApp()
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 🔐 Authentication Methods
|
|
131
|
+
|
|
132
|
+
### Method 1: Pairing Code (Recommended)
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import makeWASocket from '@mezuka/baileys'
|
|
136
|
+
|
|
137
|
+
const sock = makeWASocket({
|
|
138
|
+
printQRInTerminal: false
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
if (!sock.authState.creds.registered) {
|
|
142
|
+
const phoneNumber = '94712345678' // Without + or special characters
|
|
143
|
+
const code = await sock.requestPairingCode(phoneNumber)
|
|
144
|
+
console.log(`🔑 Pairing Code: ${code}`)
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Method 2: Single File Auth
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { useSingleFileAuthState } from '@mezuka/baileys'
|
|
152
|
+
|
|
153
|
+
const { state, saveState } = await useSingleFileAuthState('./auth.json')
|
|
154
|
+
|
|
155
|
+
const sock = makeWASocket({
|
|
156
|
+
auth: state,
|
|
157
|
+
printQRInTerminal: true
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
sock.ev.on('creds.update', saveState)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Method 3: MongoDB Auth
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import { useMongoFileAuthState } from '@mezuka/baileys'
|
|
167
|
+
import { MongoClient } from 'mongodb'
|
|
168
|
+
|
|
169
|
+
const client = new MongoClient('mongodb://localhost:27017')
|
|
170
|
+
await client.connect()
|
|
171
|
+
|
|
172
|
+
const collection = client.db('whatsapp').collection('sessions')
|
|
173
|
+
const { state, saveCreds } = await useMongoFileAuthState(collection)
|
|
174
|
+
|
|
175
|
+
const sock = makeWASocket({
|
|
176
|
+
auth: state,
|
|
177
|
+
printQRInTerminal: true
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
sock.ev.on('creds.update', saveCreds)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 📨 Sending Messages
|
|
186
|
+
|
|
187
|
+
### Text Messages
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// Simple text
|
|
191
|
+
await sock.sendMessage(jid, { text: 'Hello World!' })
|
|
192
|
+
|
|
193
|
+
// With mentions
|
|
194
|
+
await sock.sendMessage(jid, {
|
|
195
|
+
text: '@94712345678 Check this out!',
|
|
196
|
+
mentions: ['94712345678@s.whatsapp.net']
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
// Quote/Reply
|
|
200
|
+
await sock.sendMessage(jid, {
|
|
201
|
+
text: 'This is a reply'
|
|
202
|
+
}, {
|
|
203
|
+
quoted: message
|
|
204
|
+
})
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Media Messages
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
// Image
|
|
211
|
+
await sock.sendMessage(jid, {
|
|
212
|
+
image: { url: './image.jpg' },
|
|
213
|
+
caption: 'Beautiful image! 📸'
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
// Video
|
|
217
|
+
await sock.sendMessage(jid, {
|
|
218
|
+
video: { url: './video.mp4' },
|
|
219
|
+
caption: 'Check this video! 🎥',
|
|
220
|
+
gifPlayback: false
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
// Audio
|
|
224
|
+
await sock.sendMessage(jid, {
|
|
225
|
+
audio: { url: './audio.mp3' },
|
|
226
|
+
mimetype: 'audio/mp4',
|
|
227
|
+
ptt: true // Voice message
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
// Document
|
|
231
|
+
await sock.sendMessage(jid, {
|
|
232
|
+
document: { url: './document.pdf' },
|
|
233
|
+
mimetype: 'application/pdf',
|
|
234
|
+
fileName: 'important.pdf'
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
// Sticker
|
|
238
|
+
await sock.sendMessage(jid, {
|
|
239
|
+
sticker: { url: './sticker.webp' }
|
|
240
|
+
})
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Interactive Messages
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
// Buttons
|
|
247
|
+
await sock.sendMessage(jid, {
|
|
248
|
+
text: 'Choose an option:',
|
|
249
|
+
footer: 'Powered by @mezuka/baileys',
|
|
250
|
+
buttons: [
|
|
251
|
+
{ buttonId: 'id1', buttonText: { displayText: 'Option 1' } },
|
|
252
|
+
{ buttonId: 'id2', buttonText: { displayText: 'Option 2' } },
|
|
253
|
+
{ buttonId: 'id3', buttonText: { displayText: 'Option 3' } }
|
|
254
|
+
]
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
// List Message
|
|
258
|
+
await sock.sendMessage(jid, {
|
|
259
|
+
text: 'Select from menu:',
|
|
260
|
+
footer: 'Black Cat OFC',
|
|
261
|
+
title: 'Main Menu',
|
|
262
|
+
buttonText: 'View Options',
|
|
263
|
+
sections: [{
|
|
264
|
+
title: 'Section 1',
|
|
265
|
+
rows: [
|
|
266
|
+
{ title: 'Option 1', rowId: 'opt1', description: 'First option' },
|
|
267
|
+
{ title: 'Option 2', rowId: 'opt2', description: 'Second option' }
|
|
268
|
+
]
|
|
269
|
+
}]
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
// Advanced Interactive Buttons
|
|
273
|
+
await sock.sendMessage(jid, {
|
|
274
|
+
text: 'Interactive Menu',
|
|
275
|
+
title: 'Welcome!',
|
|
276
|
+
footer: 'Choose wisely',
|
|
277
|
+
interactiveButtons: [
|
|
278
|
+
{
|
|
279
|
+
name: 'quick_reply',
|
|
280
|
+
buttonParamsJson: JSON.stringify({
|
|
281
|
+
display_text: 'Quick Reply',
|
|
282
|
+
id: 'quick_1'
|
|
283
|
+
})
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
name: 'cta_url',
|
|
287
|
+
buttonParamsJson: JSON.stringify({
|
|
288
|
+
display_text: 'Visit Website',
|
|
289
|
+
url: 'https://github.com/mezuka'
|
|
290
|
+
})
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: 'cta_call',
|
|
294
|
+
buttonParamsJson: JSON.stringify({
|
|
295
|
+
display_text: 'Call Us',
|
|
296
|
+
phone_number: '+94712345678'
|
|
297
|
+
})
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
})
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Special Messages
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
// Poll
|
|
307
|
+
await sock.sendMessage(jid, {
|
|
308
|
+
poll: {
|
|
309
|
+
name: 'Favorite Programming Language?',
|
|
310
|
+
values: ['JavaScript', 'Python', 'Java', 'C++'],
|
|
311
|
+
selectableCount: 1
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
// Location
|
|
316
|
+
await sock.sendMessage(jid, {
|
|
317
|
+
location: {
|
|
318
|
+
degreesLatitude: 6.9271,
|
|
319
|
+
degreesLongitude: 79.8612,
|
|
320
|
+
name: 'Colombo, Sri Lanka'
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
// Contact Card
|
|
325
|
+
const vcard = 'BEGIN:VCARD\n'
|
|
326
|
+
+ 'VERSION:3.0\n'
|
|
327
|
+
+ 'FN:Nimeshka Mihiran\n'
|
|
328
|
+
+ 'ORG:Black Cat OFC\n'
|
|
329
|
+
+ 'TEL;type=CELL;type=VOICE;waid=94712345678:+94 71 234 5678\n'
|
|
330
|
+
+ 'END:VCARD'
|
|
331
|
+
|
|
332
|
+
await sock.sendMessage(jid, {
|
|
333
|
+
contacts: {
|
|
334
|
+
displayName: 'Nimeshka',
|
|
335
|
+
contacts: [{ vcard }]
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
// Reaction
|
|
340
|
+
await sock.sendMessage(jid, {
|
|
341
|
+
react: {
|
|
342
|
+
text: '❤️',
|
|
343
|
+
key: message.key
|
|
344
|
+
}
|
|
345
|
+
})
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## 🎨 Advanced Features
|
|
351
|
+
|
|
352
|
+
### Album/Carousel Messages
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
await sock.sendMessage(jid, {
|
|
356
|
+
album: [
|
|
357
|
+
{
|
|
358
|
+
image: { url: './image1.jpg' },
|
|
359
|
+
caption: 'Photo 1'
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
image: { url: './image2.jpg' },
|
|
363
|
+
caption: 'Photo 2'
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
video: { url: './video.mp4' },
|
|
367
|
+
caption: 'Video 1'
|
|
368
|
+
}
|
|
369
|
+
]
|
|
370
|
+
})
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### AI-Powered Messages
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
await sock.sendMessage(jid, {
|
|
377
|
+
text: 'This message has AI processing enabled! 🤖'
|
|
378
|
+
}, {
|
|
379
|
+
ai: true
|
|
380
|
+
})
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### View Once Messages
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
await sock.sendMessage(jid, {
|
|
387
|
+
image: { url: './private.jpg' },
|
|
388
|
+
caption: 'This disappears after viewing',
|
|
389
|
+
viewOnce: true
|
|
390
|
+
})
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Status/Story Messages
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
await sock.sendStatusMentions(
|
|
397
|
+
{
|
|
398
|
+
text: 'Hello everyone! 👋',
|
|
399
|
+
font: 2,
|
|
400
|
+
textColor: 'FF0000',
|
|
401
|
+
backgroundColor: '#000000'
|
|
402
|
+
},
|
|
403
|
+
['94712345678@s.whatsapp.net', '94787654321@s.whatsapp.net']
|
|
404
|
+
)
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## 👥 Group Management
|
|
410
|
+
|
|
411
|
+
### Create Group
|
|
412
|
+
|
|
413
|
+
```typescript
|
|
414
|
+
const group = await sock.groupCreate(
|
|
415
|
+
'Black Cat Developers',
|
|
416
|
+
['94712345678@s.whatsapp.net', '94787654321@s.whatsapp.net']
|
|
417
|
+
)
|
|
418
|
+
console.log('Group created:', group.id)
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### Manage Participants
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
// Add members
|
|
425
|
+
await sock.groupParticipantsUpdate(
|
|
426
|
+
groupJid,
|
|
427
|
+
['94712345678@s.whatsapp.net'],
|
|
428
|
+
'add'
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
// Remove members
|
|
432
|
+
await sock.groupParticipantsUpdate(
|
|
433
|
+
groupJid,
|
|
434
|
+
['94712345678@s.whatsapp.net'],
|
|
435
|
+
'remove'
|
|
436
|
+
)
|
|
437
|
+
|
|
438
|
+
// Promote to admin
|
|
439
|
+
await sock.groupParticipantsUpdate(
|
|
440
|
+
groupJid,
|
|
441
|
+
['94712345678@s.whatsapp.net'],
|
|
442
|
+
'promote'
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
// Demote from admin
|
|
446
|
+
await sock.groupParticipantsUpdate(
|
|
447
|
+
groupJid,
|
|
448
|
+
['94712345678@s.whatsapp.net'],
|
|
449
|
+
'demote'
|
|
450
|
+
)
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
### Group Settings
|
|
454
|
+
|
|
455
|
+
```typescript
|
|
456
|
+
// Change name
|
|
457
|
+
await sock.groupUpdateSubject(groupJid, 'New Group Name')
|
|
458
|
+
|
|
459
|
+
// Change description
|
|
460
|
+
await sock.groupUpdateDescription(groupJid, 'New amazing description')
|
|
461
|
+
|
|
462
|
+
// Update settings
|
|
463
|
+
await sock.groupSettingUpdate(groupJid, 'announcement') // Only admins can send
|
|
464
|
+
await sock.groupSettingUpdate(groupJid, 'not_announcement') // Everyone can send
|
|
465
|
+
await sock.groupSettingUpdate(groupJid, 'locked') // Only admins edit info
|
|
466
|
+
await sock.groupSettingUpdate(groupJid, 'unlocked') // Everyone can edit info
|
|
467
|
+
|
|
468
|
+
// Get invite code
|
|
469
|
+
const code = await sock.groupInviteCode(groupJid)
|
|
470
|
+
console.log('Invite link:', `https://chat.whatsapp.com/${code}`)
|
|
471
|
+
|
|
472
|
+
// Revoke invite code
|
|
473
|
+
await sock.groupRevokeInvite(groupJid)
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
---
|
|
477
|
+
|
|
478
|
+
## 🔒 Privacy & Security
|
|
479
|
+
|
|
480
|
+
### Block/Unblock Users
|
|
481
|
+
|
|
482
|
+
```typescript
|
|
483
|
+
await sock.updateBlockStatus(jid, 'block')
|
|
484
|
+
await sock.updateBlockStatus(jid, 'unblock')
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### Privacy Settings
|
|
488
|
+
|
|
489
|
+
```typescript
|
|
490
|
+
// Last seen
|
|
491
|
+
await sock.updateLastSeenPrivacy('all') // 'contacts' | 'contact_blacklist' | 'none'
|
|
492
|
+
|
|
493
|
+
// Profile picture
|
|
494
|
+
await sock.updateProfilePicturePrivacy('contacts')
|
|
495
|
+
|
|
496
|
+
// Status
|
|
497
|
+
await sock.updateStatusPrivacy('contacts')
|
|
498
|
+
|
|
499
|
+
// Read receipts
|
|
500
|
+
await sock.updateReadReceiptsPrivacy('all')
|
|
501
|
+
|
|
502
|
+
// Groups
|
|
503
|
+
await sock.updateGroupsAddPrivacy('contacts')
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### Disappearing Messages
|
|
507
|
+
|
|
508
|
+
```typescript
|
|
509
|
+
// Enable (7 days)
|
|
510
|
+
await sock.sendMessage(jid, {
|
|
511
|
+
disappearingMessagesInChat: 604800
|
|
512
|
+
})
|
|
513
|
+
|
|
514
|
+
// Disable
|
|
515
|
+
await sock.sendMessage(jid, {
|
|
516
|
+
disappearingMessagesInChat: false
|
|
517
|
+
})
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
## 📞 Contact & Support
|
|
523
|
+
|
|
524
|
+
<div align="center">
|
|
525
|
+
|
|
526
|
+
### 🌟 **Owner: Nimeshka Mihiran**
|
|
527
|
+
### 👥 **Team: Black Cat OFC**
|
|
528
|
+
|
|
529
|
+
[](https://instagram.com/nimeshka_mihiran)
|
|
530
|
+
[](https://github.com/mezuka)
|
|
531
|
+
[](https://wa.me/94712345678)
|
|
532
|
+
[](mailto:blackcatofc@gmail.com)
|
|
533
|
+
|
|
534
|
+
### 📢 Join Our Community
|
|
535
|
+
|
|
536
|
+
[](https://whatsapp.com/channel/0029VbC1tH0L7UVPPYGED62n)
|
|
537
|
+
[](https://t.me/Nimeshkamihiran)
|
|
538
|
+
[](https://discord.gg/blackcatofc)
|
|
539
|
+
|
|
540
|
+
</div>
|
|
541
|
+
|
|
542
|
+
---
|
|
543
|
+
|
|
544
|
+
## 📚 Additional Resources
|
|
545
|
+
|
|
546
|
+
### Utility Functions
|
|
547
|
+
|
|
548
|
+
```typescript
|
|
549
|
+
import {
|
|
550
|
+
getContentType,
|
|
551
|
+
getDevice,
|
|
552
|
+
downloadContentFromMessage,
|
|
553
|
+
makeCacheableSignalKeyStore
|
|
554
|
+
} from '@mezuka/baileys'
|
|
555
|
+
|
|
556
|
+
// Get message type
|
|
557
|
+
const type = getContentType(message)
|
|
558
|
+
|
|
559
|
+
// Download media
|
|
560
|
+
const buffer = await downloadContentFromMessage(message, 'image')
|
|
561
|
+
|
|
562
|
+
// Check if number exists
|
|
563
|
+
const [result] = await sock.onWhatsApp('94712345678')
|
|
564
|
+
if (result.exists) console.log('Number exists!')
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
### Data Store Implementation
|
|
568
|
+
|
|
569
|
+
```typescript
|
|
570
|
+
import { makeInMemoryStore } from '@mezuka/baileys'
|
|
571
|
+
|
|
572
|
+
const store = makeInMemoryStore({})
|
|
573
|
+
store.readFromFile('./baileys_store.json')
|
|
574
|
+
|
|
575
|
+
setInterval(() => {
|
|
576
|
+
store.writeToFile('./baileys_store.json')
|
|
577
|
+
}, 10_000)
|
|
578
|
+
|
|
579
|
+
store.bind(sock.ev)
|
|
580
|
+
|
|
581
|
+
// Access chats
|
|
582
|
+
console.log('All chats:', store.chats.all())
|
|
583
|
+
console.log('All contacts:', Object.values(store.contacts))
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
588
|
+
## 🎯 Best Practices
|
|
589
|
+
|
|
590
|
+
### Performance Optimization
|
|
591
|
+
|
|
592
|
+
```typescript
|
|
593
|
+
import { makeCacheableSignalKeyStore } from '@mezuka/baileys'
|
|
594
|
+
import NodeCache from 'node-cache'
|
|
595
|
+
|
|
596
|
+
// Cache group metadata
|
|
597
|
+
const groupCache = new NodeCache({ stdTTL: 300, useClones: false })
|
|
598
|
+
|
|
599
|
+
const sock = makeWASocket({
|
|
600
|
+
cachedGroupMetadata: async (jid) => groupCache.get(jid),
|
|
601
|
+
getMessage: async (key) => await getMessageFromStore(key)
|
|
602
|
+
})
|
|
603
|
+
|
|
604
|
+
sock.ev.on('groups.update', async ([event]) => {
|
|
605
|
+
const metadata = await sock.groupMetadata(event.id)
|
|
606
|
+
groupCache.set(event.id, metadata)
|
|
607
|
+
})
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
### Error Handling
|
|
611
|
+
|
|
612
|
+
```typescript
|
|
613
|
+
sock.ev.on('connection.update', (update) => {
|
|
614
|
+
const { connection, lastDisconnect, qr } = update
|
|
615
|
+
|
|
616
|
+
if(qr) {
|
|
617
|
+
console.log('QR Code:', qr)
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
if(connection === 'close') {
|
|
621
|
+
const statusCode = (lastDisconnect?.error as Boom)?.output?.statusCode
|
|
622
|
+
const shouldReconnect = statusCode !== DisconnectReason.loggedOut
|
|
623
|
+
|
|
624
|
+
console.log('Connection closed. Status:', statusCode)
|
|
625
|
+
|
|
626
|
+
if(shouldReconnect) {
|
|
627
|
+
setTimeout(() => connectToWhatsApp(), 3000)
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
})
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
---
|
|
634
|
+
|
|
635
|
+
## 📄 License
|
|
636
|
+
|
|
637
|
+
This project is licensed under the MIT License.
|
|
638
|
+
|
|
639
|
+
---
|
|
640
|
+
|
|
641
|
+
<div align="center">
|
|
642
|
+
|
|
643
|
+
### ⭐ Star us on GitHub!
|
|
644
|
+
|
|
645
|
+
**Made with ❤️ by Black Cat OFC**
|
|
646
|
+
|
|
647
|
+
**Special thanks to the original Baileys developers**
|
|
648
|
+
|
|
649
|
+

|
|
650
|
+
|
|
651
|
+
</div>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
yarn pbjs -t static-module -w commonjs -o ./WAProto/index.js ./WAProto/WAProto.proto;
|
|
2
|
+
yarn pbts -o ./WAProto/index.d.ts ./WAProto/index.js;
|
|
3
|
+
|
|
4
|
+
#protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=env=node,useOptionals=true,forceLong=long --ts_proto_out=. ./src/Binary/WAMessage.proto;
|