f-baileys
v1.0.1
Published
π Fast & Stable WhatsApp Bot Library β Pairing Code + QR Code Support, Multi-Platform (Termux/VPS/Panel), Full Dependency Auto-Installer
Maintainers
Readme
f-baileys π
Fast Β· Stable Β· Multi-Platform WhatsApp Bot Library
Pairing Code β | QR Code β | Auto-Install β | Termux/VPS/Panel β
β¨ Features
| Feature | Status | |---------|--------| | Pairing Code login (100% masuk) | β | | QR Code login | β | | Auto-reconnect on disconnect | β | | Multi-platform support | β | | Auto-install missing dependencies | β | | Serialized message objects | β | | Send Text/Image/Video/Audio/Sticker/Document | β | | TypeScript definitions | β | | Pterodactyl Panel compatible | β | | Termux (F-Droid) compatible | β |
π¦ Install
npm install f-baileysSaat install, f-baileys otomatis mendeteksi platform dan menginstall dependensi yang kurang.
π Quick Start
Mode QR Code
const FBaileys = require('f-baileys');
const bot = new FBaileys({
sessionPath: './session',
usePairingCode: false, // QR Code mode
printQR: true,
autoReconnect: true,
});
bot.on('open', () => console.log('β Connected!'));
bot.on('message', async (msg) => {
if (msg.fromMe) return;
if (msg.text === 'ping') {
await msg.reply('Pong! π');
}
});
bot.connect();Mode Pairing Code
const FBaileys = require('f-baileys');
const bot = new FBaileys({
sessionPath: './session',
usePairingCode: true, // β Pairing Code
phoneNumber: '628xxxxxxxxxx', // Nomor HP (tanpa + atau spasi)
autoReconnect: true,
});
bot.on('open', () => console.log('β Connected via Pairing Code!'));
bot.on('message', async (msg) => {
if (msg.text === 'halo') await msg.reply('Halo juga!');
});
bot.connect();βοΈ Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| sessionPath | string | './f_session' | Folder simpan session |
| usePairingCode | boolean | false | true = pairing code, false = QR |
| phoneNumber | string | null | Nomor HP untuk pairing code |
| printQR | boolean | true | Auto print QR ke terminal |
| logLevel | string | 'silent' | 'silent' / 'info' / 'debug' |
| autoReconnect | boolean | true | Auto reconnect saat putus |
| reconnectDelay | number | 3000 | Delay reconnect (ms) |
| baileysOptions | object | {} | Extra config ke makeWASocket |
π¨ Message Object
Setiap pesan yang diterima sudah diserialisasi:
bot.on('message', async (msg) => {
msg.id // ID pesan
msg.from // JID pengirim/grup
msg.sender // JID pengirim (di dalam grup)
msg.senderNum // Nomor pengirim (tanpa @s.whatsapp.net)
msg.fromMe // true jika pesan dari bot sendiri
msg.isGroup // true jika pesan dari grup
msg.text // Isi teks pesan
msg.type // Tipe pesan (imageMessage, videoMessage, dll)
msg.pushName // Nama pengirim
msg.timestamp // Unix timestamp
// Flags
msg.isText // Pesan teks
msg.isImage // Pesan gambar
msg.isVideo // Pesan video
msg.isAudio // Pesan audio
msg.isSticker // Pesan stiker
msg.isDocument // Pesan dokumen
// Quoted message
msg.quoted?.body // Teks quoted
msg.quoted?.type // Tipe quoted
// Helpers
await msg.reply('Teks') // Balas pesan
await msg.react('β
') // Reaksi emoji
});π€ Send Methods
// Teks
await bot.sendText(jid, 'Hello!');
await bot.sendText(jid, 'Reply!', quotedMsg);
// Gambar
await bot.sendImage(jid, './gambar.jpg', 'Caption');
await bot.sendImage(jid, 'https://..../img.jpg', 'Caption');
// Video
await bot.sendVideo(jid, './video.mp4', 'Caption');
// Audio
await bot.sendAudio(jid, './audio.mp3');
await bot.sendAudio(jid, './voice.ogg', true); // ptt = voice note
// Sticker
await bot.sendSticker(jid, './sticker.webp');
// Dokumen
await bot.sendDocument(jid, './file.pdf', 'dokumen.pdf', 'application/pdf');
// Reaksi
await bot.sendReaction(jid, msg.key, 'π₯');
// Typing indicator
await bot.sendTyping(jid, 2000); // Typing selama 2 detik
// Download media dari pesan
const buffer = await bot.downloadMedia(msg);π Platform Support
| Platform | Status | |----------|--------| | VPS Linux (Ubuntu/Debian/CentOS) | β | | Termux (Google Play) | β | | Termux (F-Droid) | β | | Pterodactyl Panel | β | | Docker | β | | Windows | β | | macOS | β |
π¦ Dependencies (Auto-Install)
Saat npm install f-baileys, package berikut otomatis diinstall jika belum ada:
| Package | Fungsi |
|---------|--------|
| @whiskeysockets/baileys | Core WhatsApp MD |
| sharp | Image processing (WebP, resize, dll) |
| jimp | Pure JS image processing |
| fluent-ffmpeg | FFmpeg wrapper (convert audio/video) |
| ffmpeg-static | Binary FFmpeg |
| ytdl-core | YouTube downloader |
| webp-converter | Konversi ke WebP (sticker) |
| color | Manipulasi warna |
| chalk | Warna terminal |
| qrcode-terminal | Print QR di terminal |
| axios | HTTP requests |
| pino | Logger |
Untuk Termux: f-baileys otomatis menjalankan
pkg install ffmpeg nodejsjuga.
π± Pairing Code Guide
- Jalankan bot dengan
usePairingCode: true - Kode 8 digit akan muncul di terminal (format:
XXXX-XXXX) - Buka WhatsApp di HP β Perangkat Tertaut β Tautkan Perangkat
- Pilih Tautkan dengan Nomor Telepon
- Masukkan kode yang tampil di terminal
- Selesai! β
π§ Events
bot.on('qr', (qr) => { ... }) // QR string
bot.on('open', (sock) => { ... }) // Connected
bot.on('close', ({ reason, code }) => {}) // Disconnected
bot.on('message', (msg) => { ... }) // Pesan masuk
bot.on('logout', () => { ... }) // Session logout
bot.on('group-update', (update) => { ... }) // Update grupπ Utility
// Convert nomor ke JID
FBaileys.toJid('628123456789') // β [email protected]
FBaileys.toGroupJid('120363xxxxxx') // β [email protected]π License
MIT Β© f-baileys
