@systemzero/baileys 1.0.3 → 1.0.4
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 +1092 -0
- package/lib/Socket/messages-send.js +50 -19
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,1092 @@
|
|
|
1
|
+
# 📦 @systemzero/baileys `v1.0.4`
|
|
2
|
+
|
|
3
|
+
> Biblioteca WhatsApp Web API em Node.js — fork ultra customizado com funções avançadas de envio de mensagens, grupos, mídias, IA e muito mais.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 📋 Sumário
|
|
8
|
+
|
|
9
|
+
- [Instalação](#instalação)
|
|
10
|
+
- [Conexão Básica](#conexão-básica)
|
|
11
|
+
- [📨 Envio de Mensagens](#-envio-de-mensagens)
|
|
12
|
+
- [Texto](#texto)
|
|
13
|
+
- [Imagem](#imagem)
|
|
14
|
+
- [Vídeo](#vídeo)
|
|
15
|
+
- [Áudio](#áudio)
|
|
16
|
+
- [Documento](#documento)
|
|
17
|
+
- [Sticker](#sticker)
|
|
18
|
+
- [Localização](#localização)
|
|
19
|
+
- [Contato](#contato)
|
|
20
|
+
- [Enquete (Poll)](#enquete-poll)
|
|
21
|
+
- [Reação](#reação)
|
|
22
|
+
- [Menção](#menção)
|
|
23
|
+
- [Link com Preview](#link-com-preview)
|
|
24
|
+
- [Resposta (Quoted)](#resposta-quoted)
|
|
25
|
+
- [Mensagem Editada](#mensagem-editada)
|
|
26
|
+
- [Mensagem Deletada](#mensagem-deletada)
|
|
27
|
+
- [Fixar Mensagem](#fixar-mensagem)
|
|
28
|
+
- [View Once](#view-once)
|
|
29
|
+
- [Modo Efêmero (Desaparecimento)](#modo-efêmero-desaparecimento)
|
|
30
|
+
- [🎨 Mensagens Interativas (Botões)](#-mensagens-interativas-botões)
|
|
31
|
+
- [Botões Rápidos (Quick Reply)](#botões-rápidos-quick-reply)
|
|
32
|
+
- [Lista](#lista)
|
|
33
|
+
- [Botões Nativos (interactiveButtons)](#botões-nativos-interactivebuttons)
|
|
34
|
+
- [Pagamento Nativo](#pagamento-nativo)
|
|
35
|
+
- [Produto](#produto)
|
|
36
|
+
- [🤖 Funções Rich (Meta AI Style)](#-funções-rich-meta-ai-style)
|
|
37
|
+
- [Texto Rico](#texto-rico)
|
|
38
|
+
- [Código Rico](#código-rico)
|
|
39
|
+
- [Lista Rica](#lista-rica)
|
|
40
|
+
- [Tabela Rica](#tabela-rica)
|
|
41
|
+
- [Rich Completo](#rich-completo)
|
|
42
|
+
- [Reels Ricos](#reels-ricos)
|
|
43
|
+
- [Perplexity IA](#perplexity-ia)
|
|
44
|
+
- [📁 Tipos Especiais de Mensagem](#-tipos-especiais-de-mensagem)
|
|
45
|
+
- [Álbum de Fotos/Vídeos](#álbum-de-fotosvídeos)
|
|
46
|
+
- [Evento](#evento)
|
|
47
|
+
- [Resultado de Enquete](#resultado-de-enquete)
|
|
48
|
+
- [Story de Grupo](#story-de-grupo)
|
|
49
|
+
- [Pagamento (requestPayment)](#pagamento-requestpayment)
|
|
50
|
+
- [👥 Funções de Grupo](#-funções-de-grupo)
|
|
51
|
+
- [💬 Funções de Chat](#-funções-de-chat)
|
|
52
|
+
- [🔒 Privacidade](#-privacidade)
|
|
53
|
+
- [🏷️ Labels](#️-labels)
|
|
54
|
+
- [📡 Presença](#-presença)
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Instalação
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install @systemzero/baileys
|
|
62
|
+
# ou
|
|
63
|
+
yarn add @systemzero/baileys
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
> **Requisito:** Node.js >= 20.0.0
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Conexão Básica
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
import makeWASocket, { useMultiFileAuthState, DisconnectReason } from '@systemzero/baileys'
|
|
74
|
+
|
|
75
|
+
const { state, saveCreds } = await useMultiFileAuthState('./auth_info')
|
|
76
|
+
|
|
77
|
+
const sock = makeWASocket({
|
|
78
|
+
auth: state,
|
|
79
|
+
printQRInTerminal: true
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
sock.ev.on('creds.update', saveCreds)
|
|
83
|
+
|
|
84
|
+
sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
|
|
85
|
+
if (connection === 'close') {
|
|
86
|
+
const shouldReconnect = lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut
|
|
87
|
+
if (shouldReconnect) conectar()
|
|
88
|
+
} else if (connection === 'open') {
|
|
89
|
+
console.log('✅ Conectado ao WhatsApp!')
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 📨 Envio de Mensagens
|
|
97
|
+
|
|
98
|
+
Todas as funções de envio usam `sock.sendMessage(jid, conteúdo, opções?)`.
|
|
99
|
+
|
|
100
|
+
O `jid` é o identificador do destinatário:
|
|
101
|
+
- **Privado:** `'5511999999999@s.whatsapp.net'`
|
|
102
|
+
- **Grupo:** `'120363xxxxxxxx@g.us'`
|
|
103
|
+
- **Status:** `'status@broadcast'`
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### Texto
|
|
108
|
+
|
|
109
|
+
Envia uma mensagem de texto simples.
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
await sock.sendMessage('5511999999999@s.whatsapp.net', {
|
|
113
|
+
text: 'Olá, mundo! 👋'
|
|
114
|
+
})
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Com formatação WhatsApp:
|
|
118
|
+
```js
|
|
119
|
+
await sock.sendMessage(jid, {
|
|
120
|
+
text: '*negrito* _itálico_ ~tachado~ `monoespaçado`'
|
|
121
|
+
})
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### Imagem
|
|
127
|
+
|
|
128
|
+
Envia uma imagem com legenda opcional. Aceita **Buffer**, **URL** ou **caminho local**.
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
// Por URL
|
|
132
|
+
await sock.sendMessage(jid, {
|
|
133
|
+
image: { url: 'https://exemplo.com/foto.jpg' },
|
|
134
|
+
caption: 'Uma linda foto 🖼️'
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
// Por Buffer
|
|
138
|
+
import { readFileSync } from 'fs'
|
|
139
|
+
await sock.sendMessage(jid, {
|
|
140
|
+
image: readFileSync('./imagem.jpg'),
|
|
141
|
+
caption: 'Foto do arquivo'
|
|
142
|
+
})
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
### Vídeo
|
|
148
|
+
|
|
149
|
+
Envia um vídeo com legenda opcional. Aceita **Buffer**, **URL** ou **caminho local**.
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
// Por URL
|
|
153
|
+
await sock.sendMessage(jid, {
|
|
154
|
+
video: { url: 'https://exemplo.com/video.mp4' },
|
|
155
|
+
caption: 'Assista esse vídeo! 🎬',
|
|
156
|
+
mimetype: 'video/mp4'
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
// Como GIF animado
|
|
160
|
+
await sock.sendMessage(jid, {
|
|
161
|
+
video: readFileSync('./animacao.mp4'),
|
|
162
|
+
gifPlayback: true, // Reproduz como GIF
|
|
163
|
+
caption: 'Olha esse gif!'
|
|
164
|
+
})
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### Áudio
|
|
170
|
+
|
|
171
|
+
Envia um áudio. Use `ptt: true` para enviar como mensagem de voz (PTT).
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
// Áudio normal (arquivo de música)
|
|
175
|
+
await sock.sendMessage(jid, {
|
|
176
|
+
audio: { url: 'https://exemplo.com/musica.mp3' },
|
|
177
|
+
mimetype: 'audio/mp4'
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
// Mensagem de voz (PTT)
|
|
181
|
+
await sock.sendMessage(jid, {
|
|
182
|
+
audio: readFileSync('./audio.ogg'),
|
|
183
|
+
mimetype: 'audio/ogg; codecs=opus',
|
|
184
|
+
ptt: true // Aparece como áudio de voz
|
|
185
|
+
})
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### Documento
|
|
191
|
+
|
|
192
|
+
Envia um arquivo/documento com nome customizado.
|
|
193
|
+
|
|
194
|
+
```js
|
|
195
|
+
await sock.sendMessage(jid, {
|
|
196
|
+
document: { url: 'https://exemplo.com/arquivo.pdf' },
|
|
197
|
+
mimetype: 'application/pdf',
|
|
198
|
+
fileName: 'Relatório Mensal.pdf',
|
|
199
|
+
caption: 'Segue o relatório em anexo 📄'
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
// Por Buffer
|
|
203
|
+
await sock.sendMessage(jid, {
|
|
204
|
+
document: readFileSync('./contrato.docx'),
|
|
205
|
+
mimetype: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
206
|
+
fileName: 'Contrato.docx'
|
|
207
|
+
})
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
### Sticker
|
|
213
|
+
|
|
214
|
+
Envia um sticker (figurinha). Deve ser WebP ou convertido previamente.
|
|
215
|
+
|
|
216
|
+
```js
|
|
217
|
+
await sock.sendMessage(jid, {
|
|
218
|
+
sticker: readFileSync('./figurinha.webp')
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
// Por URL
|
|
222
|
+
await sock.sendMessage(jid, {
|
|
223
|
+
sticker: { url: 'https://exemplo.com/sticker.webp' }
|
|
224
|
+
})
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
### Localização
|
|
230
|
+
|
|
231
|
+
Envia uma localização no mapa.
|
|
232
|
+
|
|
233
|
+
```js
|
|
234
|
+
await sock.sendMessage(jid, {
|
|
235
|
+
location: {
|
|
236
|
+
degreesLatitude: -23.5505,
|
|
237
|
+
degreesLongitude: -46.6333,
|
|
238
|
+
name: 'São Paulo, SP',
|
|
239
|
+
address: 'Av. Paulista, 1000'
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
### Contato
|
|
247
|
+
|
|
248
|
+
Envia um contato (vCard).
|
|
249
|
+
|
|
250
|
+
```js
|
|
251
|
+
const vcard = `BEGIN:VCARD
|
|
252
|
+
VERSION:3.0
|
|
253
|
+
FN:João Silva
|
|
254
|
+
ORG:Empresa LTDA;
|
|
255
|
+
TEL;type=CELL;type=VOICE;waid=5511999999999:+55 11 99999-9999
|
|
256
|
+
END:VCARD`
|
|
257
|
+
|
|
258
|
+
await sock.sendMessage(jid, {
|
|
259
|
+
contacts: {
|
|
260
|
+
displayName: 'João Silva',
|
|
261
|
+
contacts: [{ vcard }]
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
### Enquete (Poll)
|
|
269
|
+
|
|
270
|
+
Cria uma enquete interativa no WhatsApp.
|
|
271
|
+
|
|
272
|
+
```js
|
|
273
|
+
await sock.sendMessage(jid, {
|
|
274
|
+
poll: {
|
|
275
|
+
name: 'Qual sua linguagem favorita?',
|
|
276
|
+
values: ['JavaScript', 'Python', 'TypeScript', 'Go'],
|
|
277
|
+
selectableCount: 1 // Quantas opções o usuário pode escolher
|
|
278
|
+
}
|
|
279
|
+
})
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### Reação
|
|
285
|
+
|
|
286
|
+
Reage a uma mensagem com um emoji.
|
|
287
|
+
|
|
288
|
+
```js
|
|
289
|
+
await sock.sendMessage(jid, {
|
|
290
|
+
react: {
|
|
291
|
+
text: '❤️', // Emoji da reação (string vazia para remover)
|
|
292
|
+
key: mensagem.key // Key da mensagem que será reagida
|
|
293
|
+
}
|
|
294
|
+
})
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Para remover uma reação:
|
|
298
|
+
```js
|
|
299
|
+
await sock.sendMessage(jid, {
|
|
300
|
+
react: { text: '', key: mensagem.key }
|
|
301
|
+
})
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
### Menção
|
|
307
|
+
|
|
308
|
+
Menciona um ou mais usuários no texto.
|
|
309
|
+
|
|
310
|
+
```js
|
|
311
|
+
await sock.sendMessage(jid, {
|
|
312
|
+
text: 'Oi @5511999999999, tudo bem?',
|
|
313
|
+
mentions: ['5511999999999@s.whatsapp.net']
|
|
314
|
+
})
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
### Link com Preview
|
|
320
|
+
|
|
321
|
+
Envia uma mensagem de texto — o preview do link é gerado automaticamente se `generateHighQualityLinkPreview: true` estiver ativado na config.
|
|
322
|
+
|
|
323
|
+
```js
|
|
324
|
+
await sock.sendMessage(jid, {
|
|
325
|
+
text: 'Confira: https://github.com'
|
|
326
|
+
})
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
### Resposta (Quoted)
|
|
332
|
+
|
|
333
|
+
Responde a uma mensagem específica.
|
|
334
|
+
|
|
335
|
+
```js
|
|
336
|
+
// Dentro do handler de mensagens:
|
|
337
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
338
|
+
const msg = messages[0]
|
|
339
|
+
|
|
340
|
+
await sock.sendMessage(msg.key.remoteJid, {
|
|
341
|
+
text: 'Essa é minha resposta!'
|
|
342
|
+
}, {
|
|
343
|
+
quoted: msg // Passa a mensagem original para responder
|
|
344
|
+
})
|
|
345
|
+
})
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
### Mensagem Editada
|
|
351
|
+
|
|
352
|
+
Edita o conteúdo de uma mensagem já enviada.
|
|
353
|
+
|
|
354
|
+
```js
|
|
355
|
+
await sock.sendMessage(jid, {
|
|
356
|
+
text: 'Texto corrigido ✏️',
|
|
357
|
+
edit: mensagemOriginal.key // Key da mensagem a ser editada
|
|
358
|
+
})
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
### Mensagem Deletada
|
|
364
|
+
|
|
365
|
+
Deleta uma mensagem (para todos).
|
|
366
|
+
|
|
367
|
+
```js
|
|
368
|
+
await sock.sendMessage(jid, {
|
|
369
|
+
delete: mensagem.key // Key da mensagem a deletar
|
|
370
|
+
})
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
### Fixar Mensagem
|
|
376
|
+
|
|
377
|
+
Fixa uma mensagem no chat ou grupo.
|
|
378
|
+
|
|
379
|
+
```js
|
|
380
|
+
await sock.sendMessage(jid, {
|
|
381
|
+
pin: mensagem.key, // Key da mensagem a fixar
|
|
382
|
+
type: 1 // 1 = fixar, 2 = desfixar
|
|
383
|
+
})
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
### View Once
|
|
389
|
+
|
|
390
|
+
Envia mídia que some após ser visualizada uma vez.
|
|
391
|
+
|
|
392
|
+
```js
|
|
393
|
+
await sock.sendMessage(jid, {
|
|
394
|
+
image: readFileSync('./foto_secreta.jpg'),
|
|
395
|
+
viewOnce: true,
|
|
396
|
+
caption: 'Esta foto vai sumir! 🔥'
|
|
397
|
+
})
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
### Modo Efêmero (Desaparecimento)
|
|
403
|
+
|
|
404
|
+
Ativa ou desativa mensagens temporárias em grupos.
|
|
405
|
+
|
|
406
|
+
```js
|
|
407
|
+
// Ativar (86400 = 24h, 604800 = 7 dias, 7776000 = 90 dias)
|
|
408
|
+
await sock.sendMessage(jid, {
|
|
409
|
+
disappearingMessagesInChat: 604800 // 7 dias em segundos
|
|
410
|
+
})
|
|
411
|
+
|
|
412
|
+
// Desativar
|
|
413
|
+
await sock.sendMessage(jid, {
|
|
414
|
+
disappearingMessagesInChat: false
|
|
415
|
+
})
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## 🎨 Mensagens Interativas (Botões)
|
|
421
|
+
|
|
422
|
+
### Botões Rápidos (Quick Reply)
|
|
423
|
+
|
|
424
|
+
Envia botões de resposta rápida usando a sintaxe simplificada.
|
|
425
|
+
|
|
426
|
+
```js
|
|
427
|
+
await sock.sendMessage(jid, {
|
|
428
|
+
text: 'Escolha uma opção:',
|
|
429
|
+
footer: 'Sistema de Atendimento',
|
|
430
|
+
buttons: [
|
|
431
|
+
{ buttonText: { displayText: '✅ Sim' }, buttonId: 'sim' },
|
|
432
|
+
{ buttonText: { displayText: '❌ Não' }, buttonId: 'nao' },
|
|
433
|
+
{ buttonText: { displayText: '❓ Talvez' }, buttonId: 'talvez' }
|
|
434
|
+
]
|
|
435
|
+
})
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
### Lista
|
|
441
|
+
|
|
442
|
+
Envia uma lista interativa de opções (menu).
|
|
443
|
+
|
|
444
|
+
```js
|
|
445
|
+
await sock.sendMessage(jid, {
|
|
446
|
+
listMessage: {
|
|
447
|
+
title: 'Menu Principal',
|
|
448
|
+
text: 'Selecione uma opção abaixo:',
|
|
449
|
+
footer: 'Powered by SystemZero',
|
|
450
|
+
buttonText: 'Ver Opções',
|
|
451
|
+
sections: [
|
|
452
|
+
{
|
|
453
|
+
title: 'Serviços',
|
|
454
|
+
rows: [
|
|
455
|
+
{ title: 'Suporte', description: 'Falar com atendente', rowId: 'suporte' },
|
|
456
|
+
{ title: 'Financeiro', description: 'Ver cobranças', rowId: 'financeiro' }
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
]
|
|
460
|
+
}
|
|
461
|
+
})
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
### Botões Nativos (interactiveButtons)
|
|
467
|
+
|
|
468
|
+
Botões nativos com suporte a imagem/vídeo no cabeçalho.
|
|
469
|
+
|
|
470
|
+
```js
|
|
471
|
+
await sock.sendMessage(jid, {
|
|
472
|
+
interactiveButtons: [
|
|
473
|
+
{
|
|
474
|
+
name: 'quick_reply',
|
|
475
|
+
buttonParamsJson: JSON.stringify({
|
|
476
|
+
display_text: '📋 Ver Cardápio',
|
|
477
|
+
id: 'cardapio'
|
|
478
|
+
})
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
name: 'cta_url',
|
|
482
|
+
buttonParamsJson: JSON.stringify({
|
|
483
|
+
display_text: '🌐 Acessar Site',
|
|
484
|
+
url: 'https://meusite.com',
|
|
485
|
+
merchant_url: 'https://meusite.com'
|
|
486
|
+
})
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
name: 'cta_call',
|
|
490
|
+
buttonParamsJson: JSON.stringify({
|
|
491
|
+
display_text: '📞 Ligar',
|
|
492
|
+
phone_number: '+5511999999999'
|
|
493
|
+
})
|
|
494
|
+
}
|
|
495
|
+
],
|
|
496
|
+
text: 'Olá! Como posso te ajudar?',
|
|
497
|
+
footer: 'Atendimento 24h'
|
|
498
|
+
})
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
---
|
|
502
|
+
|
|
503
|
+
### Pagamento Nativo
|
|
504
|
+
|
|
505
|
+
Solicita um pagamento pelo WhatsApp Pay.
|
|
506
|
+
|
|
507
|
+
```js
|
|
508
|
+
await sock.sendMessage(jid, {
|
|
509
|
+
interactiveButtons: [
|
|
510
|
+
{
|
|
511
|
+
name: 'review_and_pay',
|
|
512
|
+
buttonParamsJson: JSON.stringify({
|
|
513
|
+
currency: 'BRL',
|
|
514
|
+
total_amount: { value: 5000, offset: 100 }, // R$ 50,00
|
|
515
|
+
reference_id: 'PEDIDO-001',
|
|
516
|
+
type: 'physical-goods',
|
|
517
|
+
order: {
|
|
518
|
+
status: 'pending',
|
|
519
|
+
subtotal: { value: 5000, offset: 100 },
|
|
520
|
+
order_type: 'ORDER',
|
|
521
|
+
items: [{
|
|
522
|
+
name: 'Produto X',
|
|
523
|
+
amount: { value: 5000, offset: 100 },
|
|
524
|
+
quantity: 1,
|
|
525
|
+
sale_amount: { value: 5000, offset: 100 }
|
|
526
|
+
}]
|
|
527
|
+
}
|
|
528
|
+
})
|
|
529
|
+
}
|
|
530
|
+
],
|
|
531
|
+
text: 'Seu pedido está pronto para pagamento!'
|
|
532
|
+
})
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
---
|
|
536
|
+
|
|
537
|
+
### Produto
|
|
538
|
+
|
|
539
|
+
Exibe um produto com imagem, preço e botões de ação.
|
|
540
|
+
|
|
541
|
+
```js
|
|
542
|
+
await sock.sendMessage(jid, {
|
|
543
|
+
productMessage: {
|
|
544
|
+
title: 'Tênis Nike Air Max',
|
|
545
|
+
description: 'Conforto e estilo para o dia a dia.',
|
|
546
|
+
thumbnail: { url: 'https://exemplo.com/tenis.jpg' },
|
|
547
|
+
productId: 'PRODUTO-001',
|
|
548
|
+
retailerId: 'LOJA-BR',
|
|
549
|
+
priceAmount1000: 39900, // R$ 399,00
|
|
550
|
+
currencyCode: 'BRL',
|
|
551
|
+
url: 'https://minhaloja.com/produto',
|
|
552
|
+
body: 'Aproveite a oferta!',
|
|
553
|
+
footer: 'Frete grátis acima de R$ 200',
|
|
554
|
+
buttons: [
|
|
555
|
+
{
|
|
556
|
+
name: 'quick_reply',
|
|
557
|
+
buttonParamsJson: JSON.stringify({ display_text: '🛒 Comprar', id: 'comprar' })
|
|
558
|
+
}
|
|
559
|
+
]
|
|
560
|
+
}
|
|
561
|
+
})
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
## 🤖 Funções Rich (Meta AI Style)
|
|
567
|
+
|
|
568
|
+
Estas funções enviam mensagens no estilo do Meta AI com formatação especial.
|
|
569
|
+
|
|
570
|
+
### Texto Rico
|
|
571
|
+
|
|
572
|
+
```js
|
|
573
|
+
await sock.sendRichText(jid, 'Esta é uma mensagem de texto rica! ✨')
|
|
574
|
+
|
|
575
|
+
// Com resposta (quoted)
|
|
576
|
+
await sock.sendRichText(jid, 'Mensagem rica em resposta', mensagemOriginal)
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
---
|
|
580
|
+
|
|
581
|
+
### Código Rico
|
|
582
|
+
|
|
583
|
+
Exibe um bloco de código com syntax highlighting.
|
|
584
|
+
|
|
585
|
+
```js
|
|
586
|
+
await sock.sendRichCode(
|
|
587
|
+
jid,
|
|
588
|
+
'Exemplo em JavaScript:', // Título (opcional)
|
|
589
|
+
'javascript', // Linguagem
|
|
590
|
+
`function soma(a, b) {
|
|
591
|
+
return a + b;
|
|
592
|
+
}
|
|
593
|
+
console.log(soma(2, 3));`
|
|
594
|
+
)
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
599
|
+
### Lista Rica
|
|
600
|
+
|
|
601
|
+
Exibe uma lista de itens formatada.
|
|
602
|
+
|
|
603
|
+
```js
|
|
604
|
+
await sock.sendRichList(
|
|
605
|
+
jid,
|
|
606
|
+
'📋 Lista de Tarefas:', // Título
|
|
607
|
+
['Estudar Node.js', 'Fazer deploy', 'Testar bot', 'Dormir']
|
|
608
|
+
)
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
---
|
|
612
|
+
|
|
613
|
+
### Tabela Rica
|
|
614
|
+
|
|
615
|
+
Exibe uma tabela formatada (primeira linha é o cabeçalho).
|
|
616
|
+
|
|
617
|
+
```js
|
|
618
|
+
await sock.sendRichTable(
|
|
619
|
+
jid,
|
|
620
|
+
'📊 Relatório de Vendas', // Título
|
|
621
|
+
[
|
|
622
|
+
['Produto', 'Qtd', 'Valor'], // Cabeçalho
|
|
623
|
+
['Camiseta', '10', 'R$ 300'],
|
|
624
|
+
['Calça', '5', 'R$ 500'],
|
|
625
|
+
['Tênis', '3', 'R$ 900']
|
|
626
|
+
],
|
|
627
|
+
'Total: R$ 1.700' // Rodapé (opcional)
|
|
628
|
+
)
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
---
|
|
632
|
+
|
|
633
|
+
### Rich Completo
|
|
634
|
+
|
|
635
|
+
Combina texto, código, lista e tabela em uma única mensagem.
|
|
636
|
+
|
|
637
|
+
```js
|
|
638
|
+
await sock.sendRichFull(jid, {
|
|
639
|
+
title: '🚀 Relatório Completo',
|
|
640
|
+
code: `const resultado = calcular()`,
|
|
641
|
+
language: 'javascript',
|
|
642
|
+
items: ['Item A', 'Item B', 'Item C'],
|
|
643
|
+
table: [
|
|
644
|
+
['Campo', 'Valor'],
|
|
645
|
+
['Status', 'Ativo'],
|
|
646
|
+
['Versão', '1.0.3']
|
|
647
|
+
],
|
|
648
|
+
footer: '© SystemZero Baileys'
|
|
649
|
+
})
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
---
|
|
653
|
+
|
|
654
|
+
### Reels Ricos
|
|
655
|
+
|
|
656
|
+
Envia uma mensagem no estilo de resultado de busca com reels/vídeos.
|
|
657
|
+
|
|
658
|
+
```js
|
|
659
|
+
await sock.sendRichReels(
|
|
660
|
+
jid,
|
|
661
|
+
'Resultado da Busca', // Título
|
|
662
|
+
'Vídeos encontrados', // Header
|
|
663
|
+
'gatos fofinhos', // Query de busca
|
|
664
|
+
[
|
|
665
|
+
{
|
|
666
|
+
title: 'Gato dançando',
|
|
667
|
+
url: 'https://video1.com',
|
|
668
|
+
thumbnail: 'https://thumb1.com/img.jpg'
|
|
669
|
+
}
|
|
670
|
+
]
|
|
671
|
+
)
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
---
|
|
675
|
+
|
|
676
|
+
### Perplexity IA
|
|
677
|
+
|
|
678
|
+
Consulta a API Perplexity e envia a resposta no chat.
|
|
679
|
+
|
|
680
|
+
```js
|
|
681
|
+
await sock.sendPerplexity(
|
|
682
|
+
jid,
|
|
683
|
+
'Qual a capital do Brasil?'
|
|
684
|
+
)
|
|
685
|
+
|
|
686
|
+
// Com opções (ex: responder a uma mensagem)
|
|
687
|
+
await sock.sendPerplexity(
|
|
688
|
+
jid,
|
|
689
|
+
'Explique inteligência artificial',
|
|
690
|
+
{ quoted: mensagemOriginal }
|
|
691
|
+
)
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
---
|
|
695
|
+
|
|
696
|
+
## 📁 Tipos Especiais de Mensagem
|
|
697
|
+
|
|
698
|
+
### Álbum de Fotos/Vídeos
|
|
699
|
+
|
|
700
|
+
Envia múltiplas fotos/vídeos como um álbum agrupado.
|
|
701
|
+
|
|
702
|
+
```js
|
|
703
|
+
await sock.sendMessage(jid, {
|
|
704
|
+
albumMessage: [
|
|
705
|
+
{ image: { url: 'https://exemplo.com/foto1.jpg' }, caption: 'Foto 1' },
|
|
706
|
+
{ image: { url: 'https://exemplo.com/foto2.jpg' }, caption: 'Foto 2' },
|
|
707
|
+
{ video: { url: 'https://exemplo.com/clip.mp4' }, caption: 'Vídeo do evento' }
|
|
708
|
+
]
|
|
709
|
+
})
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
---
|
|
713
|
+
|
|
714
|
+
### Evento
|
|
715
|
+
|
|
716
|
+
Cria um evento no grupo ou conversa.
|
|
717
|
+
|
|
718
|
+
```js
|
|
719
|
+
await sock.sendMessage(jid, {
|
|
720
|
+
eventMessage: {
|
|
721
|
+
name: '🎉 Reunião de Equipe',
|
|
722
|
+
description: 'Reunião semanal de alinhamento da equipe de desenvolvimento.',
|
|
723
|
+
location: {
|
|
724
|
+
degreesLatitude: -23.5505,
|
|
725
|
+
degreesLongitude: -46.6333,
|
|
726
|
+
name: 'Escritório Central, São Paulo'
|
|
727
|
+
},
|
|
728
|
+
joinLink: 'https://meet.google.com/abc-xyz',
|
|
729
|
+
startTime: Date.now() + 86400000, // Amanhã
|
|
730
|
+
endTime: Date.now() + 86400000 + 3600000, // +1 hora
|
|
731
|
+
extraGuestsAllowed: true,
|
|
732
|
+
isCanceled: false
|
|
733
|
+
}
|
|
734
|
+
})
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
---
|
|
738
|
+
|
|
739
|
+
### Resultado de Enquete
|
|
740
|
+
|
|
741
|
+
Envia um snapshot de resultado de votação.
|
|
742
|
+
|
|
743
|
+
```js
|
|
744
|
+
await sock.sendMessage(jid, {
|
|
745
|
+
pollResultMessage: {
|
|
746
|
+
name: 'Qual sua linguagem favorita?',
|
|
747
|
+
pollVotes: [
|
|
748
|
+
{ optionName: 'JavaScript', optionVoteCount: 42 },
|
|
749
|
+
{ optionName: 'Python', optionVoteCount: 35 },
|
|
750
|
+
{ optionName: 'TypeScript', optionVoteCount: 28 }
|
|
751
|
+
]
|
|
752
|
+
}
|
|
753
|
+
})
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
---
|
|
757
|
+
|
|
758
|
+
### Story de Grupo
|
|
759
|
+
|
|
760
|
+
Envia uma mensagem como story/status de grupo.
|
|
761
|
+
|
|
762
|
+
```js
|
|
763
|
+
await sock.sendMessage(jid, {
|
|
764
|
+
groupStatusMessage: {
|
|
765
|
+
image: { url: 'https://exemplo.com/story.jpg' },
|
|
766
|
+
caption: 'Nosso grupo é o melhor! 🔥'
|
|
767
|
+
}
|
|
768
|
+
})
|
|
769
|
+
|
|
770
|
+
// Com vídeo
|
|
771
|
+
await sock.sendMessage(jid, {
|
|
772
|
+
groupStatusMessage: {
|
|
773
|
+
video: { url: 'https://exemplo.com/story.mp4' },
|
|
774
|
+
caption: 'Evento da semana'
|
|
775
|
+
}
|
|
776
|
+
})
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
---
|
|
780
|
+
|
|
781
|
+
### Pagamento (requestPayment)
|
|
782
|
+
|
|
783
|
+
Solicita um pagamento com nota ou sticker.
|
|
784
|
+
|
|
785
|
+
```js
|
|
786
|
+
await sock.sendMessage(jid, {
|
|
787
|
+
requestPaymentMessage: {
|
|
788
|
+
amount: 15000, // R$ 150,00 (em centavos × 10)
|
|
789
|
+
currency: 'BRL',
|
|
790
|
+
from: '5511999999999@s.whatsapp.net',
|
|
791
|
+
expiry: Math.floor(Date.now() / 1000) + 86400, // 24h
|
|
792
|
+
note: 'Pagamento do serviço de bot 🤖'
|
|
793
|
+
}
|
|
794
|
+
})
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
---
|
|
798
|
+
|
|
799
|
+
## 👥 Funções de Grupo
|
|
800
|
+
|
|
801
|
+
### Criar Grupo
|
|
802
|
+
|
|
803
|
+
```js
|
|
804
|
+
const grupo = await sock.groupCreate('Nome do Grupo', [
|
|
805
|
+
'5511999999999@s.whatsapp.net',
|
|
806
|
+
'5521888888888@s.whatsapp.net'
|
|
807
|
+
])
|
|
808
|
+
console.log('Grupo criado:', grupo.id)
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
---
|
|
812
|
+
|
|
813
|
+
### Metadados do Grupo
|
|
814
|
+
|
|
815
|
+
```js
|
|
816
|
+
const info = await sock.groupMetadata('120363xxxxxxxx@g.us')
|
|
817
|
+
console.log(info.subject) // Nome do grupo
|
|
818
|
+
console.log(info.participants) // Lista de participantes
|
|
819
|
+
console.log(info.desc) // Descrição
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
---
|
|
823
|
+
|
|
824
|
+
### Adicionar / Remover / Promover / Rebaixar Participantes
|
|
825
|
+
|
|
826
|
+
```js
|
|
827
|
+
// Adicionar
|
|
828
|
+
await sock.groupParticipantsUpdate(jid, ['5511999999999@s.whatsapp.net'], 'add')
|
|
829
|
+
|
|
830
|
+
// Remover
|
|
831
|
+
await sock.groupParticipantsUpdate(jid, ['5511999999999@s.whatsapp.net'], 'remove')
|
|
832
|
+
|
|
833
|
+
// Tornar admin
|
|
834
|
+
await sock.groupParticipantsUpdate(jid, ['5511999999999@s.whatsapp.net'], 'promote')
|
|
835
|
+
|
|
836
|
+
// Remover admin
|
|
837
|
+
await sock.groupParticipantsUpdate(jid, ['5511999999999@s.whatsapp.net'], 'demote')
|
|
838
|
+
```
|
|
839
|
+
|
|
840
|
+
---
|
|
841
|
+
|
|
842
|
+
### Atualizar Nome e Descrição
|
|
843
|
+
|
|
844
|
+
```js
|
|
845
|
+
await sock.groupUpdateSubject(jid, 'Novo Nome do Grupo ✨')
|
|
846
|
+
await sock.groupUpdateDescription(jid, 'Nova descrição incrível do grupo!')
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
---
|
|
850
|
+
|
|
851
|
+
### Link de Convite
|
|
852
|
+
|
|
853
|
+
```js
|
|
854
|
+
// Obter link
|
|
855
|
+
const code = await sock.groupInviteCode(jid)
|
|
856
|
+
console.log(`https://chat.whatsapp.com/${code}`)
|
|
857
|
+
|
|
858
|
+
// Revogar e gerar novo link
|
|
859
|
+
await sock.groupRevokeInvite(jid)
|
|
860
|
+
|
|
861
|
+
// Entrar por código
|
|
862
|
+
await sock.groupAcceptInvite('CodigoAqui')
|
|
863
|
+
|
|
864
|
+
// Info do grupo pelo link
|
|
865
|
+
const info = await sock.groupGetInviteInfo('CodigoAqui')
|
|
866
|
+
```
|
|
867
|
+
|
|
868
|
+
---
|
|
869
|
+
|
|
870
|
+
### Configurações do Grupo
|
|
871
|
+
|
|
872
|
+
```js
|
|
873
|
+
// Apenas admins enviam mensagens
|
|
874
|
+
await sock.groupSettingUpdate(jid, 'announcement')
|
|
875
|
+
|
|
876
|
+
// Todos podem enviar
|
|
877
|
+
await sock.groupSettingUpdate(jid, 'not_announcement')
|
|
878
|
+
|
|
879
|
+
// Apenas admins editam info
|
|
880
|
+
await sock.groupSettingUpdate(jid, 'locked')
|
|
881
|
+
|
|
882
|
+
// Todos editam info
|
|
883
|
+
await sock.groupSettingUpdate(jid, 'unlocked')
|
|
884
|
+
|
|
885
|
+
// Modo de adição de membros
|
|
886
|
+
await sock.groupMemberAddMode(jid, 'all_member_add') // Todos podem adicionar
|
|
887
|
+
await sock.groupMemberAddMode(jid, 'admin_add') // Só admins
|
|
888
|
+
|
|
889
|
+
// Aprovação para entrar
|
|
890
|
+
await sock.groupJoinApprovalMode(jid, 'on') // Ativar aprovação
|
|
891
|
+
await sock.groupJoinApprovalMode(jid, 'off') // Desativar
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
---
|
|
895
|
+
|
|
896
|
+
### Sair do Grupo
|
|
897
|
+
|
|
898
|
+
```js
|
|
899
|
+
await sock.groupLeave(jid)
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
---
|
|
903
|
+
|
|
904
|
+
### Solicitações de Participação
|
|
905
|
+
|
|
906
|
+
```js
|
|
907
|
+
// Listar solicitações pendentes
|
|
908
|
+
const solicitacoes = await sock.groupRequestParticipantsList(jid)
|
|
909
|
+
|
|
910
|
+
// Aprovar ou rejeitar
|
|
911
|
+
await sock.groupRequestParticipantsUpdate(jid, ['5511999999999@s.whatsapp.net'], 'approve')
|
|
912
|
+
await sock.groupRequestParticipantsUpdate(jid, ['5511999999999@s.whatsapp.net'], 'reject')
|
|
913
|
+
```
|
|
914
|
+
|
|
915
|
+
---
|
|
916
|
+
|
|
917
|
+
## 💬 Funções de Chat
|
|
918
|
+
|
|
919
|
+
### Modificar Chat
|
|
920
|
+
|
|
921
|
+
```js
|
|
922
|
+
// Arquivar conversa
|
|
923
|
+
await sock.chatModify({ archive: true, lastMessages: [mensagem] }, jid)
|
|
924
|
+
|
|
925
|
+
// Marcar como não lida
|
|
926
|
+
await sock.chatModify({ markRead: false, lastMessages: [mensagem] }, jid)
|
|
927
|
+
|
|
928
|
+
// Mutar por 8 horas
|
|
929
|
+
await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
|
|
930
|
+
|
|
931
|
+
// Desmutar
|
|
932
|
+
await sock.chatModify({ mute: null }, jid)
|
|
933
|
+
|
|
934
|
+
// Fixar conversa
|
|
935
|
+
await sock.chatModify({ pin: true }, jid)
|
|
936
|
+
|
|
937
|
+
// Limpar mensagens
|
|
938
|
+
await sock.chatModify({ clear: { messages: [{ id: 'ID_MSG', fromMe: true }] } }, jid)
|
|
939
|
+
|
|
940
|
+
// Deletar conversa
|
|
941
|
+
await sock.chatModify({ delete: true, lastMessages: [mensagem] }, jid)
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
---
|
|
945
|
+
|
|
946
|
+
### Marcar como Lida
|
|
947
|
+
|
|
948
|
+
```js
|
|
949
|
+
const key = { remoteJid: jid, id: mensagem.key.id, participant: mensagem.key.participant }
|
|
950
|
+
await sock.readMessages([key])
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
---
|
|
954
|
+
|
|
955
|
+
### Status e Perfil
|
|
956
|
+
|
|
957
|
+
```js
|
|
958
|
+
// Ver foto de perfil
|
|
959
|
+
const url = await sock.profilePictureUrl('5511999999999@s.whatsapp.net', 'image')
|
|
960
|
+
|
|
961
|
+
// Atualizar foto de perfil
|
|
962
|
+
await sock.updateProfilePicture(jid, readFileSync('./nova_foto.jpg'))
|
|
963
|
+
|
|
964
|
+
// Remover foto de perfil
|
|
965
|
+
await sock.removeProfilePicture(jid)
|
|
966
|
+
|
|
967
|
+
// Atualizar status (bio)
|
|
968
|
+
await sock.updateProfileStatus('Desenvolvendo bots 🤖')
|
|
969
|
+
|
|
970
|
+
// Atualizar nome
|
|
971
|
+
await sock.updateProfileName('Meu Bot')
|
|
972
|
+
|
|
973
|
+
// Ver status de outro usuário
|
|
974
|
+
const status = await sock.fetchStatus('5511999999999@s.whatsapp.net')
|
|
975
|
+
```
|
|
976
|
+
|
|
977
|
+
---
|
|
978
|
+
|
|
979
|
+
### Bloquear / Desbloquear
|
|
980
|
+
|
|
981
|
+
```js
|
|
982
|
+
await sock.updateBlockStatus('5511999999999@s.whatsapp.net', 'block')
|
|
983
|
+
await sock.updateBlockStatus('5511999999999@s.whatsapp.net', 'unblock')
|
|
984
|
+
|
|
985
|
+
// Ver lista de bloqueados
|
|
986
|
+
const bloqueados = await sock.fetchBlocklist()
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
---
|
|
990
|
+
|
|
991
|
+
### Contatos
|
|
992
|
+
|
|
993
|
+
```js
|
|
994
|
+
// Adicionar ou editar contato
|
|
995
|
+
await sock.addOrEditContact({
|
|
996
|
+
jid: '5511999999999@s.whatsapp.net',
|
|
997
|
+
notify: 'João Silva'
|
|
998
|
+
})
|
|
999
|
+
|
|
1000
|
+
// Remover contato
|
|
1001
|
+
await sock.removeContact('5511999999999@s.whatsapp.net')
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
---
|
|
1005
|
+
|
|
1006
|
+
## 🔒 Privacidade
|
|
1007
|
+
|
|
1008
|
+
```js
|
|
1009
|
+
// Último visto: 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
|
1010
|
+
await sock.updateLastSeenPrivacy('contacts')
|
|
1011
|
+
|
|
1012
|
+
// Online: 'all' | 'match_last_seen'
|
|
1013
|
+
await sock.updateOnlinePrivacy('all')
|
|
1014
|
+
|
|
1015
|
+
// Foto de perfil: 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
|
1016
|
+
await sock.updateProfilePicturePrivacy('contacts')
|
|
1017
|
+
|
|
1018
|
+
// Status: 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
|
1019
|
+
await sock.updateStatusPrivacy('contacts')
|
|
1020
|
+
|
|
1021
|
+
// Confirmação de leitura: 'all' | 'none'
|
|
1022
|
+
await sock.updateReadReceiptsPrivacy('all')
|
|
1023
|
+
|
|
1024
|
+
// Adição em grupos: 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
|
1025
|
+
await sock.updateGroupsAddPrivacy('contacts')
|
|
1026
|
+
|
|
1027
|
+
// Chamadas: 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
|
1028
|
+
await sock.updateCallPrivacy('contacts')
|
|
1029
|
+
|
|
1030
|
+
// Preview de links: 'all' | 'none'
|
|
1031
|
+
await sock.updateDisableLinkPreviewsPrivacy('none')
|
|
1032
|
+
|
|
1033
|
+
// Modo de desaparecimento padrão
|
|
1034
|
+
await sock.updateDefaultDisappearingMode(604800) // 7 dias
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
---
|
|
1038
|
+
|
|
1039
|
+
## 🏷️ Labels
|
|
1040
|
+
|
|
1041
|
+
```js
|
|
1042
|
+
// Criar/editar label
|
|
1043
|
+
await sock.addLabel({ id: '1', name: 'Cliente VIP', color: 1 })
|
|
1044
|
+
|
|
1045
|
+
// Label em chat
|
|
1046
|
+
await sock.addChatLabel(jid, '1')
|
|
1047
|
+
await sock.removeChatLabel(jid, '1')
|
|
1048
|
+
|
|
1049
|
+
// Label em mensagem
|
|
1050
|
+
await sock.addMessageLabel(jid, msgId, '1')
|
|
1051
|
+
await sock.removeMessageLabel(jid, msgId, '1')
|
|
1052
|
+
|
|
1053
|
+
// Favoritar mensagem
|
|
1054
|
+
await sock.star(jid, [{ id: msgId, fromMe: true }], true)
|
|
1055
|
+
```
|
|
1056
|
+
|
|
1057
|
+
---
|
|
1058
|
+
|
|
1059
|
+
## 📡 Presença
|
|
1060
|
+
|
|
1061
|
+
```js
|
|
1062
|
+
// Tipos: 'available' | 'unavailable' | 'composing' | 'recording' | 'paused'
|
|
1063
|
+
await sock.sendPresenceUpdate('composing', jid) // "digitando..."
|
|
1064
|
+
await sock.sendPresenceUpdate('recording', jid) // "gravando áudio..."
|
|
1065
|
+
await sock.sendPresenceUpdate('available', jid) // Online
|
|
1066
|
+
await sock.sendPresenceUpdate('unavailable', jid) // Offline
|
|
1067
|
+
|
|
1068
|
+
// Inscrever-se na presença de alguém
|
|
1069
|
+
await sock.presenceSubscribe(jid)
|
|
1070
|
+
|
|
1071
|
+
// Ouvir updates de presença
|
|
1072
|
+
sock.ev.on('presence.update', ({ id, presences }) => {
|
|
1073
|
+
console.log(presences)
|
|
1074
|
+
})
|
|
1075
|
+
```
|
|
1076
|
+
|
|
1077
|
+
---
|
|
1078
|
+
|
|
1079
|
+
## 📌 Notas
|
|
1080
|
+
|
|
1081
|
+
- Todas as funções que enviam mensagens retornam o objeto `WAMessage` com a `key` da mensagem.
|
|
1082
|
+
- O campo `key.id` pode ser usado para referenciar a mensagem em edições, deleções e fixações.
|
|
1083
|
+
- Ao enviar mídia para grupos, certifique-se que o bot está participante do grupo.
|
|
1084
|
+
- Funções Rich (`sendRich*`) requerem que o WhatsApp do destinatário seja uma versão recente.
|
|
1085
|
+
|
|
1086
|
+
---
|
|
1087
|
+
|
|
1088
|
+
<div align="center">
|
|
1089
|
+
|
|
1090
|
+
**@systemzero/baileys v1.0.3** · Feito com ❤️ por [blackhzx](https://t.me/blackhzx)
|
|
1091
|
+
|
|
1092
|
+
</div>
|
|
@@ -12,6 +12,7 @@ import { makeNewsletterSocket } from './newsletter.js';
|
|
|
12
12
|
import Hzxx from './hzxx.js';
|
|
13
13
|
import { randomBytes } from 'crypto';
|
|
14
14
|
import axios from 'axios';
|
|
15
|
+
|
|
15
16
|
const META_AI_BOT_JID = '867051314767696@bot';
|
|
16
17
|
const META_AI_BOT_NAME = 'Meta AI';
|
|
17
18
|
const META_AI_CREATOR_NAME = 'Meta';
|
|
@@ -817,27 +818,28 @@ export const makeMessagesSocket = (config) => {
|
|
|
817
818
|
if (btn.name === 'payment_info' || btn.name === 'review_and_pay') {
|
|
818
819
|
try {
|
|
819
820
|
const params = JSON.parse(btn.buttonParamsJson);
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
params.order
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
821
|
+
if (btn.name !== 'galaxy_message') {
|
|
822
|
+
params.currency = params.currency || 'BRL';
|
|
823
|
+
params.total_amount = params.total_amount || { value: 0, offset: 100 };
|
|
824
|
+
params.reference_id = params.reference_id || randomBytes(4).toString('hex').toUpperCase();
|
|
825
|
+
params.type = params.type || 'physical-goods';
|
|
826
|
+
if (!params.order) {
|
|
827
|
+
params.order = {
|
|
828
|
+
status: 'pending',
|
|
829
|
+
subtotal: params.total_amount,
|
|
830
|
+
order_type: 'ORDER',
|
|
831
|
+
items: [{
|
|
832
|
+
name: 'Fatura via Pix',
|
|
833
|
+
amount: params.total_amount,
|
|
834
|
+
quantity: 1,
|
|
835
|
+
sale_amount: params.total_amount
|
|
836
|
+
}]
|
|
837
|
+
};
|
|
838
|
+
}
|
|
836
839
|
}
|
|
837
|
-
|
|
838
840
|
btn.buttonParamsJson = JSON.stringify(params);
|
|
839
841
|
} catch (e) {
|
|
840
|
-
logger.error({ err: e }, "
|
|
842
|
+
logger.error({ err: e }, "Erro ao processar JSON de Botao Nativo");
|
|
841
843
|
}
|
|
842
844
|
}
|
|
843
845
|
return btn;
|
|
@@ -1157,7 +1159,36 @@ export const makeMessagesSocket = (config) => {
|
|
|
1157
1159
|
ev.emit('messages.update', [{ key: message.key, update: { message: message.message } }]);
|
|
1158
1160
|
return message;
|
|
1159
1161
|
},
|
|
1160
|
-
sendMessage
|
|
1162
|
+
sendMessage,
|
|
1163
|
+
sendVitrine: async function(jid, title, description, productId, imageBuffer, options = {}) {
|
|
1164
|
+
try {
|
|
1165
|
+
const tempMsg = await generateWAMessage(jid, { image: imageBuffer }, {
|
|
1166
|
+
userJid: authState.creds.me.id,
|
|
1167
|
+
upload: waUploadToServer,
|
|
1168
|
+
logger
|
|
1169
|
+
});
|
|
1170
|
+
|
|
1171
|
+
const productImage = tempMsg.message.imageMessage;
|
|
1172
|
+
|
|
1173
|
+
const productMsg = generateWAMessageFromContent(jid, {
|
|
1174
|
+
productMessage: {
|
|
1175
|
+
product: {
|
|
1176
|
+
productImage: productImage,
|
|
1177
|
+
productId: String(productId),
|
|
1178
|
+
title: title,
|
|
1179
|
+
description: description,
|
|
1180
|
+
productImageCount: 1
|
|
1181
|
+
},
|
|
1182
|
+
businessOwnerJid: authState.creds.me.id.split(':')[0] + '@s.whatsapp.net'
|
|
1183
|
+
}
|
|
1184
|
+
}, { userJid: authState.creds.me.id, quoted: options.quoted });
|
|
1185
|
+
|
|
1186
|
+
return await relayMessage(jid, productMsg.message, { messageId: productMsg.key.id });
|
|
1187
|
+
} catch (e) {
|
|
1188
|
+
logger.error({ err: e }, "Erro ao enviar vitrine");
|
|
1189
|
+
throw e;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1161
1192
|
};
|
|
1162
1193
|
};
|
|
1163
1194
|
//# sourceMappingURL=messages-send.js.map
|