Repository navigation
Pick the /profile ladder with buttons and draw who and how - #5
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: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.
Pick the /profile chart with buttons.
/profilestarts on the ladder played last.Mark the selected buttons in blue, with Telegram's primary button style.
Store the league tier (1 to 3) from SC2 Pulse.
/fetchand the history import store it.scripts/add_tier_column.pyupgrades an existing database once.Draw who and how in the /profile chart. Two lines above the chart replace the caption:
<clan> nameand a flag.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 inicons.py.Connect to the database when the bot starts. Importing the database module used to connect at once, to
sqlite:///db.dbby default, leaving stray files. A missingCONNECTION_STRINGnow stops the bot with a message.Prepare version 0.3.0, because of the schema change.
Testing
make qapasses (173 tests, 99% coverage), including from a fresh clone.--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)
python -m scripts.add_tier_column sqlite:////data/sc2bot.dbonce.🤖 Generated with Claude Code