statchannel: ignore steam's bogus zero player counts
Steam's GetNumberOfCurrentPlayers occasionally answers 200 with player_count: 0 for a valid appid. Both Strinova stat channels were renamed to "0" on the same 09:48 tick on 2026-10-20 (the only zero in ~300 renames over 3 days), and the name sat wrong until the next 10-minute tick. Skip the rename on a non-positive count so the channel keeps its last good value, and log it so the next one is visible. !strinova had the same bug and would reply "0 players online right now". Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
d514601651
commit
93e22a8364
2 files changed
+6
No files matched your search
@@ -31,6 +31,9 @@ class StatChannel(commands.Cog):
|
||||
async with session.get('https://api.steampowered.com/ISteamUserStats/GetNumberOfCurrentPlayers/v1/?appid=1282270') as r:
|
||||
data = await r.json()
|
||||
count = data['response']['player_count']
|
||||
if not isinstance(count, int) or count <= 0:
|
||||
print(f'stat channel update skipped (channel {channel_id}): steam returned {count!r}')
|
||||
return
|
||||
channel = self.bot.get_channel(channel_id)
|
||||
if channel:
|
||||
await channel.edit(name=f'Strinova Players From Steam: {count:,}')
|
||||
|
||||
@@ -117,6 +117,9 @@ class SysInfo(commands.Cog):
|
||||
async with session.get('https://api.steampowered.com/ISteamUserStats/GetNumberOfCurrentPlayers/v1/?appid=1282270') as r:
|
||||
data = await r.json()
|
||||
count = data['response']['player_count']
|
||||
if not isinstance(count, int) or count <= 0:
|
||||
await ctx.reply('🎮 Strinova — Steam is not returning a player count right now, try again in a bit')
|
||||
return
|
||||
await ctx.reply(f'🎮 Strinova — {count:,} players online right now')
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user