A Telegram bot that allows users to host static websites by uploading HTML or ZIP files, providing instant public links for sharing. Features a referral system to increase your upload capacity.
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- File Requirements
- Referral System
- Code Structure
- Health Check Server
- Troubleshooting
- Admin Features
- Contributing
- License
- Acknowledgments
- 📤 Upload & Host Files: Upload HTML and ZIP files (up to 5MB)
- 🔗 Instant Public URLs: Get shortened public links using TinyURL
- 📂 File Management: View and delete your uploaded files
- 👥 Referral System: Invite friends to earn extra upload slots
- 🏆 Leaderboard: Compete with others for most referrals
- 📨 Admin Broadcast: Send messages to all users (admin only)
- 🔄 Health Check Server: Built-in server for deployment platforms
Before running the bot, ensure you have:
- Python 3.7+
- A Telegram Bot Token (from @BotFather)
- Firebase project with Storage and Realtime Database enabled
- TinyURL API key (register at TinyURL)
-
Clone the Repository:
git clone https://github.com/ReOneSec/tg-host.git cd tg-host -
Create a Virtual Environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies:
pip install python-telegram-bot pyrebase4 python-dotenv requests
Alternatively, create a
requirements.txtfile with these dependencies and run:pip install -r requirements.txt
-
Set Up Firebase:
- Create a Firebase project at Firebase Console
- Enable Firebase Storage and Realtime Database
- Set Storage rules to allow public read access to files
- Get your project configuration details from Project Settings
-
Set Up TinyURL API:
- Register for a TinyURL developer account
- Generate an API key for URL shortening
Create a .env file in the root directory with the following environment variables:
# Telegram Configuration
BOT_TOKEN=your_telegram_bot_token
BOT_USERNAME=your_bot_username
ADMIN_ID=your_telegram_user_id
# Firebase Configuration
FIREBASE_API_KEY=your_firebase_api_key
FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
FIREBASE_PROJECT_ID=your_project_id
FIREBASE_STORAGE_BUCKET=your_project.appspot.com
FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id
FIREBASE_APP_ID=your_app_id
FIREBASE_MEASUREMENT_ID=your_measurement_id
FIREBASE_DATABASE_URL=https://your_project.firebaseio.com
# TinyURL API Key
TINYURL_API_KEY=your_tinyurl_api_key
Important Configuration Notes:
BOT_TOKEN: Obtain from @BotFather when creating your botBOT_USERNAME: Your bot's username without the '@' symbolADMIN_ID: Your Telegram user ID (required for broadcast command)- Firebase credentials: Found in your Firebase project settings
TINYURL_API_KEY: Your API key from TinyURL developer account
-
Start the Bot:
python main.py
-
Interact with the Bot on Telegram:
- Open Telegram and search for your bot by username
- Start a conversation with the bot using the
/startcommand
| Command | Description |
|---|---|
/start |
Start the bot and view main menu |
/broadcast <message> |
Send a message to all users (Admin only) |
The bot provides an intuitive button-based interface with the following options:
- 📤 Upload File: Upload HTML or ZIP files
- 📁 My Files: View and access your uploaded files
- ❌ Delete File: Remove files you no longer need
- 🏆 Leaderboard: View top referrers
- ℹ️ Help: Get usage instructions
- 👤 Contact Owner: Direct link to contact the bot owner
- Supported formats:
.htmland.zipfiles - Maximum file size: 5MB
- ZIP files: Must contain at least one
.htmlfile - Processing: The first HTML file found in a ZIP will be used as the main file
- Each user starts with 10 upload slots by default
- Each successful referral adds 3 more upload slots
- Users can share their unique referral link from the main menu
- Referral links have the format:
https://t.me/YourBotUsername?start=UserID - The referral leaderboard shows the top 10 users with the most referrals
The bot consists of the following main components:
- Health Check Server: Simple HTTP server that responds with "OK" on port 8080
- Telegram Bot: Handles user interactions and file processing
- Firebase Integration:
- Storage: Stores uploaded HTML/ZIP files
- Database: Manages user data, file metadata, and referral information
- URL Shortening: Uses TinyURL API to create short links for the hosted files
Key functions:
run_fake_server(): Starts the health check serverstart(): Handles the /start command and referral processinghandle_file(): Processes uploaded filesbutton_handler(): Manages inline keyboard interactionsbroadcast(): Sends messages to all users (admin only)
The bot includes a simple HTTP server running on port 8080 that responds with "OK" to GET requests. This server is useful for deployment on platforms that require health checks, such as:
- Heroku
- Google Cloud Run
- AWS Elastic Beanstalk
The server runs in a separate thread with the daemon=True flag, ensuring it terminates when the main program exits.
- File Too Large: Ensure files are under 5MB
- Format Not Supported: Only .html and .zip files are accepted
- Upload Limit Reached: Delete some files or get more referrals
- Storage Access Denied: Check Firebase Storage rules to ensure public read access
- Database Connection Failed: Verify Firebase credentials in .env file
- Authentication Failed: Ensure API key is correct and has necessary permissions
- Check if your bot token is valid
- Ensure the script is running without errors
- Verify internet connectivity
The bot includes an admin broadcast feature to send messages to all users:
/broadcast Your message here
This command will only work for the Telegram user ID specified in the ADMIN_ID environment variable.
Contributions are welcome! To contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature) - Make your changes
- Commit your changes (
git commit -m 'Add some feature') - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- python-telegram-bot for the Telegram API wrapper
- Pyrebase for Firebase integration
- TinyURL for URL shortening services
- python-dotenv for environment variable management
For questions or support, please contact @ViperROX on Telegram.
