How vjbots/vj-filter-bot works
Project type and purpose
• This is an open-source, modular Telegram bot (named “VJ Filter Bot”) built in Python using the Pyrogram library.
• Its primary purpose is to provide cloning, filtering, renaming, streaming, subscription enforcement, and various utility commands inside Telegram chats and groups, backed by MongoDB.
File structure
• Top-level scripts:
• bot.py / CloneTechVJ/broadcast.py / Script.py / info.py – entry points and command orchestrators
• Dockerfile / Procfile / heroku.yml – deployment descriptors
• Core package: TechVJ/
• TechVJ/bot/clients.py – Telegram client abstraction
• TechVJ/server/ – small HTTP server (serving dl.html, req.html) for user flows
• TechVJ/util/ – helpers (config parsing, file size, human-readable, template rendering, keepalive, time formatting)
• Database layer: database/ & CloneTechVJ/database/
• Multiple modules (clone_bot_userdb.py, connections_mdb.py, filters_mdb.py, users_chats_db.py, etc.) – wrappers around MongoDB operations
• Plugins: plugins/
• plugins/Extra/… – extended commands (auto-approve, openai, font, stream, etc.)
• plugins/*.py – core feature plugins (clone, filters, broadcast, pm_filter, etc.)
• Configuration:
• README.md – environment variables (BOT_TOKEN, API_ID/HASH, DATABASE_URI, etc.)
• requirements.txt – Python dependencies
README for additional insights
• Features toggleable via environment flags
• Uses Pyrogram / Pyrofork for Telegram API
• MongoDB for persistence
• Templates for in-chat IMDB rendering and HTTP download/join flows
• Hosted on platforms like Heroku, Render, Koyeb, or any VPS
Components
a. Main components:
1. Telegram API (external)
2. Bot Service (Python process)
– Core Telegram client (Pyrogram)
– Command dispatcher & plugin loader
– Utilities & template renderer
– Built-in HTTP server (for download pages)
3. Database (MongoDB cluster)
4. File / Media Channel (Telegram channel or external storage)
5. Deployment & CI/CD (Docker / Heroku / Render / VPS)
6. Optional External Services (e.g., OpenAI for spell-check plugin, URL-shortener APIs)
b. Relationships & interactions:
• Bot Service ↔ Telegram API: Bi-directional (receives updates, sends messages)
• Bot Service → MongoDB: CRUD on users, filters, sessions, premium status
• Bot Service → HTTP server (internal module) → End Users: Serves dl.html or req.html when they click links
• Bot Service ↔ External APIs: e.g., OpenAI, telegraph, yt-dl
• Deployment platform ↔ Bot Service: Starts/stops container or Python process
c. Architectural patterns & design principles:
• Modular plugin architecture: Each feature encapsulated in a plugin module under plugins/
• Layered design:
– Presentation (Telegram client + HTTP server + templates)
– Business logic (commands.py, broadcast.py, pm_filter.py, util/)
– Data access (database/… modules)
• Configuration via environment variables for twelve-factor adherence
d. Key technologies & frameworks:
• Python 3.x, Pyrogram (Telegram client library)
• MongoDB (via pymongo or motor)
• Docker, Procfile (Heroku), heroku.yml, Render/Koyeb manifests
• Jinja2 or custom HTML templates (dl.html, req.html)
• Optional APIs: OpenAI, Telegraph, YouTube-DL