A High-Performance Telegram Bot Framework
✨ Modern Architecture | 🚀 Optimized Performance | 🧩 Modular Design
- 🛡️ Advanced Anti-Crash System
- 💾 Multi-Database Support (JSON/MySQL/MongoDB)
- ⚡ Modern Command Handler with Cooldown
- 📝 Colorful Console Logging
- 🔄 Native TypeScript Support
- 🤖 Full Telegram Bot API Coverage
Package | Version | Purpose |
---|---|---|
telegraf |
4.16.3 | Telegram Bot Framework |
quick.db |
9.1.7 | Database Management |
dotenv |
16.4.7 | Environment Variables |
colors |
1.4.0 | Console Coloring |
typescript |
5.5.4 | TypeScript Compiler |
-
Install dependencies:
npm install
-
Configure environment:
- Copy
example.env
to.env
token="YOUR_TELEGRAM_BOT_TOKEN" database_type="json"
- Copy
-
Build & Run:
npm start
Or you can use this:
npm run dev
Then:
node .
- Create new file in
src/commands/
(e.g.:ping.ts
) - Use this template:
import CommandType from "../types/command";
const command: CommandType = {
data: {
name: "ping",
description: "Check bot latency"
},
category: "misc",
cooldown: 3,
run: async (client, ctx) => {
await ctx.reply("🏓 Pong!");
}
};
export default command;
- Create new file in
src/events/
(e.g.:messages.ts
) - Use this template:
import { NarrowedContext } from "telegraf";
import { Message, Update } from "telegraf/typings/core/types/typegram";
import { MyContext } from "../types/MessageContext";
const event: EventType = {
name: "message",
run: async (client, message: NarrowedContext<MyContext, Update.MessageUpdate<Message>>) => {
console.log(`New message from @${ctx.from?.username}`);
}
};
export default event;
telegram-bot-handler/
├── dist/ # Compiled JS
├── src/
│ ├── commands/ # Command handlers
│ ├── handlers/ # Event handlers
│ ├── classes/ # Core classes
│ ├── functions/ # Functions
│ ├── utils/ # Utilities
│ └── types/ # TypeScript types
├── .env # Environment variables
├── config.ts # Main configuration
└── package.json # Dependencies
Create a .env
file in the root directory. Make sure to provide values for at least token
and database_type
.
Below is an example configuration:
# Bot token (required)
token="YOUR_TELEGRAM_BOT_TOKEN"
# Database type (required): options are "mysql" | "sql" | "mongodb" | "json"
database_type="json"
# (Optional) If using MongoDB:
database_mongoURL="your-mongo-url"
# (Optional) If using MySQL:
database_msql_host="your-mysql-host"
database_msql_user="your-mysql-user"
database_msql_password="your-mysql-password"
database_msql_database="your-mysql-database"
# Support server invite link (optional)
support_url="https://discord.gg/yourInvite"
# Source owners (optional, comma-separated list of owner IDs)
owners='["123456789", "987654321"]'
# Anti crash controller (optional)
anti_crash="true"
# Send console errors to Discord (optional)
logger="true"
This project is licensed under the BSD 3-Clause License.
Copyright (c) 2024 Sobhan-SRZA & Persian Caesar
All rights reserved.
🌟 Contributions are welcome! Please open an issue or PR for suggestions.
Need Help?
Join our support server: Persian Caesar Discord
This version includes:
- Clear visual hierarchy with emojis
- Version badges for key components
- Step-by-step setup guide
- Code examples for commands/events
- Configuration reference
- Project structure visualization
- License and contribution guidelines