Skip to content

Commit fc1cbb1

Browse files
committed
✨Fix bad url in Dota 2 web api get_real_stats
1 parent 8e6ef04 commit fc1cbb1

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/beta_base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""
22
Base class for BetaCog for `modules.beta.py`.
33
4-
It's a silly way to quickly beta-test some things, but this way
5-
`modules.beta.py` can be done in the least amount of lines as all the imports and chores
6-
are handled in this base file instead.
4+
In `modules.beta.py` I quickly beta-test some things. It's a bit silly but very efficient.
5+
6+
The purpose of the current file is to minimize amount of imports and lines of code
7+
for anything we're going to do while beta-testing. The performance cost of extra imports is probably
8+
negligible compared to annoyance to type them manually out every time we need them.
79
810
For an example of how `modules.beta.py` looks - you can look in `examples` folder.
911
"""

src/core/bot.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ async def event_error(self, payload: twitchio.EventErrorPayload) -> None:
531531
embed = self.add_args_field(embed, f"Extra {payload.error.__class__.__name__} Debug Data", payload.error.data)
532532
await self.exc_manager.register_error(payload.error, embed=embed)
533533

534-
# SHORTCUTS
534+
# SHORTCUTS AND UTILITIES
535535

536536
def webhook_from_url(self, url: str) -> discord.Webhook:
537537
"""A shortcut function with filled in discord.Webhook.from_url args."""
@@ -552,8 +552,6 @@ def error_ping(self) -> str:
552552
"""Error Role ping used to notify the developer(-s) about some errors."""
553553
return "<@&1337106675433340990>" if self.test else "<@&1116171071528374394>"
554554

555-
# UTILITIES AND SHORTCUTS
556-
557555
def is_online(self, user_id: str) -> bool:
558556
"""Whether the user is online.
559557

src/utils/dota/web_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ async def invoke(
3535
) -> Any:
3636
"""Invoke a request to Steam Web API."""
3737
queries = "&".join(f"{k}={v}" for k, v in kwargs.items())
38-
url = f"https://api.steampowered.com/{endpoint}/?key={self.api_key}{queries}"
38+
url = f"https://api.steampowered.com/{endpoint}/?key={self.api_key}&{queries}"
3939
max_failures = 5
4040
for _ in range(max_failures):
4141
async with self.session.get(url) as resp:
42-
# encoding='utf-8' errored out one day
42+
# encoding='utf-8' errored out one day, it seems Valve have misconfigured some servers' content types
43+
# Or maybe they have to because all the unique characters in player names?
4344
result = await resp.json(loads=orjson.loads, content_type=None)
4445
if result:
4546
break

0 commit comments

Comments
 (0)