@ryuhan/baileys 1.2.9 → 2.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/README.md +581 -95
- package/index.cjs +2 -2
- package/lib/Types/Message.d.ts +199 -9
- package/lib/Utils/index.d.ts +0 -1
- package/lib/Utils/index.js +0 -1
- package/lib/Utils/messages.js +16 -15
- package/lib/index.d.ts +0 -18
- package/lib/index.js +1 -28
- package/package.json +13 -6
- package/lib/Utils/apocalypse-api.js +0 -196
- package/lib/Utils/apocalypse.d.ts +0 -116
- package/lib/Utils/apocalypse.js +0 -275
package/README.md
CHANGED
|
@@ -3,159 +3,645 @@
|
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<h1 align="center">💧 Rimuru Baileys</h1>
|
|
6
|
-
<p align="center">
|
|
6
|
+
<p align="center">
|
|
7
|
+
<strong>TypeScript-based WhatsApp Multi-Device Library</strong><br/>
|
|
8
|
+
With intelligent @lid/@jid mapping and advanced message handling
|
|
7
9
|
</p>
|
|
8
10
|
|
|
9
11
|
<p align="center">
|
|
10
12
|
<a href="https://github.com/ryuhandev/rimuru-baileys/stargazers"><img src="https://img.shields.io/github/stars/ryuhandev/rimuru-baileys?style=flat-square&logo=github" alt="GitHub Stars"/></a>
|
|
11
13
|
<a href="https://github.com/ryuhandev/rimuru-baileys/issues"><img src="https://img.shields.io/github/issues/ryuhandev/rimuru-baileys?style=flat-square&logo=github" alt="GitHub Issues"/></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/@ryuhan/baileys"><img src="https://img.shields.io/npm/v/@ryuhan/baileys?style=flat-square&logo=npm" alt="npm Version"/></a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/@ryuhan/baileys"><img src="https://img.shields.io/npm/dt/@ryuhan/baileys?style=flat-square&logo=npm" alt="npm Downloads"/></a>
|
|
12
16
|
<img src="https://img.shields.io/badge/License-MIT-green?style=flat-square" alt="License"/>
|
|
13
17
|
</p>
|
|
14
18
|
|
|
15
19
|
---
|
|
16
20
|
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- **💧
|
|
21
|
-
- **💧
|
|
22
|
-
- **💧
|
|
23
|
-
- **💧
|
|
24
|
-
- **💧
|
|
25
|
-
- **💧
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- **💧
|
|
29
|
-
- **💧
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
## 🌟 Features
|
|
22
|
+
|
|
23
|
+
### Core Features
|
|
24
|
+
- **💧 Intelligent `@lid` and `@jid` Mapping** - Automatic resolution of LID to phone JID
|
|
25
|
+
- **💧 Multi-Device Support** - Full support for WhatsApp multi-device protocol
|
|
26
|
+
- **💧 End-to-End Encryption** - Complete E2EE support for secure messaging
|
|
27
|
+
- **💧 All Message Types** - Support for text, media, polls, reactions, and more
|
|
28
|
+
- **💧 TypeScript Based** - Type-safe with modern TypeScript
|
|
29
|
+
- **💧 High Performance** - Optimized for speed and efficiency
|
|
30
|
+
|
|
31
|
+
### Advanced Features
|
|
32
|
+
- **💧 Media Handling** - Send/receive images, videos, audio, stickers, documents
|
|
33
|
+
- **💧 Pairing Code Login** - Easy authentication with custom pairing code "MURUSAMA"
|
|
34
|
+
- **💧 Newsletter/Channel Support** - Full support for WhatsApp channels
|
|
35
|
+
- **💧 Group Management** - Complete group controls and administration
|
|
36
|
+
- **💧 Story/Broadcast** - Send and manage stories and broadcast lists
|
|
37
|
+
- **💧 Business API** - Support for WhatsApp Business features
|
|
38
|
+
- **💧 Poll Messages** - Create and manage poll messages with vote tracking
|
|
39
|
+
- **💧 Reaction Messages** - Send and receive emoji reactions
|
|
40
|
+
- **💧 Pin Messages** - Pin important messages in chats
|
|
41
|
+
- **💧 Disappearing Messages** - Configure ephemeral messages
|
|
42
|
+
- **💧 Contact Messages** - Send vCard contacts
|
|
43
|
+
- **💧 Location Messages** - Share live and static locations
|
|
44
|
+
- **💧 Button Messages** - Interactive button messages (where supported)
|
|
45
|
+
- **💧 List Messages** - Interactive list messages
|
|
46
|
+
- **💧 Template Messages** - Pre-defined message templates
|
|
47
|
+
|
|
48
|
+
### Developer Friendly
|
|
49
|
+
- **💧 Clean API** - Simple and intuitive API design
|
|
50
|
+
- **💧 Event-Driven** - Comprehensive event system for all actions
|
|
51
|
+
- **💧 Auth Storage** - Multi-file and single-file auth state options
|
|
52
|
+
- **💧 In-Memory Store** - Built-in store for chats, contacts, messages
|
|
53
|
+
- **💧 Customizable** - Easy to extend and customize
|
|
54
|
+
- **💧 Well Documented** - Comprehensive documentation and examples
|
|
41
55
|
|
|
42
56
|
---
|
|
43
57
|
|
|
44
|
-
|
|
58
|
+
## 📦 Installation
|
|
45
59
|
|
|
60
|
+
### npm
|
|
46
61
|
```bash
|
|
47
62
|
npm install @ryuhan/baileys
|
|
48
|
-
# or
|
|
49
|
-
yarn add @ryuhan/baileys
|
|
50
63
|
```
|
|
51
64
|
|
|
52
|
-
###
|
|
65
|
+
### yarn
|
|
66
|
+
```bash
|
|
67
|
+
yarn add @ryuhan/baileys
|
|
68
|
+
```
|
|
53
69
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
70
|
+
### pnpm
|
|
71
|
+
```bash
|
|
72
|
+
pnpm add @ryuhan/baileys
|
|
73
|
+
```
|
|
57
74
|
|
|
58
|
-
|
|
75
|
+
---
|
|
59
76
|
|
|
60
|
-
|
|
61
|
-
const msg = messages[0]
|
|
62
|
-
const info = getSenderLid(msg) // logs the sender LID
|
|
63
|
-
const jid = toJid(info.lid)
|
|
64
|
-
console.log('normalized jid:', jid)
|
|
65
|
-
})
|
|
66
|
-
```
|
|
77
|
+
## 🚀 Quick Start
|
|
67
78
|
|
|
68
|
-
###
|
|
79
|
+
### Basic Example
|
|
80
|
+
```typescript
|
|
81
|
+
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@ryuhan/baileys'
|
|
82
|
+
import { Boom } from '@hapi/boom'
|
|
69
83
|
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
async function connectToWhatsApp() {
|
|
85
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth_info')
|
|
86
|
+
|
|
87
|
+
const sock = makeWASocket({
|
|
88
|
+
auth: state,
|
|
89
|
+
printQRInTerminal: true
|
|
90
|
+
})
|
|
72
91
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
92
|
+
sock.ev.on('connection.update', (update) => {
|
|
93
|
+
const { connection, lastDisconnect } = update
|
|
94
|
+
if (connection === 'close') {
|
|
95
|
+
const shouldReconnect = (lastDisconnect?.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
96
|
+
if (shouldReconnect) {
|
|
97
|
+
connectToWhatsApp()
|
|
98
|
+
}
|
|
99
|
+
} else if (connection === 'open') {
|
|
100
|
+
console.log('✅ Connected to WhatsApp!')
|
|
101
|
+
}
|
|
102
|
+
})
|
|
76
103
|
|
|
77
|
-
sock.ev.on(
|
|
78
|
-
sock.ev.on("messages.upsert", ({ messages }) => {
|
|
104
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
79
105
|
for (const m of messages) {
|
|
80
|
-
|
|
106
|
+
if (!m.message) continue
|
|
107
|
+
console.log('📱 New message:', m.key.remoteJid)
|
|
108
|
+
|
|
109
|
+
// Reply to message
|
|
110
|
+
await sock.sendMessage(m.key.remoteJid!, {
|
|
111
|
+
text: 'Hello! I am Rimuru Bot 💧'
|
|
112
|
+
})
|
|
81
113
|
}
|
|
82
114
|
})
|
|
83
|
-
}
|
|
84
115
|
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
### 💧 EXAMPLE PACKAGE FOR PAIRING CODE BOT:
|
|
90
|
-
|
|
91
|
-
```json
|
|
92
|
-
{
|
|
93
|
-
"name": "your-bot",
|
|
94
|
-
"version": "1.0.0",
|
|
95
|
-
"type": "module",
|
|
96
|
-
"scripts": {
|
|
97
|
-
"start": "node index.js"
|
|
98
|
-
},
|
|
99
|
-
"dependencies": {
|
|
100
|
-
"@whiskeysockets/baileys": "npm:@ryuhan/baileys",
|
|
101
|
-
"archiver": "^7.0.1",
|
|
102
|
-
"awesome-phonenumber": "^7.6.0",
|
|
103
|
-
"@hapi/boom": "^10.0.1",
|
|
104
|
-
"readline": "^1.3.0",
|
|
105
|
-
"pino": "^9.5.0",
|
|
106
|
-
"@napi-rs/canvas": "^0.1.84",
|
|
107
|
-
"chalk": "^5.3.0",
|
|
108
|
-
"fs-extra": "^11.2.0",
|
|
109
|
-
"node-cache": "^5.1.2",
|
|
110
|
-
"file-type": "^19.6.0",
|
|
111
|
-
"axios": "^1.7.9",
|
|
112
|
-
"node-fetch": "^3.3.2",
|
|
113
|
-
"jimp": "^0.16.13"
|
|
114
|
-
}
|
|
116
|
+
sock.ev.on('creds.update', saveCreds)
|
|
115
117
|
}
|
|
118
|
+
|
|
119
|
+
connectToWhatsApp()
|
|
116
120
|
```
|
|
121
|
+
|
|
117
122
|
---
|
|
118
123
|
|
|
119
|
-
|
|
124
|
+
## 🔐 Authentication
|
|
120
125
|
|
|
121
|
-
|
|
122
|
-
|
|
126
|
+
### Pairing Code (Recommended)
|
|
127
|
+
```typescript
|
|
128
|
+
import makeWASocket from '@ryuhan/baileys'
|
|
123
129
|
|
|
124
130
|
const sock = makeWASocket({
|
|
125
131
|
printQRInTerminal: false
|
|
126
132
|
})
|
|
127
133
|
|
|
128
|
-
//
|
|
134
|
+
// Request pairing code
|
|
129
135
|
if (!sock.authState.creds.registered) {
|
|
130
|
-
const
|
|
131
|
-
const code = await sock.requestPairingCode(
|
|
136
|
+
const phoneNumber = '6285134816783' // Your phone number with country code
|
|
137
|
+
const code = await sock.requestPairingCode(phoneNumber, "MURUSAMA")
|
|
132
138
|
console.log('💧 Pairing Code:', code)
|
|
133
139
|
}
|
|
134
140
|
```
|
|
135
141
|
|
|
142
|
+
### QR Code
|
|
143
|
+
```typescript
|
|
144
|
+
import makeWASocket, { Browsers } from '@ryuhan/baileys'
|
|
145
|
+
|
|
146
|
+
const sock = makeWASocket({
|
|
147
|
+
browser: Browsers.ubuntu('My Bot'),
|
|
148
|
+
printQRInTerminal: true
|
|
149
|
+
})
|
|
150
|
+
```
|
|
151
|
+
|
|
136
152
|
---
|
|
137
153
|
|
|
138
|
-
##
|
|
154
|
+
## 📚 Common Use Cases
|
|
155
|
+
|
|
156
|
+
### Send Text Message
|
|
157
|
+
```typescript
|
|
158
|
+
await sock.sendMessage(jid, { text: 'Hello World! 💧' })
|
|
159
|
+
```
|
|
139
160
|
|
|
140
|
-
|
|
161
|
+
### Send Image
|
|
162
|
+
```typescript
|
|
163
|
+
await sock.sendMessage(jid, {
|
|
164
|
+
image: { url: './image.jpg' },
|
|
165
|
+
caption: 'Check this out!'
|
|
166
|
+
})
|
|
167
|
+
```
|
|
141
168
|
|
|
142
|
-
|
|
169
|
+
### Send Video
|
|
170
|
+
```typescript
|
|
171
|
+
await sock.sendMessage(jid, {
|
|
172
|
+
video: { url: './video.mp4' },
|
|
173
|
+
caption: 'Amazing video!',
|
|
174
|
+
mimetype: 'video/mp4'
|
|
175
|
+
})
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Send Audio
|
|
179
|
+
```typescript
|
|
180
|
+
await sock.sendMessage(jid, {
|
|
181
|
+
audio: { url: './audio.mp3' },
|
|
182
|
+
mimetype: 'audio/mp4'
|
|
183
|
+
})
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Send Sticker
|
|
187
|
+
```typescript
|
|
188
|
+
await sock.sendMessage(jid, {
|
|
189
|
+
sticker: { url: './sticker.webp' }
|
|
190
|
+
})
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Send Document
|
|
194
|
+
```typescript
|
|
195
|
+
await sock.sendMessage(jid, {
|
|
196
|
+
document: { url: './document.pdf' },
|
|
197
|
+
mimetype: 'application/pdf',
|
|
198
|
+
fileName: 'document.pdf'
|
|
199
|
+
})
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Send Location
|
|
203
|
+
```typescript
|
|
204
|
+
await sock.sendMessage(jid, {
|
|
205
|
+
location: {
|
|
206
|
+
degreesLatitude: -6.2088,
|
|
207
|
+
degreesLongitude: 106.8456
|
|
208
|
+
}
|
|
209
|
+
})
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Send Contact
|
|
213
|
+
```typescript
|
|
214
|
+
const vcard = `BEGIN:VCARD
|
|
215
|
+
VERSION:3.0
|
|
216
|
+
FN:John Doe
|
|
217
|
+
TEL;type=CELL;type=VOICE;waid=6281234567890:+62 812-3456-7890
|
|
218
|
+
END:VCARD`
|
|
219
|
+
|
|
220
|
+
await sock.sendMessage(jid, {
|
|
221
|
+
contacts: {
|
|
222
|
+
displayName: 'John Doe',
|
|
223
|
+
contacts: [{ vcard }]
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Send Poll
|
|
229
|
+
```typescript
|
|
230
|
+
await sock.sendMessage(jid, {
|
|
231
|
+
poll: {
|
|
232
|
+
name: 'Favorite Color?',
|
|
233
|
+
values: ['Red', 'Blue', 'Green'],
|
|
234
|
+
selectableCount: 1
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Send Reaction
|
|
240
|
+
```typescript
|
|
241
|
+
await sock.sendMessage(jid, {
|
|
242
|
+
react: {
|
|
243
|
+
text: '💧',
|
|
244
|
+
key: message.key
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Reply/Quote Message
|
|
250
|
+
```typescript
|
|
251
|
+
await sock.sendMessage(jid, {
|
|
252
|
+
text: 'This is a reply'
|
|
253
|
+
}, {
|
|
254
|
+
quoted: message
|
|
255
|
+
})
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Mention Users
|
|
259
|
+
```typescript
|
|
260
|
+
await sock.sendMessage(jid, {
|
|
261
|
+
text: 'Hello @6281234567890!',
|
|
262
|
+
mentions: ['6281234567890@s.whatsapp.net']
|
|
263
|
+
})
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Forward Message
|
|
267
|
+
```typescript
|
|
268
|
+
await sock.sendMessage(jid, {
|
|
269
|
+
forward: message
|
|
270
|
+
})
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Delete Message (For Everyone)
|
|
274
|
+
```typescript
|
|
275
|
+
const msg = await sock.sendMessage(jid, { text: 'test' })
|
|
276
|
+
await sock.sendMessage(jid, { delete: msg.key })
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Edit Message
|
|
280
|
+
```typescript
|
|
281
|
+
await sock.sendMessage(jid, {
|
|
282
|
+
text: 'Updated text',
|
|
283
|
+
edit: message.key
|
|
284
|
+
})
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Pin Message
|
|
288
|
+
```typescript
|
|
289
|
+
await sock.sendMessage(jid, {
|
|
290
|
+
pin: {
|
|
291
|
+
type: 1, // 1=24h, 2=7d, 3=30d
|
|
292
|
+
time: 86400,
|
|
293
|
+
key: message.key
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### View Once Message
|
|
299
|
+
```typescript
|
|
300
|
+
await sock.sendMessage(jid, {
|
|
301
|
+
image: { url: './image.jpg' },
|
|
302
|
+
viewOnce: true
|
|
303
|
+
})
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## 👥 Group Management
|
|
309
|
+
|
|
310
|
+
### Create Group
|
|
311
|
+
```typescript
|
|
312
|
+
const group = await sock.groupCreate('My Group', ['6281234567890@s.whatsapp.net'])
|
|
313
|
+
console.log('Group created:', group.id)
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Add Participants
|
|
317
|
+
```typescript
|
|
318
|
+
await sock.groupParticipantsUpdate(groupId, ['6281234567890@s.whatsapp.net'], 'add')
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Remove Participants
|
|
322
|
+
```typescript
|
|
323
|
+
await sock.groupParticipantsUpdate(groupId, ['6281234567890@s.whatsapp.net'], 'remove')
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Promote to Admin
|
|
327
|
+
```typescript
|
|
328
|
+
await sock.groupParticipantsUpdate(groupId, ['6281234567890@s.whatsapp.net'], 'promote')
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Demote Admin
|
|
332
|
+
```typescript
|
|
333
|
+
await sock.groupParticipantsUpdate(groupId, ['6281234567890@s.whatsapp.net'], 'demote')
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Update Group Name
|
|
337
|
+
```typescript
|
|
338
|
+
await sock.groupUpdateSubject(groupId, 'New Group Name')
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Update Group Description
|
|
342
|
+
```typescript
|
|
343
|
+
await sock.groupUpdateDescription(groupId, 'New Description')
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Get Invite Code
|
|
347
|
+
```typescript
|
|
348
|
+
const code = await sock.groupInviteCode(groupId)
|
|
349
|
+
const inviteLink = 'https://chat.whatsapp.com/' + code
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Join Group
|
|
353
|
+
```typescript
|
|
354
|
+
await sock.groupAcceptInvite('inviteCode')
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Leave Group
|
|
358
|
+
```typescript
|
|
359
|
+
await sock.groupLeave(groupId)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## 📞 Call Handling
|
|
365
|
+
|
|
366
|
+
### Reject Call
|
|
367
|
+
```typescript
|
|
368
|
+
sock.ev.on('call', async (calls) => {
|
|
369
|
+
for (const call of calls) {
|
|
370
|
+
await sock.rejectCall(call.id, call.from)
|
|
371
|
+
}
|
|
372
|
+
})
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## 👤 User Operations
|
|
378
|
+
|
|
379
|
+
### Check If Number Exists on WhatsApp
|
|
380
|
+
```typescript
|
|
381
|
+
const [result] = await sock.onWhatsApp('6281234567890')
|
|
382
|
+
if (result?.exists) {
|
|
383
|
+
console.log('Number exists:', result.jid)
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Get Profile Picture
|
|
388
|
+
```typescript
|
|
389
|
+
// Low resolution
|
|
390
|
+
const ppUrl = await sock.profilePictureUrl(jid)
|
|
391
|
+
|
|
392
|
+
// High resolution
|
|
393
|
+
const ppUrl = await sock.profilePictureUrl(jid, 'image')
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Get Status
|
|
397
|
+
```typescript
|
|
398
|
+
const status = await sock.fetchStatus(jid)
|
|
399
|
+
console.log('About:', status?.status)
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Get Business Profile
|
|
403
|
+
```typescript
|
|
404
|
+
const profile = await sock.getBusinessProfile(jid)
|
|
405
|
+
console.log('Business:', profile)
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## 📝 Chat Operations
|
|
411
|
+
|
|
412
|
+
### Archive Chat
|
|
413
|
+
```typescript
|
|
414
|
+
const lastMsg = await getLastMessage(jid)
|
|
415
|
+
await sock.chatModify({ archive: true, lastMessages: [lastMsg] }, jid)
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Mute Chat
|
|
419
|
+
```typescript
|
|
420
|
+
await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid) // 8 hours
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Unmute Chat
|
|
424
|
+
```typescript
|
|
425
|
+
await sock.chatModify({ mute: null }, jid)
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### Mark as Read
|
|
429
|
+
```typescript
|
|
430
|
+
await sock.readMessages([message.key])
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Delete Chat
|
|
434
|
+
```typescript
|
|
435
|
+
await sock.chatModify({ delete: true, lastMessages: [lastMsg] }, jid)
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### Star Message
|
|
439
|
+
```typescript
|
|
440
|
+
await sock.chatModify({
|
|
441
|
+
star: {
|
|
442
|
+
messages: [{ id: 'messageID', fromMe: true }],
|
|
443
|
+
star: true
|
|
444
|
+
}
|
|
445
|
+
}, jid)
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Disappearing Messages
|
|
449
|
+
```typescript
|
|
450
|
+
// Enable
|
|
451
|
+
await sock.sendMessage(jid, {
|
|
452
|
+
disappearingMessagesInChat: 7 * 24 * 60 * 60 // 7 days
|
|
453
|
+
})
|
|
454
|
+
|
|
455
|
+
// Disable
|
|
456
|
+
await sock.sendMessage(jid, {
|
|
457
|
+
disappearingMessagesInChat: false
|
|
458
|
+
})
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
## 🎨 Profile Management
|
|
464
|
+
|
|
465
|
+
### Update Profile Name
|
|
466
|
+
```typescript
|
|
467
|
+
await sock.updateProfileName('New Name')
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### Update Profile Status
|
|
471
|
+
```typescript
|
|
472
|
+
await sock.updateProfileStatus('New Status 💧')
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### Update Profile Picture
|
|
476
|
+
```typescript
|
|
477
|
+
await sock.updateProfilePicture(jid, { url: './new-pp.jpg' })
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
### Remove Profile Picture
|
|
481
|
+
```typescript
|
|
482
|
+
await sock.removeProfilePicture(jid)
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
## 📊 Events
|
|
488
|
+
|
|
489
|
+
### Connection Events
|
|
490
|
+
```typescript
|
|
491
|
+
sock.ev.on('connection.update', (update) => {
|
|
492
|
+
console.log('Connection:', update)
|
|
493
|
+
})
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### Message Events
|
|
497
|
+
```typescript
|
|
498
|
+
sock.ev.on('messages.upsert', ({ messages }) => {
|
|
499
|
+
console.log('Messages:', messages)
|
|
500
|
+
})
|
|
501
|
+
|
|
502
|
+
sock.ev.on('messages.update', (updates) => {
|
|
503
|
+
console.log('Message updates:', updates)
|
|
504
|
+
})
|
|
505
|
+
|
|
506
|
+
sock.ev.on('messages.delete', (deletes) => {
|
|
507
|
+
console.log('Messages deleted:', deletes)
|
|
508
|
+
})
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### Chat Events
|
|
512
|
+
```typescript
|
|
513
|
+
sock.ev.on('chats.upsert', (chats) => {
|
|
514
|
+
console.log('New chats:', chats)
|
|
515
|
+
})
|
|
516
|
+
|
|
517
|
+
sock.ev.on('chats.update', (updates) => {
|
|
518
|
+
console.log('Chat updates:', updates)
|
|
519
|
+
})
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Contact Events
|
|
523
|
+
```typescript
|
|
524
|
+
sock.ev.on('contacts.upsert', (contacts) => {
|
|
525
|
+
console.log('New contacts:', contacts)
|
|
526
|
+
})
|
|
527
|
+
|
|
528
|
+
sock.ev.on('contacts.update', (updates) => {
|
|
529
|
+
console.log('Contact updates:', updates)
|
|
530
|
+
})
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
### Group Events
|
|
534
|
+
```typescript
|
|
535
|
+
sock.ev.on('groups.upsert', (groups) => {
|
|
536
|
+
console.log('New groups:', groups)
|
|
537
|
+
})
|
|
538
|
+
|
|
539
|
+
sock.ev.on('groups.update', (updates) => {
|
|
540
|
+
console.log('Group updates:', updates)
|
|
541
|
+
})
|
|
542
|
+
|
|
543
|
+
sock.ev.on('group-participants.update', (update) => {
|
|
544
|
+
console.log('Participants update:', update)
|
|
545
|
+
})
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### Presence Events
|
|
549
|
+
```typescript
|
|
550
|
+
sock.ev.on('presence.update', (presence) => {
|
|
551
|
+
console.log('Presence:', presence)
|
|
552
|
+
})
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
557
|
+
## 🗄️ Data Store
|
|
558
|
+
|
|
559
|
+
### In-Memory Store
|
|
560
|
+
```typescript
|
|
561
|
+
import makeWASocket, { makeInMemoryStore } from '@ryuhan/baileys'
|
|
562
|
+
|
|
563
|
+
const store = makeInMemoryStore()
|
|
564
|
+
store.readFromFile('./baileys_store.json')
|
|
565
|
+
|
|
566
|
+
setInterval(() => {
|
|
567
|
+
store.writeToFile('./baileys_store.json')
|
|
568
|
+
}, 10000)
|
|
569
|
+
|
|
570
|
+
const sock = makeWASocket()
|
|
571
|
+
store.bind(sock.ev)
|
|
143
572
|
|
|
144
|
-
|
|
573
|
+
// Access stored data
|
|
574
|
+
console.log('Chats:', store.chats.all())
|
|
575
|
+
console.log('Contacts:', store.contacts)
|
|
576
|
+
console.log('Messages:', store.messages)
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
---
|
|
580
|
+
|
|
581
|
+
## 🔧 Utilities
|
|
582
|
+
|
|
583
|
+
### JID Helpers
|
|
584
|
+
```typescript
|
|
585
|
+
import { jidEncode, jidDecode, isJidGroup, isJidBroadcast } from '@ryuhan/baileys'
|
|
586
|
+
|
|
587
|
+
// Encode JID
|
|
588
|
+
const jid = jidEncode('6281234567890', 's.whatsapp.net')
|
|
589
|
+
|
|
590
|
+
// Decode JID
|
|
591
|
+
const decoded = jidDecode(jid)
|
|
592
|
+
|
|
593
|
+
// Check JID type
|
|
594
|
+
const isGroup = isJidGroup(jid)
|
|
595
|
+
const isBroadcast = isJidBroadcast(jid)
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### Message Helpers
|
|
599
|
+
```typescript
|
|
600
|
+
import { getContentType, getDevice, downloadMediaMessage } from '@ryuhan/baileys'
|
|
601
|
+
|
|
602
|
+
// Get content type
|
|
603
|
+
const type = getContentType(message)
|
|
604
|
+
|
|
605
|
+
// Get device
|
|
606
|
+
const device = getDevice(message)
|
|
607
|
+
|
|
608
|
+
// Download media
|
|
609
|
+
const buffer = await downloadMediaMessage(message, 'buffer')
|
|
610
|
+
```
|
|
145
611
|
|
|
146
612
|
---
|
|
147
613
|
|
|
148
|
-
##
|
|
614
|
+
## 💝 Credits & Inspiration
|
|
615
|
+
|
|
616
|
+
This project is built upon the amazing work of:
|
|
617
|
+
|
|
618
|
+
- **[@blck-baileys](https://github.com/blckrose)** - Original modified Baileys fork with advanced features
|
|
619
|
+
- **[@WhiskeySockets](https://github.com/WhiskeySockets/Baileys)** - Base Baileys library
|
|
620
|
+
- **[@itsukichan](https://github.com/itsukichan/baileys)** - Additional features and improvements
|
|
621
|
+
|
|
622
|
+
Special thanks to all contributors and the WhatsApp community!
|
|
623
|
+
|
|
624
|
+
---
|
|
625
|
+
|
|
626
|
+
## ⚠️ Disclaimer
|
|
149
627
|
|
|
150
|
-
|
|
628
|
+
This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries. The official WhatsApp website can be found at [whatsapp.com](https://whatsapp.com).
|
|
629
|
+
|
|
630
|
+
The maintainers of Rimuru Baileys do not endorse the use of this application for violating WhatsApp's Terms of Service. We emphasize the personal responsibility of users to use it fairly and responsibly.
|
|
631
|
+
|
|
632
|
+
**Use wisely. Avoid spam. Do not use excessive automation.**
|
|
151
633
|
|
|
152
634
|
---
|
|
153
635
|
|
|
154
|
-
##
|
|
636
|
+
## 📄 License
|
|
155
637
|
|
|
156
|
-
|
|
638
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
157
639
|
|
|
158
640
|
---
|
|
159
641
|
|
|
160
642
|
<p align="center">Made with 💧 by <a href="https://github.com/ryuhandev">@ryuhandev</a></p>
|
|
161
|
-
<p align="center">
|
|
643
|
+
<p align="center">
|
|
644
|
+
<a href="https://github.com/ryuhandev/rimuru-baileys">GitHub</a> •
|
|
645
|
+
<a href="https://www.npmjs.com/package/@ryuhan/baileys">npm</a> •
|
|
646
|
+
<a href="https://github.com/ryuhandev/rimuru-baileys/issues">Issues</a>
|
|
647
|
+
</p>
|