Skip to content

Itzmepromgitman/FileStore

Repository files navigation

β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β•  β•šβ•β•β•β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•
β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β•šβ•β•     β•šβ•β•β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•   β•šβ•β•    β•šβ•β•β•β•β•β• β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•β•

⚑ Next-Gen Telegram File Sharing & Monetization Bot ⚑

πŸš€ Share files. Lock content. Earn money. β€” All inside Telegram. FileStore is a lightning-fast πŸ”₯ bot with built-in Force-Subscribe πŸ›‘οΈ, Ad-Shortener monetization πŸ’°, Premium tiers πŸ’Ž, auto-deletion ⏳, and a full admin panel πŸ‘‘ β€” zero coding needed after deploy.

Python Pyrogram MongoDB License Stars


🧠 What is FileStore?

FileStore is a production-ready, fully async Telegram Bot built for high-traffic file distribution. Unlike generic file bots, it ships with:

  • πŸ”₯ uvloop for a blazing-fast event loop
  • πŸ›‘οΈ Semaphore-guarded request handling β€” no server crashes under load
  • πŸ’° Monetization-first design β€” force users through ad-shorteners or pay for premium

Built with Pyrogram v2, MongoDB, aiohttp, and love for reliability.


✨ Feature Showcase

πŸ›‘οΈ Force Subscribe System
  • Normal F-Sub: Requires users to join specified channels before accessing files
  • Request F-Sub (R-Sub): Requires users to send a join request (great for private/approval channels)
  • Add or remove channels live from within Telegram via the /fsub command panel
  • Supports multiple channels simultaneously with per-channel join buttons
πŸ”— Ad-Shortener Monetization

Two powerful modes:

Mode How It Works
24H Pass User watches one ad β†’ unlocked for 24 hours
Per Link Every file request requires an ad click

Premium users bypass ads entirely. Set via /shortner panel.

⚑ High Performance Architecture
  • uvloop + tgcrypto β€” 2–4Γ— faster than standard asyncio
  • GLOBAL_SEMAPHORE(100) β€” caps concurrent /start executions
  • Per-user asyncio.Lock β€” eliminates race conditions
  • flood_safe() β€” automatic FloodWait retry with exponential backoff
  • Auto-delete & broadcast run as background tasks β€” main coroutine returns instantly
πŸ‘‘ Admin Panel & Controls

Everything controlled from within Telegram β€” no SSH, no config files:

  • Add/Remove Admins
  • Configure Shortener API, Website and Bypass count
  • Toggle Content Protection, Caption Hiding, Auto-Delete timer
  • Manage Premium users
  • Pull server logs with /log
  • Hot-restart bot with /restart
πŸ“¦ Batch File Delivery
  • Encode any range of DB channel messages into a single shareable Base64 link
  • Supports 1 file or 100+ files in a single link
  • Semaphore-controlled copy loop prevents API spam

πŸ—οΈ Project Structure

FileStore/
β”‚
β”œβ”€β”€ πŸ“„ bot.py              ← Pyrogram Client + startup logic
β”œβ”€β”€ πŸ“„ config.py           ← ENV loading with MongoDB fallback
β”œβ”€β”€ πŸ“„ main.py             ← Entry point
β”œβ”€β”€ πŸ“„ helper_func.py      ← Base64, Shortzy, flood-safe helpers
β”œβ”€β”€ πŸ“„ users.py            ← User management
β”œβ”€β”€ πŸ“„ update.py           ← Auto-update from upstream
β”‚
β”œβ”€β”€ πŸ“ plugins/
β”‚   β”œβ”€β”€ start.py           ← /start, file delivery, rate limiting
β”‚   β”œβ”€β”€ new.py             ← All commands + global callback router
β”‚   β”œβ”€β”€ link_generator.py  ← Batch link generation
β”‚   β”œβ”€β”€ channel_post.py    ← Channel post handler
β”‚   └── cbb.py
β”‚
β”œβ”€β”€ πŸ“ command/
β”‚   β”œβ”€β”€ admin.py           ← Shortener & admin panel logic
β”‚   β”œβ”€β”€ fsub.py            ← F-Sub / R-Sub management
β”‚   β”œβ”€β”€ work.py            ← Subscription verification engine
β”‚   β”œβ”€β”€ call.py            ← Settings callbacks
β”‚   β”œβ”€β”€ call2.py           ← Auto-delete callbacks
β”‚   β”œβ”€β”€ pre.py             ← Premium tier management
β”‚   β”œβ”€β”€ restart.py         ← Process restart handler
β”‚   └── setting.py         ← /file settings
β”‚
β”œβ”€β”€ πŸ“ database/
β”‚   └── database.py        ← MongoDB abstraction (get/set variable)
β”‚
└── πŸ“ basic/
    └── loop.py            ← Background API-switch loop

βš™οΈ Configuration

πŸ”΄ Required Variables

Variable Description
TG_BOT_TOKEN Bot token from @BotFather
APP_ID API ID from my.telegram.org
API_HASH API Hash from my.telegram.org
owner Your Telegram User ID (master admin)
CHANNEL_ID DB Channel ID (e.g. -1001234567890)
DATABASE_URL MongoDB connection URI

🟑 Optional Variables

Variable Default Description
PORT 8080 Web server port
TG_BOT_WORKERS 500 Worker thread count
START_MSG Built-in Custom HTML welcome message ({mention}, {first}, {id})

πŸ“œ Command Reference

β”Œβ”€ USER COMMANDS ────────────────────────────────────────────┐
β”‚  /start          Start the bot or open a shared file link  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€ ADMIN COMMANDS ───────────────────────────────────────────┐
β”‚  /admin          Master admin management panel             β”‚
β”‚  /shortner       Configure Ad-Shortener settings           β”‚
β”‚  /fsub           Manage Force-Subscribe channels           β”‚
β”‚  /file           File delivery settings                    β”‚
β”‚  /auto_del       Auto-delete timer configuration           β”‚
β”‚  /add_prem       Grant a user Premium access               β”‚
β”‚  /rem_prem       Revoke Premium access                     β”‚
β”‚  /list_prem      List all Premium users                    β”‚
β”‚  /users          Total user count                          β”‚
β”‚  /broadcast      Broadcast message to all users            β”‚
β”‚  /log            Fetch server log file directly in chat    β”‚
β”‚  /restart        Hot-restart the bot process               β”‚
β”‚  /code           Extract HTML caption from a message       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€ OWNER ONLY ───────────────────────────────────────────────┐
β”‚  /config         Set any DB variable manually              β”‚
β”‚  /get            Read any DB variable value                β”‚
β”‚  /reset          Reset R-Sub tracking data                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Deployment

Option 1 β€” VPS / Local

# Clone the repository
git clone https://github.com/Itzmepromgitman/FileStore
cd FileStore

# Install requirements
pip3 install -r requirements.txt

# Set ENV variables (or edit config.py)
export TG_BOT_TOKEN="your_bot_token"
export APP_ID="your_app_id"
export API_HASH="your_api_hash"
export owner="your_telegram_id"
export CHANNEL_ID="your_channel_id"
export DATABASE_URL="your_mongodb_uri"

# Start the bot
python3 bot.py

Option 2 β€” Docker

docker build -t FileStore .
docker run --env-file .env FileStore

Option 3 β€” Heroku

Deploy to Heroku


πŸ” Security Checklist

Before going public or deploying, ensure:

  • All ENV variables are set via environment β€” no hardcoded tokens in code
  • Bot is Admin in DB Channel with Send Messages permission
  • Bot is Admin in F-Sub channels with Invite Users via Link permission
  • MongoDB URI is private and not committed to version control
  • .gitignore includes .env, *.session, and bot.txt

πŸ“¦ Requirements

pyrogram
pyromod
tgcrypto
motor
uvloop
aiohttp
shortzy
pip3 install -r requirements.txt

πŸ™Œ Credits & Acknowledgements

Contributor Role
Pyrogram Core Telegram MTProto framework
pyromod Conversational client.listen() support
shortzy URL shortener API adapter
CodeXBotz Original inspiration

πŸ“œ License

Distributed under the GNU General Public License v3.0. See LICENSE for full details.


If this project helped you, please drop a ⭐ β€” it means a lot!

Made with πŸ”₯ + Python + too much caffeine

About

πŸš€ Share files. Lock content. Earn money. β€” All inside Telegram. FileStore is a lightning-fast πŸ”₯ bot with built-in Force-Subscribe πŸ›‘οΈ, Ad-Shortener monetization πŸ’°, Premium tiers πŸ’Ž, auto-deletion ⏳, and a full admin panel πŸ‘‘ β€” zero coding needed after deploy.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages