✨ Features
|
Feature |
Description |
| 🔐 |
QR Login |
Scan in the terminal or in your browser at /qr |
| 🔑 |
Pairing Code |
Link with a phone number, no scanning needed |
| 🧩 |
Plugin System |
Every .js file in plugins/ is auto-loaded |
| ☁️ |
MEGA Session |
Optional SESSION_ID restore |
| 🛡️ |
Work Modes |
public, private, groups, inbox |
| 👀 |
Auto Status |
Optional auto read + react to statuses |
| 🔁 |
Auto Reconnect |
Reconnects safely without duplicating plugins |
📁 Structure
WhatsApp-PluginBot-Script/
├── index.js # connection, login (QR/pair), message handler
├── config.js # reads config.env / environment variables
├── command.js # cmd() registry used by plugins
├── config.env.example # copy to config.env
├── lib/
│ ├── functions.js # helpers (getBuffer, fetchJson, runtime ...)
│ └── msg.js # message serializer (sms, downloadMediaMessage)
└── plugins/
└── ping.js # example plugin
🚀 Installation
git clone https://github.com/dnuzi/WhatsApp-PluginBot-Script
cd WhatsApp-PluginBot-Script
npm install
cp config.env.example config.env
nano config.env # set OWNER_NUMBER, CONNECT_MODE ...
npm start
🔐 Login Methods
1️⃣ QR Code (default)
CONNECT_MODE=qr
- Run
npm start
- Scan the QR shown in the terminal, or open
http://localhost:8000/qr
- WhatsApp → Linked Devices → Link a Device
2️⃣ Pairing Code
CONNECT_MODE=pair
PAIR_NUMBER=94712345678
- Run
npm start
- An 8 character code appears, for example
ABCD-1234
- WhatsApp → Linked Devices → Link with phone number instead → enter the code
If PAIR_NUMBER is empty, the terminal asks for the number.
The session is saved in auth_info_baileys/, so you only log in once.
⚙️ Configuration
| Variable |
Default |
Description |
BOT_NAME |
FREE BASE DANUZZ |
Bot display name |
PREFIX |
. |
Command prefix |
OWNER_NUMBER |
– |
Owner number(s), comma separated |
CONNECT_MODE |
qr |
qr or pair |
PAIR_NUMBER |
– |
Number used for pairing code |
SESSION_ID |
– |
Optional MEGA session |
MODE |
public |
public / private / groups / inbox |
AUTO_READ_STATUS |
false |
Auto view + react to statuses |
ALWAYS_OFFLINE |
false |
Hide online presence |
PORT |
8000 |
Web server port |
🧩 Creating a Plugin
Create plugins/hello.js:
const { cmd } = require('../command');
cmd({
pattern: "hello", // .hello
alias: ["hi"], // .hi
desc: "Say hello",
react: "👋",
category: "main",
filename: __filename
}, async (conn, mek, m, { from, pushname, q, isOwner, isGroup, reply }) => {
reply(`Hello ${pushname}! 👋`);
});
Restart the bot and .hello works.
Available values in the 4th argument
from · quoted · body · command · args · q · isGroup · sender · senderNumber · botNumber · pushname · isOwner · isMe · groupMetadata · groupName · participants · groupAdmins · isBotAdmins · isAdmins · reply
Event plugins
cmd({ on: "body" }, async (conn, mek, m, { body, reply }) => {
if (body === "hi") reply("Hello!");
});
Supported: body, text, image, sticker.
☁️ Running 24/7 with PM2
npm run pm2 # start
npm run restart # restart
npm run stop # stop
🛡️ Security Tips
- Never commit
config.env or auth_info_baileys/ (already in .gitignore).
- Never hardcode session IDs, tokens or database passwords in code.
- If a secret was ever public, rotate it.
❓ Troubleshooting
| Problem |
Fix |
| Pairing code not shown |
Check PAIR_NUMBER has country code, no + |
| QR keeps changing |
Normal, scan quickly or use /qr |
| Logged out |
Session is deleted automatically, restart and link again |
| Plugin not loading |
Check the terminal for Plugin failed: errors |
⭐ Star the repo if it helped you!