@sixcore/baileys
v1.0.2
Published
Baileys core adaptado para @sixcore/baileys
Maintainers
Readme
@sixcore/baileys
Fork modificado e extendido do Baileys — WhatsApp Web API
Desenvolvido em Moçambique , para o mundo.
Suporte nativo a botões, interactive messages, buttons flow, download melhorado e muito mais.
"A luta continua"
⚠️ Aviso
Este projeto não é afiliado, endossado ou conectado oficialmente ao WhatsApp Inc. ou Meta Platforms, Inc.
Use com responsabilidade. O autor não se responsabiliza por banimentos ou violações dos Termos de Serviço do WhatsApp.
📦 Instalação
npm install @sixcore/baileys🚀 Início Rápido
const makeWASocket = require('@sixcore/baileys').default
const { useMultiFileAuthState, fetchLatestBaileysVersion, DisconnectReason } = require('@sixcore/baileys')
const qrcode = require('qrcode-terminal')
async function start() {
const { state, saveCreds } = await useMultiFileAuthState('./auth_info')
const { version } = await fetchLatestBaileysVersion()
const sock = makeWASocket({
version,
auth: state,
printQRInTerminal: false,
browser: ['Ubuntu', 'Chrome', '20.0.04'],
})
sock.ev.on('creds.update', saveCreds)
sock.ev.on('connection.update', ({ connection, lastDisconnect, qr }) => {
if (qr) qrcode.generate(qr, { small: true })
if (connection === 'open') console.log('✅ Conectado!')
if (connection === 'close') {
const code = lastDisconnect?.error?.output?.statusCode
if (code !== DisconnectReason.loggedOut) start()
}
})
sock.ev.on('messages.upsert', async ({ messages, type }) => {
if (type !== 'notify') return
for (const m of messages) {
if (m.key.fromMe) continue
console.log('Nova mensagem de:', m.key.remoteJid)
}
})
}
start()🔗 Conexão
QR Code
const sock = makeWASocket({
auth: state,
printQRInTerminal: true
})Pairing Code (sem QR)
const sock = makeWASocket({
auth: state,
printQRInTerminal: false
})
if (!sock.authState.creds.registered) {
const number = '2588XXXXXXXX' // número moçambicano: 258 + número
const code = await sock.requestPairingCode(number)
console.log('Código:', code)
}💬 Mensagens
Texto simples
await sock.sendMessage(jid, { text: 'Olá! Maboko!' })Responder mensagem
await sock.sendMessage(jid, { text: 'Resposta!' }, { quoted: message })Mencionar usuário
await sock.sendMessage(jid, {
text: '@2588XXXXXXXX olá!',
mentions: ['[email protected]']
})Editar mensagem
const sent = await sock.sendMessage(jid, { text: 'Texto original' })
await sock.sendMessage(jid, { text: 'Texto corrigido', edit: sent.key })Apagar para todos
const sent = await sock.sendMessage(jid, { text: 'Olá' })
await sock.sendMessage(jid, { delete: sent.key })Reagir
await sock.sendMessage(jid, {
react: { text: '', key: message.key }
})🔘 Botões
Buttons simples
await sock.sendMessage(jid, {
text: 'Escolha uma opção:',
footer: '@sixcore/baileys ',
buttons: [
{ buttonId: 'op1', buttonText: { displayText: '✅ Opção 1' }, type: 1 },
{ buttonId: 'op2', buttonText: { displayText: '❌ Opção 2' }, type: 1 },
],
headerType: 1,
viewOnce: true,
})Buttons Flow (botões + lista embutida)
Exclusivo do
@sixcore/baileys— combina botões clicáveis com lista dropdown num único componente.
await sock.sendMessage(jid, {
text: 'Escolha:',
footer: '@sixcore/baileys ',
buttons: [
{ buttonId: 'b1', buttonText: { displayText: '🤖 Opção A' }, type: 1 },
{
buttonId: 'b2',
buttonText: { displayText: '📋 Abrir Lista' },
type: 4,
nativeFlowInfo: {
name: 'single_select',
paramsJson: JSON.stringify({
title: 'Selecione',
sections: [{
title: 'Secção 1',
highlight_label: '⭐ Novo',
rows: [
{ id: 'row1', title: 'Item 1', description: 'Descrição 1' },
{ id: 'row2', title: 'Item 2', description: 'Descrição 2' },
]
}]
})
}
}
],
headerType: 1,
viewOnce: true,
})Interactive Buttons
await sock.sendMessage(jid, {
text: 'Selecione uma ação:',
title: 'Menu',
footer: '@sixcore/baileys ',
interactiveButtons: [
{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: '✅ Confirmar', id: 'confirm' }) },
{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: '❌ Cancelar', id: 'cancel' }) },
{ name: 'cta_url', buttonParamsJson: JSON.stringify({ display_text: '🌐 GitHub', url: 'https://github.com/Ytsixx/lena-baileys' }) },
],
})Interactive Lista
await sock.sendMessage(jid, {
text: 'Escolha um item:',
title: 'Menu',
footer: '@sixcore/baileys ',
interactiveButtons: [{
name: 'single_select',
buttonParamsJson: JSON.stringify({
title: 'Abrir lista',
sections: [
{
title: 'Secção 1',
rows: [
{ id: 'item1', title: 'Item 1', description: 'Descrição 1' },
{ id: 'item2', title: 'Item 2', description: 'Descrição 2' },
]
}
]
})
}]
})Imagem com Botões
await sock.sendMessage(jid, {
image: buffer,
caption: 'Legenda',
footer: '@sixcore/baileys ',
buttons: [
{ buttonId: 'sim', buttonText: { displayText: '✅ Sim' }, type: 1 },
{ buttonId: 'nao', buttonText: { displayText: '❌ Não' }, type: 1 },
],
headerType: 4,
viewOnce: true,
})Imagem com Interactive Buttons
await sock.sendMessage(jid, {
image: buffer,
caption: 'Descrição',
title: 'Título',
footer: '@sixcore/baileys ',
media: true,
interactiveButtons: [
{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: '❤️ Curtir', id: 'like' }) },
{ name: 'cta_url', buttonParamsJson: JSON.stringify({ display_text: '🌐 Ver mais', url: 'https://github.com/Ytsixx/lena-baileys' }) },
],
})🖼️ Mídia
Imagem
await sock.sendMessage(jid, {
image: { url: 'https://...' },
caption: 'Legenda'
})Vídeo
await sock.sendMessage(jid, {
video: { url: 'https://...' },
caption: 'Legenda',
mimetype: 'video/mp4'
})GIF
await sock.sendMessage(jid, {
video: { url: 'https://...' },
gifPlayback: true,
mimetype: 'video/mp4'
})Áudio
await sock.sendMessage(jid, {
audio: { url: 'https://...' },
mimetype: 'audio/mp4'
})PTT (nota de voz)
await sock.sendMessage(jid, {
audio: { url: 'https://...' },
mimetype: 'audio/ogg; codecs=opus',
ptt: true
})Documento
await sock.sendMessage(jid, {
document: { url: 'https://...' },
mimetype: 'application/pdf',
fileName: 'arquivo.pdf'
})Sticker
await sock.sendMessage(jid, { sticker: buffer })View Once
await sock.sendMessage(jid, {
image: { url: 'https://...' },
viewOnce: true,
caption: 'Ver uma vez'
})📥 Download de Mídia
Original
const { downloadContentFromMessage } = require('@sixcore/baileys')
const stream = await downloadContentFromMessage(message.imageMessage, 'image')
const chunks = []
for await (const chunk of stream) chunks.push(chunk)
const buffer = Buffer.concat(chunks)V1 — Melhorado ⚡
Retry automático, progresso, cache em memória, timeout e salvamento direto em arquivo.
const { downloadContentFromMessageV1 } = require('@sixcore/baileys')
// Como buffer
const buffer = await downloadContentFromMessageV1(message.imageMessage, 'image', {
asBuffer: true,
useCache: true,
timeoutMs: 60_000,
retries: 3,
onProgress: ({ downloaded, total, percent }) => {
console.log(`Download: ${percent}%`)
}
})
// Salvar em arquivo
await downloadContentFromMessageV1(message.videoMessage, 'video', {
saveToFile: './video.mp4',
retries: 5,
timeoutMs: 120_000,
})Opções do V1
| Opção | Tipo | Padrão | Descrição |
|---|---|---|---|
| asBuffer | boolean | false | Retorna Buffer em vez de stream |
| useCache | boolean | false | Cache em memória para evitar re-downloads |
| saveToFile | string | null | Caminho para salvar direto em arquivo |
| timeoutMs | number | 60000 | Timeout em milissegundos |
| retries | number | 3 | Tentativas automáticas em caso de falha |
| onProgress | function | null | ({ downloaded, total, percent }) => void |
👤 Perfil
// Foto de perfil
const url = await sock.profilePictureUrl(jid, 'image')
// Status/Bio
const status = await sock.fetchStatus(jid)
// Verificar se número existe
const [result] = await sock.onWhatsApp(jid)
if (result.exists) console.log('JID:', result.jid)
// Atualizar foto
await sock.updateProfilePicture(jid, { url: './foto.jpg' })
// Atualizar nome
await sock.updateProfileName('Novo Nome')
// Atualizar status
await sock.updateProfileStatus('Feito em Moçambique ')👥 Grupos
// Criar grupo
const group = await sock.groupCreate('Nome do Grupo', ['[email protected]'])
// Adicionar / Remover / Promover / Rebaixar
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'add')
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'remove')
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'promote')
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'demote')
// Metadados
const meta = await sock.groupMetadata(jid)
// Link de convite
const code = await sock.groupInviteCode(jid)
console.log('https://chat.whatsapp.com/' + code)
// Sair do grupo
await sock.groupLeave(jid)🔔 Eventos
sock.ev.on('messages.upsert', ({ messages, type }) => { })
sock.ev.on('messages.update', (updates) => { })
sock.ev.on('connection.update', ({ connection, qr, lastDisconnect }) => { })
sock.ev.on('creds.update', saveCreds)
sock.ev.on('group-participants.update', ({ id, participants, action }) => { })
sock.ev.on('presence.update', ({ id, presences }) => { })
sock.ev.on('call', (calls) => { })🛠️ Utilitários
const {
getContentType,
getDevice,
jidNormalizedUser,
detectMimeType,
clearDownloadCache
} = require('@sixcore/baileys')
// Tipo da mensagem
const type = getContentType(message)
// 'conversation' | 'imageMessage' | 'videoMessage' | ...
// Dispositivo pelo ID
const device = getDevice(message.key.id)
// 'android' | 'ios' | 'web' | 'desktop'
// Normalizar JID
const jid = jidNormalizedUser('[email protected]')
// Mime type por buffer
const mime = detectMimeType(buffer)
// 'image/jpeg' | 'video/mp4' | 'audio/ogg' | ...
// Limpar cache de downloads
clearDownloadCache()📋 Enquetes
await sock.sendMessage(jid, {
poll: {
name: 'Qual cidade preferes?',
values: ['Maputo 🌆', 'Beira 🌊', 'Nampula 🌿', 'Tete ⛏️'],
selectableCount: 1,
}
})📍 Localização
// Maputo — capital de Moçambique
await sock.sendMessage(jid, {
location: {
degreesLatitude: -25.9692,
degreesLongitude: 32.5732
}
})🔒 Privacidade
await sock.updateLastSeenPrivacy('contacts')
await sock.updateOnlinePrivacy('all')
await sock.updateProfilePicturePrivacy('contacts')
await sock.updateStatusPrivacy('contacts')
await sock.updateReadReceiptsPrivacy('all')
await sock.updateGroupsAddPrivacy('contacts')
await sock.updateBlockStatus(jid, 'block') // ou 'unblock'🆔 Formato de JIDs
| Tipo | Formato |
|---|---|
| Usuário (MZ) | [email protected] |
| Grupo | [email protected] |
| Status | status@broadcast |
| Broadcast | 123456789@broadcast |
| Newsletter | 123456789@newsletter |
⚙️ Configuração do Socket
const sock = makeWASocket({
version,
auth: state,
printQRInTerminal: false,
browser: ['Ubuntu', 'Chrome', '20.0.04'],
markOnlineOnConnect: false,
syncFullHistory: false,
getMessage: async (key) => { /* buscar do store */ },
cachedGroupMetadata: async (jid) => groupCache.get(jid),
logger: pino({ level: 'silent' }),
})📝 Changelog
v7.0.0-rc.9
- ✅ Suporte nativo a buttons, buttons flow, interactive buttons, interactive lista
- ✅ Suporte a imagem/vídeo com botões
- ✅
downloadContentFromMessageV1— retry automático, cache, progresso, timeout, salvar em arquivo - ✅
detectMimeType— detecção de mime type por buffer - ✅
clearDownloadCache— limpeza manual do cache de downloads
📄 Licença
MIT — © Sixx
Feito com em Moçambique
@sixcore/baileys — por Sixx
Moçambique para o mundo 🌍
