npm package: @mihiranga_mihiranga/mezuka-baileys
Description: Baileys Mod By blackcat ofc
Author: ElrayyXml
Latest version: 1.0.2

<div align="center">

# 🚀 @mezuka/baileys

### *Advanced WhatsApp Web API - Modified by Black Cat OFC*

<img src="https://files.catbox.moe/fhuqe1.jpg" width="400" alt="Mezuka Baileys Banner" />

[![npm version](https://img.shields.io/npm/v/@mezuka/baileys.svg?style=for-the-badge&color=FF6B6B)](https://www.npmjs.com/package/@mezuka/baileys)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
[![Downloads](https://img.shields.io/npm/dt/@mezuka/baileys.svg?style=for-the-badge&color=blueviolet&logo=npm)](https://www.npmjs.com/package/@mezuka/baileys)
[![Node.js](https://img.shields.io/badge/Node.js-20%2B-green.svg?style=for-the-badge&logo=node.js)](https://nodejs.org)
[![WhatsApp](https://img.shields.io/badge/WhatsApp-API-25D366.svg?style=for-the-badge&logo=whatsapp)](https://whatsapp.com)

---

### 👨‍💻 **Owner:** Nimeshka Mihiran | **Team:** Black Cat OFC

</div>

---

## 📑 Table of Contents

- [✨ Features](#-features)
- [📦 Installation](#-installation)
- [🚀 Quick Start](#-quick-start)
- [🔐 Authentication Methods](#-authentication-methods)
- [📨 Sending Messages](#-sending-messages)
- [🎨 Advanced Features](#-advanced-features)
- [👥 Group Management](#-group-management)
- [🔒 Privacy & Security](#-privacy--security)
- [📞 Contact & Support](#-contact--support)

---

## ✨ Features

<div align="center">

| Feature | Status | Feature | Status |
|---------|--------|---------|--------|
| 🔐 **QR Code Auth** | ✅ | 📱 **Pairing Code** | ✅ |
| 💬 **All Message Types** | ✅ | 🖼️ **Media Support** | ✅ |
| 👥 **Group Management** | ✅ | 📊 **Polls & Events** | ✅ |
| 🔒 **Privacy Controls** | ✅ | 🎨 **Interactive Buttons** | ✅ |
| 📦 **Product Messages** | ✅ | 💳 **Payment Messages** | ✅ |
| 🤖 **AI Integration** | ✅ | 🌐 **Multi-Device** | ✅ |

</div>

---

## 📦 Installation

### NPM Installation
```bash
npm install @mezuka/baileys
```

### Yarn Installation
```bash
yarn add @mezuka/baileys
```

### Using as Baileys Fork
Add to your `package.json`:
```json
{
  "dependencies": {
    "baileys": "npm:@mezuka/baileys"
  }
}
```

---

## 🚀 Quick Start

### Basic Setup with QR Code

```typescript
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@mezuka/baileys'
import { Boom } from '@hapi/boom'

async function connectToWhatsApp() {
    const { state, saveCreds } = await useMultiFileAuthState('./auth_info_baileys')
    
    const sock = makeWASocket({
        auth: state,
        printQRInTerminal: true,
        browser: ['Black Cat Bot', 'Chrome', '1.0.0']
    })
    
    sock.ev.on('connection.update', (update) => {
        const { connection, lastDisconnect } = update
        
        if(connection === 'close') {
            const shouldReconnect = (lastDisconnect?.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
            console.log('Connection closed, reconnecting:', shouldReconnect)
            
            if(shouldReconnect) {
                connectToWhatsApp()
            }
        } else if(connection === 'open') {
            console.log('✅ Connected successfully!')
        }
    })
    
    sock.ev.on('messages.upsert', async ({ messages }) => {
        for (const m of messages) {
            console.log('📨 New message:', m)
            
            if(m.message) {
                await sock.sendMessage(m.key.remoteJid!, { 
                    text: '👋 Hello from @mezuka/baileys!' 
                })
            }
        }
    })
    
    sock.ev.on('creds.update', saveCreds)
}

connectToWhatsApp()
```

---

## 🔐 Authentication Methods

### Method 1: Pairing Code (Recommended)

```typescript
import makeWASocket from '@mezuka/baileys'

const sock = makeWASocket({
    printQRInTerminal: false
})

if (!sock.authState.creds.registered) {
    const phoneNumber = '94712345678' // Without + or special characters
    const code = await sock.requestPairingCode(phoneNumber)
    console.log(`🔑 Pairing Code: ${code}`)
}
```

### Method 2: Single File Auth

```typescript
import { useSingleFileAuthState } from '@mezuka/baileys'

const { state, saveState } = await useSingleFileAuthState('./auth.json')

const sock = makeWASocket({
    auth: state,
    printQRInTerminal: true
})

sock.ev.on('creds.update', saveState)
```

### Method 3: MongoDB Auth

```typescript
import { useMongoFileAuthState } from '@mezuka/baileys'
import { MongoClient } from 'mongodb'

const client = new MongoClient('mongodb://localhost:27017')
await client.connect()

const collection = client.db('whatsapp').collection('sessions')
const { state, saveCreds } = await useMongoFileAuthState(collection)

const sock = makeWASocket({
    auth: state,
    printQRInTerminal: true
})

sock.ev.on('creds.update', saveCreds)
```

---

## 📨 Sending Messages

### Text Messages

```typescript
// Simple text
await sock.sendMessage(jid, { text: 'Hello World!' })

// With mentions
await sock.sendMessage(jid, {
    text: '@94712345678 Check this out!',
    mentions: ['94712345678@s.whatsapp.net']
})

// Quote/Reply
await sock.sendMessage(jid, {
    text: 'This is a reply'
}, {
    quoted: message
})
```

### Media Messages

```typescript
// Image
await sock.sendMessage(jid, {
    image: { url: './image.jpg' },
    caption: 'Beautiful image! 📸'
})

// Video
await sock.sendMessage(jid, {
    video: { url: './video.mp4' },
    caption: 'Check this video! 🎥',
    gifPlayback: false
})

// Audio
await sock.sendMessage(jid, {
    audio: { url: './audio.mp3' },
    mimetype: 'audio/mp4',
    ptt: true // Voice message
})

// Document
await sock.sendMessage(jid, {
    document: { url: './document.pdf' },
    mimetype: 'application/pdf',
    fileName: 'important.pdf'
})

// Sticker
await sock.sendMessage(jid, {
    sticker: { url: './sticker.webp' }
})
```

### Interactive Messages

```typescript
// Buttons
await sock.sendMessage(jid, {
    text: 'Choose an option:',
    footer: 'Powered by @mezuka/baileys',
    buttons: [
        { buttonId: 'id1', buttonText: { displayText: 'Option 1' } },
        { buttonId: 'id2', buttonText: { displayText: 'Option 2' } },
        { buttonId: 'id3', buttonText: { displayText: 'Option 3' } }
    ]
})

// List Message
await sock.sendMessage(jid, {
    text: 'Select from menu:',
    footer: 'Black Cat OFC',
    title: 'Main Menu',
    buttonText: 'View Options',
    sections: [{
        title: 'Section 1',
        rows: [
            { title: 'Option 1', rowId: 'opt1', description: 'First option' },
            { title: 'Option 2', rowId: 'opt2', description: 'Second option' }
        ]
    }]
})

// Advanced Interactive Buttons
await sock.sendMessage(jid, {
    text: 'Interactive Menu',
    title: 'Welcome!',
    footer: 'Choose wisely',
    interactiveButtons: [
        {
            name: 'quick_reply',
            buttonParamsJson: JSON.stringify({
                display_text: 'Quick Reply',
                id: 'quick_1'
            })
        },
        {
            name: 'cta_url',
            buttonParamsJson: JSON.stringify({
                display_text: 'Visit Website',
                url: 'https://github.com/mezuka'
            })
        },
        {
            name: 'cta_call',
            buttonParamsJson: JSON.stringify({
                display_text: 'Call Us',
                phone_number: '+94712345678'
            })
        }
    ]
})
```

### Special Messages

```typescript
// Poll
await sock.sendMessage(jid, {
    poll: {
        name: 'Favorite Programming Language?',
        values: ['JavaScript', 'Python', 'Java', 'C++'],
        selectableCount: 1
    }
})

// Location
await sock.sendMessage(jid, {
    location: {
        degreesLatitude: 6.9271,
        degreesLongitude: 79.8612,
        name: 'Colombo, Sri Lanka'
    }
})

// Contact Card
const vcard = 'BEGIN:VCARD\n'
    + 'VERSION:3.0\n'
    + 'FN:Nimeshka Mihiran\n'
    + 'ORG:Black Cat OFC\n'
    + 'TEL;type=CELL;type=VOICE;waid=94712345678:+94 71 234 5678\n'
    + 'END:VCARD'

await sock.sendMessage(jid, {
    contacts: {
        displayName: 'Nimeshka',
        contacts: [{ vcard }]
    }
})

// Reaction
await sock.sendMessage(jid, {
    react: {
        text: '❤️',
        key: message.key
    }
})
```

---

## 🎨 Advanced Features

### Album/Carousel Messages

```typescript
await sock.sendMessage(jid, {
    album: [
        {
            image: { url: './image1.jpg' },
            caption: 'Photo 1'
        },
        {
            image: { url: './image2.jpg' },
            caption: 'Photo 2'
        },
        {
            video: { url: './video.mp4' },
            caption: 'Video 1'
        }
    ]
})
```

### AI-Powered Messages

```typescript
await sock.sendMessage(jid, {
    text: 'This message has AI processing enabled! 🤖'
}, {
    ai: true
})
```

### View Once Messages

```typescript
await sock.sendMessage(jid, {
    image: { url: './private.jpg' },
    caption: 'This disappears after viewing',
    viewOnce: true
})
```

### Status/Story Messages

```typescript
await sock.sendStatusMentions(
    {
        text: 'Hello everyone! 👋',
        font: 2,
        textColor: 'FF0000',
        backgroundColor: '#000000'
    },
    ['94712345678@s.whatsapp.net', '94787654321@s.whatsapp.net']
)
```

---

## 👥 Group Management

### Create Group

```typescript
const group = await sock.groupCreate(
    'Black Cat Developers',
    ['94712345678@s.whatsapp.net', '94787654321@s.whatsapp.net']
)
console.log('Group created:', group.id)
```

### Manage Participants

```typescript
// Add members
await sock.groupParticipantsUpdate(
    groupJid,
    ['94712345678@s.whatsapp.net'],
    'add'
)

// Remove members
await sock.groupParticipantsUpdate(
    groupJid,
    ['94712345678@s.whatsapp.net'],
    'remove'
)

// Promote to admin
await sock.groupParticipantsUpdate(
    groupJid,
    ['94712345678@s.whatsapp.net'],
    'promote'
)

// Demote from admin
await sock.groupParticipantsUpdate(
    groupJid,
    ['94712345678@s.whatsapp.net'],
    'demote'
)
```

### Group Settings

```typescript
// Change name
await sock.groupUpdateSubject(groupJid, 'New Group Name')

// Change description
await sock.groupUpdateDescription(groupJid, 'New amazing description')

// Update settings
await sock.groupSettingUpdate(groupJid, 'announcement') // Only admins can send
await sock.groupSettingUpdate(groupJid, 'not_announcement') // Everyone can send
await sock.groupSettingUpdate(groupJid, 'locked') // Only admins edit info
await sock.groupSettingUpdate(groupJid, 'unlocked') // Everyone can edit info

// Get invite code
const code = await sock.groupInviteCode(groupJid)
console.log('Invite link:', `https://chat.whatsapp.com/${code}`)

// Revoke invite code
await sock.groupRevokeInvite(groupJid)
```

---

## 🔒 Privacy & Security

### Block/Unblock Users

```typescript
await sock.updateBlockStatus(jid, 'block')
await sock.updateBlockStatus(jid, 'unblock')
```

### Privacy Settings

```typescript
// Last seen
await sock.updateLastSeenPrivacy('all') // 'contacts' | 'contact_blacklist' | 'none'

// Profile picture
await sock.updateProfilePicturePrivacy('contacts')

// Status
await sock.updateStatusPrivacy('contacts')

// Read receipts
await sock.updateReadReceiptsPrivacy('all')

// Groups
await sock.updateGroupsAddPrivacy('contacts')
```

### Disappearing Messages

```typescript
// Enable (7 days)
await sock.sendMessage(jid, {
    disappearingMessagesInChat: 604800
})

// Disable
await sock.sendMessage(jid, {
    disappearingMessagesInChat: false
})
```

---

## 📞 Contact & Support

<div align="center">

### 🌟 **Owner: Nimeshka Mihiran**
### 👥 **Team: Black Cat OFC**

[![Instagram](https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white)](https://instagram.com/nimeshka_mihiran)
[![GitHub](https://img.shields.io/badge/GitHub-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/mezuka)
[![WhatsApp](https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white)](https://wa.me/94712345678)
[![Email](https://img.shields.io/badge/Email-D14836?style=for-the-badge&logo=gmail&logoColor=white)](mailto:blackcatofc@gmail.com)

### 📢 Join Our Community

[![WhatsApp Channel](https://img.shields.io/badge/Join-WhatsApp%20Channel-25D366?style=for-the-badge&logo=whatsapp&logoColor=white)](https://whatsapp.com/channel/0029VbC1tH0L7UVPPYGED62n)
[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white)](https://t.me/Nimeshkamihiran)
[![Discord](https://img.shields.io/badge/Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/blackcatofc)

</div>

---

## 📚 Additional Resources

### Utility Functions

```typescript
import { 
    getContentType,
    getDevice,
    downloadContentFromMessage,
    makeCacheableSignalKeyStore
} from '@mezuka/baileys'

// Get message type
const type = getContentType(message)

// Download media
const buffer = await downloadContentFromMessage(message, 'image')

// Check if number exists
const [result] = await sock.onWhatsApp('94712345678')
if (result.exists) console.log('Number exists!')
```

### Data Store Implementation

```typescript
import { makeInMemoryStore } from '@mezuka/baileys'

const store = makeInMemoryStore({})
store.readFromFile('./baileys_store.json')

setInterval(() => {
    store.writeToFile('./baileys_store.json')
}, 10_000)

store.bind(sock.ev)

// Access chats
console.log('All chats:', store.chats.all())
console.log('All contacts:', Object.values(store.contacts))
```

---

## 🎯 Best Practices

### Performance Optimization

```typescript
import { makeCacheableSignalKeyStore } from '@mezuka/baileys'
import NodeCache from 'node-cache'

// Cache group metadata
const groupCache = new NodeCache({ stdTTL: 300, useClones: false })

const sock = makeWASocket({
    cachedGroupMetadata: async (jid) => groupCache.get(jid),
    getMessage: async (key) => await getMessageFromStore(key)
})

sock.ev.on('groups.update', async ([event]) => {
    const metadata = await sock.groupMetadata(event.id)
    groupCache.set(event.id, metadata)
})
```

### Error Handling

```typescript
sock.ev.on('connection.update', (update) => {
    const { connection, lastDisconnect, qr } = update
    
    if(qr) {
        console.log('QR Code:', qr)
    }
    
    if(connection === 'close') {
        const statusCode = (lastDisconnect?.error as Boom)?.output?.statusCode
        const shouldReconnect = statusCode !== DisconnectReason.loggedOut
        
        console.log('Connection closed. Status:', statusCode)
        
        if(shouldReconnect) {
            setTimeout(() => connectToWhatsApp(), 3000)
        }
    }
})
```

---

## 📄 License

This project is licensed under the MIT License.

---

<div align="center">

### ⭐ Star us on GitHub!

**Made with ❤️ by Black Cat OFC**

**Special thanks to the original Baileys developers**

![Visitor Count](https://visitor-badge.laobi.icu/badge?page_id=mezuka.baileys)

</div>