mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Fix bugs in matchmaking and steampowered
This commit is contained in:
parent
a265295437
commit
e820846a27
2 changed files with 10 additions and 8 deletions
|
@ -59,11 +59,12 @@ class MatchmakingCommand(Command):
|
||||||
except OverflowError:
|
except OverflowError:
|
||||||
dt = None
|
dt = None
|
||||||
if dt is None:
|
if dt is None:
|
||||||
await data.reply("⚠️ La data che hai specificato non è valida.")
|
raise InvalidInputError("⚠️ La data che hai specificato non è valida.")
|
||||||
return
|
|
||||||
if dt <= datetime.datetime.now():
|
if dt <= datetime.datetime.now():
|
||||||
await data.reply("⚠️ La data che hai specificato è nel passato.")
|
raise InvalidInputError("⚠️ La data che hai specificato è nel passato.")
|
||||||
return
|
if dt - datetime.datetime.now() >= datetime.timedelta(days=366):
|
||||||
|
raise InvalidInputError("⚠️ Hai specificato una data tra più di un anno!\n"
|
||||||
|
"Se volevi scrivere un'orario, ricordati che le ore sono separati ")
|
||||||
mmevent: MMEvent = self.alchemy.get(MMEvent)(creator=author,
|
mmevent: MMEvent = self.alchemy.get(MMEvent)(creator=author,
|
||||||
datetime=dt,
|
datetime=dt,
|
||||||
title=title,
|
title=title,
|
||||||
|
|
|
@ -32,12 +32,11 @@ 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(self, method, *args, **kwargs):
|
||||||
async def _call(method, *args, **kwargs):
|
|
||||||
try:
|
try:
|
||||||
await asyncify(method, *args, **kwargs)
|
await asyncify(method, *args, **kwargs)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
raise ExternalError("Steam API request returned an error.")
|
raise ExternalError("\n".join(e.args).replace(self.config["Steam"]["web_api_key"], "HIDDEN"))
|
||||||
|
|
||||||
async def _update(self, account: Steam):
|
async def _update(self, account: Steam):
|
||||||
# noinspection PyProtectedMember
|
# noinspection PyProtectedMember
|
||||||
|
@ -54,6 +53,8 @@ class SteampoweredCommand(Command):
|
||||||
if len(args) > 0:
|
if len(args) > 0:
|
||||||
url = args.joined()
|
url = args.joined()
|
||||||
steamid64 = await self._call(steam.steamid.steam64_from_url, url)
|
steamid64 = await self._call(steam.steamid.steam64_from_url, url)
|
||||||
|
if steamid64 is None:
|
||||||
|
raise InvalidInputError("Quel link non è associato ad alcun account Steam.")
|
||||||
response = await self._call(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)(
|
||||||
|
|
Loading…
Reference in a new issue