A Telegram bot platform for hosting PHP-based bots with file management, subscription plans, and quota management.
This platform allows users to:
- Upload and manage PHP files through Telegram
- Host their own Telegram bots with automatic webhook setup
- Manage files and folders with an intuitive interface
- Choose between Free and Pro subscription plans
- Monitor usage and quotas in real-time
Built with a clean, layered architecture:
- Presentation Layer: Telegram bot interface (python-telegram-bot)
- Application Layer: Business logic services
- Domain Layer: Core models and entities
- Infrastructure Layer: PostgreSQL, Redis, PHP-FPM
- Python 3.11+: Main application runtime
- python-telegram-bot 21.x: Telegram bot framework
- FastAPI: Webhook receiver and API
- PostgreSQL 16+: Primary database
- Redis 7+: Caching and queues
- PHP-FPM 8.3: Execute user bots
- SQLAlchemy 2.0+: Database ORM
- APScheduler: Background tasks
src/
├── core/ # Core infrastructure (config, database, cache, logger)
├── models/ # Domain models (User, Bot, File, Subscription)
├── repositories/ # Data access layer
├── services/ # Business logic
├── handlers/ # Telegram command handlers
├── middleware/ # Authentication, rate limiting, logging
├── tasks/ # Background tasks
├── utils/ # Utilities and helpers
└── web/ # Webhook receiver and PHP gateway
config/ # PHP and PHP-FPM configuration
migrations/ # Database migrations
tests/ # Unit, integration, and e2e tests
scripts/ # Utility scripts
-
Clone the repository
git clone <repository-url> cd php-bot
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment
cp .env.example .env # Edit .env with your configuration -
Setup database
python scripts/setup_db.py python scripts/migrate.py
-
Run the bot
python -m src
- 50 MB storage
- 30 files maximum
- 5 folders maximum
- 1 bot
- 10,000 webhook calls/day
- 1 GB storage
- 500 files maximum
- 50 folders maximum
- 5 bots
- 100,000 webhook calls/day
- PHP sandbox with
open_basedirisolation - Disabled dangerous PHP functions
- Rate limiting per user and IP
- Input validation and sanitization
- Secure file upload handling
- Structured logging with structlog
- Real-time quota tracking
- Webhook call monitoring
- Activity logs
# Run all tests
pytest
# Run with coverage
pytest --cov=src --cov-report=html
# Run specific test suite
pytest tests/unit/
pytest tests/integration/
pytest tests/e2e/Optimized for Railway deployment. See ARCHITECTURE_PLAN.md for detailed deployment instructions.
ARCHITECTURE_PLAN.md: Detailed architecture and design decisionsAGENTS.md: Development workflow and guidelines
[Add your license here]
Contributions are welcome! Please read the contributing guidelines before submitting PRs.
[Add contact information]
Version: 1.0
Status: In Development
Last Updated: May 28, 2026