Nikolay Tatarinov d60a4fdf3f Enhance Telegram bot with database integration and API features
- Added SQLite database support with Alembic for migrations.
- Implemented FastAPI for HTTP API to manage duties.
- Updated configuration to include database URL and HTTP port.
- Created entrypoint script for Docker to handle migrations and permissions.
- Expanded command handlers to register users and display duties.
- Developed a web application for calendar display of duties.
- Included necessary Pydantic schemas and SQLAlchemy models for data handling.
- Updated requirements.txt to include new dependencies for FastAPI and SQLAlchemy.
2026-02-17 12:51:01 +03:00

Duty Teller (Telegram Bot)

A minimal Telegram bot boilerplate using python-telegram-bot v22 with the Application API.

Get a bot token

  1. Open Telegram and search for @BotFather.
  2. Send /newbot and follow the prompts to create a bot.
  3. Copy the token BotFather gives you.

Setup

  1. Clone and enter the project

    cd duty-teller
    
  2. Create a virtual environment (recommended)

    python -m venv venv
    source venv/bin/activate   # Linux/macOS
    # or: venv\Scripts\activate  # Windows
    
  3. Install dependencies

    pip install -r requirements.txt
    
  4. Configure the bot

    cp .env.example .env
    

    Edit .env and set BOT_TOKEN to the token from BotFather.

Run

python main.py

The bot runs in polling mode. Send /start or /help to your bot in Telegram to test.

Run with Docker

Ensure .env exists (e.g. cp .env.example .env) and contains BOT_TOKEN.

  • Dev (volume mount; code changes apply without rebuild):

    docker compose -f docker-compose.dev.yml up --build
    

    Stop with Ctrl+C or docker compose -f docker-compose.dev.yml down.

  • Prod (no volume; runs the built image; restarts on failure):

    docker compose -f docker-compose.prod.yml up -d --build
    

    For production deployments you may use Docker secrets or your orchestrators env instead of a .env file.

Project layout

  • main.py Builds the Application, registers handlers, runs polling.
  • config.py Loads BOT_TOKEN from env; exits if missing.
  • handlers/ Command and error handlers; add new handlers here.
  • requirements.txt Pinned dependencies (PTB with job-queue, python-dotenv).

To add commands, define async handlers in handlers/commands.py (or a new module) and register them in handlers/__init__.py.

Description
No description provided
Readme 2.8 MiB
v2.1.3 Latest
2026-03-07 00:40:47 +03:00
Languages
HTML 52.1%
Python 25.8%
TypeScript 20.7%
CSS 1.2%
Dockerfile 0.1%