Repository: https://github.com/MeherMankar/CleanAcc
Developer: @MeherMankar
A comprehensive Telegram bot for cleaning and managing multiple Telegram accounts with advanced features including progress tracking, error recovery, and security enhancements.
- Multi-Account Management: Add and manage multiple Telegram accounts
- Comprehensive Cleanup: Clean personal chats, bot chats, groups, channels, and contacts
- Preview Mode: See what will be deleted before cleanup
- Progress Tracking: Real-time progress updates with detailed metrics
- Error Recovery: Robust error handling with retry mechanisms
- Input Validation: Comprehensive validation for all user inputs
- Rate Limiting: Prevent abuse with configurable rate limits
- Session Security: Encrypted session storage with validation
- Activity Logging: Complete audit trail of all user actions
- Admin Controls: Advanced admin panel with user management
- Connection Pooling: Efficient database connection management
- Proxy Support: Automatic proxy testing and rotation
- Background Tasks: Health monitoring and maintenance
- Flood Protection: Telegram API rate limit handling
- Graceful Degradation: Continues operation even with partial failures
- Python 3.8+
- Redis Server
- SQLite (included)
- Telegram Bot Token
- Telegram API credentials
git clone https://github.com/MeherMankar/CleanAcc.git
cd CleanAccpip install -r requirements.txt- Open Telegram and message @BotFather
- Send
/newbotcommand - Choose a name for your bot (e.g., "My CleanAcc Bot")
- Choose a username ending in "bot" (e.g., "mycleanaccbot")
- Copy the bot token (looks like:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
- Go to https://my.telegram.org
- Login with your phone number
- Click "API Development Tools"
- Fill the form:
- App title:
CleanAcc Bot - Short name:
cleanaccbot - Platform:
Desktop
- App title:
- Copy your
api_id(number like:12345678) - Copy your
api_hash(text like:abcdef1234567890abcdef1234567890)
- Message @userinfobot on Telegram
- Copy your ID number (like:
123456789)
- Copy
.env.exampleto.env:cp .env.example .env
- Open
.envfile in any text editor - Replace the placeholder values:
BOT_TOKEN=paste_your_bot_token_here API_ID=paste_your_api_id_here API_HASH=paste_your_api_hash_here ADMIN_IDS=paste_your_telegram_id_here
- Download Redis from https://redis.io/download
- Install and start Redis service
# Ubuntu/Debian
sudo apt install redis-server
sudo systemctl start redis
# Mac with Homebrew
brew install redis
brew services start redispython main.pyIf you see "Bot initialized" - congratulations! Your bot is running! π
# Bot Configuration (REQUIRED)
BOT_TOKEN=your_bot_token_here
API_ID=your_api_id_here
API_HASH=your_api_hash_here
ADMIN_IDS=123456789,987654321
# Database Configuration
DATABASE_PATH=bot_database.db
DATABASE_POOL_SIZE=10
# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
# Rate Limiting
RATE_LIMIT_REQUESTS=10
RATE_LIMIT_WINDOW=60
# Cleanup Configuration
MAX_CLEANUP_BATCH_SIZE=50
CLEANUP_DELAY_SECONDS=0.5
# Logging
LOG_LEVEL=INFO
LOG_FILE=bot.log- Proxy Settings: Configure proxy list URL for account protection
- Sessions Directory: Custom location for session files
- Logging: Adjust log levels and file locations
-
Start Redis server
redis-server
-
Run the bot
python main.py
-
Monitor logs
tail -f logs/bot.log
- Start the bot with
/start - Click "β Add Account"
- Enter phone number in international format
- Enter verification code
- Complete 2FA if enabled
- Go to "π§Ή Clean Account"
- Select account to clean
- Choose cleanup options
- Preview changes (recommended)
- Confirm and start cleanup
- Access "π€ Personal Cabinet"
- View "π± My Accounts"
- Select account for management
- Clean or delete sessions
- Use
/admincommand (admin only) - View comprehensive statistics
- Manage users and sessions
- Configure proxy settings
- Send broadcasts
- Ban/unban users
- View user activity logs
- Monitor cleanup operations
- Access detailed statistics
- Phone number format validation
- Telegram ID validation
- Cleanup settings validation
- URL and filename sanitization
- Per-user request limits
- Configurable time windows
- Automatic cooldown periods
- Admin bypass options
- Complete audit trail
- Suspicious activity detection
- Failed attempt tracking
- Admin notifications
- Database connectivity
- Redis connectivity
- Proxy availability
- Service status checks
- Structured logging with levels
- File and console output
- Error tracking
- Performance metrics
- User registration trends
- Cleanup operation metrics
- Error rates and types
- System performance data
- Automatic connection pooling
- Transaction management
- Backup recommendations
- Migration support
- Automatic proxy testing
- Failed proxy removal
- Performance monitoring
- Health statistics
- Log rotation
- Archive policies
- Cleanup procedures
- Monitoring alerts
Error: "Token is invalid!"
- β
Solution: Check your
BOT_TOKENin.envfile - Make sure you copied the complete token from @BotFather
- Token should look like:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz
Error: "API_ID is required"
- β Solution: Get API credentials from https://my.telegram.org
- Make sure
API_IDis a number (like12345678) - Make sure
API_HASHis filled (likeabcdef1234567890abcdef1234567890)
Error: "Redis connection failed"
- β Solution: This is optional - bot will work without Redis
- To fix: Install Redis server or set
REDIS_HOST=(empty) in.env
Bot doesn't respond to /start
- Check if bot is running (should show "Bot initialized" message)
- Make sure you're messaging the correct bot
- Try stopping and restarting:
Ctrl+Cthenpython main.py
"Access denied" errors
- Make sure your Telegram ID is in
ADMIN_IDSin.envfile - Get your ID from @userinfobot
"Permission denied" errors
- Make sure you have write permissions in the bot folder
- Try running as administrator (Windows) or with
sudo(Linux/Mac)
"Module not found" errors
- Run:
pip install -r requirements.txt - Make sure you're in the correct folder:
cd CleanAcc
- Check the logs: Look at
logs/bot.logfile for detailed error messages - Restart the bot: Stop with
Ctrl+Cand runpython main.pyagain - Check your .env file: Make sure all required fields are filled
- Test your credentials:
- Message your bot on Telegram
- Check if @BotFather shows your bot as active
- Verify API credentials at https://my.telegram.org
- Automatic retry mechanisms
- Graceful degradation
- Session recovery
- Data consistency checks
- Connection pooling
- Query optimization
- Index management
- Batch operations
- Efficient data structures
- Garbage collection
- Resource cleanup
- Memory monitoring
- Request batching
- Connection reuse
- Timeout management
- Retry strategies
- Use environment variables
- Secure file permissions
- Network isolation
- Access controls
- Session encryption
- Secure storage
- Data minimization
- Regular cleanup
- Security event logging
- Anomaly detection
- Access monitoring
- Incident response
- Fork the repository
- Create feature branch
- Make changes with tests
- Submit pull request
- Follow code review process
This project is licensed under the MIT License - see the LICENSE file for details.
This bot is for educational and legitimate account management purposes only. Users are responsible for complying with Telegram's Terms of Service and applicable laws. The developers are not responsible for any misuse of this software.
- Create Bot: @BotFather
- Get API Credentials: https://my.telegram.org
- Get Your Telegram ID: @userinfobot
- Download Redis: https://redis.io/download
- Repository: https://github.com/MeherMankar/CleanAcc
- Check troubleshooting section above
- Review logs: Look at
logs/bot.logfor errors - Submit issues: Create issue on GitHub with error details
- Include information: Bot version, Python version, OS, error messages