A comprehensive, production-ready Telegram bot system for distributing resources with verification, force subscription, and bypass detection. Monetize your content delivery through URL shorteners while preventing users from bypassing the verification process.
- 📦 Resource Management: Upload and distribute files with unique links
- 📚 Batch Distribution: Send multiple files with a single link
- 🔐 Force Subscription: Require channel subscriptions before access
- ✅ Verification System: Token-based verification through URL shorteners
- 🛡️ Bypass Detection: Prevent users from bypassing URL shorteners
- ⏰ Auto-deletion: Automatically delete messages after set time
- 📢 Broadcasting: Send messages to all users
- 👥 User Management: Ban/unban users, track statistics
- 💰 Revenue Generation: Earn through URL shortener views
- Multi-URL Shortener Support: Use multiple shorteners simultaneously
- Smart Scheduling: Background tasks for cleanup and maintenance
- Persistent Storage: Messages scheduled for deletion survive bot restarts
- Join Request Tracking: Tracks private channel join requests
- ZIP Password Protection: Automatic password captions for ZIP files
- Customizable Settings: All parameters configurable via admin commands
- Production Ready: systemd services, monitoring, backups
- Quick Start
- System Requirements
- Installation
- Configuration
- Usage
- Documentation
- Architecture
- Troubleshooting
- FAQ
- Contributing
- License
# 1. Clone repository
git clone https://github.com/yourusername/telegram-resource-system.git
cd telegram-resource-system
# 2. Run setup
chmod +x setup.sh
./setup.sh
# 3. Configure environment
nano .env # Add your bot tokens and settings
# 4. Start system
./run.shThat's it! Your system is now running. 🎉
- OS: Ubuntu 20.04+ / Debian 11+ / Any Linux distro
- Python: 3.10.11 (exact version)
- MongoDB: 4.4+
- RAM: 1GB
- Storage: 10GB
- Network: Public IP or domain (for bypass server)
- RAM: 2GB+
- Storage: 20GB+
- CPU: 2 cores
- Bandwidth: Unlimited
# Download and extract
tar -xzf telegram-resource-system.tar.gz
cd telegram-resource-system
# Run setup script
./setup.shThe setup script will:
- ✅ Check Python 3.10.11
- ✅ Check/install MongoDB
- ✅ Create virtual environment
- ✅ Install dependencies
- ✅ Create .env file
- ✅ Setup database indexes
- ✅ Make scripts executable
# Install Python 3.10
sudo apt update
sudo apt install -y python3.10 python3.10-venv python3.10-dev
# Install MongoDB
sudo apt install -y mongodb
sudo systemctl start mongodb
sudo systemctl enable mongodb
# Create virtual environment
python3.10 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Copy environment file
cp .env.example .envVisit @BotFather and create two bots:
Admin Bot - For resource management User Bot - For resource delivery
Save both bot tokens.
nano .envRequired Settings:
# Admin Bot
ADMIN_BOT_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
ADMIN_IDS=123456789,987654321
# User Bot
USER_BOT_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
USER_BOT_USERNAME=your_user_bot
# Channels
STORAGE_CHANNEL_ID=-1001234567890
PUBLIC_CHANNEL_USERNAME=@your_public_channel
# MongoDB
MONGO_URI=mongodb://localhost:27017/
DB_NAME=telegram_resource_system
# URL Shorteners
AROLINKS_API_TOKEN=your_token
AROLINKS_BASE_URL=https://arolinks.com/api
LINKPAYS_API_TOKEN=your_token
LINKPAYS_BASE_URL=https://linkpays.in/api
# Bypass Server
SERVER_HOST=152.42.212.81
SERVER_PORT=5000
SERVER_SECRET_KEY=your_random_secret_keyConfigure commands via @BotFather:
Admin Bot: See DEPLOYMENT.md for full command list
User Bot:
start - Start the bot
help - Get help information
create_new_token - Create new verification token
All Components at Once:
./run.shIndividual Components:
./run_admin_bot.sh # Admin bot only
./run_user_bot.sh # User bot only
./run_bypass_server.sh # Bypass server onlyUsing tmux (Recommended for servers):
tmux new -s telegram-system
# Split window and run each component
./run_admin_bot.sh
./run_user_bot.sh
./run_bypass_server.sh
# Ctrl+B then D to detach# Resource Management
/generate_link # Generate single resource link
/generate_batch # Generate batch link
/regenerate_post # Regenerate existing post
# Broadcasting
/broadcast # Send message to all users
# Force Subscription
/add_force_sub # Add channel to force sub
/remove_force_sub # Remove channel
/list_force_sub # List all channels
# User Management
/ban_user # Ban a user
/unban_user # Unban a user
/verification_stats # View statistics
# Configuration
/set_free_media_access # Set free media count
/set_paid_access # Set paid access for user
/set_password # Set ZIP password
/set_deletion_time # Set auto-deletion time
/set_token_limit # Set token generation limit
/set_how_to_verify # Set verification guide link- User clicks link in public channel
- Force Sub Check: Must join required channels
- Verification Check: Must verify via URL shortener
- Resource Delivery: Receives files
- Auto-deletion: Files deleted after set time
- Re-download: Can get files again via link
Comprehensive documentation is available:
- DEPLOYMENT.md - Complete deployment guide
- ARCHITECTURE.md - System architecture
- TROUBLESHOOTING.md - Common issues and solutions
- FAQ.md - Frequently asked questions
- schedulers/README.md - Background scheduler docs
- bypass_server/README.md - Bypass server docs
Admin Bot ──┐
├──► Shared Layer ──► Database (MongoDB)
User Bot ───┤ ▲
│ │
Bypass Server ──────────────────────┘
Schedulers (in User Bot):
├── Token Cleanup (2x daily)
├── Message Deleter (every minute)
├── Broadcast Deleter (hourly)
└── Token Count Reset (daily)
- Backend: Python 3.10.11
- Bot Framework: aiogram 3.4.1
- Web Server: Flask 3.0.0
- Database: MongoDB 4.4+
- Scheduler: APScheduler 3.10.4
- Frontend: HTML5, CSS3, JavaScript
See ARCHITECTURE.md for detailed architecture.
Bot not responding?
# Check if running
ps aux | grep python3
# Check logs
sudo journalctl -u telegram-admin-bot -n 50
# Restart
./run.shDatabase connection error?
# Check MongoDB
sudo systemctl status mongodb
# Restart MongoDB
sudo systemctl restart mongodbBypass detection issues?
- Check time threshold (120 seconds)
- Verify URL shortener domains in whitelist
- Check referer header
See TROUBLESHOOTING.md for detailed solutions.
Q: Do I need coding knowledge? A: Minimal. Just follow the setup guide and use bot commands.
Q: How many users can it handle? A: 1,000-5,000 active users with default VPS.
Q: Can I use different URL shorteners? A: Yes! Add any shortener with API support to .env.
Q: Is it secure? A: Yes, with proper configuration. Includes admin middleware, bypass detection, and token validation.
Q: Can I monetize? A: Yes! Earn through URL shortener views.
See FAQ.md for more questions.
Create service files for each component:
sudo nano /etc/systemd/system/telegram-admin-bot.service
sudo nano /etc/systemd/system/telegram-user-bot.service
sudo nano /etc/systemd/system/telegram-bypass-server.serviceEnable and start:
sudo systemctl enable telegram-admin-bot telegram-user-bot telegram-bypass-server
sudo systemctl start telegram-admin-bot telegram-user-bot telegram-bypass-serverSee DEPLOYMENT.md for complete production setup.
- ✅ Admin authentication middleware
- ✅ Token-based verification
- ✅ Bypass detection (time & origin)
- ✅ Environment variable protection
- ✅ Rate limiting
- ✅ Input validation
# Secure .env file
chmod 600 .env
# Enable MongoDB auth (recommended)
# Edit /etc/mongod.conf
# Use HTTPS for bypass server
# Use Let's Encrypt + Nginx
# Regular backups
mongodump --db telegram_resource_system --out ~/backup# Check services
sudo systemctl status telegram-admin-bot
sudo systemctl status telegram-user-bot
sudo systemctl status telegram-bypass-server
# Check bypass server health
curl http://152.42.212.81:5000/health
# Check database
mongosh --eval "db.adminCommand('ping')"# Bot logs
sudo journalctl -u telegram-admin-bot -f
sudo journalctl -u telegram-user-bot -f
# Bypass server logs
sudo journalctl -u telegram-bypass-server -f# Add to crontab
crontab -e
# Daily backup at 3 AM
0 3 * * * mongodump --db telegram_resource_system --out ~/backups/$(date +\%Y\%m\%d)# Backup database
mongodump --db telegram_resource_system --out ~/backup
# Compress
tar -czf backup_$(date +%Y%m%d).tar.gz ~/backup
# Backup config
cp .env ~/.env.backup# Restore from backup
mongorestore --db telegram_resource_system ~/backup/telegram_resource_system- Command Response: <100ms
- Resource Delivery: <500ms
- Concurrent Users: 100+
- Messages/Second: 20-30
- Use indexes (auto-created)
- Regular database maintenance
- Monitor disk space
- Use SSD storage
- Scale vertically for more users
telegram-resource-system/
├── admin_bot/ # Admin bot code
├── user_bot/ # User bot code
├── bypass_server/ # Bypass detection server
├── database/ # Database models & operations
├── shared/ # Shared utilities
├── schedulers/ # Background tasks
├── .env # Configuration
└── run.sh # Launch script
- Create new handler module
- Register in main.py
- Add command to @BotFather
- Update documentation
Contributions welcome! Please:
- Fork the repository
- Create feature branch
- Make changes
- Test thoroughly
- Submit pull request
- Documentation: Check docs in repo
- Issues: Create GitHub issue
- Questions: See FAQ.md
Private Project - All Rights Reserved
Built with:
- aiogram - Telegram Bot Framework
- Flask - Web Framework
- MongoDB - Database
- APScheduler - Task Scheduler
Add screenshots of your bot in action here
- Web dashboard
- Payment integration
- Advanced analytics
- Multi-language support
- CDN integration
- API endpoints
⭐ Star this repo if you find it useful!
🚀 Ready to deploy? Follow DEPLOYMENT.md
Made with ❤️ for the Telegram community