A comprehensive Telegram bot for advanced group management and moderation with extensive admin features.
- File ID Extraction: Get file IDs from media messages for use in other commands
- Chat Registration: Register chats for bot management
- Debug Information: Comprehensive chat and bot status information
- Silence Mode: Restrict chat to admin-only communication
- Under Attack Mode: Emergency protection mode that silences chat and kicks new users
- Message Management: Pin/unpin messages and bulk delete (purge) functionality
- Admin Cache: Reload and manage admin permissions cache
- Promotion System: Promote/demote users with custom titles
- Ban System: Local and global banning with silent options
- Kick System: Temporary removal with global capabilities
- Mute System: Time-based muting with flexible duration parsing
- Warning System: Progressive warning system with auto-ban on limit
- Whitelist System: Bypass filters and restrictions for trusted users
- User Profiles: Comprehensive user information and statistics
- Activity Tracking: Last active timestamps and reputation system
- Reset Functions: Clear user violations and reset reputation
- Admin Verification: Verify admin status by forwarding messages
- Global Systems: Cross-chat banning and whitelisting
- Silent Actions: Discrete moderation without notifications
- Anti-Spam Protection: Basic flood and spam detection
-
Clone the repository:
git clone https://github.com/shahrukh275/Telegram-Bot-.git cd Telegram-Bot- -
Install dependencies:
pip install -r requirements.txt
-
Configure the bot:
cp .env.example .env # Edit .env with your bot token and settings -
Run the bot:
python bot.py
Create a .env file with the following variables:
# Required
BOT_TOKEN=your_bot_token_from_botfather
BOT_USERNAME=your_bot_username
SUPER_ADMIN_ID=your_telegram_user_id
# Optional
DATABASE_URL=sqlite:///bot.db
LOG_LEVEL=INFO- Message @BotFather on Telegram
- Use
/newbotcommand and follow instructions - Copy the token provided
- Get your user ID by messaging @userinfobot
/fileid- Get file ID from replied media message
/activate- Register the current chat/silence//unsilence- Control who can chat/ua//underattack- Toggle under attack mode/reload- Reload admin cache/debug- Show debug information/pin//unpin- Pin/unpin messages/purge [amount]- Delete messages
/promote//demote- Admin management/title- Set admin titles/ban//unban- Ban management/kick- Kick users/mute//unmute- Mute management/warn//unwarn- Warning system/whitelist//unwhitelist- Whitelist management
/user- User information/lastactive- Last activity check/id- Get user/chat IDs/chatinfo- Chat statistics
All user management commands have global variants (prefix with g):
/gban//gunban- Global ban management/gkick- Global kick/gwarn- Global warnings/gwhitelist//gunwhitelist- Global whitelist
Most moderation commands have silent variants (prefix with s):
/sban- Silent ban/skick- Silent kick/smute- Silent mute/swarn- Silent warning
Commands marked with * support multiple usage formats:
- Reply to message:
/ban(reply to user's message) - Username:
/ban @username - User ID:
/ban 123456789
For time-based commands (mute, etc.), use these formats:
30s- 30 seconds5m- 5 minutes2h- 2 hours1d- 1 day
Forward any message from a user to the bot in private chat to verify if they're an admin in any chat where the bot is present. This helps prevent admin impersonation scams.
The bot uses SQLite by default but supports any SQLAlchemy-compatible database. The database stores:
- Chat registrations and settings
- User information and activity
- Admin assignments and titles
- Bans, warnings, and mutes
- Whitelist entries
- Reputation scores
- Admin-only commands: Most commands require admin privileges
- Global ban protection: Automatically bans globally banned users
- Under attack mode: Emergency protection for raids
- Silent moderation: Discrete actions without notifications
- Comprehensive logging: Full audit trail of all actions
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or feature requests:
- Check existing issues on GitHub
- Create a new issue with detailed information
- Contact the bot administrator
This bot is designed for legitimate group management purposes. Users are responsible for complying with Telegram's Terms of Service and applicable laws when using this bot.