@nozezlab/baileys
v1.0.0
Published
Premium drop-in replacement for '@whiskeysockets/baileys' featuring native interactive buttons, single-select submenus, automated phone pairing, and high-performance message serialization.
Maintainers
Readme
@nozezlab/baileys 🚀
Customized premium wrapper for @whiskeysockets/baileys featuring native flow interactive buttons, single-select dropdown submenus, quick phone pairing, and automatic message serialization helper functions.
Designed as a 100% compatible, drop-in replacement!
📦 Installation
To install this customized library:
npm install @nozezlab/baileys✨ Core Features
- Native Interactive Buttons (
sendButtons): Easily send interactive buttons (replies, links, copy codes). - Single-Select Dropdown Menus (
sendList): Send structured dropdown options. - Message Serializer (
serializeMessage): Extracted fields likem.bodydirectly mapped (even for native button responses) and attached reply helpers likem.replyButtonsandm.replyList. - Built-in Phone Pairing (
pairWithPhoneNumber): Connect instantly by displaying the pairing code cleanly in the terminal.
🚀 Quick Start Example
Here is how easily you can initialize the socket and use the custom helpers:
const makeWASocket = require('@nozezlab/baileys').default;
const { useMultiFileAuthState } = require('@nozezlab/baileys');
async function startBot() {
const { state, saveCreds } = await useMultiFileAuthState('./session');
const sock = makeWASocket({
auth: state,
printQRInTerminal: false // Set to false to use Pairing Code
});
sock.ev.on('creds.update', saveCreds);
// 1. Phone pairing setup (if not registered yet)
if (!sock.authState.creds.registered) {
const phoneNumber = "628xxx"; // Change to your bot's phone number
await sock.pairWithPhoneNumber(phoneNumber);
}
sock.ev.on('connection.update', (update) => {
const { connection } = update;
if (connection === 'open') {
console.log("✅ Bot connected successfully!");
}
});
sock.ev.on('messages.upsert', async (chatUpdate) => {
const mek = chatUpdate.messages[0];
if (!mek.message) return;
// Serialize message to get custom helpers & body parser
const m = sock.serializeMessage(mek);
// Command handler example
if (m.body === '.menu') {
const buttons = [
{ type: 'reply', displayText: '📁 Show All Features', id: '.allfeatures' },
{ type: 'url', displayText: '🌐 Visit Website', url: 'https://nozez.dev' },
{ type: 'copy', displayText: '🔑 Copy API Key', code: 'API_KEY_12345' }
];
// Send buttons cleanly!
await m.replyButtons(
"🤖 NOZEZLAB SYSTEM", // Header (Optional)
"Welcome to KChartify Bot. Please select one option:", // Body text
"© NozezLab Ecosystem", // Footer (Optional)
buttons // Button list
);
}
});
}
startBot();🛠️ API Reference
1. sock.sendButtons(jid, header, text, footer, buttons, quoted, mediaOptions)
buttonssupports the following structures:const buttons = [ { type: 'reply', displayText: 'Option A', id: 'opt_a' }, { type: 'url', displayText: 'Open Website', url: 'https://example.com' }, { type: 'copy', displayText: 'Copy Code', code: 'MY_CODE' } ]mediaOptionssupports native image headers:await sock.sendButtons(jid, "Header", "Text", "Footer", buttons, null, { image: "https://example.com/banner.png" // or local file buffer });
2. sock.sendList(jid, header, text, footer, buttonText, sections, quoted, mediaOptions)
sectionsstructure:const sections = [ { title: "Category 1", rows: [ { title: "Option 1", description: "Select Option 1", id: ".opt1" }, { title: "Option 2", description: "Select Option 2", id: ".opt2" } ] } ]; await sock.sendList(jid, "Menu", "Select below", "Footer", "Click here", sections);
📄 License
MIT © NozezLab
