Skip to content

kapusta123b/Telegram-Moderation-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

57 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Telegram Profanity Filter & Moderation Bot

Python Version Aiogram Version Docker Supported License


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.


πŸš€ Tech Stack


✨ Key Features

  • πŸ›‘οΈ 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.

πŸ—οΈ Project Architecture

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
Loading

πŸ“‚ File Structure

πŸ“¦ 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

πŸ“‹ Available Commands

πŸ‘€ Private Chat

  • /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.

πŸ‘₯ Group Moderation (Admin Only)

  • /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.

πŸ›‘οΈ Public Group Commands

  • /report β€” Report a message to admins (Reply required).
  • /stats β€” View your stats in the current chat.

βš™οΈ Installation & Setup

🐳 Method 1: Docker (Recommended)

  1. Clone the repository:
    git clone https://github.com/kapusta123b/Telegram-Moderation-Bot
    cd Telegram-Moderation-Bot
  2. Configure environment: Create app/.env and add your token:
    BOT_TOKEN=your_bot_token_here
  3. Launch with Docker Compose:
    docker-compose up -d --build

🐍 Method 2: Manual Installation

  1. Clone the repository:
    git clone https://github.com/kapusta123b/Telegram-Moderation-Bot
    cd Telegram-Moderation-Bot
  2. Install dependencies:
    pip install -r app/requirements.txt
  3. Configure environment: Create app/.env:
    BOT_TOKEN=your_bot_token_here
  4. Run the bot:
    cd app
    python app.py

⚠️ Important Note

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.


🀝 Connect

Telegram Gmail


Made with ❀️ for clean communities

About

Advanced profanity filter and moderation bot for Telegram groups using aiogram 3.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors