# Telegram appointment booking bot (aiogram 3)

This is a ready-to-adapt appointment booking template for a barbershop,
clinic, rental desk, or other small service. It contains a real aiogram 3
polling bot plus a standard-library booking core that is easy to test without
Telegram credentials.

## Included

- `/book` with inline slot selection and a transaction-safe capacity check.
- `/mybookings` and `/cancel SLOT_ID` for customers.
- Admin-only `/admin_add YYYY-MM-DD HH:MM [capacity]` and `/admin_list`.
- SQLite persistence with a unique user/slot constraint and WAL mode.
- IANA timezone parsing/rendering through `zoneinfo`; timestamps are stored in
  UTC and displayed in `BOT_TIMEZONE`.
- A once-per-minute reminder loop with an idempotent reminder claim table, so
  restarts do not send the same reminder twice.
- `.env.example`, a short requirements file, deterministic core tests, and
  `SHA256SUMS`.

## Run

```bash
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
# set BOT_TOKEN and ADMIN_IDS in .env, then export the variables
python booking_bot.py
```

The bot never needs a wallet, payment, or private data. Keep the BotFather
token in the environment and do not commit `.env`. For production, run the
poller under a supervisor and put a backup policy around the SQLite file.

## Verify without Telegram

```bash
python -m unittest -v test_booking_core.py
sha256sum -c SHA256SUMS
```

The tests cover timezone conversion, capacity enforcement, cancellation and
idempotent reminder claiming. The public bundle is a proof artifact; it does
not include a bot token or personal data.
