npm package: @nexoraa/wb
Description: Simplicity WhatsApp Bot (Baileys)
Author: Kens Ransyah
Latest version: 1.0.0-rc.10

## Simplicity WhatsApp Bot (Baileys)

Simplicity WhatsApp Bot is a modular, lightweight WhatsApp automation system built on top of the Baileys multi-device library. The project focuses on structured command handling, plugin extensibility, and predictable event processing. Repository maintained under the slightnich account.

---

## Core Characteristics

- Command-driven message handling  
- Multi-prefix command parsing  
- Plugin-based feature extension  
- Minimal runtime overhead  
- Structured event payload mapping  
- Compatible with Baileys multi-device architecture  

---

## Runtime Message Event Model

The bot processes normalized message events derived from Baileys. Each incoming message is transformed into a standardized execution object used by command handlers and plugins.

### Example Event Payload

```js
{
   m: {
      key: {
         remoteJid: '628888375863@s.whatsapp.net',
         fromMe: false,
         id: 'NXN5E1FB9C33178CD11673178C46CA1E',
         participant: undefined
      },
      messageTimestamp: 1689557472,
      pushName: 'Kens Ransyah',
      broadcast: false,
      message: Message {
         extendedTextMessage: [ExtendedTextMessage],
         messageContextInfo: [MessageContextInfo]
      },
      id: 'NXN5E1FB9C33178CD11673178C46CA1E',
      isBot: false,
      chat: '628888375863@s.whatsapp.net',
      fromMe: false,
      isGroup: false,
      sender: '628888375863@s.whatsapp.net',
      mtype: 'extendedTextMessage',
      msg: ExtendedTextMessage {
         text: '.menu',
         previewType: 0,
         contextInfo: [ContextInfo],
         inviteLinkGroupTypeV2: 0
      },
      quoted: null,
      mentionedJid: [],
      reply: [Function(anonymous)],
      text: '.menu'
   },
   body: '.menu',
   prefix: '.',
   plugins: [],
   commands: [],
   args: [],
   command: 'menu',
   text: '',
   prefixes: ['.', '#', '!', '/']
}
```

### Structural Breakdown

#### Root Execution Object

| Field | Description |
|---|---|
| m | Raw normalized message object from Baileys |
| body | Raw message string before parsing |
| prefix | Detected command prefix |
| plugins | Loaded plugin registry |
| commands | Registered command definitions |
| args | Parsed command arguments |
| command | Resolved command identifier |
| text | Residual text payload |
| prefixes | Supported prefix array |

---

### Message Object (m)

Contains message metadata, sender identity, and payload.

#### Identity Layer

| Field | Description |
|---|---|
| key | Unique message key container |
| remoteJid | Chat identifier |
| id | Message unique ID |
| participant | Group participant ID |

---

#### Sender Metadata

| Field | Description |
|---|---|
| pushName | Display name |
| sender | Sender WhatsApp JID |
| fromMe | Bot-originated flag |
| isBot | Sender bot detection |
| isGroup | Group message flag |
| broadcast | Broadcast flag |

---

#### Temporal

| Field | Description |
|---|---|
| messageTimestamp | UNIX timestamp |

---

#### Payload Layer

| Field | Description |
|---|---|
| message | Raw Baileys message node |
| mtype | Message type classification |
| msg | Extracted message object |
| text | Extracted textual content |
| quoted | Referenced message |
| mentionedJid | Mentioned users list |
| reply | Reply helper binding |

---

### Command Resolution Pipeline

| Step | Process |
|---|---|
| 1 | Raw event received from Baileys socket |
| 2 | Message normalized into execution object |
| 3 | Prefix detection |
| 4 | Command extraction |
| 5 | Argument parsing |
| 6 | Plugin/command registry lookup |
| 7 | Handler execution |
| 8 | Response dispatch |

### Installation

git clone https://github.com/slightnich/nexora-bot.git
cd nexora-bot
npm install


## Configuration

Runtime configuration must be defined before bot initialization. The system depends on environment-level definitions and structured runtime paths.

| Component | Description | Example |
|---|---|---|
| WhatsApp Session Storage | Location/provider for Baileys auth state persistence | `./session` |
| Owner Identifier | Primary privileged WhatsApp JID | `628xxxxxxxxxx@s.whatsapp.net` |
| Prefix Configuration | Command trigger prefixes | `. ! # /` |
| Plugin Loading Path | Directory scanned for plugin modules | `./plugins` |
| Database Integration | Optional persistence layer | MongoDB / SQLite / JSON |

Example configuration layout:

```bash
Lib/System/
 ├─ settings.json
 ├─ config.js
 └─ baileys.js
```

### Execution

```bash
npm start
```

## Extension Model

The bot uses a modular plugin architecture where features are injected at runtime without modifying the core runtime layer.

### Plugin Architecture

| Layer | Responsibility |
|---|---|
| Core Runtime | Message routing, prefix parsing, execution orchestration |
| Plugin Loader | Dynamic module discovery and registration |
| Command Registry | Mapping command → handler |
| Execution Context | Scoped access to socket, message, utilities |
| Lifecycle Hooks | Event interception before/after execution |

---

### Capabilities

| Capability | Technical Behavior |
|---|---|
| Independent Command Injection | Plugins register commands directly into runtime registry |
| Isolated Execution Context | Each plugin executes in its own handler scope |
| Optional Lifecycle Hooks | Hooks available: init, message, command, shutdown |
| Runtime Command Registration | Plugins loaded dynamically without restart |

---

### Plugin Loading Flow

| Step | Process |
|---|---|
| 1 | Runtime scans plugin directory |
| 2 | Module imported dynamically |
| 3 | Metadata parsed (name, command, tags) |
| 4 | Handler registered into command map |
| 5 | Context bound (sock, m, utils) |
| 6 | Plugin ready for execution |

---

### Example Plugin Structure

plugins/ 
 ├─ ai/
 ├─ owner/
 └─ about

### Minimum Plugin Template

```js
export default const run = {
  execution: ["ping"],
  obscure: ["ping"],
  use: "server",
  category: ["utility"],
  async: async (m, { sock }) => {
    return m.reply("pong")
  }
}
```

## License

This project is licensed under the MIT License.

| Permission | Status |
|---|---|
| Commercial use | Allowed |
| Modification | Allowed |
| Distribution | Allowed |
| Private use | Allowed |

| Limitation | Description |
|---|---|
| Liability | No liability provided |
| Warranty | No warranty provided |

Full license text available in the [`LICENSE`](./LICENSE) file.

## Attribution

This project is built on top of the Baileys multi-device framework and supported by multiple open-source components within the Node.js ecosystem.

### Core Framework

| Component | Role |
|---|---|
| Baileys (Multi-Device) | WhatsApp transport layer and message event bridge |

### Runtime Environment

| Component | Role |
|---|---|
| Node.js | Execution runtime |
| Event Loop | Async message processing |
| File System API | Session and plugin loading |

### Supporting Dependencies

| Component | Role |
|---|---|
| Axios | HTTP client for external integrations |
| JSON / Local Storage | Lightweight persistence |
| Plugin Modules | Feature extension layer |

### Open-Source Acknowledgment

Architecture and implementation rely on the broader open-source ecosystem, including community-maintained libraries, tooling, and runtime infrastructure.

### Credits

Owner: [Kens Ransyah](https://github.com/slightnich)
Support: [Itsukichann](https://github.com/Itsukichann)