A powerful Telegram bot that uploads images to multiple hosting services and provides shareable links instantly.
- ๐ค Multiple Image Hosting Services: Upload to ImgBB, FreeImage, or PostImages
- ๐ User Preferences: Remember each user's preferred hosting service
- ๐ Force Subscription: Optional channel subscription requirement
- ๐ User Tracking: Track served users in MongoDB
- โก Serverless Deployment: Deploy on Vercel with zero maintenance
- ๐ Webhook Integration: Real-time Telegram updates via webhook
- ๐พ Database: MongoDB integration for persistence
- ๐จ Beautiful UI: Inline keyboard buttons for seamless navigation
Before you begin, ensure you have:
- Telegram Account - For creating a bot
- Vercel Account - For hosting (free tier available)
- MongoDB Account - For database (free tier M0 available)
- Open Telegram and search for @BotFather
- Send
/startand follow the prompts - Send
/newbotto create a new bot - Follow the setup wizard and save your:
- Bot Token (will look like
123456789:ABCdefGHIjklmnoPQRstuvWXYZ)
- Bot Token (will look like
Refer to this video for detailed step by step tutorial: https://youtu.be/SMXbGrKe5gM (Not my video, I just think he explained it well.)
- Go to MongoDB Atlas
- Create a free account
- Create a new cluster (M0 Free tier)
- Create a database user with username and strong password
- Go to network tab and allow from everywhere
- Get your connection string:
- Click "Connect" โ "Connect your application"
- Copy the MongoDB URI:
mongodb+srv://username:[email protected]/
-
Fork the Repository
- Go to GitHub Repository
- Click "Fork" in the top right corner
-
Connect to Vercel
- Visit vercel.com
- Sign up or log in with GitHub
- Click "Add New..." โ "Project"
- Select your forked repository
- Click "Import"
-
Configure Environment Variables
- In the "Environment Variables" section, add the following:
Variable Value Example MONGO_URIYour MongoDB connection string mongodb+srv://user:[email protected]/MONGO_DB_NAMEDatabase name img_uploadbotBOT_TOKENYour bot token from @BotFather 123456789:ABCdefGHIjklmnoPQRstWEBHOOK_URLYour Vercel app URL (YOU WILL GET IT AFTER FIRST DEPLOYING THE PROJECT. So leave it empty for now.) https://your-app-name.vercel.app/api/webhookADMIN_IDSYour Telegram user ID (without spaces) 123456789,987654321FORCE_SUBEnable force subscription trueorfalseFORCE_SUB_CHANNELChannel username for subscription @YourChannelNameNote: Get your Telegram user ID by messaging @userinfobot
-
Deploy
- Click "Deploy"
- Wait for the deployment to complete (usually 1-2 minutes)
- Copy your Vercel deployment URL (e.g.,
https://your-app-name.vercel.app) - Go to settings > Go to
Environment Variables> EditWEBHOOK_URLwithhttps://your-app-name.vercel.app/api/webhook(don't forget to add/api/webhookafter your vercel deployment URL) > Click save > (a popup will apear) On that popup clickRedeploy
After deployment, set your bot's webhook to receive updates:
Option A: Using Telegram Bot API (Recommended)
Send a GET reques to (just open it in browser):
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=<VERCEL_DEPLOYMENT_URL>/api/webhook
Replace <YOUR_BOT_TOKEN> with your
BOT TOKENand <VERCEL_DEPLOYMENT_URL> with yourDEPLOYMENT URL
Option B: Using Python
import requests
bot_token = "YOUR_BOT_TOKEN"
webhook_url = "https://your-app-name.vercel.app"
response = requests.get(
f"https://api.telegram.org/bot{bot_token}/setWebhook",
params={"url": f"{webhook_url}/api/webhook"}
)
print(response.json())Option C: Using curl
curl "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=<VERCEL_DEPLOYMENT_URL>/api/webhook"Replace <YOUR_BOT_TOKEN> with your
BOT TOKENand <VERCEL_DEPLOYMENT_URL> with yourDEPLOYMENT URL
โ Expected Response:
{
"ok": true,
"result": true,
"description": "Webhook was set"
}- Open Telegram
- Open your bot
- Send
/start - Try uploading an image
- Select your preferred hosting service
ImgUploadBot/
โโโ api/
โ โโโ index.py # Main Flask app & webhook handler
โโโ database/
โ โโโ __init__.py
โ โโโ settings.py # User settings management
โ โโโ users.py # User tracking
โโโ methods/
โ โโโ inline_keyboard.py # Keyboard UI components
โ โโโ updates.py # Telegram Bot API wrapper
โโโ uploaders/
โ โโโ __init__.py
โ โโโ imgbb.py # ImgBB uploader
โ โโโ freeimage.py # FreeImage uploader
โ โโโ postimages.py # PostImages uploader
โโโ config.py # Configuration & environment variables
โโโ utils.py # Helper functions & messages
โโโ requirements.txt # Python dependencies
โโโ vercel.json # Vercel configuration
โโโ example.env # Example environment variables
# MongoDB Configuration
MONGO_URI=mongodb+srv://username:[email protected]/
MONGO_DB_NAME=img_uploadbot
# Telegram bot credentials
BOT_TOKEN=1234567890:ABCdefGHIjklmnoPQRstuvWXYZ1234567
# Deployment
WEBHOOK_URL=https://your-app-name.vercel.app/api/webhook
# Admin settings
ADMIN_IDS=123456789,987654321
# Force subscription settings
FORCE_SUB=true
FORCE_SUB_CHANNEL=@YourChannelName| Command | Description |
|---|---|
/start |
Start the bot and see welcome message |
| Button: โ๏ธ Change Hosting | Switch between uploading services |
| Button: ๐ข Join Channel | Join the bot's channel |
| Button: |
View the GitHub repository |
- User sends image โ Bot receives it via Telegram webhook
- Download image โ Bot downloads the image to memory
- Select uploader โ Uses user's saved preference or ImgBB as default
- Upload image โ Image uploaded to selected service
- Send link โ Bot sends shareable link back to user
- Save preference โ User's choice stored in MongoDB for next time
Dependencies:
- beautifulsoup4: HTML parsing
- Flask: Web framework
- pymongo: MongoDB driver
- Requests: HTTP library
- UserAgentReplica: User agent spoofing
- โ Check if webhook is correctly set
- โ Verify bot token is correct
- โ Ensure Vercel deployment is active
# Check webhook status
curl "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getWebhookInfo"- โ Verify MONGO_URI format is correct
- โ Check if database user password is URL-encoded
- โ Ensure IP whitelist includes Vercel servers (set to 0.0.0.0/0 if on free tier)
- โ Make sure Vercel app is deployed and active
- โ Check Vercel logs for errors
- โ Verify webhook URL is publicly accessible
- Each user's hosting preference is saved in MongoDB
- Default uploader is ImgBB if no preference is set
- Users can change their preference anytime
Enable this feature to require users to join a channel before using the bot. Configure via:
FORCE_SUB=trueFORCE_SUB_CHANNEL=@YourChannelName
Admins (configured in ADMIN_IDS) can broadcast messages to all served users. When an admin sends a message, All commands gets pinned for better experience for admin.
- Serverless: Auto-scales with Vercel
- Database: MongoDB free tier supports ~500MB storage
- Requests: Flask handles concurrent requests efficiently
- Rate Limits: Telegram Bot API has rate limiting (~30 messages/second)
Contributions are welcome! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- GitHub: TheHritu
- Telegram Channel: @XylonBots
- Report Issues: GitHub Issues
- โญ Star the repository if you find it helpful
- ๐ Report bugs via GitHub Issues
- ๐ฌ Discuss improvements in GitHub Discussions
- ๐ง Contact Hritu maintainers on Telegram
Made with โค๏ธ by XylonBots
