Shared Hosting Deployment
Relevant source files
The following files were used as context for generating this wiki page:
Shared Hosting Deployment allows you to run the Telegram Summary Bot on standard web hosting environments like cPanel, Hostinger, or Plesk. The application operates with minimal dependencies and supports PHP 7.4+ and MySQL environments for its extended MiniApp features.
The bot architecture is designed to be lightweight, making it compatible with environments that lack advanced containerization or complex build tools. It runs as a background process or worker to handle Telegram long-polling updates.
Sources: README.md:144-147, README.md:46-48
System Requirements and Dependencies
The application maintains zero external package manager dependencies for its core hosting capabilities. It does not require Composer, Node.js, or specific frameworks to operate on shared platforms.
| Requirement | Specification | Description |
|---|---|---|
| PHP Version | 7.4+ | Required for the MiniApp control panel. |
| Database | MySQL | Stores configuration and management data. |
| Python | 3.x | Runs the core bot.py logic. |
| Network | Outbound HTTPS | Must reach https://api.telegram.org. |
Sources: README.md:144-148, bot.py:46-52, requirements.txt:1-6
Deployment Architecture
The deployment uses a worker-based model where the Python script maintains a persistent connection to the Telegram API.
The diagram shows how the bot resides on the shared host and communicates with Telegram via long-polling, keeping recent messages in local memory.
Sources: README.md:46-48, bot.py:33-35, bot.py:113-125
Core Components
- Worker Process: The
bot.pyscript functions as a long-running worker. Sources: README.md:46, Procfile:1 - State Management: Recent messages are stored in a
defaultdictusingdequeto manage memory constraints. Sources: bot.py:33-35 - Environment Configuration: Settings are loaded from a
.envfile usingpython-dotenv. Sources: bot.py:22-30, .env.example
Configuration and Setup
To deploy on shared hosting, you must configure the environment variables and install the Python dependencies listed in requirements.txt.
Environment Variables
Shared hosting providers often allow setting these via a web interface or a .env file in the application root.
| Variable | Default | Function |
|---|---|---|
TELEGRAM_BOT_TOKEN | None | Authenticates the bot with Telegram. |
POLL_TIMEOUT | 30 | Sets the long-poll duration in seconds. |
MAX_STORED_MESSAGES | 100 | Limits per-chat history for summarization. |
SUMMARY_SENTENCES | 5 | Determines the length of the output summary. |
Sources: README.md:31-38, bot.py:25-28
Installation Steps
- Upload the project files to the hosting directory.
- Initialize a Python virtual environment:
python3 -m venv .venv. - Activate the environment and install requirements:
pip install -r requirements.txt. - Configure the
.envfile with yourTELEGRAM_BOT_TOKEN. - Start the bot as a background process or via the provider's task manager:
python bot.py.
Sources: README.md:14-23, README.md:46-51
Execution Logic
The bot utilizes a polling loop to retrieve updates. If the hosting environment supports Procfile workers, it identifies the start command automatically.
The sequence diagram illustrates the continuous polling cycle and the conditional logic for message storage and summarization.
Sources: bot.py:84-102, bot.py:113-125
Summarization Logic in Limited Environments
The bot uses an extractive summarization method that is computationally light and suitable for shared hosting CPU limits. It does not require external AI API keys.
- Cleaning: It removes excess whitespace and joins fragments.
- Splitting: It breaks the text into sentences using punctuation markers (
.,!,?). - Extraction: It selects the first $N$ sentences, where $N$ is defined by
SUMMARY_SENTENCES. - Formatting: It joins the selected sentences back into a single string.
Sources: bot.py:65-79, README.md:8-10
Shared hosting deployment provides a cost-effective way to host the Telegram Summary Bot using standard PHP/MySQL environments and simple Python background workers. The system's zero-dependency design and local summarization logic ensure high compatibility across various hosting providers.