mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Fix steampowered leaking API keys
This commit is contained in:
parent
ca5b362cf2
commit
877fad5b2b
1 changed files with 13 additions and 4 deletions
|
@ -19,7 +19,8 @@ class SteampoweredCommand(Command):
|
||||||
raise ConfigurationError("[c]Steam.web_api_key[/c] config option is missing!")
|
raise ConfigurationError("[c]Steam.web_api_key[/c] config option is missing!")
|
||||||
self._api = steam.WebAPI(self.config["Steam"]["web_api_key"])
|
self._api = steam.WebAPI(self.config["Steam"]["web_api_key"])
|
||||||
|
|
||||||
def _display(self, account: Steam):
|
@staticmethod
|
||||||
|
def _display(account: Steam):
|
||||||
string = f"ℹ️ [b]{account.persona_name}[/b]\n" \
|
string = f"ℹ️ [b]{account.persona_name}[/b]\n" \
|
||||||
f"{account.profile_url}\n" \
|
f"{account.profile_url}\n" \
|
||||||
f"\n" \
|
f"\n" \
|
||||||
|
@ -31,8 +32,16 @@ class SteampoweredCommand(Command):
|
||||||
f"Created on: [b]{account.account_creation_date}[/b]\n"
|
f"Created on: [b]{account.account_creation_date}[/b]\n"
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
async def _call(method, *args, **kwargs):
|
||||||
|
try:
|
||||||
|
await asyncify(method, *args, **kwargs)
|
||||||
|
except Exception:
|
||||||
|
raise ExternalError("Steam API request returned an error.")
|
||||||
|
|
||||||
async def _update(self, account: Steam):
|
async def _update(self, account: Steam):
|
||||||
response = await asyncify(self._api.ISteamUser.GetPlayerSummaries_v2, steamids=account._steamid)
|
# noinspection PyProtectedMember
|
||||||
|
response = await self._call(self._api.ISteamUser.GetPlayerSummaries_v2, steamids=account._steamid)
|
||||||
r = response["response"]["players"][0]
|
r = response["response"]["players"][0]
|
||||||
account.persona_name = r["personaname"]
|
account.persona_name = r["personaname"]
|
||||||
account.profile_url = r["profileurl"]
|
account.profile_url = r["profileurl"]
|
||||||
|
@ -44,8 +53,8 @@ class SteampoweredCommand(Command):
|
||||||
author = await data.get_author()
|
author = await data.get_author()
|
||||||
if len(args) > 0:
|
if len(args) > 0:
|
||||||
url = args.joined()
|
url = args.joined()
|
||||||
steamid64 = await asyncify(steam.steamid.steam64_from_url, url)
|
steamid64 = await self._call(steam.steamid.steam64_from_url, url)
|
||||||
response = await asyncify(self._api.ISteamUser.GetPlayerSummaries_v2, steamids=steamid64)
|
response = await self._call(self._api.ISteamUser.GetPlayerSummaries_v2, steamids=steamid64)
|
||||||
r = response["response"]["players"][0]
|
r = response["response"]["players"][0]
|
||||||
steam_account = self.alchemy.get(Steam)(
|
steam_account = self.alchemy.get(Steam)(
|
||||||
user=author,
|
user=author,
|
||||||
|
|
Loading…
Reference in a new issue