How harmish77/jisshu-filter-bot works
Project Type and Purpose
• This is a backend‑focused Telegram Bot application with a lightweight HTTP server for indexing features.
• It consumes the Telegram API, processes commands via plugin modules, persists state in MongoDB, renders occasional HTML templates, and is packaged for deployment (Docker, Heroku, Render, VPS).
File Structure
• Entry Points
• bot.py – main Telegram Bot runner
• app.py – lightweight HTTP server for “index”/web views
• Script.py – auxiliary scripts (e.g., DB migrations or cron tasks)
• Core Package
• Jisshu/ – internal libraries
– bot/ – Telegram client wrapper (clients.py)
– server/ – request handling logic for HTTP server
– template/ – Jinja2 HTML templates (dl.html, req.html)
– util/ – helper modules (config parser, file size, human‑readable formats, keepalive, template rendering, etc.)
• Plugins (plugins/)
– Each command or feature (e.g., broadcast.py, pm_filter.py, Top.py, Extra features) lives here.
– Loaded dynamically by the bot core.
• Database Layer (database/)
– Collections management (e.g., users_chats_db.py, jsreferdb.py, topdb.py, ia_filterdb.py)
– Exposed via a shared MongoDB client.
• Config & Deployment
– info.py, environment variables, Procfile, Dockerfile, heroku.yml, runtime.txt, requirements.txt
README for Insights
• Bot Features: streaming, download, filtering, premium management, auto‑delete, welcome messages, subscription enforcement, index pages.
• Dependencies: Python, MongoDB, Jinja2, any Telegram client library (Pyrogram/Telethon).
• Deployment targets: Heroku, Koyeb, Render, VPS, Docker.
Main Components & Their Interactions
a. Telegram API (External Service)
– Receives updates (messages, commands)
– Bot responds via API calls
b. Bot Core
– bot.py uses client wrapper (Jisshu/bot/clients.py)
– Dispatches incoming updates to the Plugin Manager
c. Plugin Manager & Plugins
– Dynamically loads modules from plugins/
– Each plugin defines handlers for commands or message patterns
– Makes calls to utility modules and database
d. Utilities Layer
– Shared logic: parsing configs, formatting sizes/dates, rendering templates, shortener integrations, keeping the bot alive
e. Database (MongoDB)
– Central persistence for users, chats, index data, stats, premium codes, top/trending
– Accessed via database/ modules
f. HTTP Server
– app.py and Jisshu/server/ handle inbound HTTP requests (e.g., /index)
– Renders templates from Jisshu/template/ using Jinja2 and data from MongoDB
g. External APIs & Services
– IMDb API, custom shorteners, streaming & download providers
– Logging channel (Telegram) for operational logs
h. Deployment Environment
– Docker container or direct Python runtime
– Environment variables injected via Heroku, Render, Koyeb, or VPS
– Dockerfile, Procfile, heroku.yml, runtime.txt
Architectural Patterns & Design Principles
• Modular Plugin Architecture – each feature is isolated in its own module, enabling easy extension.
• Layered Structure – clear separation between transport (Telegram / HTTP), business logic (plugins), utilities, and data access.
• Template‑View Pattern – HTTP server uses Jinja2 templates to render HTML views.