Skip to content

Repository files navigation

⚡ Telegram File Stream Bot

Cover Image

Turn any Telegram file into an instant direct download / streaming link.
No waiting for the full file to download first — just send it, get the link.

🐞 Report a Bug · ✨ Request a Feature


📑 Table of Contents
  1. About This Bot
  2. How to Deploy
  3. Configuration
  4. How to Use
  5. Admin Commands
  6. Contact
  7. Credits
  8. License

🚀 About This Bot

Telegram Logo

Send any file to this bot and get an instant direct download / streaming link in return.

Direct download links with original filename
File size shown in the reply
Multi-client support to dodge flood limits
Supports documents, videos, audio, photos, stickers & more
Optional MongoDB user tracking
Optional Force-Subscribe (FSub) gating
Built-in /stats and /broadcast for the bot owner

📦 How to Deploy

Run Locally / VPS

git clone https://github.com/GouthamSER/TG-FileStreamBot
cd TG-FileStreamBot
python3 -m venv ./venv
. ./venv/bin/activate
pip3 install -r requirements.txt
python3 -m WebStreamer

Stop with CTRL+C.

Run 24/7 on a VPS with tmux:

sudo apt install tmux -y
tmux
python3 -m WebStreamer

Detach with CTRL+B then D. Bot keeps running after you close SSH.

Deploy using Docker

git clone https://github.com/GouthamSER/TG-FileStreamBot
cd TG-FileStreamBot
docker build . -t fsb

Create your .env file, then run:

docker run -d --restart unless-stopped --name fsb \
-v /PATH/TO/.env:/app/.env \
-p 8080:8080 \
fsb

PORT in .env must match the exposed port. Example: PORT=9000-p 9000:9000

Restart after changing .env:

docker restart fsb

Deploy using docker-compose

sudo apt install docker-compose -y
git clone https://github.com/GouthamSER/TG-FileStreamBot
cd TG-FileStreamBot

Edit the variables inside docker-compose.yml, then:

sudo docker compose up -d

Deploy on Koyeb / Heroku

Deploy to HerokuDeploy to Koyeb

One-click: click a button above, fill in the env vars in the platform's UI, deploy 🚀

Manual:

  1. Fork this repo
  2. Set all env vars in the platform dashboard
  3. Procfileweb: python3 -m WebStreamer
  4. .python-version3.10
  5. Deploy 🚀

⚠️Koyeb (Dockerfile deploy): container EXPOSEs 8080. In Koyeb's service settings, set Port → 8080 (and protocol HTTP) to match, or set PORT=8080 env var if you change the exposed port. Health checks hit /.

⚠️Heroku (container deploy): the button above uses heroku.yml + Dockerfile (stack: container), matching app.json. Fill mandatory vars (API_ID, API_HASH, BOT_TOKEN, BIN_CHANNEL) on the deploy form; everything else has a sane default.


⚙️ Configuration

Create a .env file in the root directory (for local/VPS):

API_ID=452525
API_HASH=esx576f8738x883f3sfzx83
BOT_TOKEN=55838383:yourbottokenhere
BIN_CHANNEL=-1001234567890
PORT=8080
FQDN=yourdomain.com
HAS_SSL=True

Mandatory Vars

VariableDescription
API_IDTelegram API ID from my.telegram.org
API_HASHTelegram API Hash from my.telegram.org
BOT_TOKENBot token from @BotFather
BIN_CHANNELChannel ID where the bot forwards & stores files. Create a channel, forward any message to @missrose_bot and reply /id to get the ID

Optional Vars

VariableDefaultDescription
ALLOWED_USERS(empty)Comma-separated Telegram user IDs/usernames allowed to use the bot. Leave empty for public access
HASH_LENGTH6Length of the hash in generated URLs. Must be between 6 and 63
SLEEP_THRESHOLD60Seconds to sleep on flood wait before retrying
WORKERS6Max concurrent workers for handling updates
PORT8080Port the web server listens on
WEB_SERVER_BIND_ADDRESS0.0.0.0Server bind address
FQDN(bind address)Your domain name, used for link generation
HAS_SSLTrueSet True to generate https:// links
NO_PORTTrueSet True to hide the port from generated links (use when port is 80/443)
KEEP_ALIVEFalsePing self every PING_INTERVAL seconds — handy for PaaS free tiers
PING_INTERVAL1200Ping interval in seconds (default 20 min)
USE_SESSION_FILEFalseUse session files instead of in-memory SQLite
DEBUGFalseEnable debug logging

MongoDB / User Tracking (optional)

Set DATABASE_URI to enable storing user IDs — required for /stats and /broadcast.

VariableDefaultDescription
DATABASE_URI(empty)MongoDB connection string. Leave empty to disable DB features entirely
DATABASE_NAMEFileStreamBotDatabase name
USERS_COLLECTIONfsb_usersCollection used to store user IDs
OWNER_ID0Your Telegram user ID — required to use /stats and /broadcast

Only the user ID is stored — no message content, no file data, no byte tracking.

Force-Subscribe (optional)

Require users to join a channel before they can use the bot.

VariableDefaultDescription
FSUB_CHANNEL(empty)Channel username (@mychannel) or ID (-100xxxxxxxxxx) users must join. Leave empty to disable

The bot must be an admin in FSUB_CHANNEL to check membership.

Multi-Client Support

Multi-client spreads Telegram API requests across multiple bots to avoid flood limits and handle more concurrent streams.

To enable, add extra bot tokens as env vars:

MULTI_TOKEN1=token_of_bot_1
MULTI_TOKEN2=token_of_bot_2
MULTI_TOKEN3=token_of_bot_3

Add as many as you need — no upper limit tested.

⚠️Important: Add every multi-client bot to BIN_CHANNEL as an admin.


📲 How to Use

⚠️ Add all bots (including multi-client ones) to BIN_CHANNEL as admins before starting.

CommandDescription
/startCheck if the bot is running (also runs the FSub check if enabled)

Simply forward or send any media file to the bot. It instantly replies with:

  • 📄 File name
  • 📦 File size
  • 🔗 Direct download link
  • Buttons: Shortened link + Download link

Links stay valid as long as the bot is running and BIN_CHANNEL is intact.


🛠 Admin Commands

These require OWNER_ID and DATABASE_URI to be set, and only work for the owner in a private chat.

CommandDescription
/statsShows total tracked users
/broadcastReply to any message with this command to send it to every tracked user

📬 Contact

Developed and maintained by GouthamSER

GitHubTelegram


🙌 Credits


📄 License

Copyright (C) 2026 GouthamSER under the GNU Affero General Public License v3.0.

This is free software — use, study, share and improve it under the terms of the AGPL-3.0 license.

About

File To Link Converts Easy To Download tg things via FDM or 1DM App

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages