1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Add more features to steam

This commit is contained in:
Steffo 2020-07-09 04:13:54 +02:00
parent 632c3327b7
commit 2e88bc879c
Signed by: steffo
GPG key ID: 896A80F55F7C97F0
2 changed files with 38 additions and 2 deletions

View file

@ -23,8 +23,12 @@ class SteampoweredCommand(rc.Command):
@staticmethod @staticmethod
def _display(account: Steam): def _display(account: Steam):
string = f" [b]{account.persona_name}[/b]\n" \ string = f" [url={account.profile_url}]{account.persona_name}[/url]\n" \
f"{account.profile_url}\n" \ f"[b]Level {account.account_level}[/b]\n" \
f"\n" \
f"Owned games: [b]{account.owned_games_count}[/b]\n" \
f"Most played 2 weeks: [url=https://store.steampowered.com/app/{account.most_played_game_2weeks}]{account.most_played_game_2weeks}[/url]\n" \
f"Most played forever: [url=https://store.steampowered.com/app/{account.most_played_game_forever}]{account.most_played_game_forever}[/url]\n" \
f"\n" \ f"\n" \
f"SteamID: [c]{account.steamid.as_32}[/c]\n" \ f"SteamID: [c]{account.steamid.as_32}[/c]\n" \
f"SteamID2: [c]{account.steamid.as_steam2}[/c]\n" \ f"SteamID2: [c]{account.steamid.as_steam2}[/c]\n" \
@ -50,6 +54,22 @@ class SteampoweredCommand(rc.Command):
account.primary_clan_id = r["primaryclanid"] account.primary_clan_id = r["primaryclanid"]
account.account_creation_date = datetime.datetime.fromtimestamp(r["timecreated"]) account.account_creation_date = datetime.datetime.fromtimestamp(r["timecreated"])
# noinspection PyProtectedMember
response = await self._call(self._api.IPlayerService.GetSteamLevel_v1, steamid=account._steamid)
account.account_level = response["response"]["player_level"]
# noinspection PyProtectedMember
response = await self._call(self._api.IPlayerService.GetOwnedGames_v1,
steamid=account._steamid,
include_appinfo=False,
include_played_free_games=True,
include_free_sub=False,
appids_filter=None)
account.owned_games_count = response["response"]["game_count"]
if response["response"]["game_count"] >= 0:
account.most_played_game_2weeks = sorted(response["response"]["games"], key=lambda g: -g.get("playtime_2weeks", 0))[0]["appid"]
account.most_played_game_forever = sorted(response["response"]["games"], key=lambda g: -g.get("playtime_forever", 0))[0]["appid"]
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
author = await data.get_author() author = await data.get_author()
if len(args) > 0: if len(args) > 0:

View file

@ -43,6 +43,22 @@ class Steam:
def account_creation_date(self): def account_creation_date(self):
return Column(DateTime) return Column(DateTime)
@declared_attr
def account_level(self):
return Column(Integer, nullable=False, default=0)
@declared_attr
def owned_games_count(self):
return Column(Integer, nullable=False, default=0)
@declared_attr
def most_played_game_2weeks(self):
return Column(Integer, nullable=False, default=753)
@declared_attr
def most_played_game_forever(self):
return Column(Integer, nullable=False, default=753)
def json(self): def json(self):
return { return {
"steamid2": self.steamid.as_steam2, "steamid2": self.steamid.as_steam2,