Skip to content

hesameworks/telegram-service-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Service/Notify Bot — v0.1

A modern, production-ready Telegram bot skeleton for services, notifications, and lightweight order management.
Built with python-telegram-bot (async), SQLAlchemy, and httpx. Fully containerized and easy to deploy on any small VPS.


✨ Features

  • User-friendly commands:
    • /start → Welcome & orientation
    • /help → Clear, scannable list of all commands
    • /order → Guided multi-step order placement (title, qty, optional note)
    • /status <id> → Live status lookup (external API integration)
    • /history → Review last 3–5 orders
    • /contact → Leave a support message
  • Persistent storage: SQLite (via SQLAlchemy) for orders & message logs
  • Admin-ready: Easy to extend with admin-only commands (e.g., /ping)
  • Rate limiting: Built-in per-user cooldown to prevent spam
  • External API stub: Mock-first design for order status endpoint
  • Deployment ready: Dockerfile + docker-compose.yml provided
  • Clean architecture: Clear separation of handlers, services, and models

🚀 Quickstart (Local)

# 1. Clone repository
git clone https://github.com/yourname/telegram-service-bot.git
cd telegram-service-bot

# 2. Create virtual environment
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate

# 3. Install dependencies
pip install -r requirements.txt

# 4. Configure environment
cp .env.example .env  # edit with your values

# 5. Run the bot
python -m src.bot

🐳 Quickstart (Docker)

# Build & start
docker compose up -d --build

# View logs
docker compose logs -f

⚙️ Environment Variables

Variable Required Default Description
BOT_TOKEN Telegram BotFather token
ADMIN_IDS Optional Comma-separated list of admin user IDs
EXTERNAL_API_BASE Optional Base URL of external API for /status
EXTERNAL_API_KEY Optional API key if required by external API
DATABASE_URL Optional sqlite:///data.db Database URL (SQLite/Postgres)
RATE_LIMIT_SECONDS Optional 3 Per-user rate limit (seconds)

📂 Project Structure

telegram-service-bot/
├─ src/
│  ├─ bot.py              # App entrypoint
│  ├─ config.py           # Environment config
│  ├─ handlers/           # Command handlers
│  ├─ models/             # SQLAlchemy models
│  ├─ services/           # API + storage utilities
│  └─ middleware/         # Rate limiting
├─ tests/                 # (future) Unit tests
├─ requirements.txt
├─ Dockerfile
├─ docker-compose.yml
└─ README.md

🔐 Security Best Practices

  • Keep your BOT_TOKEN and API keys in .env only (never commit).
  • Enable Privacy Mode in BotFather.
  • Validate user input (title, qty, etc.).
  • Use rate limiting to reduce spam & abuse.

📈 Roadmap

  • v0.1 → Core features (this release)
  • v0.2 → Webhook support (Caddy/Nginx, HTTPS)
  • v0.3 → Admin dashboard (FastAPI)
  • v0.4 → Push notifications (status changes, inventory alerts)
  • v1.0 → Multi-language support + CI/CD pipeline

🤝 Contributing

Pull requests and issues are welcome! Please:

  • Use English for all code, comments, and commit messages.
  • Follow PEP8 + project conventions.
  • Keep feature branches small and focused.

📜 License

Released under the MIT License. See LICENSE for details.


Telegram Service/Notify Bot — designed for reliability, clarity, and quick iteration.

“Simple flows, real persistence, and production focus from day one.”