How starkbotsindustries/restrictedcontentsaver works
Project Type and Purpose
• This is a monolithic, Python-based Telegram Bot (“Restricted Content Saver Bot”) built with the Pyrogram library.
• Purpose: Receive restricted-media links from users, save the content via a userbot into a “universal cache” channel, and retrieve it on demand.
File Structure
• Top-level:
• Unlock/ — main Python package
– __main__.py — bot entry point (python –m Unlock)
– modules/ — code organized by feature
• start.py — handles /start, /help, /repo, /tos commands
• send_restricted.py — /save command logic
• UserBot/ — userbot integration
· saver.py — sends/receives media via userbot session
· Special/UniversalDatabase.py — cache manager abstraction
• Config & Deployment:
• .env.example — environment variables template
• requirements.txt — Python dependencies
• Support:
• tests/test_bot.py — basic unit test for core functionality
Extract Insights from README
• Uses Pyrogram to interact with both Bot API and a userbot session.
• Requires Telegram Bot Token, API_ID, API_HASH, StringSession (for userbot).
• Caching strategy: bot itself cannot bypass restrictions, so it uses an admin userbot in a cache channel to store and serve content.
Main Components
a. External Entities:
• Telegram User (client)
• Telegram Servers (Bot API endpoint + userbot endpoint)
• Universal Cache Channel (on Telegram)
b. Internal Components:
• Configuration Loader (.env → runtime settings)
• Bot Application (Unlock/__main__.py)
• Command Handlers (modules/start.py, modules/send_restricted.py)
• UserBot Manager (modules/UserBot/saver.py)
• Cache Abstraction (modules/UserBot/Special/UniversalDatabase.py)
• Logging Subsystem
• Dependencies: Pyrogram library, python-dotenv
c. Data Stores:
• In-memory/session state (handled by Pyrogram)
• Telegram cache channel (persistent store)
d. External Services:
• Telegram Bot API
• Telegram API (for userbot)
Relationships and Data Flow
1. Telegram User → sends “/save <link>” → Telegram Bot API
2. Bot Application (/start or /save handler) receives Update via Pyrogram
3. send_restricted.py parses link and enqueues request to saver.py
4. saver.py (UserBot) uses the userbot session to forward/download media into Universal Cache Channel
5. UniversalDatabase abstraction confirms caching, stores metadata if needed
6. Bot Application retrieves the cached media link/id from the channel
7. Bot Application sends media back to user via Bot API
8. All steps are logged via built-in logging
Architectural Patterns and Principles
• Modular Handler Pattern: each command lives in its own module.
• Single Process, Event-Driven: Pyrogram event loop dispatches updates to handlers.
• Separation of Concerns:
• Config management (.env)
• Command routing (Unlock/__main__.py)
• Business logic (modules)
• External integration (UserBot)
• Cache abstraction (UniversalDatabase)