A professional Telegram moderation tool built with Python and Aiogram 3. This bot provides automatic profanity filtering, anti-spam protection, and advanced administrative tools to keep your group chats clean and safe. Fully containerized with Docker Compose.
- π‘οΈ Join Captcha: Automated anti-bot verification for new members.
- π Automated Moderation: Real-time scanning for prohibited keywords and external links.
- π« Anti-Advertising: Automatically detects and removes Telegram invitation links.
- π User Statistics: Track mutes, bans, warning history, and message count.
- π Moderation Logs: Dedicated channel logging for all administrative actions.
- π§ Modular Architecture: Decoupled handlers and services for high maintainability.
β οΈ Smart Warning System: Configurable warning limits (default: 5) leading to auto-mutes.- π Progressive Mutes: Restriction durations that scale based on violation history.
- π οΈ Admin Toolkit: Comprehensive commands for manual moderation and filter management.
graph TD
subgraph Core[Bot Entry Point]
A[app/app.py]
end
subgraph Config[Central Configuration]
CFG[app/config/config.py]
STR[app/config/strings.py]
LOG_CFG[app/config/logging_config.py]
end
subgraph Handlers[Modular Handlers]
H_MOD[moderation.py]
H_CAP[captcha.py]
H_LST[lists.py]
H_REP[reports.py]
H_FADMIN[filter_admin.py]
H_PRIV[user_private.py]
H_USR[user.py]
end
subgraph Services[Business Logic]
S_REST[restriction_service.py]
S_HIST[history_service.py]
S_LOG[log_service.py]
S_CAP[captcha_service.py]
S_FILT[filters_service.py]
end
subgraph Data[Persistence & Middlewares]
DB[(app/database/)]
MID[app/middlewares/]
UTL(app/utils/)
end
A --> Config
A --> Handlers
Handlers --> Services
Services --> Data
Handlers --> Data
A --> MID
π¦ Telegram-Moderation-Bot
β£ π app
β β£ π config # Configuration, strings, and logging setup
β β£ π database # SQLAlchemy models, SQLite, and banwords
β β£ π filters # Admin validation and chat-type filters
β β£ π handlers # Modular routers (Moderation, Captcha, Filters, etc.)
β β£ π middlewares # DB session and Statistics middlewares
β β£ π services # Core business logic (Restrictions, History, Filters)
β β£ π utils # Helper functions (Time parsing, Text normalization)
β β£ π app.py # Main entry point & dispatcher configuration
β β£ π requirements.txt # Project dependencies
β β π .env # Environment variables
β£ π docker-compose.yml # Docker orchestration
β π LICENSE # MIT License
/startβ Start the bot and get an overview./helpβ Detailed guide on how to use commands./statsβ View your personal statistics./aboutβ Technical information about the bot./how_use_botβ Step-by-step setup instructions.
/set_admin_chatβ Configure current chat for admin logs./unset_admin_chatβ Disable admin logging for current chat./warnβ Issue a warning (Reply required)./unwarnβ Remove one warning (Reply required)./mute [duration/ID] [set] [reason]β Mute a user./unmute [ID]β Lift a mute./ban [duration/ID] [set] [reason]β Ban a user./unban [ID]β Lift a ban./addfilter [word]β Add a word to the profanity filter./removefilter [word]β Remove a word from the filter./mute_list [current]β View mute history./ban_list [current]β View ban history./warn_listβ View warning history.
/reportβ Report a message to admins (Reply required)./statsβ View your stats in the current chat.
- Clone the repository:
git clone https://github.com/kapusta123b/Telegram-Moderation-Bot cd Telegram-Moderation-Bot - Configure environment:
Create
app/.envand add your token:BOT_TOKEN=your_bot_token_here
- Launch with Docker Compose:
docker-compose up -d --build
- Clone the repository:
git clone https://github.com/kapusta123b/Telegram-Moderation-Bot cd Telegram-Moderation-Bot - Install dependencies:
pip install -r app/requirements.txt
- Configure environment:
Create
app/.env:BOT_TOKEN=your_bot_token_here
- Run the bot:
cd app python app.py
This bot uses a keyword-matching system. You can manage the filter list directly using /addfilter and /removefilter commands in your group, or by manually editing app/database/banwords.txt.
Made with β€οΈ for clean communities