Mirror — primary at git.dannydannydanny.me
Find a file
Danny bc1d44b556 feat: per-user workout numbering (#7)
Display workouts as "#N" based on each user's own ordered list of
non-deleted workouts (rank by timestamp ascending). Global auto-
increment id stays the primary key, used only internally and in
exports. User-visible surfaces now all use the per-user number:
- /history listing
- /delete now accepts the per-user number
- Save confirmations (bot text and Mini App toast)

Deleting a workout renumbers the later ones downward, as expected
for a pure display transform.

New db helpers: get_user_workout_number, resolve_user_number, and
get_workouts now includes user_number per row via SQLite window
function.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 22:32:24 +02:00
tests feat: per-user workout numbering (#7) 2026-04-18 22:32:24 +02:00
webapp feat: per-user workout numbering (#7) 2026-04-18 22:32:24 +02:00
.env.example feat(tg-fitness-bot): initial Telegram workout tracker bot 2026-03-24 15:50:05 +01:00
.gitignore feat(tg-fitness-bot): initial Telegram workout tracker bot 2026-03-24 15:50:05 +01:00
bot.py feat: per-user workout numbering (#7) 2026-04-18 22:32:24 +02:00
db.py feat: per-user workout numbering (#7) 2026-04-18 22:32:24 +02:00
flake.lock feat(tg-fitness-bot): initial Telegram workout tracker bot 2026-03-24 15:50:05 +01:00
flake.nix feat(tg-fitness-bot): add test suite with pre-commit hook 2026-04-13 20:41:03 +02:00
LICENSE docs: add LICENSE (MIT) and README 2026-04-17 14:21:12 +02:00
parser.py feat(tg-fitness-bot): multi-set format, delete, export, SQL stats 2026-04-07 22:46:10 +02:00
README.md docs: add muscle emoji to README heading 2026-04-17 14:41:40 +02:00
requirements.txt feat(tg-fitness-bot): initial Telegram workout tracker bot 2026-03-24 15:50:05 +01:00
ROADMAP.md feat: per-user workout numbering (#7) 2026-04-18 22:32:24 +02:00
server.py feat: per-user workout numbering (#7) 2026-04-18 22:32:24 +02:00
start.py fix(start): force http2 protocol and drain cloudflared output 🐛 2026-03-29 18:58:16 +02:00

BigBiggerBiggestBot 💪

A Telegram bot for logging gym workouts, with an embedded Mini App.

Send workouts as plain text, forward them from Saved Messages, or tap through a structured log form inside Telegram. History, stats, notes, edit & delete, JSON/CSV export — all per-user, all in SQLite.

Format

Send messages like:

Bench press: 4x8x35
Shoulder press (3032): 8x25, 5x35, 6x40
Pull-ups: 3x10
  • SETSxREPSxWEIGHT — uniform sets
  • REPSxWEIGHT, REPSxWEIGHT, ... — per-set (weight/reps vary)
  • Omit weight for bodyweight exercises
  • (machine_id) is optional (gym equipment ID)
  • Blank line separates superset groups; consecutive lines form a superset
  • Both , and . work as decimal separators

Commands

  • /start — help & open Mini App
  • /history — recent workouts
  • /stats — summary (total workouts, sets, volume)
  • /delete <id> — soft-delete a workout
  • /export — download all data as JSON
  • /feedback <text> — send feedback to the bot author

Run locally

nix run

This launches:

  • API server (port 8080)
  • cloudflared tunnel for the Mini App
  • Telegram bot (polling)

Put your bot token (from @BotFather) in ~/.secrets/bigbiggerbiggestbot or a .env file:

BOT_TOKEN=123456:your-bot-token-here

nix develop drops you into a dev shell with Python + deps.

Tests

nix develop --command pytest tests/ -v

Deployment

Runs as a systemd service. A timer pulls this repo periodically and restarts the service when the remote has new commits — push to main and the bot redeploys itself within ~15 minutes.

The SQLite database lives next to the code at workouts.db (gitignored).

Architecture

  • bot.py — Telegram command handlers, polling, message parsing
  • server.py — aiohttp REST API + static file server for the Mini App
  • db.py — SQLite data layer (workouts, supersets, exercises, feedback; soft delete)
  • parser.py — workout text → structured data
  • webapp/ — Mini App (HTML/CSS/vanilla JS, Telegram WebApp SDK)
  • start.py — orchestrator: starts server + tunnel + bot, wires up the Mini App URL
  • tests/ — pytest suite for parser + db

License

MIT — see LICENSE.