mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
publish: 5.8.23
This commit is contained in:
parent
6af7554b7c
commit
5ad727ce21
7 changed files with 52 additions and 6 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "royalpack"
|
name = "royalpack"
|
||||||
version = "5.8.22"
|
version = "5.8.23"
|
||||||
description = "A Royalnet command pack for the Royal Games community"
|
description = "A Royalnet command pack for the Royal Games community"
|
||||||
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
|
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
|
||||||
license = "AGPL-3.0+"
|
license = "AGPL-3.0+"
|
||||||
|
|
|
@ -16,6 +16,7 @@ from .api_polls_list import ApiPollsList
|
||||||
from .api_cvstats_latest import ApiCvstatsLatestStar
|
from .api_cvstats_latest import ApiCvstatsLatestStar
|
||||||
from .api_cvstats_avg import ApiCvstatsAvgStar
|
from .api_cvstats_avg import ApiCvstatsAvgStar
|
||||||
from .api_user_get_ryg import ApiUserGetRygStar
|
from .api_user_get_ryg import ApiUserGetRygStar
|
||||||
|
from .api_user_find_ryg import ApiUserFindRygStar
|
||||||
|
|
||||||
# Enter the PageStars of your Pack here!
|
# Enter the PageStars of your Pack here!
|
||||||
available_page_stars = [
|
available_page_stars = [
|
||||||
|
@ -36,6 +37,7 @@ available_page_stars = [
|
||||||
ApiCvstatsLatestStar,
|
ApiCvstatsLatestStar,
|
||||||
ApiCvstatsAvgStar,
|
ApiCvstatsAvgStar,
|
||||||
ApiUserGetRygStar,
|
ApiUserGetRygStar,
|
||||||
|
ApiUserFindRygStar,
|
||||||
]
|
]
|
||||||
|
|
||||||
# Don't change this, it should automatically generate __all__
|
# Don't change this, it should automatically generate __all__
|
||||||
|
|
38
royalpack/stars/api_user_find_ryg.py
Normal file
38
royalpack/stars/api_user_find_ryg.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import royalnet.constellation.api as rca
|
||||||
|
import royalnet.utils as ru
|
||||||
|
import royalnet.backpack.tables as rbt
|
||||||
|
from .api_user_get_ryg import ApiUserGetRygStar
|
||||||
|
|
||||||
|
|
||||||
|
class ApiUserFindRygStar(ApiUserGetRygStar):
|
||||||
|
summary = "Ottieni le informazioni su un utente della Royal Games."
|
||||||
|
|
||||||
|
description = ""
|
||||||
|
|
||||||
|
methods = ["GET"]
|
||||||
|
|
||||||
|
path = "/api/user/find/ryg/v1"
|
||||||
|
|
||||||
|
requires_auth = False
|
||||||
|
|
||||||
|
parameters = {"alias": "L'alias dell'utente di cui vuoi vedere le informazioni."}
|
||||||
|
|
||||||
|
tags = ["user"]
|
||||||
|
|
||||||
|
async def get_user(self, data: rca.ApiData):
|
||||||
|
user = await rbt.User.find(self.alchemy, data.session, data["alias"])
|
||||||
|
if user is None:
|
||||||
|
raise rca.NotFoundError("No such user.")
|
||||||
|
return user
|
||||||
|
|
||||||
|
async def api(self, data: rca.ApiData) -> dict:
|
||||||
|
user = await self.get_user(data)
|
||||||
|
result = {
|
||||||
|
**user.json(),
|
||||||
|
"bio": user.bio.json() if user.bio is not None else None,
|
||||||
|
"fiorygi": user.fiorygi.fiorygi if user.fiorygi is not None else None,
|
||||||
|
"steam": [steam.json() for steam in user.steam],
|
||||||
|
"leagueoflegends": [leagueoflegends.json() for leagueoflegends in user.leagueoflegends],
|
||||||
|
"trivia": user.trivia_score.json() if user.trivia_score is not None else None
|
||||||
|
}
|
||||||
|
return result
|
|
@ -18,7 +18,7 @@ class ApiUserGetRygStar(rca.ApiStar):
|
||||||
|
|
||||||
tags = ["user"]
|
tags = ["user"]
|
||||||
|
|
||||||
async def api(self, data: rca.ApiData) -> dict:
|
async def get_user(self, data: rca.ApiData):
|
||||||
user_id_str = data["id"]
|
user_id_str = data["id"]
|
||||||
try:
|
try:
|
||||||
user_id = int(user_id_str)
|
user_id = int(user_id_str)
|
||||||
|
@ -27,6 +27,10 @@ class ApiUserGetRygStar(rca.ApiStar):
|
||||||
user: rbt.User = await ru.asyncify(data.session.query(self.alchemy.get(rbt.User)).get, user_id)
|
user: rbt.User = await ru.asyncify(data.session.query(self.alchemy.get(rbt.User)).get, user_id)
|
||||||
if user is None:
|
if user is None:
|
||||||
raise rca.NotFoundError("No such user.")
|
raise rca.NotFoundError("No such user.")
|
||||||
|
return user
|
||||||
|
|
||||||
|
async def api(self, data: rca.ApiData) -> dict:
|
||||||
|
user = await self.get_user(data)
|
||||||
result = {
|
result = {
|
||||||
**user.json(),
|
**user.json(),
|
||||||
"bio": user.bio.json() if user.bio is not None else None,
|
"bio": user.bio.json() if user.bio is not None else None,
|
||||||
|
|
|
@ -43,6 +43,8 @@ class Brawlhalla:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rank_1v1(self):
|
def rank_1v1(self):
|
||||||
|
if self.metal_1v1 is None:
|
||||||
|
return None
|
||||||
return BrawlhallaRank(metal=self.metal_1v1, tier=self.tier_1v1)
|
return BrawlhallaRank(metal=self.metal_1v1, tier=self.tier_1v1)
|
||||||
|
|
||||||
@rank_1v1.setter
|
@rank_1v1.setter
|
||||||
|
@ -93,12 +95,12 @@ class Brawlhalla:
|
||||||
"rating": self.rating_1v1,
|
"rating": self.rating_1v1,
|
||||||
"metal": one_rank.metal.name,
|
"metal": one_rank.metal.name,
|
||||||
"tier": one_rank.tier.name
|
"tier": one_rank.tier.name
|
||||||
},
|
} if one_rank is not None else None,
|
||||||
"2v2": {
|
"2v2": {
|
||||||
"rating": self.rating_2v2,
|
"rating": self.rating_2v2,
|
||||||
"metal": two_rank.metal.name,
|
"metal": two_rank.metal.name,
|
||||||
"tier": two_rank.tier.name
|
"tier": two_rank.tier.name
|
||||||
}
|
} if two_rank is not None else None
|
||||||
}
|
}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
|
@ -80,7 +80,7 @@ class Dota:
|
||||||
"raw": self._rank_tier,
|
"raw": self._rank_tier,
|
||||||
"medal": rank.medal.name,
|
"medal": rank.medal.name,
|
||||||
"rank": rank.stars.name
|
"rank": rank.stars.name
|
||||||
},
|
} if self._rank_tier is not None else None,
|
||||||
"wins": self.wins,
|
"wins": self.wins,
|
||||||
"losses": self.losses
|
"losses": self.losses
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
semantic = "5.8.22"
|
semantic = "5.8.23"
|
||||||
|
|
Loading…
Reference in a new issue