How vjbots/vj-file-store works
Project type and purpose
• This is a Python-based, full-stack Telegram file-storage bot with an integrated HTTP server for streaming and download links.
• Purpose: receive files via Telegram, store them (in a channel or on‐chain), generate permanent shareable and streamable URLs (with optional URL-shortener), support batch links, cloning of bot instances, auto-deletion, and custom start messages.
File structure
• Top-level scripts:
• bot.py – launches the Telegram bot
• app.py – launches the HTTP server (stream/download endpoints)
• config.py, logging.conf – central configuration
• Core Python package “TechVJ”:
• TechVJ/bot – orchestration of the Telegram client(s) (clients.py) and command handlers
• TechVJ/server – HTTP route definitions (stream_routes.py) and exception handling
• TechVJ/template – HTML templates for download/stream pages (dl.html, req.html)
• TechVJ/utils – cross-cutting utilities (config parsing, human-readable sizes, templating, keep-alive, time formatting)
• plugins/ and clone_plugins/ – modular commands and clone-bot feature extensions
• Dockerfile, Procfile, runtime.txt – containerization and deployment scripts
• requirements.txt – Python dependencies (Pyrogram or Telethon, FastAPI/Flask, Jinja2, Motor or PyMongo)
README for additional insights
• Confirms: Telegram API (API_ID/HASH/BOT_TOKEN), MongoDB (DB_URI, CLONE_DB_URI), web server URL, port.
• Features: permanent links via website, clone feature, streaming support, custom shortener, auto-delete, broadcast.
a. Main components
– Telegram Bot component (bot.py + TechVJ.bot + plugins)
– HTTP Server component (app.py + TechVJ.server + TechVJ.template)
– Utility library (TechVJ.utils)
– MongoDB database (user data, clone metadata, config)
– External services: Telegram API, URL-shortener API (optional)
– Clone-bot instances (spawned via clone_plugins)
b. Relationships & data flow
1. User ↔ Telegram Bot: commands (/link, /batch, /broadcast, etc.)
2. Bot ↔ MongoDB: store/retrieve user settings, tokens, custom URLs
3. Bot → HTTP Server: constructs stream/download URLs (pointing to the server)
4. User ↔ HTTP Server: HTTP GET /stream, /dl endpoints → streams or downloads file
5. HTTP Server ↔ TechVJ.utils: compute file metadata, render templates
6. Bot ↔ External URL-shortener API (if configured)
c. Architectural patterns & design principles
– Modular package organization: separate “bot” vs “server” vs “utils”
– Plugin architecture: commands and clone logic loaded dynamically from plugins/
– MVC-style for the server: stream_routes.py (controller), templates (view), utils (model/helper)
– Dependency injection via environment variables (config.py reads ENV)
– Loose coupling: both Bot and HTTP Server import from shared TechVJ library
d. Key technologies & frameworks
– Python 3.10
– Telegram client library (Pyrogram or Telethon)
– Web framework (FastAPI or Flask)
– Jinja2 for HTML templating
– MongoDB (Motor or PyMongo)
– Docker, Procfile for Heroku
– Logging via logging.conf