Skip to content

Pick the /profile ladder with buttons and draw who and how - #5

Merged
gvieralopez merged 7 commits into
mainfrom
profile-charts
Oct 27, 2026
Merged

gvieralopez merged 7 commits into
mainfrom
profile-charts

Conversation

@gvieralopez

Copy link
Copy Markdown
Owner

A new /profile: one ladder per chart, picked with buttons, with who and how drawn above the chart. Plus the league tier and two fixes. One commit per change:

  1. Ask Telegram for every update type. Telegram remembers the update types a bot last asked for, and aiogram asked only for messages. Without this fix, button taps never reach the bot, and that includes the deployed one.

  2. Pick the /profile chart with buttons.

    • Three rows of buttons pick the ladder: server, race (by its emoji) and time range (6 months, 1 year, all).
    • A tap replaces the chart in the same message, and /profile starts on the ladder played last.
    • The line has one point per day, and two weeks or more without a game is drawn lighter.
  3. Mark the selected buttons in blue, with Telegram's primary button style.

  4. Store the league tier (1 to 3) from SC2 Pulse.

    • The daily fetch, /fetch and the history import store it.
    • An unchanged ladder gets the tier filled in on its latest stat.
    • scripts/add_tier_column.py upgrades an existing database once.
  5. Draw who and how in the /profile chart. Two lines above the chart replace the caption:

    • <clan> name and a flag.
    • The race emblem, the league badge with the tier, the MMR and the win rate.

    The Zerg, Protoss and Terran emblems are Blizzard's, from the StarCraft II site. They are used under Blizzard's non-commercial fan terms, with their own notice, and are not covered by the MIT license (src/sc2bot/emblems/NOTICE.md, README). Flags, league badges and the Random icon are drawn in icons.py.

  6. Connect to the database when the bot starts. Importing the database module used to connect at once, to sqlite:///db.db by default, leaving stray files. A missing CONNECTION_STRING now stops the bot with a message.

  7. Prepare version 0.3.0, because of the schema change.

Testing

  • make qa passes (173 tests, 99% coverage), including from a fresh clone.
  • Tried on a test bot with a copy of the production data.
  • In the image under --memory 256m --read-only, the bot starts at 120 MB. Memory levels off at about 172 MB over 180 charts, and the emblems are packaged.

Deploying on the homelab (in this order)

  1. Stop the bot and back up its data.
  2. Run python -m scripts.add_tier_column sqlite:////data/sc2bot.db once.
  3. Start 0.3.0.

🤖 Generated with Claude Code

Telegram remembers the update types a bot last asked for, and aiogram asked only for messages. python-telegram-bot doesn't send the list unless given one, so button taps never reached the bot.
The chart showed every ladder at once, told apart only by colour and dash style. Now it shows one ladder, and three rows of buttons pick it: server, race (by its emoji) and time range (6 months, 1 year or everything before the ladder's last game). A tap replaces the chart in the same message. /profile starts on the ladder played last, and a server and race without games shows an empty chart.

The line has one point per day, so a session of games reads as one move instead of a burst. Two weeks or more without a game is drawn lighter, at the MMR held.
The current server, race and time range are blue buttons (Telegram's primary style) instead of a bullet before the label.
Each stat gets its tier within the league, 1 (top) to 3, from SC2 Pulse: the daily fetch and the history import store it, and a fetch that finds a ladder unchanged fills in the tier of its latest stat if that has none. scripts/add_tier_column.py adds the column to an existing database, once, before upgrading; the README says how.
The caption goes: the chart says it in two lines above it. The first is the player on their server, <clan> name and flag. The second is how they do with the race: its emblem, the league badge with the tier inside, the MMR and the win rate of the season.

Zerg, Protoss and Terran use Blizzard's race emblems from the StarCraft II site, under Blizzard's non-commercial fan terms; they keep their own notice and are not covered by the MIT license. Flags, league badges and the Random icon are drawn in sc2bot/icons.py.
Importing the database module connected at once, to "sqlite:///db.db" when CONNECTION_STRING was not set, which left an empty db.db wherever the code ran. The session is now bound when the bot starts, and a missing CONNECTION_STRING stops it with a message.
The database gets a column (scripts/add_tier_column.py upgrades an existing one), so the next release is 0.3.0 rather than 0.2.1.
@gvieralopez
gvieralopez merged commit 04c75af into main Oct 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant