Skip to content

dcodemaxz/vikaru-baileys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

66 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Vikaru Baileys

πŸ“ Important Note

Important

This is a custom Baileys build by dcodemaxz, based on WhiskeySockets/Baileys.
This version includes several improvements, enhanced performance, and TypeScript compatibility.


✨ Added Features and Improvements

Tip

πŸ”₯ This Baileys is intended to support the Vikaru-Bot project

Message Management

Feature Description
πŸ’¬ Send Messages Send text, media, documents, and more with rich formatting
✏️ Edit Messages Edit sent messages after delivery
πŸ—‘οΈ Delete Messages Delete messages from your side or for everyone
❀️ React Messages React to messages with emojis (add/remove reactions)
πŸ“Œ Pin Messages Pin important messages in chats or groups
πŸ“ Keep Messages Mark messages as kept/important for later reference
πŸ—³οΈ Poll Messages Create and send interactive poll messages
πŸ€– AI Message Icon Add AI-styled icons to bot messages (biz_bot marker)

Media & Upload

Feature Description
πŸ–ΌοΈ Send Album Messages Send grouped media (album style) with captions
🎨 Media Utilities Resize, convert, compress, and sticker creation
🌊 Audio Waveform Automatic waveform generation for audio messages
πŸ“€ Media Upload Optimized media upload to WhatsApp servers
πŸ“₯ Media Download Download and save media from messages
πŸ–ΌοΈ Full-Size Profile Pictures Upload HD profile pictures without cropping
🎞️ Video to GIF Convert videos to animated GIFs

Interactive Messages

Feature Description
πŸ”˜ Button Messages Send interactive button messages (quick reply, URL, call)
πŸ“‹ List Messages Send single and multi-select list messages
🎫 Interactive Buttons Quick reply, copy, URL, call, and copy coupon buttons
πŸ“‘ Single Select Single selection from categorized item lists

Group Management

Feature Description
πŸ‘₯ Group Operations Create, update, leave, and manage groups
πŸ‘€ Member Management Add, remove, promote, and demote group members
🏷️ Label Group Members Set labels/tags for individual group members
πŸ“ Group Metadata Get group info, participants, settings
πŸ“Š Group Settings Configure member add mode, approval mode, ephemeral msgs
πŸ“’ Group Invites Generate, revoke, and manage group invite codes/links
πŸ‘₯ JID/LID Support Full support for @jid and @lid group identifiers
πŸ“± Ephemeral Messages Auto-delete messages in groups (24h, 7d, 90d)
πŸ“Š Group Status Messages Send status updates visible only in groups
πŸ“… Event Invitations Create and send event invitation messages

Newsletter Management

Feature Description
πŸ—žοΈ Newsletter Operations Create, follow, unfollow, and manage newsletters
πŸ“ Newsletter Metadata Get newsletter info, subscribers, verification status
πŸ“ Update Newsletter Info Change newsletter name, description, and profile picture
πŸ‘€ Newsletter Management Add/remove admins, change owner, manage subscribers
πŸ“Š Admin Count Get count of newsletter administrators
πŸ”• Mute/Unmute Mute and unmute newsletter notifications
πŸ“’ Multiple Newsletter Follow Follow multiple newsletters at once
❀️ Newsletter React Messages React to messages in newsletters

Message Utilities

Feature Description
πŸ“– Read Receipts Send read receipts and mark messages as read
βœ… Duplicate Prevention Prevent duplicate message handling with ID caching
πŸ” Message Searching Query and retrieve messages from store
πŸ“Š Message Updates Handle message edits and media retries

Account & Security

Feature Description
πŸ”‘ Custom Pairing Codes Generate and use your own pairing codes
πŸ› οΈ Pairing/QR Fixes Fixed bugs for WhatsApp linking issues (Pairing/QR)
🚫 Check Banned Numbers Check if a number is banned on WhatsApp
πŸ“Š Privacy Settings Fetch and manage privacy settings (read receipts, etc)
πŸšͺ Logout Safely logout and end the session
βš™οΈ Multi-file Auth Support Built-in multi-file auth like official Baileys

Channels & Discovery

Feature Description
πŸ“Ί Channel Metadata Get channel info from URLs
πŸ”— Channel ID Checker Extract channel IDs and metadata from links
πŸ“’ Status Messages Send and manage status/story messages

Performance & Infrastructure

Feature Description
πŸ“ˆ Optimized Performance Rewritten modules for faster connection and retries
πŸ“‘ Libsignal Fixes Latest libsignal-node from WhiskeySockets (clean logs)
πŸ—ƒοΈ makeInMemoryStore In-memory store support for message caching
πŸ”„ Device Sync (USync) Latest device protocol with USync query improvements
⏱️ Delay Function Built-in async delay/sleep function
πŸ”§ Advanced Handlers Enhanced message and event handling

Protocol & Compatibility

Feature Description
🌐 Communities Support Full support for WhatsApp Communities
🏒 Business Features Business account and catalog support
πŸ“‘ Multi-Device (MD) Support Full multi-device protocol compliance
πŸ” E2E Encryption End-to-end encryption with Signal protocol

πŸ“₯ Installation

Install via package.json:

"dependencies": {
    "baileys": "github:dcodemaxz/vikaru-baileys"
}

Install via terminal:

npm install baileys@github:dcodemaxz/vikaru-baileys

πŸš€ Quick Example (Anti-duplicate messages)

Tip

A simple example of preventing duplicate executions due to duplicate messages from a WhatsApp message ID. This code caches the first message ID and then automatically ignores messages with the same ID (second, etc.), preventing the bot from executing the command twice. The cache is automatically cleared after reaching 10 IDs to keep it lightweight.

// Duplicate message ( cached )
const duplicateMsg = new Map();

vikaru.ev.on("messages.upsert", ({ messages }) => {
    const mek = messages[0]

    // Stop execution if the same ID is detected
    if (duplicateMsg.has(mek.key.id)) {
        console.log(`\nβ€Ί [ Duplicate-Id ] β–Έ ${mek.key.participant || mek.key.remoteJid} | ${mek.key.id}`);
        return;
    }

    // Delete saved id after 10 id
    if (duplicateMsg.size >= 10) duplicateMsg.clear();

    // Save the incoming id
    duplicateMsg.set(mek.key.id, true);

    // Command ( case / plugin )
    // ...
})

πŸ§ͺ Advanced Usage (index.js)

Details
// Import variables from baileys
const {
    default: makeWASocket,
    useMultiFileAuthState,
    DisconnectReason,
} = require("baileys");

// Function starts
async function vikarustart() {
    const { state, saveCreds } = await useMultiFileAuthState("./session/")
    const vikaru = makeWASocket({
        auth: state,
        browser: ["Ubuntu", "Chrome", "20.0.04"],
        getMessage: async (key) => await getMessageFromStore(key),
        cachedGroupMetadata: async (jid) => groupCache.get(jid),
    });

// ------------------------------------------------------------------- //

    // Piring code
    if (!vikaru.authState.creds.registered) {
        const phoneNumber = "6289508899033"
        const customCode = "MAXZBAIL";
        const code = await vikaru.requestPairingCode(phoneNumber, customCode);
        console.log(`Pairing Code : ${code?.match(/.{1,4}/g)?.join("-") || code}`);
    }

    // Save credentials after connecting
    vikaru.ev.on("creds.update", saveCreds)

// ------------------------------------------------------------------- //

    // Detecting connection to server
    vikaru.ev.on("connection.update", async (update) => {
        const { connection, lastDisconnect } = update;

        // Connecting
        if (connection == "connecting") {
            console.log(`\nβ€Ί [ Starting Bot ] β–Έ Connecting To WhatsApp Server...`);

        // Connected
        } else if (connection === "open") {
            console.log(`\nβ€Ί [ Connected To ] β–Έ ${vikaru.user.id}`);

        // Disconnected
        } else if (connection === "close") {
            const reason = new Boom(lastDisconnect?.error)?.output.statusCode;
            if (reason === DisconnectReason.badSession) {
                console.log(`\nβ€Ί [ Disconnected ] β–Έ Bad Session File, Please Delete Session and Pairing Again`);
                process.exit(1);
            } else if (reason === DisconnectReason.connectionClosed) {
                console.log(`\nβ€Ί [ Reconnecting ] β–Έ Connection Closed...`);
                vikarustart();
            } else if (reason === DisconnectReason.connectionLost) {
                console.log(`\nβ€Ί [ Reconnecting ] β–Έ Connection Lost From Server...`);
                vikarustart();
            } else if (reason === DisconnectReason.connectionReplaced) {
                console.log(`\nβ€Ί [ Disconnected ] β–Έ Connection Replaced, Another New Session Opened`);
                process.exit(1);
            } else if (reason === DisconnectReason.loggedOut) {
                console.log(`\nβ€Ί [ Disconnected ] β–Έ Device Logged Out, Deleted session Folder and Pairing Again.`);
                process.exit(1);
            } else if (reason === DisconnectReason.restartRequired) {
                console.log(`\nβ€Ί [ Reconnecting ] β–Έ Restarting connection...`);
                vikarustart();
            } else if (reason === DisconnectReason.timedOut) {
                console.log(`\nβ€Ί [ Reconnecting ] β–Έ Connection TimedOut...`);
                vikarustart();
            } else {
                console.log(`\nβ€Ί [ Disconnected ] β–Έ Unknown DisconnectReason: ${reason} | ${connection}`);
                process.exit(1);
            }
        }
    });

// ------------------------------------------------------------------- //

    // Duplicate message ( cached )
    const duplicateMsg = new Set();

    // Receive messages
    vikaru.ev.on("messages.upsert", ({ messages }) => {
        const mek = messages[0]

        // Stop execution if the same ID is detected
        if (duplicateMsg.has(mek.key.id)) {
            console.log(`\nβ€Ί [ Duplicate-Id ] β–Έ ${mek.key.participant || mek.key.remoteJid} | ${mek.key.id}`);
            return;
        }

        // Delete saved id after 10 id
        if (duplicateMsg.size >= 10) duplicateMsg.clear();

        // Save the incoming id
        duplicateMsg.set(mek.key.id, true);

        // Simple command
        const text = mek.message.conversation
        if (text?.startsWith(["/", "#", "!"])) {
            const command = text.substring(1).split(" ")[0]
            
            if (command === "ping") {
                await vikaru.sendMessage(mek.key.remoteJid, 
                    { text: "Pong! πŸ“" }, 
                    { quoted: mek }
                )
            }
        }
    })

// ------------------------------------------------------------------- //

} // end

// Call the start function
vikarustart()

🧩 Feature Examples

Details

✏️ Edit Message

await vikaru.edit(message, "Updated message text")

// Or
await vikaru.sendMessage(chatId, {
    edit: message.key,
    text: "New text content"
})

πŸ—‘οΈ Delete Message (Revoke)

// Delete for yourself
await vikaru.sendMessage(chatId, {
    delete: message.key
})

// For groups/newsletter, delete for everyone (admin only)
// Automatically handled based on context

πŸ”” Read Receipts & Mark as Read

// Send read receipt for single message
await vikaru.sendReadReceipt(chatId, participantJid, [messageId], 'read')

// Bulk read messages
await vikaru.readMessages([
    { remoteJid: chatId, id: messageId1 },
    { remoteJid: chatId, id: messageId2 }
])

// Read receipt types: 'read', 'read-self', 'delivery', 'played'

πŸ“Œ Pin & Keep Messages

// Pin message
await vikaru.sendMessage(chatId, {
    pin: message.key
})

// Keep message (mark as important)
await vikaru.sendMessage(chatId, {
    keep: message.key
})

πŸ—³οΈ Poll Messages

await vikaru.sendMessage(chatId, {
    poll: {
        name: "Which feature do you like?",
        values: ["Feature A", "Feature B", "Feature C"],
        selectableCount: 1
    }
})

🎨 Media Utilities (Resize, Convert, Compress, Sticker)

// Resize image
const resized = await vikaru.resize(imageBuffer, 800, 600, { quality: 85 })

// Convert image format
const converted = await vikaru.convert(imageBuffer, { to: '.png' })

// Convert to sticker (512x512 WebP)
const sticker = await vikaru.toSticker(imageBuffer, { quality: 80 })

// Compress video
const compressed = await vikaru.compress(videoBuffer, { quality: 60 })

// Send as sticker pack
await vikaru.sendMessage(chatId, {
    stickerPack: {
        sticker: await vikaru.toSticker(imageBuffer)
    }
})

🌊 Audio Waveform & Audio Messages

// Send audio with automatic waveform generation
const audioBuffer = fs.readFileSync('./audio.mp3')
await vikaru.sendMessage(chatId, {
    audio: audioBuffer,
    mimetype: 'audio/mpeg'
    // Waveform is automatically generated
})

πŸ’¬ Send Message with Text, Links & Preview

// Simple text message
await vikaru.sendMessage(chatId, { text: "Hello!" })

// With link preview
await vikaru.sendMessage(chatId, {
    text: "Check this: https://github.com/dcodemaxz/vikaru-baileys"
})

// Force link preview generation (high quality)
// Configure: generateHighQualityLinkPreview: true in socket config

🎫 Button Messages (Interactive)

await vikaru.sendMessage(chatId, {
    title: "❏ *`EXAMPLE BUTTONS`*",
    text: "Choose one of the options below:",
    footer: "Β© dcodemaxz baileys",
    // image: { url: "https://example.com/image.jpg" },

    interactiveButtons: [
        // Reply button
        {
            name: "quick_reply",
            buttonParamsJson: JSON.stringify({
                display_text: "Quick Reply",
                id: "reply_id_1"
            })
        },

        // Copy button (copy to clipboard)
        {
            name: "quick_copy",
            buttonParamsJson: JSON.stringify({
                display_text: "Copy Code",
                id: "copy_id_1",
                copy_code: "VIKARU-2025"
            })
        },

        // URL button
        {
            name: "cta_url",
            buttonParamsJson: JSON.stringify({
                display_text: "Visit Website",
                url: "https://github.com/dcodemaxz"
            })
        },

        // Call button
        {
            name: "cta_call",
            buttonParamsJson: JSON.stringify({
                display_text: "Call Support",
                phone_number: "+6289508899033"
            })
        }
    ]
}, { quoted: null })

πŸ“‹ List/Select Messages

// Single select list
await vikaru.sendMessage(chatId, {
    title: "❏ *`SELECT ITEMS`*",
    text: "Choose one of the following:",
    footer: "Β© dcodemaxz baileys",

    interactiveButtons: [
        {
            name: "single_select",
            buttonParamsJson: JSON.stringify({
                title: "Choose Product",
                sections: [
                    {
                        title: "πŸ›οΈ Category 1",
                        highlight_label: "Recommended",
                        rows: [
                            {
                                header: "Product A",
                                title: "Buy Product A",
                                description: "High quality product",
                                id: "buy_a"
                            },
                            {
                                header: "Product B",
                                title: "Buy Product B",
                                description: "Budget friendly",
                                id: "buy_b"
                            }
                        ]
                    },
                    {
                        title: "🎁 Category 2",
                        rows: [
                            {
                                header: "Product C",
                                title: "Buy Product C",
                                description: "Premium option",
                                id: "buy_c"
                            }
                        ]
                    }
                ]
            })
        }
    ]
}, { quoted: null })

πŸ–ΌοΈ Album Messages (Grouped Media)

await vikaru.sendMessage(chatId, {
    album: [
        { image: { url: "https://example.com/image1.jpg" } },
        { image: { url: "https://example.com/image2.jpg" } },
        { video: { url: "https://example.com/video.mp4" } },
        { image: { url: "https://example.com/image3.jpg" } }
    ],
    caption: "Beautiful album collection 🎨"
})

❀️ React to Messages (Emoji Reactions)

// React with emoji
await vikaru.react(message, "πŸ”₯")

// Or
await vikaru.sendMessage(chatId, {
    react: {
        text: "πŸ˜‚",
        key: message.key
    }
})

// Remove reaction
await vikaru.unreact(message)

πŸ“ž Quoted Messages (Reply)

// Reply/Quote to a message
await vikaru.sendMessage(chatId, {
    text: "This is a reply!"
}, {
    quoted: message  // or message.key
})

πŸ€– AI Message Icon

// Add AI bot icon to message
await vikaru.sendMessage(chatId, {
    text: "This message is from AI Bot! πŸ€–",
    ai: true  // Displays AI icon
})

πŸ—³οΈ Newsletter Management

// Create newsletter
const newsletter = await vikaru.newsletterCreate(
    "My Newsletter",
    "Latest updates and news",
    fs.readFileSync('./newsletter-pic.jpg')
)

// Follow newsletter
await vikaru.newsletterFollow("123456789@newsletter")

// Unfollow newsletter
await vikaru.newsletterUnfollow("123456789@newsletter")

// Update newsletter name
await vikaru.newsletterUpdateName("123456789@newsletter", "Updated Name")

// Update description
await vikaru.newsletterUpdateDescription("123456789@newsletter", "New description here")

// Update profile picture
await vikaru.newsletterUpdatePicture("123456789@newsletter", fs.readFileSync('./pic.jpg'))

// Remove profile picture
await vikaru.newsletterRemovePicture("123456789@newsletter")

// Mute/Unmute newsletters
await vikaru.newsletterMute("123456789@newsletter")
await vikaru.newsletterUnmute("123456789@newsletter")

// Change newsletter owner
await vikaru.newsletterChangeOwner("123456789@newsletter", "1234567890@s.whatsapp.net")

// Demote admin
await vikaru.newsletterDemote("123456789@newsletter", "1234567890@s.whatsapp.net")

// Delete newsletter
await vikaru.newsletterDelete("123456789@newsletter")

// Get admin count
const adminCount = await vikaru.newsletterAdminCount("123456789@newsletter")

// React to newsletter message
await vikaru.newsletterReactMessage("123456789@newsletter", "175", "πŸ₯³")

// Get newsletter metadata
const metadata = await vikaru.newsletterMetadata("invite", "code_here")

// Subscribe to newsletter live updates
await vikaru.subscribeNewsletterUpdates("123456789@newsletter")

πŸ‘₯ Group Management

// Create group
const group = await vikaru.groupCreate("My Group", ["628xx@s.whatsapp.net", "628yy@s.whatsapp.net"])

// Get group metadata
const metadata = await vikaru.groupMetadata(groupJid)

// Update group name
await vikaru.groupUpdateSubject(groupJid, "New Group Name")

// Update group description
await vikaru.groupUpdateDescription(groupJid, "Group description here")

// Add member(s)
await vikaru.groupParticipantsUpdate(groupJid, ["628xx@s.whatsapp.net"], "add")

// Remove member(s)
await vikaru.groupParticipantsUpdate(groupJid, ["628xx@s.whatsapp.net"], "remove")

// Promote to admin
await vikaru.groupParticipantsUpdate(groupJid, ["628xx@s.whatsapp.net"], "promote")

// Demote admin
await vikaru.groupParticipantsUpdate(groupJid, ["628xx@s.whatsapp.net"], "demote")

// Leave group
await vikaru.groupLeave(groupJid)

// Get group invite code
const inviteCode = await vikaru.groupInviteCode(groupJid)

// Revoke invite
await vikaru.groupRevokeInvite(groupJid)

// Accept group invite
const joinedGroup = await vikaru.groupAcceptInvite("inviteCodeHere")

// Get invite info
const inviteInfo = await vikaru.groupGetInviteInfo("inviteCodeHere")

// Set label for group member
await vikaru.setLabelGroup(groupJid, "VIP Members")

// Toggle ephemeral messages (auto-delete)
await vikaru.groupToggleEphemeral(groupJid, 604800) // 7 days

// Update group settings
await vikaru.groupSettingUpdate(groupJid, "announcement") // announcement only

// Set member add mode
await vikaru.groupMemberAddMode(groupJid, [{ tag: "member_add_mode", attrs: {}, content: "restricted" }])

// Set join approval mode
await vikaru.groupJoinApprovalMode(groupJid, "on")

πŸ“’ Group Status Messages

// Send status message visible to group
await vikaru.sendStatusMention({
    text: "Group update! Check this out πŸ“’"
}, [groupJid])

πŸ“Ί Channel/Newsletter Info

// Check channel/newsletter from URL
const channelInfo = await vikaru.cekIDSaluran("https://whatsapp.com/channel/xxxx")
console.log(channelInfo)
// Returns: { name, id, state, subscribers, verification, creation_time }

🚫 Check Banned Numbers

// Check if number is banned
const isBanned = await vikaru.checkBanned("6289508899033@s.whatsapp.net")
if (isBanned) {
    console.log("This number is banned on WhatsApp")
}

⏱️ Delay/Sleep Function

// Delay for 5 seconds
await vikaru.delay(5)

// Delay for 2.5 seconds
await vikaru.delay(2.5)

πŸ”‘ Custom Pairing Codes

// Request pairing code
const phoneNumber = "6289508899033"
const customCode = "MAXZBAIL"  // Optional custom code
const code = await vikaru.requestPairingCode(phoneNumber, customCode)

console.log(`Your Pairing Code: ${code?.match(/.{1,4}/g)?.join("-") || code}`)

πŸšͺ Logout

// Logout and end session
await vikaru.logout("Goodbye!")

πŸ“Š Update Media Message

// Retry and update media message (if media failed)
const updatedMessage = await vikaru.updateMediaMessage(message)

πŸ“– Fetch Privacy Settings

// Get your privacy settings
const privacySettings = await vikaru.fetchPrivacySettings()
// Returns: { readreceipts, lastseen, onlineStatus, profilePhoto, ... }

πŸ—ƒοΈ In-Memory Store

const { makeWASocket, makeInMemoryStore } = require('baileys')

const store = makeInMemoryStore({ 
    logger: pino({ level: 'debug' }) 
})

const vikaru = makeWASocket({ auth: state })
store.bind(vikaru.ev)

// Now you can access messages from store
console.log(store.messages[chatId])
console.log(store.contacts[jid])
console.log(store.chats)

πŸ”„ Event Listening

// Connection updates
vikaru.ev.on('connection.update', (update) => {
    const { connection, lastDisconnect, isNewLogin } = update
    console.log(connection, lastDisconnect, isNewLogin)
})

// Messages
vikaru.ev.on('messages.upsert', ({ messages, type }) => {
    console.log(`Messages: ${type}`, messages)
})

// Message updates
vikaru.ev.on('messages.update', (updates) => {
    console.log('Message updates:', updates)
})

// Chats
vikaru.ev.on('chats.upsert', (chats) => {
    console.log('Chats upserted:', chats)
})

// Groups
vikaru.ev.on('groups.update', (updates) => {
    console.log('Groups updated:', updates)
})

// Contacts
vikaru.ev.on('contacts.upsert', (contacts) => {
    console.log('Contacts upserted:', contacts)
})

// Credentials
vikaru.ev.on('creds.update', saveCreds)

πŸͺ² Reporting Issues

Note

If you find a bug or need help, please open an issue.

⚑ Developer

⚠️ Disclaimer

Caution

This project is not affiliated with WhatsApp Inc.
Use it responsibly. Avoid spam, abuse, or illegal activity.

⚑ Thanks to
  • whiskeysockets
  • baileys-mod
  • whileys

πŸ“„ License

MIT Β© 2025 dcodemaxz

About

This project is intended to support the Vikaru-Bot project.

Topics

Resources

License

Stars

Watchers

Forks

Contributors