<div align="center">

```
██████╗  ██████╗ ███╗   ██╗████████╗ █████╗ 
██╔══██╗██╔═══██╗████╗  ██║╚══██╔══╝██╔══██╗
██████╔╝██║   ██║██╔██╗ ██║   ██║   ███████║
██╔═══╝ ██║   ██║██║╚██╗██║   ██║   ██╔══██║
██║     ╚██████╔╝██║ ╚████║   ██║   ██║  ██║
╚═╝      ╚═════╝ ╚═╝  ╚═══╝   ╚═╝   ╚═╝  ╚═╝
███████╗ ██████╗  ██████╗██╗  ██╗███████╗████████╗███████╗
██╔════╝██╔═══██╗██╔════╝██║ ██╔╝██╔════╝╚══██╔══╝██╔════╝
███████╗██║   ██║██║     █████╔╝ █████╗     ██║   ███████╗
╚════██║██║   ██║██║     ██╔═██╗ ██╔══╝     ██║   ╚════██║
███████║╚██████╔╝╚██████╗██║  ██╗███████╗   ██║   ███████║
╚══════╝ ╚═════╝  ╚═════╝╚═╝  ╚═╝╚══════╝   ╚═╝   ╚══════╝
```

### **B A I L E Y S**
*WhatsApp Web API · Custom Fork · Node.js*

<br>

[![npm](https://img.shields.io/npm/v/@pontasockets/baileys?style=for-the-badge&color=7c3aed&logo=npm&logoColor=white&label=NPM)](https://npmjs.com/package/@pontasockets/baileys)
[![license](https://img.shields.io/github/license/pontasockets/baileys?style=for-the-badge&color=10b981&logo=github&logoColor=white)](https://github.com/pontasockets/baileys/blob/main/LICENSE)
[![stars](https://img.shields.io/github/stars/pontasockets/baileys?style=for-the-badge&color=f59e0b&logo=github&logoColor=white)](https://github.com/pontasockets/baileys/stargazers)

<br>

> *Extended from [@whiskeysockets/baileys](https://github.com/WhiskeySockets/Baileys) · Packed with exclusive patches & features*

<br>

---

</div>

## 📑 Table of Contents

- [What's Different](#-whats-different)
- [Features](#-features)
- [Installation](#-installation)
- [Quick Start](#-quick-start)
- [Documentation](#-documentation)
  - [Connecting Account](#-connecting-account)
  - [Handling Events](#-handling-events)
  - [Sending Messages](#-sending-messages)
  - [Newsletter](#-newsletter)
  - [Groups](#-groups)
  - [Privacy](#-privacy)
  - [Advanced](#-advanced)
- [Contact](#-contact)
- [Disclaimer](#-disclaimer)

---

## ✨ What's Different

This fork introduces targeted custom patches on top of the original Baileys library. Here's everything that's been changed or added:

<br>

| # | Patch | Description |
|---|-------|-------------|
| `01` | 🤖 **Code Block Message** | Send syntax-highlighted code via `{ code, language }` — renders as AI bot message in WhatsApp |
| `02` | 🪪 **Custom Message ID** | All outgoing message IDs prefixed with `PONTASOCKETS` |
| `03` | 🐛 **LID Bug Fixes** | Full fix for participant, mentionedJid, sender, and group admin LID resolution |
| `04` | 📦 **makeInMemoryStore Fix** | Corrected store behavior for stable session handling |
| `05` | 📣 **Newsletter Support** | Full channel/newsletter create, follow, react, and admin management |
| `06` | 🤖 **AI Logo Message** | Support for AI bot avatar in message context |
| `07` | 📊 **Logger Buffer Clear** | Prevents memory buildup from log buffers |
| `08` | 🔁 **LID → JID Conversion** | Auto-converts LID mentions, sender LID, and group member LID to JID |

---

## 🌟 Features

```
✔  Multi-Device Support          ✔  End-to-End Encryption
✔  Real-Time Messaging           ✔  Session Persistence
✔  Code Block Messages           ✔  Newsletter Management
✔  Group & Channel Management    ✔  Rich Interactive Messages
✔  Poll, Album, Carousel         ✔  LID → JID Auto-Conversion
```

---

## 📥 Installation

```bash
# Using npm
npm install @pontasockets/baileys

# Using yarn
yarn add @pontasockets/baileys
```

---

## 🚀 Quick Start

```javascript
const {
  default: makeWASocket,
  useMultiFileAuthState,
} = require('@pontasockets/baileys');

async function start() {
  const { state, saveCreds } = await useMultiFileAuthState('./sessions')

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

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

  sock.ev.on('messages.upsert', ({ messages }) => {
    console.log('New message:', messages[0].message)
  })
}

start()
```

---

## 📖 Documentation

### 🔌 Connecting Account

<details>
<summary><b>🔗 Connect with QR Code</b></summary>
<br>

```javascript
const sock = makeWASocket({
  printQRInTerminal: true, // Display QR in terminal
  auth: state
})
```

</details>

<details>
<summary><b>🔢 Connect with Pairing Code</b></summary>
<br>

```javascript
const sock = makeWASocket({
  printQRInTerminal: false,
  auth: state
})

if (!sock.authState.creds.registered) {
  const number = '62xxxx'

  // Default pairing code
  const code = await sock.requestPairingCode(number)

  // Custom 8-digit pairing code
  const customCode = await sock.requestPairingCode(number, 'PONTASOCKETS')

  console.log(code)
}
```

</details>

---

### 📡 Handling Events

<details>
<summary><b>📌 Basic Message Listener</b></summary>
<br>

```javascript
sock.ev.on('messages.upsert', ({ messages }) => {
  const msg = messages[0]
  console.log('From:', msg.key.remoteJid)
  console.log('Content:', msg.message)
})
```

</details>

<details>
<summary><b>🗳️ Decrypt Poll Votes</b></summary>
<br>

```javascript
sock.ev.on('messages.update', (m) => {
  if (m.pollUpdates) {
    console.log('Poll vote received:', m.pollUpdates)
  }
})
```

</details>

---

### 📨 Sending Messages

```
sock.sendMessage(jid, content, options?)
  ↳ jid     — Recipient JID (user or group)
  ↳ content — Message payload object
  ↳ options — Optional: { quoted, ephemeral, ... }
```

<details>
<summary><b>📝 Text Message</b></summary>
<br>

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

// With quoted reply
await sock.sendMessage(jid, { text: 'Reply!' }, { quoted: message })

// With link preview
await sock.sendMessage(jid, {
  text: 'Visit https://example.com',
  linkPreview: {
    'canonical-url': 'https://example.com',
    title: 'Example Domain',
    description: 'A demo website',
    jpegThumbnail: fs.readFileSync('preview.jpg')
  }
})
```

</details>

<details>
<summary><b>💻 Code Block Message <kbd>NEW</kbd></b></summary>
<br>

> Renders as a syntax-highlighted code block in WhatsApp (AI bot style message)

```javascript
// JavaScript
await sock.sendMessage(jid, {
  code: 'console.log("Hello World")',
  language: 'javascript'
}, { quoted: message })

// Python
await sock.sendMessage(jid, {
  code: 'print("Hello World")',
  language: 'python'
}, { quoted: message })

// Bash / Terminal
await sock.sendMessage(jid, {
  code: stderr.trim(),
  language: 'bash'
}, { quoted: message })
```

**Supported Languages:**

| Language | Keys |
|----------|------|
| JavaScript | `javascript` · `js` |
| TypeScript | `typescript` · `ts` |
| Python | `python` · `py` |
| Bash / Shell | `bash` · `sh` · `zsh` |
| Go | `go` · `golang` |
| Rust | `rust` · `rs` |
| C | `c` · `h` |
| C++ | `cpp` · `c++` |
| C# | `csharp` · `cs` |
| CSS | `css` |
| HTML | `html` |
| PowerShell | `powershell` · `ps1` |
| CMD | `cmd` · `bat` |

</details>

<details>
<summary><b>🖼️ Image Message</b></summary>
<br>

```javascript
// From local file
await sock.sendMessage(jid, {
  image: fs.readFileSync('image.jpg'),
  caption: 'My cat!',
  mentions: ['1234567890@s.whatsapp.net']
})

// From URL
await sock.sendMessage(jid, {
  image: { url: 'https://example.com/image.jpg' },
  caption: 'Downloaded image'
})
```

</details>

<details>
<summary><b>🎥 Video Message</b></summary>
<br>

```javascript
// From local file
await sock.sendMessage(jid, {
  video: fs.readFileSync('video.mp4'),
  caption: 'Funny clip!'
})

// View Once
await sock.sendMessage(jid, {
  video: fs.readFileSync('secret.mp4'),
  viewOnce: true
})
```

</details>

<details>
<summary><b>🎵 Audio / PTT Message</b></summary>
<br>

```javascript
// Regular audio
await sock.sendMessage(jid, {
  audio: fs.readFileSync('audio.mp3'),
  ptt: false
})

// Push-to-talk voice note
await sock.sendMessage(jid, {
  audio: fs.readFileSync('voice.ogg'),
  ptt: true,
  waveform: [0, 1, 0, 1, 0]
})
```

</details>

<details>
<summary><b>👤 Contact Message</b></summary>
<br>

```javascript
const vcard = [
  'BEGIN:VCARD',
  'VERSION:3.0',
  'FN:Jeff Singh',
  'ORG:Ashoka Uni',
  'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890',
  'END:VCARD'
].join('\n')

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

</details>

<details>
<summary><b>💥 React to Message</b></summary>
<br>

```javascript
// Add reaction
await sock.sendMessage(jid, {
  react: {
    text: '👍',
    key: message.key
  }
})

// Remove reaction (empty string)
await sock.sendMessage(jid, {
  react: {
    text: '',
    key: message.key
  }
})
```

</details>

<details>
<summary><b>📌 Pin & Keep Message</b></summary>
<br>

| Duration | Seconds |
|----------|---------|
| 24 Hours | `86400` |
| 7 Days | `604800` |
| 30 Days | `2592000` |

```javascript
// Pin a message
await sock.sendMessage(jid, {
  pin: { type: 1, time: 86400, key: message.key }
})

// Keep a message
await sock.sendMessage(jid, {
  keep: { key: message.key, type: 1 }
})
```

</details>

<details>
<summary><b>📍 Location Message</b></summary>
<br>

```javascript
// Static location
await sock.sendMessage(jid, {
  location: {
    degreesLatitude: 37.422,
    degreesLongitude: -122.084,
    name: 'Google HQ'
  }
})

// Live location
await sock.sendMessage(jid, {
  location: {
    degreesLatitude: 37.422,
    degreesLongitude: -122.084,
    accuracyInMeters: 10
  },
  live: true,
  caption: "I'm here!"
})
```

</details>

<details>
<summary><b>📞 Call Message</b></summary>
<br>

```javascript
// Voice call
await sock.sendMessage(jid, {
  call: { name: 'Call message', type: 1 }
})

// Video call
await sock.sendMessage(jid, {
  call: { name: 'Video call', type: 2 }
})
```

</details>

<details>
<summary><b>📊 Poll Message</b></summary>
<br>

```javascript
await sock.sendMessage(jid, {
  poll: {
    name: 'Favorite color?',
    values: ['Red', 'Blue', 'Green'],
    selectableCount: 1
  }
})
```

</details>

<details>
<summary><b>📸 Album Message</b></summary>
<br>

```javascript
await sock.sendAlbumMessage(jid, [
  {
    image: { url: 'https://example.com/image.jpg' },
    caption: 'First photo'
  },
  {
    video: { url: 'https://example.com/video.mp4' },
    caption: 'First video'
  }
], { quoted: message, delay: 3000 })
```

</details>

<details>
<summary><b>👥 Group Invite Message</b></summary>
<br>

```javascript
await sock.sendMessage(jid, {
  groupInvite: {
    jid: '123xxx@g.us',
    name: 'Group Name!',
    caption: 'Join my WhatsApp group!',
    code: 'xYz3yAtf...',
    expiration: 86400,
    jpegThumbnail: fs.readFileSync('preview.jpg')
  }
})
```

</details>

<details>
<summary><b>👨‍💻 Interactive Messages</b></summary>
<br>

<details>
<summary>Shop Flow Message</summary>

```javascript
await sock.sendMessage(jid, {
  text: 'Here is body message',
  title: 'Here is title',
  subtitle: 'Here is subtitle',
  footer: '© PONTASOCKETS Baileys',
  viewOnce: true,
  shop: {
    surface: 1,
    id: 'facebook_store_name'
  }
})
```

</details>

<details>
<summary>Native Flow Message</summary>

```javascript
const buttons = [{
  name: 'quick_reply',
  buttonParamsJson: JSON.stringify({
    display_text: 'Quick Reply',
    id: '123'
  })
}]

await sock.sendMessage(jid, {
  text: 'Choose an option:',
  title: 'Title',
  footer: '© PONTASOCKETS Baileys',
  interactive: buttons
})
```

</details>

<details>
<summary>Carousel Message</summary>

```javascript
await sock.sendMessage(jid, {
  text: 'Check out our collection!',
  title: 'Catalog',
  footer: '© PONTASOCKETS Baileys',
  cards: [{
    image: { url: 'https://example.com/image.jpg' },
    title: 'Product Name',
    body: 'Product description here',
    footer: '© PONTASOCKETS',
    buttons: [{
      name: 'quick_reply',
      buttonParamsJson: JSON.stringify({
        display_text: 'Select',
        id: '123'
      })
    }]
  }]
})
```

</details>

</details>

<details>
<summary><b>🎭 List Message</b></summary>
<br>

```javascript
await sock.sendMessage(jid, {
  text: 'Choose from the menu:',
  sections: [{
    title: 'Food Menu',
    rows: [
      { title: 'Pizza', rowId: 'pizza', description: 'Cheese & pepperoni' },
      { title: 'Burger', rowId: 'burger', description: 'Double patty' }
    ]
  }],
  buttonText: 'Browse Menu'
})
```

</details>

---

### 📣 Newsletter

<details>
<summary><b>📋 Get Newsletter Metadata</b></summary>
<br>

```javascript
// By invite code
const newsletter = await sock.newsletterMetadata('invite', '0029Vaf0HPMLdQeZsp3XRp2T')

// By JID
const newsletter = await sock.newsletterMetadata('jid', '120363282083849178@newsletter')

console.log(newsletter)
```

</details>

<details>
<summary><b>👆 Follow / Unfollow / Mute / Unmute</b></summary>
<br>

```javascript
const nlJid = '120363282083849178@newsletter'

await sock.newsletterFollow(nlJid)
await sock.newsletterUnfollow(nlJid)
await sock.newsletterMute(nlJid)
await sock.newsletterUnmute(nlJid)
```

</details>

<details>
<summary><b>📣 Create Newsletter</b></summary>
<br>

```javascript
const newsletter = await sock.newsletterCreate(
  'Newsletter Name',
  'Description here',
  { url: 'https://example.com/image.jpg' }
)

console.log('Created:', newsletter)
```

</details>

<details>
<summary><b>🌟 React to Newsletter Post</b></summary>
<br>

```javascript
await sock.newsletterReactMessage(
  '120363282083849178@newsletter',
  '12',   // message server ID
  '🦖'    // emoji reaction
)
```

</details>

---

### 🛠️ Groups

<details>
<summary><b>🔄 Create Group</b></summary>
<br>

```javascript
const group = await sock.groupCreate('Group Title', [
  '1234567890@s.whatsapp.net',
  '0987654321@s.whatsapp.net'
])

console.log('Group JID:', group.id)
```

</details>

<details>
<summary><b>⚙️ Group Settings</b></summary>
<br>

```javascript
const jid = '123456789@g.us'

// Restrict: only admins can send messages
await sock.groupSettingUpdate(jid, 'announcement')

// Open: everyone can send messages
await sock.groupSettingUpdate(jid, 'not_announcement')

// Lock: only admins can edit group info
await sock.groupSettingUpdate(jid, 'locked')

// Unlock: everyone can edit group info
await sock.groupSettingUpdate(jid, 'unlocked')
```

</details>

<details>
<summary><b>💯 Add / Remove / Promote / Demote</b></summary>
<br>

```javascript
const participants = ['1234567890@s.whatsapp.net']

await sock.groupParticipantsUpdate(jid, participants, 'add')
await sock.groupParticipantsUpdate(jid, participants, 'remove')
await sock.groupParticipantsUpdate(jid, participants, 'promote')
await sock.groupParticipantsUpdate(jid, participants, 'demote')
```

</details>

<details>
<summary><b>🔗 Invite Link</b></summary>
<br>

```javascript
// Get invite code
const code = await sock.groupInviteCode(jid)
console.log('Link: https://chat.whatsapp.com/' + code)

// Revoke and regenerate
const newCode = await sock.groupRevokeInvite(jid)
console.log('New link: https://chat.whatsapp.com/' + newCode)
```

</details>

<details>
<summary><b>📋 Group Metadata</b></summary>
<br>

```javascript
const metadata = await sock.groupMetadata(jid)

console.log('Name:', metadata.subject)
console.log('Description:', metadata.desc)
console.log('Participants:', metadata.participants.length)
```

</details>

---

### 🔒 Privacy

<details>
<summary><b>🖼️ Update Profile Picture</b></summary>
<br>

```javascript
// Set new picture
await sock.updateProfilePicture(jid, { url: 'https://example.com/image.jpg' })

// Remove picture
await sock.removeProfilePicture(jid)
```

</details>

<details>
<summary><b>🚫 Block / Unblock</b></summary>
<br>

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

</details>

<details>
<summary><b>👁️ Privacy Settings</b></summary>
<br>

```javascript
// Last seen visibility
await sock.updateLastSeenPrivacy('all')         // "all" | "contacts" | "none"

// Online status visibility
await sock.updateOnlinePrivacy('all')           // "all" | "match_last_seen"

// Profile picture visibility
await sock.updateProfilePicturePrivacy('all')   // "all" | "contacts" | "none"

// Read receipts
await sock.updateReadReceiptsPrivacy('all')     // "all" | "none"

// Who can add to groups
await sock.updateGroupsAddPrivacy('all')        // "all" | "contacts"

// Default disappearing message timer
await sock.updateDefaultDisappearingMode(86400) // 0 to disable
```

</details>

---

### ⚙️ Advanced

<details>
<summary><b>🔧 Debug Logging</b></summary>
<br>

```javascript
const sock = makeWASocket({
  logger: { level: 'debug' }, // "fatal" | "error" | "warn" | "info" | "debug" | "trace"
  auth: state
})
```

</details>

<details>
<summary><b>📡 Raw WebSocket Events</b></summary>
<br>

```javascript
sock.ws.on('CB:presence', (json) => {
  console.log('Presence update:', json)
})

sock.ws.on('CB:edge_routing', (node) => {
  console.log('Edge routing:', node)
})
```

</details>

---

## ⚡ Contact

| Platform | Link |
|----------|------|
| 💬 Telegram | [@pontact](https://t.me/pontact) |
| 📢 Channel | [WhatsApp Channel](https://whatsapp.com/channel/0029VagslooA89MdSX0d1X1z) |
| 🌐 Rest API | [api.codeteam.web.id](https://api.codeteam.web.id) |

---

## 🤝 Contributing

Contributions are welcome and appreciated!

1. **Fork** the repository
2. **Create** a feature branch → `git checkout -b feat/your-feature`
3. **Commit** your changes → `git commit -m "feat: add something awesome"`
4. **Push** to your branch → `git push origin feat/your-feature`
5. **Open** a Pull Request with a clear description

All PRs are reviewed before merging.

---

## 📜 License

This project is licensed for **personal and non-commercial use only**.

- ✅ Personal use and modification allowed
- ✅ Redistribution with attribution allowed
- ❌ Commercial use strictly prohibited
- ❌ Resale or rebranding prohibited

---

## ⚠️ Disclaimer

> This project is **not affiliated** with WhatsApp or Meta in any way.
> Use at your own risk and refer to [WhatsApp's Terms of Service](https://www.whatsapp.com/legal) for compliance.

---

<div align="center">

**[📦 NPM](https://npmjs.com/package/@pontasockets/baileys)** · **[📖 Baileys Wiki](https://github.com/whiskeysockets/baileys/wiki)** · **[⭐ Star this repo](https://github.com/pontasockets/baileys)**

<br>

*Made with ♥ by PONTASOCKETS*

</div>
