Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8f0588f
Replace Knight with Ruhvaan across repo
elanaforrozeira-jpg Mar 22, 2026
1d2a78b
Replace Knight with Ruhvaan across repo
elanaforrozeira-jpg Mar 22, 2026
e455ecc
Initial plan
Copilot Mar 23, 2026
125f522
Add slow mode/cooldown timer feature for WhatsApp groups
Copilot Mar 23, 2026
67e47e1
Merge pull request #1 from elanaforrozeira-jpg/copilot/add-slowmode-c…
elanaforrozeira-jpg Mar 23, 2026
96baadc
Update config.js
elanaforrozeira-jpg Mar 23, 2026
c9c5237
Update app.json
elanaforrozeira-jpg Mar 23, 2026
f31e6ec
Update package.json
elanaforrozeira-jpg Mar 23, 2026
56998a3
Initial plan
Copilot Mar 23, 2026
5311910
Fix memory leaks and Heroku OOM crashes
Copilot Mar 23, 2026
73ee747
Merge pull request #2 from elanaforrozeira-jpg/copilot/fix-memory-lea…
elanaforrozeira-jpg Mar 23, 2026
415e304
Initial plan
Copilot Mar 23, 2026
17f6ce0
Fix slowmode to only exempt bot owner and group owner, not all admins
Copilot Mar 23, 2026
83d49c4
Merge pull request #3 from elanaforrozeira-jpg/copilot/fix-slowmode-e…
elanaforrozeira-jpg Mar 23, 2026
eb25978
Update handler.js
elanaforrozeira-jpg Mar 23, 2026
030d1eb
Update handler.js
elanaforrozeira-jpg Mar 23, 2026
ecffa9f
Update handler.js
elanaforrozeira-jpg Mar 23, 2026
5771320
Update handler.js
elanaforrozeira-jpg Mar 23, 2026
13c9080
Update Procfile
elanaforrozeira-jpg Mar 23, 2026
13e9ecf
Update index.js
elanaforrozeira-jpg Mar 23, 2026
f7d1132
Add new configuration options for socket connection
elanaforrozeira-jpg Mar 23, 2026
28ee2bf
Update index.js
elanaforrozeira-jpg Mar 23, 2026
40408eb
Update index.js
elanaforrozeira-jpg Mar 23, 2026
badfbcb
Update index.js
elanaforrozeira-jpg Mar 23, 2026
b7f6925
Add scripts to create sudo user and wrapper + sudoers fragment
elanaforrozeira-jpg Mar 23, 2026
026bf4d
Add interactive quiz command and handler support
elanaforrozeira-jpg Mar 23, 2026
4b59baf
Update quiz.js
elanaforrozeira-jpg Mar 23, 2026
13a580d
Create quiz_bank.json
elanaforrozeira-jpg Mar 23, 2026
1cfd564
Update handler.js
elanaforrozeira-jpg Mar 23, 2026
1a162b9
Enhance quiz feature to include images and MIME types
elanaforrozeira-jpg Mar 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: node index.js
web: node --max-old-space-size=400 index.js
228 changes: 1 addition & 227 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,227 +1 @@
<div align="center">

## Knight Bot Mini

[![Made with Baileys](https://img.shields.io/badge/Made%20with-Baileys-00bcd4?style=for-the-badge)](https://github.com/WhiskeySockets/Baileys)
[![Node.js](https://img.shields.io/badge/Node.js-18%2B-339933?style=for-the-badge&logo=node.js&logoColor=white)](https://nodejs.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](LICENSE)

<img src="utils/bot_image.jpg" alt="Knight Bot Mini" width="260">

</div>

Knight Bot Mini is a WhatsApp MD bot built on top of the **Baileys** library.
It’s designed to be fast, lightweight, and easy to customize without touching the core code.
This project is **fully open source** — you can modify it, rebrand it, and make your **own bot** from this codebase **free of cost**, without needing any permission from our side.
All commands and the overall structure are written in a way that makes customization (bot image, prefix, name, features, etc.) as easy as possible.

---


## ✨ Features

- **Fully Open Source** – entire codebase is editable; host it anywhere (Heroku, panel, VPS, etc.).
- **Easy Customization via Commands** – change **bot image**, **prefix**, **channel/newsletter**, **bot name**, etc. with simple commands.
- **Modular Command System** – commands are organized in the `commands` folder for easy editing.
- **Optimized for Stability** – RAM‑optimized media handling (streaming, temp cleanup), better session handling via `sessionID` in `config.js`.
- **Owner Utilities** – restart, update from ZIP, and more owner‑only tools.

---

### 1. Fork the Repository

<div align="center">

<a href="https://github.com/mruniquehacker/Knightbot-Mini/fork" target="_blank">
<img src="https://img.shields.io/badge/Fork%20Repository-GitHub-181717?style=for-the-badge&logo=github&logoColor=white" alt="Fork on GitHub">
</a>

</div>

> This creates your own copy of `Knightbot-Mini` under your GitHub account.

---

### 2. Get Pair Code

Deploy a small helper to generate a **pair code** and obtain your session string.

<div align="center">

<a href="https://knight-bot-paircode.onrender.com/" target="_blank">
<img src="https://img.shields.io/badge/Generate-Pair%20Code-blueviolet?style=for-the-badge" alt="Generate Pair Code">
</a>

</div>

After scanning, you will receive a **session string** starting with:

```text
KnightBot!H4....
```

Copy that full string and paste it into `config.js`:

```js
sessionID: 'KnightBot!H4.....'
```

Or set it via the `SESSION_ID` environment variable when hosting.

---

### 3. Deploy on Panel (Katabump, etc.)

<div align="center">

<a href="https://dashboard.katabump.com/auth/login#d6b7d6" target="_blank">
<img src="https://img.shields.io/badge/Deploy%20on-Katabump-orange?style=for-the-badge" alt="Deploy on Katabump">
</a>

</div>

For a full step‑by‑step deployment tutorial (panels / VPS / Heroku), add or update your YouTube guide here:

<div align="center">
<a href="https://youtu.be/4PQcn-qqrcE">
<img src="https://img.shields.io/badge/Deploy Tutorial-dc3545?style=for-the-badge&logo=youtube" alt="YouTube Link"/>
</a>
</div>

---

## 🛠 Local Setup

### 1️⃣ Clone the repository

```bash
git clone https://github.com/mruniquehacker/Knightbot-Mini.git
cd Knightbot-Mini
```

### 2️⃣ Install dependencies

```bash
npm install
```

### 3️⃣ Configure session

Edit `config.js`:

- **Option A: Use session string**

```js
sessionID: 'KnightBot!H4.....'
```

- **Option B: Scan QR**

```js
sessionID: ''
```

Run the bot and scan the QR from the terminal.

### 4️⃣ Run the bot

```bash
node index.js
```

When the bot starts:

- If `sessionID` is empty, a **QR code** will appear in the terminal – scan it using **Linked Devices** in WhatsApp.
- If `sessionID` is set, it will log in using that session string.

---

## 🌐 Community

<div align="center">

<a href="https://t.me/+3QhFUZHx-nhhZmY1" target="_blank">
<img src="https://img.shields.io/badge/Join-Telegram-0088cc?style=for-the-badge&logo=telegram&logoColor=white" alt="Join Telegram">
</a>

<a href="https://whatsapp.com/channel/0029Va90zAnIHphOuO8Msp3A" target="_blank">
<img src="https://img.shields.io/badge/Join-WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white" alt="Join WhatsApp Channel">
</a>

</div>

---

## 🙏 Credits

- **Mr Unique Hacker** – Main developer & maintainer
- **Baileys** – WhatsApp Web API library (`@whiskeysockets/baileys`)
- Other open‑source libraries listed in `package.json`

---

## ☕ Support Me

<div align="center">

<a href="https://buymeacoffee.com/mruniquehacker" target="_blank">
<img src="https://img.shields.io/badge/Buy%20Me%20a%20Coffee-Support%20Developer-FF813F?style=for-the-badge&logo=buy-me-a-coffee&logoColor=white" alt="Buy Me a Coffee">
</a>

</div>

If you find this project helpful and want to support the developer, consider buying me a coffee! Your support helps maintain and improve this open-source project.

<div align="center">

<img src="utils/bmc_qr.png" alt="Buy Me a Coffee QR Code" width="200">

</div>

---


## ⚠️ Important Warning

- This bot is created **for educational purposes only**.
- This is **NOT** an official WhatsApp bot.
- Using third‑party bots **may violate WhatsApp’s Terms of Service** and can lead to your account being **banned**.

> You use this bot **at your own risk**.
> The developers are **not responsible** for any bans, issues, or damages resulting from its use.

---

## 📝 Legal

- This project is **not affiliated with, authorized, maintained, sponsored, or endorsed** by WhatsApp Inc. or any of its affiliates or subsidiaries.
- This is **independent and unofficial software**.
- **Do not spam** people using this bot.
- **Do not** use this bot for bulk messaging, harassment, or any **illegal activities**.
- The developers assume **no liability** and are **not responsible** for any misuse or damage caused by this program.

---

## 📄 License (MIT)

This project is licensed under the **MIT License**.

You must:

- Use this software in compliance with **all applicable laws and regulations**.
- Keep the **original license and copyright** notices.
- **Credit the original authors**.
- **Not** use this for spam, abuse, or malicious purposes.

---

## 📜 Copyright Notice

Copyright (c) **2026 Professor**.
All rights reserved.

This project contains code from various open‑source projects and AI tools, including but not limited to:

- **Baileys** – MIT License
- Other libraries as listed in `package.json`

# Ruhvaan Mini\n\nThis is the README for the Ruhvaan Mini project where you can find various functionalities and tools related to it.\n\n## Overview\nThe Ruhvaan Mini project aims to provide you with a mini bot to assist you with your tasks. \n\n## Getting Started\nFollow the instructions below to get started with the Ruhvaan Mini bot.\n\n## Contributing\nFeel free to contribute to this project by submitting pull requests and issues.\n\n## License\nThis project is licensed under the MIT License.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Knight Bot MINI",
"name": "Ruhvaan",
"description": "WhatsApp MD bot (Baileys)",
"repository": "",
"keywords": ["whatsapp", "baileys", "bot", "node"],
Expand Down
87 changes: 87 additions & 0 deletions commands/admin/slowmode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/**
* Slowmode Command - Enable/disable and configure per-group slow mode
*/

const database = require('../../database');
const { clearGroupCooldowns } = require('../../utils/slowMode');

module.exports = {
name: 'slowmode',
aliases: ['slow'],
category: 'admin',
description: 'Configure slow mode (message cooldown) for the group',
usage: '.slowmode <on/off/set <seconds>/get>',
groupOnly: true,
adminOnly: true,
botAdminNeeded: false,

async execute(sock, msg, args, extra) {
try {
if (!args[0]) {
const settings = database.getGroupSettings(extra.from);
const status = settings.slowmode ? 'ON' : 'OFF';
const cooldown = settings.slowmodeCooldown || 30;
return extra.reply(
`🐢 *Slow Mode Status*\n\n` +
`Status: *${status}*\n` +
`Cooldown: *${cooldown} seconds*\n\n` +
`Usage:\n` +
` .slowmode on\n` +
` .slowmode off\n` +
` .slowmode set <seconds>\n` +
` .slowmode get`
);
}

const opt = args[0].toLowerCase();

if (opt === 'on') {
if (database.getGroupSettings(extra.from).slowmode) {
return extra.reply('🐢 *Slow mode is already ON*');
}
database.updateGroupSettings(extra.from, { slowmode: true });
const cooldown = database.getGroupSettings(extra.from).slowmodeCooldown || 30;
return extra.reply(`🐢 *Slow mode has been turned ON*\n\nCooldown: *${cooldown} seconds* between messages per user.\n\nAdmins and bot owner are exempt.`);
}

if (opt === 'off') {
database.updateGroupSettings(extra.from, { slowmode: false });
clearGroupCooldowns(extra.from);
return extra.reply('🐢 *Slow mode has been turned OFF*');
}

if (opt === 'set') {
if (!args[1]) {
return extra.reply('*Please specify cooldown in seconds: .slowmode set <seconds>*');
}

const seconds = parseInt(args[1], 10);
if (isNaN(seconds) || seconds < 1) {
return extra.reply('*Invalid value. Cooldown must be a positive number of seconds.*');
}
if (seconds > 3600) {
return extra.reply('*Maximum cooldown is 3600 seconds (1 hour).*');
}

database.updateGroupSettings(extra.from, {
slowmodeCooldown: seconds,
slowmode: true // Auto-enable when setting cooldown
});
clearGroupCooldowns(extra.from); // Reset existing cooldowns for fresh start
return extra.reply(`🐢 *Slow mode cooldown set to ${seconds} seconds*\nSlow mode has been enabled.`);
}

if (opt === 'get') {
const settings = database.getGroupSettings(extra.from);
const status = settings.slowmode ? 'ON' : 'OFF';
const cooldown = settings.slowmodeCooldown || 30;
return extra.reply(`🐢 *Slow Mode Configuration:*\nStatus: ${status}\nCooldown: ${cooldown} seconds`);
}

return extra.reply('*Use .slowmode for usage information.*');

} catch (error) {
await extra.reply(`❌ Error: ${error.message}`);
}
}
};
48 changes: 48 additions & 0 deletions commands/fun/quiz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const fs = require('fs');
const { prepareWAMessageMedia } = require('@whiskeysockets/baileys');

async function sendQuiz(sock, jid) {
try {
// --- Quiz question ---
const question = 'What is the capital of India?\n\nA) Delhi\nB) Mumbai\nC) Kolkata\nD) Chennai';

// Agar aap media bhejna chahte hain
const imagePath = './path/to/image.jpg'; // Sahi file path daalein
if (!fs.existsSync(imagePath)) {
await sock.sendMessage(jid, { text: question }); // Sirf text bheje agar image nahi hai
return;
}

// Media file read karo aur MIME type sahi define karo
const mediaBuffer = fs.readFileSync(imagePath);
const mediaType = 'image/jpeg'; // image/png bhi ho sakta hai

// prepareWAMessageMedia se media bana lo
const mediaMsg = await prepareWAMessageMedia(
{ image: mediaBuffer, mimetype: mediaType },
{ upload: sock.waUploadToServer }
);

// Media ke saath quiz bheje
await sock.sendMessage(jid, {
image: mediaBuffer,
mimetype: mediaType,
caption: question
});

console.log('Quiz sent successfully!');
} catch (err) {
console.error('Quiz send error:', err);
await sock.sendMessage(jid, { text: 'Quiz bhejne mein error aa gaya: ' + err.message });
}
}

// Sample Baileys event: message handler
module.exports = {
name: 'quiz',
description: 'Send a quiz with image and proper MIME type',
async execute(sock, msg) {
const jid = msg.key.remoteJid;
await sendQuiz(sock, jid);
}
};
Loading