@fer2809fl/baileys 1.4.7 → 1.4.9
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 +352 -115
- package/lib/Baileys.jpeg +0 -0
- package/lib/Signal/Group/group_cipher.js +22 -13
- package/lib/Signal/Group/sender-key-record.js +27 -14
- package/lib/Socket/newsletter.js +1 -1
- package/lib/Socket/setup.js +3 -3
- package/lib/Socket/setup.ts +3 -3
- package/lib/Socket/socket.js +560 -0
- package/lib/Utils/auth-utils.js +23 -11
- package/lib/Utils/button-handler.js +151 -0
- package/lib/Utils/error-handler.js +37 -0
- package/lib/Utils/index.d.ts +1 -0
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/interactive.js +254 -0
- package/lib/Utils/messages.js +2 -2
- package/lib/Utils/process-message.js +43 -25
- package/lib/Utils/use-multi-file-auth-state.js +41 -21
- package/lib/WABinary/constants.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
<img src="https://raw.githubusercontent.com/Fer2809fl/Baileys/refs/heads/main/lib/Baileys.jpeg" alt="Baileys" width="
|
|
3
|
+
<img src="https://raw.githubusercontent.com/Fer2809fl/Baileys/refs/heads/main/lib/Baileys.jpeg" alt="Baileys" width="500" style="border-radius: 20px;"/>
|
|
4
4
|
|
|
5
|
-
# @
|
|
5
|
+
# @fer2809fl/baileys
|
|
6
6
|
### API de WhatsApp Web para Node.js
|
|
7
7
|
|
|
8
|
-
[](https://www.npmjs.com/package/@fer2809fl/baileys)
|
|
9
9
|
[](LICENSE)
|
|
10
|
-
[](https://nodejs.org)
|
|
11
11
|
[](https://www.typescriptlang.org)
|
|
12
12
|
|
|
13
13
|
*Conéctate a WhatsApp Web directamente desde Node.js sin navegadores ni Selenium*
|
|
@@ -16,31 +16,67 @@
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
+
## 🆕 Novedades — v1.8.9
|
|
20
|
+
|
|
21
|
+
### ✅ Nuevas funciones añadidas
|
|
22
|
+
- **Botones interactivos** — Se agregaron funciones nativas para enviar botones de WhatsApp:
|
|
23
|
+
- `sendCopyButton` — Botón que copia texto al portapapeles
|
|
24
|
+
- `sendUrlButton` — Botón que abre un enlace en el navegador
|
|
25
|
+
- `sendQuickReplyButtons` — Botones de respuesta rápida
|
|
26
|
+
- `sendCallButton` — Botón para iniciar una llamada telefónica
|
|
27
|
+
- `sendListMenu` — Menú desplegable con secciones y filas
|
|
28
|
+
- `sendInteractiveMessage` — Combinación de botones mixtos (URL + Copiar + Rápido)
|
|
29
|
+
|
|
30
|
+
### 🐛 Correcciones
|
|
31
|
+
- **Error en macOS** — Se reparó un bug crítico que impedía iniciar sesión correctamente en dispositivos Mac. El proceso de pairing/QR ahora funciona de forma estable en macOS.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
19
35
|
## ⚠️ Nota Importante
|
|
20
36
|
|
|
21
37
|
ꕤ Esta librería está basada en Baileys. No está afiliada ni aprobada oficialmente por WhatsApp.
|
|
22
38
|
|
|
23
|
-
> **@
|
|
39
|
+
> **@fer2809fl/baileys** y su desarrollador no se hacen responsables por el mal uso de esta librería.
|
|
24
40
|
> Úsala de forma responsable — nada de spam ni actividades maliciosas.
|
|
25
41
|
|
|
26
42
|
---
|
|
27
43
|
|
|
28
44
|
## 📦 Instalación
|
|
29
45
|
|
|
30
|
-
Puedes instalarla de
|
|
46
|
+
Puedes instalarla de varias formas, todas funcionan igual:
|
|
31
47
|
|
|
48
|
+
**Opción 1 — Desde npm (recomendado)**
|
|
32
49
|
```bash
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
npm install @fer2809fl/baileys
|
|
51
|
+
yarn add @fer2809fl/baileys
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Opción 2 — Desde GitHub directamente**
|
|
55
|
+
```bash
|
|
56
|
+
npm install github:Fer2809fl/Baileys
|
|
57
|
+
yarn add github:Fer2809fl/Baileys
|
|
58
|
+
```
|
|
36
59
|
|
|
37
|
-
|
|
60
|
+
**Opción 3 — También funciona con el paquete original**
|
|
61
|
+
```bash
|
|
38
62
|
npm install @whiskeysockets/baileys
|
|
39
63
|
yarn add @whiskeysockets/baileys
|
|
64
|
+
```
|
|
40
65
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
66
|
+
**Opción — En tu package.json** (elige una de estas formas):
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@fer2809fl/baileys": "^1.8.9"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"@whiskeysockets/baileys": "github:Fer2809fl/Baileys"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
44
80
|
```
|
|
45
81
|
|
|
46
82
|
---
|
|
@@ -49,7 +85,7 @@ yarn add github:Fer280809/Baileys
|
|
|
49
85
|
|
|
50
86
|
### JavaScript
|
|
51
87
|
```javascript
|
|
52
|
-
const { makeWASocket, useMultiFileAuthState } = require('@
|
|
88
|
+
const { makeWASocket, useMultiFileAuthState } = require('@fer2809fl/baileys')
|
|
53
89
|
|
|
54
90
|
async function startBot() {
|
|
55
91
|
const { state, saveCreds } = await useMultiFileAuthState('session-mymelody')
|
|
@@ -81,7 +117,7 @@ startBot()
|
|
|
81
117
|
|
|
82
118
|
### TypeScript
|
|
83
119
|
```typescript
|
|
84
|
-
import makeWASocket, { useMultiFileAuthState, DisconnectReason } from '@
|
|
120
|
+
import makeWASocket, { useMultiFileAuthState, DisconnectReason } from '@fer2809fl/baileys'
|
|
85
121
|
import { Boom } from '@hapi/boom'
|
|
86
122
|
|
|
87
123
|
async function startBot(): Promise<void> {
|
|
@@ -124,7 +160,7 @@ startBot()
|
|
|
124
160
|
- 📸 Mensajes multimedia (imágenes, video, audio, documentos)
|
|
125
161
|
- 🤖 Comandos personalizados fáciles de implementar
|
|
126
162
|
- 👥 Soporte para grupos y chats privados
|
|
127
|
-
- 🔘 Mensajes interactivos con botones y
|
|
163
|
+
- 🔘 **Mensajes interactivos con botones, listas y más** *(nuevo en v1.8.9)*
|
|
128
164
|
|
|
129
165
|
### Técnicas
|
|
130
166
|
- ⚡ Sin Selenium — Conexión directa vía WebSocket
|
|
@@ -134,6 +170,289 @@ startBot()
|
|
|
134
170
|
- 🔄 Reconexión automática ante desconexiones
|
|
135
171
|
- 🔐 Sesiones persistentes guardadas localmente
|
|
136
172
|
- 🌐 API completa de WhatsApp Web
|
|
173
|
+
- 🍎 **Compatible con macOS** — Error de pairing reparado *(fix en v1.8.9)*
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 🔘 Botones Interactivos *(nuevo en v1.8.9)*
|
|
178
|
+
|
|
179
|
+
Desde la versión **1.8.9** puedes importar y usar funciones nativas para enviar botones interactivos de WhatsApp.
|
|
180
|
+
|
|
181
|
+
### Importar las funciones
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
// JavaScript (CommonJS)
|
|
185
|
+
const {
|
|
186
|
+
sendCopyButton,
|
|
187
|
+
sendUrlButton,
|
|
188
|
+
sendQuickReplyButtons,
|
|
189
|
+
sendCallButton,
|
|
190
|
+
sendListMenu,
|
|
191
|
+
sendInteractiveMessage
|
|
192
|
+
} = require('@fer2809fl/baileys')
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
// TypeScript / ESM
|
|
197
|
+
import {
|
|
198
|
+
sendCopyButton,
|
|
199
|
+
sendUrlButton,
|
|
200
|
+
sendQuickReplyButtons,
|
|
201
|
+
sendCallButton,
|
|
202
|
+
sendListMenu,
|
|
203
|
+
sendInteractiveMessage
|
|
204
|
+
} from '@fer2809fl/baileys'
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
### 📋 `sendCopyButton` — Botón Copiar
|
|
210
|
+
Muestra un botón que al tocarlo copia un texto al portapapeles del usuario.
|
|
211
|
+
|
|
212
|
+
```javascript
|
|
213
|
+
await sendCopyButton(
|
|
214
|
+
conn,
|
|
215
|
+
jid,
|
|
216
|
+
'📋 *CÓDIGO DE INSTALACIÓN*\n\nEjecuta este comando en tu terminal:',
|
|
217
|
+
'npm install asta-bot', // texto que se copiará
|
|
218
|
+
'📋 Copiar Comando' // etiqueta del botón
|
|
219
|
+
)
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
### 🔗 `sendUrlButton` — Botón URL
|
|
225
|
+
Abre un enlace en el navegador al tocar el botón.
|
|
226
|
+
|
|
227
|
+
```javascript
|
|
228
|
+
await sendUrlButton(
|
|
229
|
+
conn,
|
|
230
|
+
jid,
|
|
231
|
+
'🔗 *ENLACES IMPORTANTES*\n\nVisita nuestro repositorio oficial:',
|
|
232
|
+
'https://github.com/Fer2809fl/Asta_bot', // URL de destino
|
|
233
|
+
'🌐 Ver GitHub' // etiqueta del botón
|
|
234
|
+
)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### ⚡ `sendQuickReplyButtons` — Botones de Respuesta Rápida
|
|
240
|
+
Muestra varios botones de respuesta rápida debajo del mensaje.
|
|
241
|
+
|
|
242
|
+
```javascript
|
|
243
|
+
await sendQuickReplyButtons(
|
|
244
|
+
conn,
|
|
245
|
+
jid,
|
|
246
|
+
'🎮 *MENÚ DE OPCIONES*\n\n¿Qué deseas hacer?',
|
|
247
|
+
[
|
|
248
|
+
{ id: 'menu', text: '📋 Ver Menú' },
|
|
249
|
+
{ id: 'info', text: 'ℹ️ Información' },
|
|
250
|
+
{ id: 'owner', text: '👑 Owner' }
|
|
251
|
+
]
|
|
252
|
+
)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
### 📞 `sendCallButton` — Botón de Llamada
|
|
258
|
+
Inicia una llamada al número indicado al tocar el botón.
|
|
259
|
+
|
|
260
|
+
```javascript
|
|
261
|
+
await sendCallButton(
|
|
262
|
+
conn,
|
|
263
|
+
jid,
|
|
264
|
+
'📞 *SOPORTE TÉCNICO*\n\n¿Necesitas ayuda? Llámanos:',
|
|
265
|
+
'+5214183357841', // número de teléfono
|
|
266
|
+
'📞 Llamar Ahora' // etiqueta del botón
|
|
267
|
+
)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
### 📋 `sendListMenu` — Menú Desplegable (Lista)
|
|
273
|
+
Muestra un menú con secciones y opciones seleccionables.
|
|
274
|
+
|
|
275
|
+
```javascript
|
|
276
|
+
await sendListMenu(
|
|
277
|
+
conn,
|
|
278
|
+
jid,
|
|
279
|
+
'📋 *SELECCIONA UNA OPCIÓN*',
|
|
280
|
+
'Menú Principal', // título del botón que abre la lista
|
|
281
|
+
[
|
|
282
|
+
{
|
|
283
|
+
title: '📱 COMANDOS BÁSICOS',
|
|
284
|
+
rows: [
|
|
285
|
+
{ id: '#menu', title: '📋 Menú', description: 'Ver todos los comandos' },
|
|
286
|
+
{ id: '#ping', title: '🏓 Ping', description: 'Ver latencia del bot' },
|
|
287
|
+
{ id: '#owner', title: '👑 Owner', description: 'Info del creador' }
|
|
288
|
+
]
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
title: '🎮 COMANDOS DE GRUPO',
|
|
292
|
+
rows: [
|
|
293
|
+
{ id: '#add', title: '➕ Agregar', description: 'Agregar usuario al grupo' },
|
|
294
|
+
{ id: '#kick', title: '👢 Expulsar', description: 'Expulsar usuario del grupo' },
|
|
295
|
+
{ id: '#promote', title: '⭐ Promover', description: 'Dar admin a un usuario' }
|
|
296
|
+
]
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
title: '🔧 CONFIGURACIÓN',
|
|
300
|
+
rows: [
|
|
301
|
+
{ id: '#sinprefix', title: '⚙️ Sin Prefijo', description: 'Activar/desactivar prefijo' },
|
|
302
|
+
{ id: '#antilink', title: '🔗 Anti Link', description: 'Bloquear enlaces' }
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
]
|
|
306
|
+
)
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
### 🎯 `sendInteractiveMessage` — Múltiples Botones Mixtos
|
|
312
|
+
Combina distintos tipos de botones en un solo mensaje.
|
|
313
|
+
|
|
314
|
+
```javascript
|
|
315
|
+
await sendInteractiveMessage(
|
|
316
|
+
conn,
|
|
317
|
+
jid,
|
|
318
|
+
'🎯 *PANEL DE CONTROL*\n\nSelecciona una acción rápida:',
|
|
319
|
+
[
|
|
320
|
+
{ type: 'url', text: '🌐 GitHub', value: 'https://github.com/Fer2809fl/Asta_bot' },
|
|
321
|
+
{ type: 'copy', text: '📋 Comando Inicio', value: 'npm start' },
|
|
322
|
+
{ type: 'quick', text: '📋 Ver Menú', value: 'menu' }
|
|
323
|
+
]
|
|
324
|
+
)
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
### Plugin de ejemplo completo
|
|
330
|
+
|
|
331
|
+
Aquí un plugin listo para usar en tu bot con todos los tipos de botones:
|
|
332
|
+
|
|
333
|
+
```javascript
|
|
334
|
+
// plugins/botones.js
|
|
335
|
+
import {
|
|
336
|
+
sendCopyButton,
|
|
337
|
+
sendUrlButton,
|
|
338
|
+
sendQuickReplyButtons,
|
|
339
|
+
sendCallButton,
|
|
340
|
+
sendListMenu,
|
|
341
|
+
sendInteractiveMessage
|
|
342
|
+
} from '@fer2809fl/baileys'
|
|
343
|
+
|
|
344
|
+
let handler = async (m, { conn, usedPrefix }) => {
|
|
345
|
+
|
|
346
|
+
// #boton1 — Botón Copiar
|
|
347
|
+
if (m.text === `${usedPrefix}boton1`) {
|
|
348
|
+
await sendCopyButton(conn, m.chat,
|
|
349
|
+
'📋 *CÓDIGO DE INSTALACIÓN*\n\nEjecuta este comando en tu terminal:',
|
|
350
|
+
'npm install asta-bot',
|
|
351
|
+
'📋 Copiar Comando'
|
|
352
|
+
)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// #boton2 — Botón URL
|
|
356
|
+
else if (m.text === `${usedPrefix}boton2`) {
|
|
357
|
+
await sendUrlButton(conn, m.chat,
|
|
358
|
+
'🔗 *ENLACES IMPORTANTES*\n\nVisita nuestro repositorio oficial:',
|
|
359
|
+
'https://github.com/Fer2809fl/Asta_bot',
|
|
360
|
+
'🌐 Ver GitHub'
|
|
361
|
+
)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// #boton3 — Botones de Respuesta Rápida
|
|
365
|
+
else if (m.text === `${usedPrefix}boton3`) {
|
|
366
|
+
await sendQuickReplyButtons(conn, m.chat,
|
|
367
|
+
'🎮 *MENÚ DE OPCIONES*\n\n¿Qué deseas hacer?',
|
|
368
|
+
[
|
|
369
|
+
{ id: 'menu', text: '📋 Ver Menú' },
|
|
370
|
+
{ id: 'info', text: 'ℹ️ Información' },
|
|
371
|
+
{ id: 'owner', text: '👑 Owner' }
|
|
372
|
+
]
|
|
373
|
+
)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// #boton4 — Botón de Llamada
|
|
377
|
+
else if (m.text === `${usedPrefix}boton4`) {
|
|
378
|
+
await sendCallButton(conn, m.chat,
|
|
379
|
+
'📞 *SOPORTE TÉCNICO*\n\n¿Necesitas ayuda? Llámanos:',
|
|
380
|
+
'+5214183357841',
|
|
381
|
+
'📞 Llamar Ahora'
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// #boton5 — Lista Desplegable
|
|
386
|
+
else if (m.text === `${usedPrefix}boton5`) {
|
|
387
|
+
await sendListMenu(conn, m.chat,
|
|
388
|
+
'📋 *SELECCIONA UNA OPCIÓN*',
|
|
389
|
+
'Menú Principal',
|
|
390
|
+
[
|
|
391
|
+
{
|
|
392
|
+
title: '📱 COMANDOS BÁSICOS',
|
|
393
|
+
rows: [
|
|
394
|
+
{ id: '#menu', title: '📋 Menú', description: 'Ver todos los comandos' },
|
|
395
|
+
{ id: '#ping', title: '🏓 Ping', description: 'Ver latencia del bot' },
|
|
396
|
+
{ id: '#owner', title: '👑 Owner', description: 'Info del creador' }
|
|
397
|
+
]
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
title: '🎮 COMANDOS DE GRUPO',
|
|
401
|
+
rows: [
|
|
402
|
+
{ id: '#add', title: '➕ Agregar', description: 'Agregar usuario al grupo' },
|
|
403
|
+
{ id: '#kick', title: '👢 Expulsar', description: 'Expulsar usuario del grupo' },
|
|
404
|
+
{ id: '#promote', title: '⭐ Promover', description: 'Dar admin a un usuario' }
|
|
405
|
+
]
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
title: '🔧 CONFIGURACIÓN',
|
|
409
|
+
rows: [
|
|
410
|
+
{ id: '#sinprefix', title: '⚙️ Sin Prefijo', description: 'Activar/desactivar prefijo' },
|
|
411
|
+
{ id: '#antilink', title: '🔗 Anti Link', description: 'Bloquear enlaces' }
|
|
412
|
+
]
|
|
413
|
+
}
|
|
414
|
+
]
|
|
415
|
+
)
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// #boton6 — Botones Mixtos
|
|
419
|
+
else if (m.text === `${usedPrefix}boton6`) {
|
|
420
|
+
await sendInteractiveMessage(conn, m.chat,
|
|
421
|
+
'🎯 *PANEL DE CONTROL*\n\nSelecciona una acción rápida:',
|
|
422
|
+
[
|
|
423
|
+
{ type: 'url', text: '🌐 GitHub', value: 'https://github.com/Fer2809fl/Asta_bot' },
|
|
424
|
+
{ type: 'copy', text: '📋 Comando Inicio', value: 'npm start' },
|
|
425
|
+
{ type: 'quick', text: '📋 Ver Menú', value: 'menu' }
|
|
426
|
+
]
|
|
427
|
+
)
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// #botones — Ayuda
|
|
431
|
+
else if (m.text === `${usedPrefix}botones`) {
|
|
432
|
+
await conn.reply(m.chat,
|
|
433
|
+
`🧪 *COMANDOS DE PRUEBA - BOTONES INTERACTIVOS*\n\n` +
|
|
434
|
+
`┌✦ *BOTÓN COPIAR*\n` +
|
|
435
|
+
`│ ${usedPrefix}boton1 - Botón que copia texto\n│\n` +
|
|
436
|
+
`├✦ *BOTÓN URL*\n` +
|
|
437
|
+
`│ ${usedPrefix}boton2 - Botón que abre enlace\n│\n` +
|
|
438
|
+
`├✦ *BOTONES RÁPIDOS*\n` +
|
|
439
|
+
`│ ${usedPrefix}boton3 - Botones de respuesta\n│\n` +
|
|
440
|
+
`├✦ *BOTÓN LLAMADA*\n` +
|
|
441
|
+
`│ ${usedPrefix}boton4 - Botón para llamar\n│\n` +
|
|
442
|
+
`├✦ *LISTA DESPLEGABLE*\n` +
|
|
443
|
+
`│ ${usedPrefix}boton5 - Menú con opciones\n│\n` +
|
|
444
|
+
`└✦ *MÚLTIPLES BOTONES*\n` +
|
|
445
|
+
` ${usedPrefix}boton6 - Combinación de botones\n\n` +
|
|
446
|
+
`✨ *Prueba cada uno y mira cómo funcionan!*`, m)
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
handler.command = ['boton1', 'boton2', 'boton3', 'boton4', 'boton5', 'boton6', 'botones']
|
|
451
|
+
handler.help = ['boton1', 'boton2', 'boton3', 'boton4', 'boton5', 'boton6', 'botones']
|
|
452
|
+
handler.tags = ['test']
|
|
453
|
+
|
|
454
|
+
export default handler
|
|
455
|
+
```
|
|
137
456
|
|
|
138
457
|
---
|
|
139
458
|
|
|
@@ -143,7 +462,7 @@ startBot()
|
|
|
143
462
|
|
|
144
463
|
```javascript
|
|
145
464
|
// JavaScript
|
|
146
|
-
const { makeWASocket, useMultiFileAuthState } = require('@
|
|
465
|
+
const { makeWASocket, useMultiFileAuthState } = require('@fer2809fl/baileys')
|
|
147
466
|
|
|
148
467
|
const { state, saveCreds } = await useMultiFileAuthState('session-mymelody')
|
|
149
468
|
const melody = makeWASocket({ auth: state, printQRInTerminal: true })
|
|
@@ -152,7 +471,7 @@ melody.ev.on('creds.update', saveCreds)
|
|
|
152
471
|
|
|
153
472
|
```typescript
|
|
154
473
|
// TypeScript
|
|
155
|
-
import makeWASocket, { useMultiFileAuthState } from '@
|
|
474
|
+
import makeWASocket, { useMultiFileAuthState } from '@fer2809fl/baileys'
|
|
156
475
|
|
|
157
476
|
const { state, saveCreds } = await useMultiFileAuthState('session-mymelody')
|
|
158
477
|
const melody = makeWASocket({ auth: state, printQRInTerminal: true })
|
|
@@ -225,19 +544,9 @@ melody.ev.on('messages.upsert', async ({ messages }) => {
|
|
|
225
544
|
text: '¡Hola! Soy Delta, ¿en qué puedo ayudarte?'
|
|
226
545
|
})
|
|
227
546
|
break
|
|
228
|
-
|
|
229
547
|
case 'ping':
|
|
230
|
-
await melody.sendMessage(m.key.remoteJid, {
|
|
231
|
-
text: '🏓 Pong!'
|
|
232
|
-
})
|
|
548
|
+
await melody.sendMessage(m.key.remoteJid, { text: '🏓 Pong!' })
|
|
233
549
|
break
|
|
234
|
-
|
|
235
|
-
case 'stickers':
|
|
236
|
-
await melody.sendMessage(m.key.remoteJid, {
|
|
237
|
-
text: '¡Aquí tienes stickers lindos!'
|
|
238
|
-
})
|
|
239
|
-
break
|
|
240
|
-
|
|
241
550
|
default:
|
|
242
551
|
await melody.sendMessage(m.key.remoteJid, {
|
|
243
552
|
text: `Comando desconocido: ${cmd}`
|
|
@@ -246,44 +555,10 @@ melody.ev.on('messages.upsert', async ({ messages }) => {
|
|
|
246
555
|
})
|
|
247
556
|
```
|
|
248
557
|
|
|
249
|
-
### TypeScript
|
|
250
|
-
```typescript
|
|
251
|
-
melody.ev.on('messages.upsert', async ({ messages }) => {
|
|
252
|
-
const m = messages[0]
|
|
253
|
-
const body: string = m.message?.conversation
|
|
254
|
-
?? m.message?.extendedTextMessage?.text
|
|
255
|
-
?? ''
|
|
256
|
-
|
|
257
|
-
const prefix = '!'
|
|
258
|
-
if (!body.startsWith(prefix)) return
|
|
259
|
-
|
|
260
|
-
const [cmd, ...args]: string[] = body.slice(prefix.length).trim().split(' ')
|
|
261
|
-
|
|
262
|
-
const commands: Record<string, () => Promise<void>> = {
|
|
263
|
-
hola: async () => {
|
|
264
|
-
await melody.sendMessage(m.key.remoteJid!, {
|
|
265
|
-
text: '¡Hola! Soy My Melody, ¿en qué puedo ayudarte?'
|
|
266
|
-
})
|
|
267
|
-
},
|
|
268
|
-
ping: async () => {
|
|
269
|
-
await melody.sendMessage(m.key.remoteJid!, { text: '🏓 Pong!' })
|
|
270
|
-
},
|
|
271
|
-
info: async () => {
|
|
272
|
-
await melody.sendMessage(m.key.remoteJid!, {
|
|
273
|
-
text: `📌 JID: ${m.key.remoteJid}\n👤 Sender: ${m.key.participant ?? m.key.remoteJid}`
|
|
274
|
-
})
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
await commands[cmd.toLowerCase()]?.()
|
|
279
|
-
})
|
|
280
|
-
```
|
|
281
|
-
|
|
282
558
|
---
|
|
283
559
|
|
|
284
560
|
## ⚙️ Configuración Avanzada
|
|
285
561
|
|
|
286
|
-
### JavaScript
|
|
287
562
|
```javascript
|
|
288
563
|
const melody = makeWASocket({
|
|
289
564
|
auth: state,
|
|
@@ -296,21 +571,6 @@ const melody = makeWASocket({
|
|
|
296
571
|
})
|
|
297
572
|
```
|
|
298
573
|
|
|
299
|
-
### TypeScript
|
|
300
|
-
```typescript
|
|
301
|
-
import pino from 'pino'
|
|
302
|
-
|
|
303
|
-
const melody = makeWASocket({
|
|
304
|
-
auth: state,
|
|
305
|
-
printQRInTerminal: true,
|
|
306
|
-
markOnlineOnConnect: false,
|
|
307
|
-
browser: ["Delta", "Chrome", "1.0.0"] as [string, string, string],
|
|
308
|
-
logger: pino({ level: 'silent' }),
|
|
309
|
-
syncFullHistory: false,
|
|
310
|
-
generateHighQualityLinkPreview: true
|
|
311
|
-
})
|
|
312
|
-
```
|
|
313
|
-
|
|
314
574
|
---
|
|
315
575
|
|
|
316
576
|
## 🛠️ Funciones Útiles
|
|
@@ -327,7 +587,7 @@ async function broadcastMessage(jids, message) {
|
|
|
327
587
|
|
|
328
588
|
### Descargar medios recibidos
|
|
329
589
|
```javascript
|
|
330
|
-
const { downloadMediaMessage } = require('@
|
|
590
|
+
const { downloadMediaMessage } = require('@fer2809fl/baileys')
|
|
331
591
|
|
|
332
592
|
melody.ev.on('messages.upsert', async ({ messages }) => {
|
|
333
593
|
const m = messages[0]
|
|
@@ -356,35 +616,6 @@ await melody.sendMessage(jid, {
|
|
|
356
616
|
|
|
357
617
|
---
|
|
358
618
|
|
|
359
|
-
## 📘 TypeScript — Tipos Personalizados
|
|
360
|
-
|
|
361
|
-
```typescript
|
|
362
|
-
import makeWASocket, { WASocket, proto } from '@Fer280809/Baileys'
|
|
363
|
-
|
|
364
|
-
// Tipo para un mensaje con datos del remitente
|
|
365
|
-
type MessageWithSender = proto.IWebMessageInfo & {
|
|
366
|
-
senderName?: string
|
|
367
|
-
isGroup?: boolean
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// Función tipada para procesar mensajes
|
|
371
|
-
async function processMessage(
|
|
372
|
-
sock: WASocket,
|
|
373
|
-
msg: MessageWithSender
|
|
374
|
-
): Promise<void> {
|
|
375
|
-
const jid = msg.key.remoteJid!
|
|
376
|
-
const text = msg.message?.conversation ?? ''
|
|
377
|
-
|
|
378
|
-
if (text === '!tipo') {
|
|
379
|
-
await sock.sendMessage(jid, {
|
|
380
|
-
text: `Tipo de chat: ${msg.isGroup ? 'Grupo' : 'Privado'}`
|
|
381
|
-
})
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
---
|
|
387
|
-
|
|
388
619
|
## 📁 Estructura Recomendada del Proyecto
|
|
389
620
|
|
|
390
621
|
```
|
|
@@ -394,7 +625,8 @@ mi-bot/
|
|
|
394
625
|
├── commands/
|
|
395
626
|
│ ├── hola.js
|
|
396
627
|
│ ├── ping.js
|
|
397
|
-
│
|
|
628
|
+
│ ├── stickers.js
|
|
629
|
+
│ └── botones.js
|
|
398
630
|
├── events/
|
|
399
631
|
│ ├── messages.js
|
|
400
632
|
│ └── connection.js
|
|
@@ -405,20 +637,25 @@ mi-bot/
|
|
|
405
637
|
|
|
406
638
|
---
|
|
407
639
|
|
|
408
|
-
##
|
|
640
|
+
## 📝 Historial de Versiones
|
|
409
641
|
|
|
410
|
-
|
|
411
|
-
|
|
642
|
+
| Versión | Cambios |
|
|
643
|
+
|---------|---------|
|
|
644
|
+
| **1.8.9** | ✅ Botones interactivos (`sendCopyButton`, `sendUrlButton`, `sendQuickReplyButtons`, `sendCallButton`, `sendListMenu`, `sendInteractiveMessage`) — 🐛 Fix error de pairing en macOS |
|
|
645
|
+
| 1.4.5 | Versión estable anterior |
|
|
412
646
|
|
|
413
647
|
---
|
|
414
648
|
|
|
415
|
-
|
|
649
|
+
## 🔗 Links
|
|
416
650
|
|
|
417
|
-
|
|
651
|
+
- 📦 npm: [npmjs.com/package/@fer2809fl/baileys](https://www.npmjs.com/package/@fer2809fl/baileys)
|
|
652
|
+
- 💻 Repositorio: [github.com/Fer2809fl/Baileys](https://github.com/Fer2809fl/Baileys)
|
|
653
|
+
- 🐛 Issues: [github.com/Fer2809fl/Baileys/issues](https://github.com/Fer2809fl/Baileys/issues)
|
|
418
654
|
|
|
419
655
|
---
|
|
420
656
|
|
|
421
|
-
|
|
657
|
+
<div align="center">
|
|
422
658
|
|
|
659
|
+
Desarrollado con 🤍 por [Fer2809fl](https://github.com/Fer2809fl)
|
|
423
660
|
|
|
424
661
|
</div>
|
package/lib/Baileys.jpeg
ADDED
|
Binary file
|
|
@@ -7,6 +7,7 @@ exports.GroupCipher = void 0;
|
|
|
7
7
|
const crypto_1 = require("libsignal/src/crypto");
|
|
8
8
|
const queue_job_1 = __importDefault(require("./queue-job"));
|
|
9
9
|
const sender_key_message_1 = require("./sender-key-message");
|
|
10
|
+
|
|
10
11
|
class GroupCipher {
|
|
11
12
|
constructor(senderKeyStore, senderKeyName) {
|
|
12
13
|
this.senderKeyStore = senderKeyStore;
|
|
@@ -35,20 +36,28 @@ class GroupCipher {
|
|
|
35
36
|
}
|
|
36
37
|
async decrypt(senderKeyMessageBytes) {
|
|
37
38
|
return await this.queueJob(async () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
try {
|
|
40
|
+
const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
|
|
41
|
+
if (!record) {
|
|
42
|
+
throw new Error('No SenderKeyRecord found for decryption');
|
|
43
|
+
}
|
|
44
|
+
const senderKeyMessage = new sender_key_message_1.SenderKeyMessage(null, null, null, null, senderKeyMessageBytes);
|
|
45
|
+
const senderKeyState = record.getSenderKeyState(senderKeyMessage.getKeyId());
|
|
46
|
+
if (!senderKeyState) {
|
|
47
|
+
throw new Error('No session found to decrypt message');
|
|
48
|
+
}
|
|
49
|
+
senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic());
|
|
50
|
+
const senderKey = this.getSenderKey(senderKeyState, senderKeyMessage.getIteration());
|
|
51
|
+
const plaintext = await this.getPlainText(senderKey.getIv(), senderKey.getCipherKey(), senderKeyMessage.getCipherText());
|
|
52
|
+
await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
|
|
53
|
+
return plaintext;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (error.message === 'Bad MAC' || error.message === 'No session found to decrypt message') {
|
|
56
|
+
// Ignorar error silenciosamente
|
|
57
|
+
throw new Error('Bad MAC');
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
46
60
|
}
|
|
47
|
-
senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic());
|
|
48
|
-
const senderKey = this.getSenderKey(senderKeyState, senderKeyMessage.getIteration());
|
|
49
|
-
const plaintext = await this.getPlainText(senderKey.getIv(), senderKey.getCipherKey(), senderKeyMessage.getCipherText());
|
|
50
|
-
await this.senderKeyStore.storeSenderKey(this.senderKeyName, record);
|
|
51
|
-
return plaintext;
|
|
52
61
|
});
|
|
53
62
|
}
|
|
54
63
|
getSenderKey(senderKeyState, iteration) {
|