https://github.com/sobhan-srza/telegram-robot-handler
Make telegram robot with telegraf.js and my custom handlers.
https://github.com/sobhan-srza/telegram-robot-handler
bot handler javascript mr-sinre nodejs npm persian-caesar sobhan-srza telegraf telegraf-bots telegraf-framework telegraf-js telegrafjs telegram telegram-api telegram-bot telegram-bot-api telegram-userbot telegrambot typescript
Last synced: about 1 month ago
JSON representation
Make telegram robot with telegraf.js and my custom handlers.
- Host: GitHub
- URL: https://github.com/sobhan-srza/telegram-robot-handler
- Owner: Sobhan-SRZA
- License: bsd-3-clause
- Created: 2025-01-24T13:37:59.000Z (3 months ago)
- Default Branch: 0.0.2
- Last Pushed: 2025-02-08T21:52:02.000Z (3 months ago)
- Last Synced: 2025-02-08T22:27:33.481Z (3 months ago)
- Topics: bot, handler, javascript, mr-sinre, nodejs, npm, persian-caesar, sobhan-srza, telegraf, telegraf-bots, telegraf-framework, telegraf-js, telegrafjs, telegram, telegram-api, telegram-bot, telegram-bot-api, telegram-userbot, telegrambot, typescript
- Language: TypeScript
- Homepage:
- Size: 68.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# 🤖 Telegram Bot Handler - Telegraf.js Framework
**A High-Performance Telegram Bot Framework**
✨ Modern Architecture | 🚀 Optimized Performance | 🧩 Modular Design


## 🌟 Key Features
- 🛡️ 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## 📦 Core Dependencies
| 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 |## 🚀 Quick Start
1. **Install dependencies**:
```bash
npm install
```2. **Configure environment**:
- Copy `example.env` to `.env`
```env
token="YOUR_TELEGRAM_BOT_TOKEN"
database_type="json"
```3. **Build & Run**:
```bash
npm start
```
Or you can use this:
```bash
npm run dev
```Then:
```bash
node .
```## ⌨️ Creating Commands
1. Create new file in `src/commands/` (e.g.: `ping.ts`)
2. Use this template:```typescript
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;
```## 🎭 Creating Events
1. Create new file in `src/events/` (e.g.: `messages.ts`)
2. Use this template:```typescript
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>) => {
console.log(`New message from @${ctx.from?.username}`);
}
};export default event;
```## 📂 Project Structure
```
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
```## ⚙️ Configuration Options
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:```ini
# 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"
```## 📜 License
This project is licensed under the [BSD 3-Clause License](./license).```
Copyright (c) 2024 Sobhan-SRZA & Persian Caesar
All rights reserved.
```## 👥 Maintainers
- [Sobhan-SRZA](https://github.com/Sobhan-SRZA) 🧑💻
- [Persian Caesar](https://github.com/Persian-Caesar) 👑🌟 Contributions are welcome! Please open an issue or PR for suggestions.
---
**Need Help?**
Join our support server: [Persian Caesar Discord](https://dsc.gg/persian-caesar)This version includes:
1. Clear visual hierarchy with emojis
2. Version badges for key components
3. Step-by-step setup guide
4. Code examples for commands/events
5. Configuration reference
6. Project structure visualization
7. License and contribution guidelines---
## Contact