A CLI tool to create Telegram bot projects with Bun and Telegraf
npm install create-telebotA CLI tool to quickly create Telegram bot projects with Bun and Telegraf.
Create a new Telegram bot project with one command:
``bash`
npx create-telebot my-botor
bunx create-telebot my-bot
Then:
`bash`
cd my-bot
cp .env.example .envAdd your bot token to .env
bun run dev
Install globally for repeated use:
`bash
npm install -g create-telebotor
bun install -g create-telebot
What's Included
The generated project includes:
- Telegraf - Modern Telegram Bot API framework
- TypeScript - Full TypeScript support
- Bun - Fast JavaScript runtime
- Hot reload - Development with auto-restart
- Environment config - Secure token management
- Basic commands -
/start and /help handlers
- Message echo - Example text message handling
- Graceful shutdown - Proper bot lifecycle managementProject Structure
`
my-bot/
├── index.ts # Main bot file
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── .env.example # Environment template
├── .gitignore # Git ignore rules
└── README.md # Project documentation
`Development
After creating a project:
1. Get your bot token from @BotFather
2. Copy
.env.example to .env and add your token
3. Run bun run dev for development with hot reload
4. Run bun run start for production$3
To add webhook support to your project, run the following command:
`bash
bun run add:webhook
`This will install the necessary dependencies and create a
server.ts file with a basic webhook setup.You can also choose between
fastify (default) and hono as the server framework:`bash
bun run add:webhook --framework hono
``- Bun installed on your system