Skip to content

Fetch from SC2 Pulse and add /ping - #4

Merged
gvieralopez merged 7 commits into
mainfrom
pulse-fetch
Oct 27, 2026
Merged

gvieralopez merged 7 commits into
mainfrom
pulse-fetch

Conversation

@gvieralopez

@gvieralopez gvieralopez commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Makes the deployed bot work without Blizzard credentials and within 256 MB limit, plus a few features found while testing. One commit per change:

  1. Fetch profiles and ladders from SC2 Pulse.
    • The daily fetch and /fetch asked the Blizzard API, which needs credentials, and its public fallback is gone.
    • SC2 Pulse gives every stored profile's current-season 1v1 ladders in one call per season.
    • A ladder is stored only when its MMR or game count changed, dated by when it was last played.
    • Every fetch also searches each user's Battle Tag again, so new profiles appear by themselves.
    • /link, the Blizzard client and the BLIZZARD_CLIENT_ID, BLIZZARD_CLIENT_SECRET and REALM_ID settings are removed.
    • China gets a flag and a chart style.
  2. Make the replies shorter and consistent.
    • Every command is a tappable /command.
    • Monospace is kept for what is worth copying.
    • Usernames get their @, and users without a username are stored as a link again.
    • /help is grouped into You and Everyone.
  3. Send long replies in several messages. Replies are cut between lines to fit Telegram's limits: 4096 characters per message, 1024 per photo caption. The daily post pins its first part.
  4. Add /ping to mention the group.
    • In a group, it mentions the bot's users who are members of that group, except the caller.
    • It sends four mentions per message, because Telegram only notifies the first four of a message.
    • In a private chat it answers with its help.
  5. Read tapped help links in groups. In a group, a tapped link arrives as /help_fetch@bot, which was read as help for a command called fetch@bot.
  6. Replace aiogram with python-telegram-bot.
    • aiogram builds all ~450 of its models at import, about 140 MB. python-telegram-bot costs about 20 MB.
    • Inside the image, the bot starts at 119 MB instead of 247 MB.
    • After every user's /profile it peaks at 145 MB instead of 272 MB.
    • The charts are byte-for-byte the same.
    • The daily fetch runs on python-telegram-bot's job queue, in the server's time zone.
  7. Prepare version 0.2.0. Removing a command and three settings makes the next release 0.2.0.

Testing

  • make qa passes (108 tests, 98% coverage), including from a fresh clone.
  • The daily fetch was run against a copy of the production database.
  • The image was run as a test bot under --memory 256m --read-only and tried in Telegram.

After merge

  • Redeploy 0.2.0 on the homelab.
  • Drop the Blizzard variables from the stack.
  • Set LOG_CHANNEL_ID to the group.

🤖 Generated with Claude Code

The daily fetch and /fetch asked the Blizzard API, which needs credentials, and its public fallback is gone. SC2 Pulse gives the current-season 1v1 ladders of every stored profile in one call per season, so the bot needs no Blizzard credentials. A ladder is stored only when its MMR or number of games changed, dated by when it was last played.

Each fetch also searches every user's Battle Tag again, so new profiles are added by themselves. /link, the Blizzard client and the BLIZZARD_CLIENT_ID, BLIZZARD_CLIENT_SECRET and REALM_ID settings are gone. China gets its flag.
Commands are tappable everywhere, monospace is kept for what is worth copying (Battle Tags, profile ids, examples, MMR), and usernames get their @. Users without a username are stored as a link to them again, as the old bot did. /help groups the commands into You and Everyone, and the ranking shows each user's Battle Tag name.
Telegram takes at most 4096 characters per message and 1024 per photo caption, so a big group's /rank or /ladders, or the daily post, would be refused. Replies are cut between lines, which keeps each part valid HTML. A /profile whose ladders don't fit in the caption sends the chart first and the ladders after it, and the daily post pins its first part.
In a group, /ping mentions every user of the bot who is a member of that group (asked to Telegram, user by user), except whoever asked, four per message: Telegram only notifies the first four mentions of a message. In a private chat it answers its help.
In a group, tapping /help_fetch sends "/help_fetch@bot", which was read as help for a command named "fetch@bot". The bot name is now taken off before the arguments, and links for other bots are ignored.
aiogram builds all of its ~450 pydantic models when it is imported: about 140 MB, more than the rest of the bot together. python-telegram-bot costs about 20 MB. Inside the image the bot starts at 119 MB instead of 247 MB and peaks at 145 MB instead of 272 MB after every user's /profile, so it fits the 256 MB limit of the homelab with room to spare. The charts are byte-for-byte the same.

The daily fetch runs on python-telegram-bot's job queue, in the server's time zone (it defaults to UTC), instead of a second scheduler of our own.
/link and the BLIZZARD_CLIENT_ID, BLIZZARD_CLIENT_SECRET and REALM_ID settings are gone, so the next release is 0.2.0 rather than 0.1.1.
@gvieralopez gvieralopez changed the title Fetch from SC2 Pulse, fit the homelab and add /ping Fetch from SC2 Pulse and add /ping Oct 27, 2026
@gvieralopez
gvieralopez merged commit 1055b0b 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