Skip to content

Commit 1fa270a

Browse files
authored
1.9.9
- Updated dependency: migrated from Motor to PyMongo - Replaced centralized flood-wait handling with per-instance custom logic - Added public Docker support for easier deployment • One-click deploy button for Koyeb • Deployment guides for Render and Railway - Expanded FAQ section
1 parent 7f1478e commit 1fa270a

22 files changed

Lines changed: 1000 additions & 426 deletions

.github/workflows/dockerize.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Docker Build & Push
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v5
13+
14+
- name: Login to Docker Hub
15+
uses: docker/login-action@v3
16+
with:
17+
username: fyaz05
18+
password: ${{ secrets.DOCKER_TOKEN }}
19+
20+
- name: Build and Push
21+
uses: docker/build-push-action@v6
22+
with:
23+
context: .
24+
push: true
25+
tags: fyaz05/thunder:latest

README.md

Lines changed: 139 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
- [About The Project](#about-the-project)
2222
- [How It Works](#how-it-works)
2323
- [Features](#features)
24-
- [Getting Started](#getting-started)
25-
- [Prerequisites](#prerequisites)
26-
- [Installation](#installation)
2724
- [Configuration](#configuration)
2825
- [Essential Configuration](#essential-configuration)
2926
- [Optional Configuration](#optional-configuration)
@@ -34,8 +31,14 @@
3431
- [Token System](#token-system)
3532
- [URL Shortening](#url-shortening)
3633
- [Rate Limiting System](#rate-limiting-system)
37-
- [Production Deployment Guide](#production-deployment-guide)
38-
- [Custom Domain & FQDN System](#custom-domain--fqdn-system)
34+
- [Network Speed Testing](#network-speed-testing)
35+
- [Deployment Guide](#deployment-guide)
36+
- [Prerequisites](#prerequisites)
37+
- [Installation](#installation)
38+
- [Quick Deploy](#quick-deploy)
39+
- [Deploy to Koyeb](#deploy-to-koyeb)
40+
- [Deploy to Render](#deploy-to-render)
41+
- [Deploy to Railway](#deploy-to-railway)
3942
- [Reverse Proxy Setup](#reverse-proxy-setup)
4043
- [Support & Community](#support--community)
4144
- [Troubleshooting & FAQ](#troubleshooting--faq)
@@ -95,65 +98,6 @@ User Uploads File → Telegram Bot → Forwards to Channel → Generates Direct
9598
- 🎨 **Custom Templates** - Personalize messages sent by the bot to match your brand.
9699
- 📈 **Media Info Display** - Shows file size, duration, and format details in the response message.
97100

98-
## Getting Started
99-
100-
This section covers the system requirements and step-by-step installation guide for setting up Thunder.
101-
102-
### Prerequisites
103-
104-
| Requirement | Description | Source |
105-
| :--- | :--- | :--- |
106-
| Python 3.13 | Programming language | [python.org](https://python.org) |
107-
| MongoDB | Database | [mongodb.com](https://mongodb.com) |
108-
| Telegram API | API credentials | [my.telegram.org](https://my.telegram.org/apps) |
109-
| Bot Token | From @BotFather | [@BotFather](https://t.me/BotFather) |
110-
| Public Server | VPS/Dedicated server | Any provider |
111-
| Storage Channel | For file storage | Create in Telegram |
112-
113-
### Installation
114-
115-
#### Docker Installation (Recommended)
116-
117-
```bash
118-
# 1. Clone repository
119-
git clone https://github.com/fyaz05/FileToLink.git
120-
cd FileToLink
121-
122-
# 2. Configure
123-
cp config_sample.env config.env
124-
nano config.env # Edit your settings
125-
126-
# 3. Build and run
127-
docker build -t thunder .
128-
docker run -d --name thunder -p 8080:8080 thunder
129-
```
130-
131-
<details>
132-
<summary>Manual Installation</summary>
133-
134-
```bash
135-
# 1. Clone repository
136-
git clone https://github.com/fyaz05/FileToLink.git
137-
cd FileToLink
138-
139-
# 2. Setup virtual environment
140-
python3 -m venv venv
141-
source venv/bin/activate # Windows: venv\Scripts\activate
142-
143-
# 3. Install dependencies
144-
pip install -r requirements.txt
145-
146-
# 4. Configure
147-
cp config_sample.env config.env
148-
nano config.env
149-
150-
# 5. Run bot
151-
python -m Thunder
152-
```
153-
154-
> **Tip:** Start with the essential configuration to get Thunder running, then add optional features as needed.
155-
156-
</details>
157101

158102
## Configuration
159103

@@ -168,15 +112,16 @@ Copy `config_sample.env` to `config.env` and fill in your values.
168112
| `BOT_TOKEN` | Bot token from @BotFather | `123456:ABCdefGHI` |
169113
| `BIN_CHANNEL` | Storage channel ID | `-1001234567890` |
170114
| `OWNER_ID` | Owner user ID | `12345678` |
171-
| `OWNER_USERNAME` | Owner username | `yourusername` |
172115
| `DATABASE_URL` | MongoDB connection | `mongodb+srv://...` |
173116
| `FQDN` | Domain/IP address | `f2l.thunder.com` |
174117
| `HAS_SSL` | HTTPS enabled | `True` or `False` |
175118
| `PORT` | Server port | `8080` |
176119
| `NO_PORT` | Hide port in URLs | `True` or `False` |
177120

121+
### Optional Configuration
122+
178123
<details>
179-
<summary><h3>Optional Configuration</h3></summary>
124+
<summary>Optional Configuration Details</summary>
180125

181126
| Variable | Description | Default |
182127
| :--- | :--- | :--- |
@@ -324,19 +269,95 @@ Monitor server performance with built-in speed testing:
324269

325270
Features include download/upload speeds, latency measurements, and shareable result images for performance monitoring.
326271

327-
## Production Deployment Guide
272+
## Deployment Guide
273+
274+
This section covers the complete setup process for deploying Thunder, from prerequisites to production deployment.
275+
276+
### Prerequisites
277+
278+
| Requirement | Description | Source |
279+
| :--- | :--- | :--- |
280+
| Python 3.13 | Programming language | [python.org](https://python.org) |
281+
| MongoDB | Database | [mongodb.com](https://mongodb.com) |
282+
| Telegram API | API credentials | [my.telegram.org](https://my.telegram.org/apps) |
283+
| Bot Token | From @BotFather | [@BotFather](https://t.me/BotFather) |
284+
| Public Server | VPS/Dedicated server | Any provider |
285+
| Storage Channel | For file storage | Create in Telegram |
286+
287+
### Installation
328288

329-
### Custom Domain & FQDN System
289+
#### Docker Installation (Recommended)
290+
291+
```bash
292+
# 1. Clone repository
293+
git clone https://github.com/fyaz05/FileToLink.git
294+
cd FileToLink
330295

331-
Thunder provides enterprise-grade domain configuration through the `FQDN` setting, enabling professional file sharing with custom domains and comprehensive SSL support.
296+
# 2. Configure
297+
cp config_sample.env config.env
298+
nano config.env # Edit your settings
332299

333-
- **Custom Domain Support**: Set your primary domain for file sharing.
334-
- **Protocol Selection**: Dynamically serves over HTTP/HTTPS based on your `HAS_SSL` configuration.
335-
- **Cloudflare Compatible**: Full support for Cloudflare Origin Certificates and reverse proxies.
336-
- **Security Headers**: Adds proper security headers for production deployments.
300+
# 3. Build and run
301+
docker build -t thunder .
302+
docker run -d --name thunder -p 8080:8080 thunder
303+
```
337304

338305
<details>
339-
<summary><h3>Reverse Proxy Setup</h3></summary>
306+
<summary>Manual Installation</summary>
307+
308+
```bash
309+
# 1. Clone repository
310+
git clone https://github.com/fyaz05/FileToLink.git
311+
cd FileToLink
312+
313+
# 2. Setup virtual environment
314+
python3 -m venv venv
315+
source venv/bin/activate # Windows: venv\Scripts\activate
316+
317+
# 3. Install dependencies
318+
pip install -r requirements.txt
319+
320+
# 4. Configure
321+
cp config_sample.env config.env
322+
nano config.env
323+
324+
# 5. Run bot
325+
python -m Thunder
326+
```
327+
328+
> **Tip:** Start with the essential configuration to get Thunder running, then add optional features as needed.
329+
330+
</details>
331+
332+
## Quick Deploy
333+
334+
### Deploy to Koyeb
335+
336+
[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=docker&image=docker.io/fyaz05/thunder:latest&name=thunder&ports=8080;http;/&env[API_ID]=&env[API_HASH]=&env[BOT_TOKEN]=&env[BIN_CHANNEL]=&env[OWNER_ID]=&env[DATABASE_URL]=&env[FQDN]=)
337+
338+
339+
After deployment, to add any additional environment variables, use the Koyeb dashboard under **Settings****Environment Variables**.
340+
341+
### Deploy to Render
342+
343+
1. Open [Render Dashboard](https://dashboard.render.com)**New****Web Service**
344+
2. Choose **Existing Image**: `fyaz05/thunder:latest`
345+
3. Add your environment variables
346+
4. Click **Deploy**
347+
348+
### Deploy to Railway
349+
350+
1. Open [Railway](https://railway.app)**New Project****Deploy Service**
351+
2. Choose **Docker Image**: `fyaz05/thunder:latest`
352+
3. Add your environment variables
353+
4. Click **Deploy**
354+
355+
> **Note:** See the [Configuration](#configuration) section for required environment variables.
356+
357+
## Reverse Proxy Setup
358+
359+
<details>
360+
<summary>Reverse Proxy Guide</summary>
340361

341362
This guide will help you set up a secure reverse proxy using **NGINX** for your file streaming bot with **Cloudflare SSL protection**.
342363

@@ -433,23 +454,54 @@ Your reverse proxy is now securely streaming files behind Cloudflare!
433454

434455
### Troubleshooting & FAQ
435456

436-
**Bot not responding?**
457+
#### **Initial Setup**
458+
459+
**Q: Why isn't my bot responding after setup?**
460+
A: This is usually a configuration issue. Please check the following:
461+
1. **Verify `config.env`**: Make sure all essential variables (`API_ID`, `API_HASH`, `BOT_TOKEN`, `BIN_CHANNEL`, `DATABASE_URL`) are filled in correctly.
462+
2. **Use `config.env` Only**: Do not edit `vars.py` or `config_sample.env`. The bot is designed to only read your settings from `config.env`.
463+
3. **Check Logs**: Review the console logs on your server or hosting platform (Koyeb, Render, Heroku) for any startup errors.
464+
465+
**Q: What do I use for the `FQDN` variable?**
466+
A: It's the public URL or IP address of your bot.
467+
- **With a Domain**: Use your subdomain (e.g., `f2l.thunder.com`).
468+
- **On Koyeb/Render/Heroku**: Use the public URL provided by the platform.
469+
- **On a VPS**: Use your server's public IP address.
470+
471+
**Q: Why are my links not working on a VPS?**
472+
A: For links to work on a VPS, the URL must include the port number (e.g., `http://YOUR_VPS_IP:8080`). Ensure that `NO_PORT` is set to `False` in `config.env` and that your server is configured to allow traffic through that port.
473+
474+
#### **Common Errors**
475+
476+
**Q: Why are my links showing a "Resource Not Found" error or not working?**
477+
A: This error means the bot can't access the file. Check these three things:
478+
1. **Invalid Token**: Your `BOT_TOKEN` or one of the `MULTI_TOKEN`s might be wrong. Double-check them with @BotFather.
479+
2. **Missing Admin Rights**: The bot and **all** your client accounts must be **administrators** in the `BIN_CHANNEL`.
480+
3. **File Deleted**: The link will break if the file was deleted from your `BIN_CHANNEL`.
481+
482+
**Q: Why isn't video or audio playing correctly in my browser?**
483+
A: Your browser likely doesn't support the file's audio or video format (codec). This is a browser limitation, not a bot issue.
484+
- **Solution**: For perfect playback, copy the link and play it in a dedicated media player. Recommended players include **VLC Media Player**, **MX Player**, **PotPlayer**, **IINA**, and **MPV**.
485+
486+
**Q: Why does the bot sometimes become unresponsive?**
487+
A: This is likely a **Telegram Flood Wait**. To prevent spam, Telegram temporarily limits accounts that make too many requests. The bot is designed to handle this automatically by pausing and will resume on its own once the limit is lifted.
437488

438-
- Check if the `BOT_TOKEN` is correct in your `config.env`.
439-
- Ensure your server's firewall is not blocking the bot's port.
440-
- View bot logs for any error messages.
489+
#### **Performance**
441490

442-
**Links not working?**
491+
**Q: How can I fix slow download and streaming speeds?**
492+
A: If your speeds are slow, here’s how to fix it:
493+
- **Add More Clients**: This is the best solution. Add `MULTI_TOKEN`s to your `config.env` to distribute the workload and increase throughput.
494+
- **Use DC4 Accounts**: For top performance, use Telegram accounts from **Data Center 4 (DC4)**, as they often have the fastest connection. Use `/dc` to check an account's data center.
495+
- **Upgrade Your Server**: A server with a slow network will bottleneck your speeds. Consider upgrading your VPS plan.
443496

444-
- Verify your `FQDN` and `PORT` settings are correct.
445-
- If using SSL (`HAS_SSL=True`), ensure your reverse proxy and certificates are set up correctly.
446-
- Check that the bot has admin rights in the `BIN_CHANNEL` and can forward messages there.
497+
#### **Bot Usage**
447498

448-
**Q: How do I get my API credentials?**
449-
A: Visit [my.telegram.org/apps](https://my.telegram.org/apps) to get your `API_ID` and `API_HASH`.
499+
**Q: How do I generate links for multiple files at once?**
500+
A: The `/link` command can process multiple files sent in sequence. To use it, **reply to the first file** of the series with the command and the total count.
501+
- **Example**: For a series of 5 files, reply to the very first file with `/link 5`.
450502

451-
**Q: Where can I create a bot token?**
452-
A: Use [@BotFather](https://t.me/BotFather) on Telegram to create and manage your bot.
503+
**Q: Can I mix tokens from different accounts and data centers?**
504+
A: Yes. Mixing clients from different accounts and data centers (like DC1, DC4, and DC5) is a great way to improve bot performance and reliability.
453505

454506
### Contributing
455507

@@ -469,7 +521,7 @@ Licensed under the [Apache License 2.0](LICENSE). See the `LICENSE` file for det
469521

470522
- [Pyrofork](https://github.com/Mayuri-Chan/pyrofork) - Telegram MTProto API Framework
471523
- [aiohttp](https://github.com/aio-libs/aiohttp) - Asynchronous HTTP Client/Server
472-
- [Motor](https://github.com/mongodb/motor) - Asynchronous MongoDB Driver
524+
- [PyMongo](https://github.com/mongodb/mongo-python-driver) - Asynchronous MongoDB Driver
473525
- [TgCrypto](https://github.com/pyrogram/tgcrypto) - High-performance cryptography library
474526

475527
## ⚠️ Disclaimer

Thunder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
import time
44

55
StartTime = time.time()
6-
__version__ = "1.9.8"
6+
__version__ = "1.9.9"

Thunder/__main__.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
install()
1313
from aiohttp import web
1414
from pyrogram import idle
15+
from pyrogram.errors import FloodWait, MessageNotModified
1516

1617
from Thunder import __version__
1718
from Thunder.bot import StreamBot
1819
from Thunder.bot.clients import cleanup_clients, initialize_clients
1920
from Thunder.server import web_server
2021
from Thunder.utils.commands import set_commands
2122
from Thunder.utils.database import db
22-
from Thunder.utils.handler import handle_flood_wait
2323
from Thunder.utils.keepalive import ping_server
2424
from Thunder.utils.logger import logger
2525
from Thunder.utils.messages import MSG_ADMIN_RESTART_DONE
@@ -100,8 +100,20 @@ async def start_services():
100100

101101
print(" ▶ Starting Telegram Bot initialization...")
102102
try:
103-
await handle_flood_wait(StreamBot.start)
104-
bot_info = await handle_flood_wait(StreamBot.get_me)
103+
try:
104+
await StreamBot.start()
105+
except FloodWait as e:
106+
logger.debug(f"FloodWait in bot start, sleeping for {e.value}s")
107+
await asyncio.sleep(e.value)
108+
await StreamBot.start()
109+
110+
try:
111+
bot_info = await StreamBot.get_me()
112+
except FloodWait as e:
113+
logger.debug(f"FloodWait in get_me, sleeping for {e.value}s")
114+
await asyncio.sleep(e.value)
115+
bot_info = await StreamBot.get_me()
116+
105117
StreamBot.username = bot_info.username
106118
print(f" ✓ Bot initialized successfully as @{StreamBot.username}")
107119

@@ -111,12 +123,22 @@ async def start_services():
111123
restart_message_data = await db.get_restart_message()
112124
if restart_message_data:
113125
try:
114-
await handle_flood_wait(
115-
StreamBot.edit_message_text,
116-
chat_id=restart_message_data["chat_id"],
117-
message_id=restart_message_data["message_id"],
118-
text=MSG_ADMIN_RESTART_DONE,
119-
)
126+
try:
127+
await StreamBot.edit_message_text(
128+
chat_id=restart_message_data["chat_id"],
129+
message_id=restart_message_data["message_id"],
130+
text=MSG_ADMIN_RESTART_DONE,
131+
)
132+
except FloodWait as e:
133+
logger.debug(f"FloodWait in restart message edit, sleeping for {e.value}s")
134+
await asyncio.sleep(e.value)
135+
await StreamBot.edit_message_text(
136+
chat_id=restart_message_data["chat_id"],
137+
message_id=restart_message_data["message_id"],
138+
text=MSG_ADMIN_RESTART_DONE,
139+
)
140+
except MessageNotModified:
141+
pass
120142
await db.delete_restart_message(
121143
restart_message_data["message_id"]
122144
)
@@ -197,7 +219,6 @@ async def start_services():
197219
print(f" ▶ Bot Name: {bot_info.first_name}")
198220
print(f" ▶ Username: @{bot_info.username}")
199221
print(f" ▶ Server: {bind_address}:{Var.PORT}")
200-
print(f" ▶ Owner: {Var.OWNER_USERNAME}")
201222
print(f" ▶ Startup Time: {elapsed_time:.2f} seconds")
202223
print("╚═══════════════════════════════════════════════════════════╝")
203224
print(" ▶ Bot is now running! Press CTRL+C to stop.")

0 commit comments

Comments
 (0)