# dreamxbotz/auto_filter_bot architecture

> Architecture diagram of the GitHub repository dreamxbotz/auto_filter_bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dreamxbotz/auto_filter_bot
- Repository: https://github.com/dreamxbotz/auto_filter_bot

## Overview

1. **What this repo is**
   - This is a **Telegram bot system** centered on media/file search, indexing, moderation, and premium access management.
   - The README features confirm a bot that supports **file filtering, post links, batch links, streaming/download modes, verification, broadcast, and premium memberships**.

2. **Runtime entry points and deployment shape**
   - The main execution entry appears to be **`bot.py`**, with **`Script.py`** likely used as an alternate launcher or bootstrap wrapper.
   - Deployment is designed for **container/Heroku-style hosting**: `Dockerfile`, `docker-compose.yml`, `Procfile`, `app.json`, and `heroku.yml` all indicate the bot can run as a long-lived service with optional web process support.

3. **Telegram client layer**
   - `dreamxbotz/Bot/clients.py` and `dreamxbotz/Bot/__init__.py` likely define the Telegram client(s), shared session objects, and startup wiring.
   - The bot is organized around **message/update handlers** rather than a monolith, which is important for the architecture: Telegram events enter the client layer and are dispatched to plugins.

4. **Plugin-based feature architecture**
   - The `plugins/` directory is the core functional boundary.
   - Each plugin covers a feature slice: `commands.py`, `misc.py`, `broadcast.py`, `banned.py`, `pmfilter.py`, `join_req.py`, `post_handler.py`, `route.py`, `extract.py`, `files_delete.py`, `index.py`, `channel.py`, `Premium.py`, and more.
   - This suggests a **modular event-driven bot** where handlers are loaded by feature, not by a centralized service class.

5. **Primary user-facing flows**
   - The bot’s main flow is: **user sends a query or command → plugin handles it → data is fetched from storage → formatted response is sent back in Telegram**.
   - Features such as `link`, `batch`, `top`, `start`, `settings`, `stats`, `info`, and `id` indicate a mix of **content discovery**, **account/status commands**, and **administrative controls**.

6. **File indexing and delivery path**
   - The repository strongly suggests a **file catalog / searchable index** model.
   - `database/ia_filterdb.py`, `plugins/index.py`, `plugins/extract.py`, `plugins/post_handler.py`, and `dreamxbotz/util/custom_dl.py` point to a pipeline where incoming media/posts are **indexed**, searchable later, and then **delivered as links or forwarded files**.
   - README items like **“file indexing above 2GB,” “auto file send,” “file protection,” “single filter button,” and “bot PM file send mode”** reinforce that content delivery is a core subsystem.

7. **Moderation, access control, and chat management**
   - Several plugins implement operational controls: `banned.py`, `channel.py`, `join_req.py`, `pmfilter.py`, `leave`, `disable`, `enable`, and `files_delete.py`.
   - This indicates the bot manages **who can use it, which groups are allowed, and what content is available**, with support for **group join requests**, **forward restrictions**, **chat bans**, and **group-specific settings**.
   - The README’s “3 verification system” and “verified user counter” imply a dedicated access-verification path.

8. **Premium, referral, and monetization-like flows**
   - `plugins/Premium.py`, `plugins/Dreamxfutures/Redeem.py`, and `database/refer.py` indicate a **premium entitlement subsystem** with **redeem codes or referral-based access**.
   - Commands such as `plan`, `myplan`, `add_premium`, `remove_premium`, and `premium_users` show that subscription state is part of the bot’s persistent model.

9. **Persistence layer**
   - The `database/` package is the storage boundary: `users_chats_db.py`, `ia_filterdb.py`, `refer.py`, and `config_db.py`.
   - This layer stores **user/chat records, filter/index entries, referral data, and configuration/settings**.
   - The repository does not expose the DB engine directly in the tree, so the important architectural point is that **handlers do not own persistence logic; they call into database modules**.

10. **Web-serving and template layer**
   - `dreamxbotz/server/`, `dreamxbotz/template/dl.html`, and `dreamxbotz/template/req.html` indicate a small **HTTP-facing layer** alongside Telegram.
   - `dreamxbotz/util/render_template.py`, `custom_dl.py`, and `file_properties.py` suggest this layer renders **download/request pages** and formats file metadata for users.
   - This is likely used for **shareable links, request pages, and streaming/download presentation**, not as a general website.

11. **Utility and content-enrichment helpers**
   - `dreamxbotz/util/` contains support code for **configuration parsing, keepalive, file-size formatting, time formatting, and human-readable output**.
   - `plugins/Dreamxfutures/Imdbposter.py`, `telegraph.py`, `font.py`, and `fotnt_string.py` add **content enrichment and presentation**, such as poster metadata and stylized text.
   - `plugins/monkey_patch.py` and `utils.py` indicate cross-cutting runtime adjustments and shared helpers.

12. **Operational and hosting concerns**
   - `dreamxbotz/util/keepalive.py`, `plugins/Dreamxfutures/check_alive.py`, and the deployment files show that the app is designed to **stay awake in managed hosting environments**.
   - Logging is explicitly configured via `logging.conf`, which is relevant because the bot’s behavior depends on many handler paths and background checks.

13. **External boundaries**
   - The primary external dependency is **Telegram**, which is both the UI and event source.
   - Secondary external integrations appear to include **media metadata sources and link/rendering services** such as IMDb/Telegraph-style content generation, plus whatever backend datastore is configured in `database/config_db.py`.

14. **How to diagram it**
   - A clear architecture diagram should show:
     - **Telegram users/groups/channels** feeding into the **Telegram client layer**
     - client updates routed into **feature plugins**
     - plugins reading/writing through the **database modules**
     - some flows passing through the **HTTP/template layer** for shareable download/request pages
     - supporting **utility modules** for formatting, keepalive, and deployment
   - The main architectural boundary is between **event handlers (plugins)** and **shared persistence/serving infrastructure**.

Main entry points: [`plugins/__init__.py`](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/__init__.py) (Plugins init), [`database`](https://github.com/dreamxbotz/auto_filter_bot/tree/DreamXBotz/database) (Database), [`dreamxbotz/Bot/clients.py`](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/dreamxbotz/Bot/clients.py) (Clients), [`dreamxbotz/Bot/__init__.py`](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/dreamxbotz/Bot/__init__.py) (Bot init)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_telegram_users(("Telegram users<br/>external actor"))
  node_bot_py["bot.py<br/>entrypoint<br/>[bot.py]"]
  node_script_py["Script.py<br/>launcher<br/>[Script.py]"]
  node_deploy["Deploy files<br/>hosting config"]
end

subgraph group_core["Bot core"]
  node_bot_init["Bot init<br/>bootstrap<br/>[__init__.py]"]
  node_clients_py["Clients<br/>telegram client<br/>[clients.py]"]
end

subgraph group_features["Features"]
  node_plugins_init["Plugins init<br/>plugin loader<br/>[__init__.py]"]
  node_commands_py["Commands<br/>command handlers<br/>[commands.py]"]
  node_misc_py["Misc<br/>general handlers<br/>[misc.py]"]
  node_index_py["Indexing<br/>catalog pipeline<br/>[index.py]"]
  node_extract_py["Extract<br/>delivery pipeline<br/>[extract.py]"]
  node_pmfilter_py["PM filter<br/>access flow<br/>[pmfilter.py]"]
  node_broadcast_py["Broadcast<br/>admin tooling<br/>[broadcast.py]"]
  node_premium_py["Premium<br/>entitlement<br/>[Premium.py]"]
  node_channel_py["Channel<br/>chat control<br/>[channel.py]"]
  node_join_req_py["Join req<br/>access control<br/>[join_req.py]"]
end

subgraph group_data["Data & serving"]
  node_db_layer[("Database<br/>persistence layer")]
  node_web_layer["Web layer<br/>http serving"]
  node_templates["Templates<br/>html views"]
  node_util_layer["Utilities<br/>shared helpers"]
end

node_telegram_users -->|"messages"| node_clients_py
node_bot_py -->|"starts"| node_bot_init
node_script_py -->|"bootstraps"| node_bot_init
node_bot_init -->|"creates"| node_clients_py
node_clients_py -->|"loads"| node_plugins_init
node_plugins_init -->|"dispatches"| node_commands_py
node_plugins_init -->|"dispatches"| node_misc_py
node_plugins_init -->|"dispatches"| node_index_py
node_plugins_init -->|"dispatches"| node_extract_py
node_plugins_init -->|"dispatches"| node_pmfilter_py
node_plugins_init -->|"dispatches"| node_broadcast_py
node_plugins_init -->|"dispatches"| node_premium_py
node_plugins_init -->|"dispatches"| node_channel_py
node_plugins_init -->|"dispatches"| node_join_req_py
node_index_py -->|"reads/writes"| node_db_layer
node_extract_py -->|"reads"| node_db_layer
node_pmfilter_py -->|"reads/writes"| node_db_layer
node_premium_py -->|"reads/writes"| node_db_layer
node_broadcast_py -->|"reads"| node_db_layer
node_web_layer -->|"renders"| node_templates
node_util_layer -->|"supports"| node_web_layer
node_util_layer -->|"supports"| node_clients_py
node_deploy -->|"runs"| node_bot_py
node_deploy -->|"enables"| node_web_layer

click node_bot_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/bot.py"
click node_script_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/Script.py"
click node_bot_init "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/dreamxbotz/Bot/__init__.py"
click node_clients_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/dreamxbotz/Bot/clients.py"
click node_plugins_init "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/__init__.py"
click node_commands_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/commands.py"
click node_misc_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/misc.py"
click node_index_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/index.py"
click node_extract_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/extract.py"
click node_pmfilter_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/pmfilter.py"
click node_broadcast_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/broadcast.py"
click node_premium_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/Premium.py"
click node_channel_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/channel.py"
click node_join_req_py "https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/join_req.py"
click node_db_layer "https://github.com/dreamxbotz/auto_filter_bot/tree/DreamXBotz/database"
click node_web_layer "https://github.com/dreamxbotz/auto_filter_bot/tree/DreamXBotz/dreamxbotz/server"
click node_templates "https://github.com/dreamxbotz/auto_filter_bot/tree/DreamXBotz/dreamxbotz/template"
click node_util_layer "https://github.com/dreamxbotz/auto_filter_bot/tree/DreamXBotz/dreamxbotz/util"
click node_deploy "https://github.com/dreamxbotz/auto_filter_bot/tree/DreamXBotz/Dockerfile"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_telegram_users,node_bot_py,node_script_py,node_deploy toneBlue
class node_bot_init,node_clients_py toneAmber
class node_plugins_init,node_commands_py,node_misc_py,node_index_py,node_extract_py,node_pmfilter_py,node_broadcast_py,node_premium_py,node_channel_py,node_join_req_py toneMint
class node_db_layer,node_web_layer,node_templates,node_util_layer toneRose
```

## Components

### Runtime

Entry points and deployment wrappers

- **Telegram users**: external actor · End users, groups, and channels interacting with the bot
- [bot.py](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/bot.py): entrypoint · Primary bot startup script · `bot.py`
- [Script.py](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/Script.py): launcher · Alternate bootstrap or launch wrapper · `Script.py`
- [Deploy files](https://github.com/dreamxbotz/auto_filter_bot/tree/DreamXBotz/Dockerfile): hosting config · Container, Procfile, and platform deployment configuration · `Dockerfile`

### Bot core

Telegram client bootstrap and event dispatch

- [Bot init](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/dreamxbotz/Bot/__init__.py): bootstrap · Package initialization and startup wiring · `dreamxbotz/Bot/__init__.py`
- [Clients](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/dreamxbotz/Bot/clients.py): telegram client · Telegram client/session setup and shared bot objects · `dreamxbotz/Bot/clients.py`

### Features

Plugin-based bot capabilities

- [Plugins init](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/__init__.py): plugin loader · Plugin package initialization · `plugins/__init__.py`
- [Commands](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/commands.py): command handlers · Core command responses and bot actions · `plugins/commands.py`
- [Misc](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/misc.py): general handlers · Utility and auxiliary message handling · `plugins/misc.py`
- [Indexing](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/index.py): catalog pipeline · Indexes incoming files and searchable content · `plugins/index.py`
- [Extract](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/extract.py): delivery pipeline · Extracts and prepares media or file responses · `plugins/extract.py`
- [PM filter](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/pmfilter.py): access flow · Private-message filtering and gated file access · `plugins/pmfilter.py`
- [Broadcast](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/broadcast.py): admin tooling · Broadcasts messages to users or chats · `plugins/broadcast.py`
- [Premium](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/Premium.py): entitlement · Premium plans and membership management · `plugins/Premium.py`
- [Channel](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/channel.py): chat control · Channel and subscription-related controls · `plugins/channel.py`
- [Join req](https://github.com/dreamxbotz/auto_filter_bot/blob/DreamXBotz/plugins/join_req.py): access control · Join request and verification handling · `plugins/join_req.py`

### Data & serving

Persistence, web pages, and shared helpers

- [Database](https://github.com/dreamxbotz/auto_filter_bot/tree/DreamXBotz/database): persistence layer · Shared storage boundary for users, filters, referrals, and config · `database`
- [Web layer](https://github.com/dreamxbotz/auto_filter_bot/tree/DreamXBotz/dreamxbotz/server): http serving · Request/download pages and lightweight HTTP surface · `dreamxbotz/server`
- [Templates](https://github.com/dreamxbotz/auto_filter_bot/tree/DreamXBotz/dreamxbotz/template): html views · Download and request page templates · `dreamxbotz/template`
- [Utilities](https://github.com/dreamxbotz/auto_filter_bot/tree/DreamXBotz/dreamxbotz/util): shared helpers · Formatting, file helpers, keepalive, and template rendering · `dreamxbotz/util`

## Connections

- Telegram users → Clients: messages · User, group, and channel updates arrive at the Telegram client
- bot.py → Bot init: starts · Primary entrypoint initializes the bot package
- Script.py → Bot init: bootstraps · Alternate launcher also enters the bot package
- Bot init → Clients: creates · Initialization wires shared clients and runtime state
- Clients → Plugins init: loads · Client runtime registers plugin handlers
- Plugins init → Commands: dispatches · Core command handlers are loaded as plugins
- Plugins init → Misc: dispatches · Auxiliary handlers are loaded as plugins
- Plugins init → Indexing: dispatches · Indexing pipeline is loaded as a plugin
- Plugins init → Extract: dispatches · File extraction and delivery handlers are loaded
- Plugins init → PM filter: dispatches · Access-gated PM filtering is loaded
- Plugins init → Broadcast: dispatches · Administrative broadcast features are loaded
- Plugins init → Premium: dispatches · Premium entitlement handlers are loaded
- Plugins init → Channel: dispatches · Channel and subscription controls are loaded
- Plugins init → Join req: dispatches · Join-request and verification handling is loaded
- Indexing → Database: reads/writes · Search index and file catalog are persisted
- Extract → Database: reads · Delivery flows resolve stored file metadata
- PM filter → Database: reads/writes · Access checks and user state are stored
- Premium → Database: reads/writes · Plan and premium membership state is persisted
- Broadcast → Database: reads · Broadcast targets and user records are retrieved
- Web layer → Templates: renders · HTTP surface serves request and download pages
- Utilities → Web layer: supports · Template rendering and file helpers back the web surface
- Utilities → Clients: supports · Shared helpers support runtime formatting and keepalive
- Deploy files → bot.py: runs · Deployment artifacts launch the bot service
- Deploy files → Web layer: enables · Deployment can expose the HTTP serving layer
