Note
Yoru is a modern Telegram bot framework designed for developers who need a robust foundation for building feature-rich bots. Whether you're creating a simple utility bot or a complex, multi-service platform, Yoru provides the architecture and tools to scale efficiently and optimized for lightweight performance.
- Why Choose Yoru?
- Requirements
- Getting Started
- Configuration
- Running the Bot
- Installation via Docker
- Plugin Development
- PM2 Configuration
- Contributing
- Troubleshooting
- License
- Free & Open Source: Completely free for personal and commercial use under the MIT License.
- Modular Architecture: Easily extend functionality with a simple plug-and-play plugin system.
- Fast & Stable: Powered by Telegraf, one of the most popular and reliable Telegram bot libraries.
- Hybrid Storage: Choose between simple JSON file-based storage or a powerful MongoDB database for scalability.
- Active Roadmap:
- Robust Error Handling: A more resilient system to gracefully handle errors and maintain a stable connection.
- Easy Deployment: Streamlined processes for hosting on various platforms.
- NodeJS: Version
16.xor higher. (Recommended20.x) - Git: For cloning the repository.
- vCPU: 1 Core
- RAM: 500 MB
- Hosting: Hostdata (NAT VPS), Optiklink, VPS, RDPWin
- Database: MongoDB Atlas for a free cloud database.
# Clone the repository
git clone https://github.com/yuurahz/yoru.git
# Navigate into the project directory
cd yoru
# Install all required dependencies
npm installCopy the example .env file to create your own configuration file.
cp .env.example .envNext, open the .env file and customize the values as needed.
Edit the .env file you just created:
| Variable | Description | Example Value |
|---|---|---|
TOKEN_BOT |
Your unique bot token from @BotFather. | - |
OWNER_ID |
ID of the account that will be used as the owner. | - |
TZ |
The local timezone of your server. | Asia/Jakarta |
LIMIT |
The daily command usage limit per user. | 50 |
DATABASE_STATE |
Choose json for local files or mongodb for a database. |
json |
DATABASE_NAME |
The name of your database (for MongoDB). | yoru_db |
MONGO_URL |
Your MongoDB connection string (if using mongodb). |
- |
You can run the bot in several different modes:
- Production Mode:
npm start
- Development Mode (with auto-reload on file changes):
npm run dev
- Using PM2 (to keep the bot online):
npm run pm2
For an easy and isolated setup, you can use Docker.
# Update packages and install dependencies
sudo apt update -y && sudo apt install curl git -y
# Install Docker
curl -fsSL https://get.docker.com | bash
# Clone the repository
git clone https://github.com/yuurahz/yoru
# Navigate into the directory
cd yoru
# (IMPORTANT) Create and edit your .env file before building the image
# cp .env.example .env
# nano .env
# Build the Docker image
docker build -t yoru-bot .
# Run the container in detached mode and set it to always restart
docker run -d --name yoru --restart always yoru-bot
# View the bot's logs in real-time
docker logs -f yoruTo stop the container:
docker stop yoruYoru uses a flexible and easy-to-extend plugin system.
This is a simple ping plugin to check the bot's latency.
// file: plugins/tools/ping.js
module.exports = {
// Plugin metadata
help: ["ping"],
category: "tools",
command: "ping",
// The main logic of the plugin
run: async (m, { client }) => {
const start = Date.now();
const msg = await m.reply("Pinging...");
const latency = Date.now() - start;
await client.telegram.editMessageText(
m.chat,
msg.message_id,
null,
`π Pong!\n*Latency:* ${latency} ms`,
{ parse_mode: "Markdown" }
);
},
// Plugin permissions and properties
group: true, // Works in groups
admin: false, // Does not require admin
limit: 1, // Consumes 1 usage limit (can be a Number or Boolean)
premium: false, // Not premium-only
botAdmin: false, // Bot does not need to be an admin
owner: false, // Not owner-only
};Plugins can also respond to events instead of commands, such as replying to specific messages.
// file: plugins/events/auto-reply.js
module.exports = {
// The 'before' function runs on every incoming message
before: async (m, { client }) => {
if (m.body?.toLowerCase().includes("hello yoru")) {
await m.reply("π Hello there!");
}
// Always return a boolean value
return true;
},
};If you run the bot using npm run pm2, you can customize its configuration in the ecosystem.config.js file.
module.exports = {
apps: [
{
name: "yoru",
script: "index.js",
exec_mode: "fork",
instances: 1,
max_memory_restart: "300M",
watch: false, // Set to true to automatically restart on file changes
},
],
};Your contributions are highly appreciated! If you'd like to help improve Yoru, please follow these steps:
- Fork the repository.
- Create a new feature branch (
git checkout -b feature/NewFeature). - Make your changes and commit them (
git commit -m "Add NewFeature"). - Push to your branch (
git push origin feature/NewFeature). - Open a Pull Request.
Bot is not responding
- Check Bot Token: Ensure the token in your
.envfile is correct and has no extra spaces. - Verify Internet Connectivity: Try to
ping google.comfrom your server. - Check Logs: Run the bot in
devmode (npm run dev) or check Docker/PM2 logs for any error messages. - Rate Limits: Make sure the bot is not sending too many messages in a short period, which could get it rate-limited by Telegram.
Database connection issues
- Verify MongoDB URL: Double-check that the URL and credentials (username/password) are correct.
- Database Server is Running: Ensure your database server is active.
- Whitelist IP: If using MongoDB Atlas, make sure your server's IP address has been whitelisted.
- Firewall: Check for any firewall rules that might be blocking the outbound connection to the database port.
Plugin is not loading
- Check Syntax: Ensure there are no syntax errors in your plugin file.
- Plugin Structure: Verify that the
module.exportsstructure is correct. - Look for Errors: Check the console on startup for any error messages related to loading plugins.
- File Location: Make sure the plugin file is inside the correct
pluginsdirectory.
This project is licensed under the MIT License. Free for personal & commercial use.
Need Help? Open an Issue or join the discussions!
β Star this repo if you like it! β
Built with β€οΈ for the Telegram community