A Telegram bot built with TypeScript that generates QR codes on demand. Fast, reliable, and easy to use!
- Generate QR codes instantly via Telegram
- Built with TypeScript for type safety
- Powered by Bun for exceptional performance
- MySQL database for user tracking and analytics
- Production-ready with Nginx reverse proxy
- Bun v1.3.2 or higher
- MySQL 8.x
- Nginx
- A Telegram Bot Token (get it from @BotFather)
-
Clone the repository
git clone https://github.com/IvanDeus/QRcode-bot-ts.git cd QRcode-bot-ts -
Set up environment variables
cp .env-example .env # Edit .env with your configuration - Copy the bot token to your `.env` file -
Configure the database
mysql databasename < QRcodebot_cfg.sql
Configure your bot to use a webhook endpoint:
# Example webhook URL format
curl -F "url=https://{ext-fqdn}/" https://api.telegram.org/bot{token}/setWebhookbun run index.tsbun run index.ts &Add this to your Nginx configuration to proxy requests to the bot if needed:
location /QRcodebot {
rewrite ^/QRcodebot(.*)$ $1 break;
proxy_pass http://localhost:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 40s;
proxy_send_timeout 40s;
proxy_read_timeout 40s;
}Once the bot is running, interact with it on Telegram:
- Start a chat with your bot
- Follow instructions to generate a QR code
- The bot will reply with a QR code image
- Bot not responding? Check if the webhook is properly set up
- Database errors? Verify MySQL is running and credentials are correct
- Nginx 502 errors? Ensure the bot process is running on local port
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this project useful, please consider giving it a star on GitHub!
2025 [ ivan deus ]