|
|
|
@ -44,8 +44,96 @@ class Player: |
|
|
|
def played_on_servers(self): |
|
|
|
return self.current.get("lastplay", {}) or self.current.get("gametime", {}) |
|
|
|
|
|
|
|
@property |
|
|
|
def embedNext(self) -> Embed: |
|
|
|
if not self.current: |
|
|
|
raise NotLoadProfile |
|
|
|
embed = Embed( |
|
|
|
title = self.current["steam_data"]["nickname"] + " | Профиль стим", |
|
|
|
description = f"ИМЕЕТСЯ БАН\n{utime2human(self.current['ban']['ban_utime'])}" if self.current.get("ban", {}) else "", |
|
|
|
url = self.current["steamids"]["community_url"]) |
|
|
|
|
|
|
|
embed.set_thumbnail(url = self.current["steam_data"]["avatar"]) |
|
|
|
|
|
|
|
embed.set_author( |
|
|
|
name="Профиль на сайте Факты13", |
|
|
|
icon_url="https://cdn.discordapp.com/avatars/684685147144060948/174fe6511f1f07aaa4c784d15c48b306.webp?size=1024", |
|
|
|
url=f"https://tf2.pblr-nyk.pro/#/profile/{self.current['steamids']['steam64']}" |
|
|
|
) |
|
|
|
|
|
|
|
#image set in call func |
|
|
|
|
|
|
|
#bans |
|
|
|
if self.current.get("ban", {}): |
|
|
|
value = f"Кто забанил: {self.current['ban']['banned_by']} | <@{self.current['ban']['admin_info']['discord_id']}>" |
|
|
|
if self.current['ban']['active'] == True: |
|
|
|
if self.current['ban']['ban_length'] == 0: |
|
|
|
value += "\nДанный бан навсегда!" |
|
|
|
else: |
|
|
|
value += f"\nДата разбана: {utime2human(self.current['ban']['ban_utime'] + self.current['ban']['ban_length_seconds'])}" |
|
|
|
|
|
|
|
embed.add_field( |
|
|
|
name=f"Причина: {self.current['ban']['ban_reason']}", |
|
|
|
value=value, inline=False) |
|
|
|
|
|
|
|
#ban history |
|
|
|
if "ban_list" in self.current and self.current["ban_list"]: |
|
|
|
embed.add_field( |
|
|
|
name="Был в бане", |
|
|
|
value=f"{len(self.current['ban_list'])} раз", |
|
|
|
inline=True) |
|
|
|
|
|
|
|
#report history |
|
|
|
if "reports" in self.current and self.current["reports"]: |
|
|
|
embed.add_field( |
|
|
|
name="Жаловались", |
|
|
|
value=f"{self.current.get('reports',{}).get('accepted', 0)} раз", |
|
|
|
inline=True |
|
|
|
) |
|
|
|
embed.add_field( |
|
|
|
name="Репортил", |
|
|
|
value=f"{self.current.get('reports',{}).get('created', 0)} раз", |
|
|
|
inline=True) |
|
|
|
|
|
|
|
#permitions |
|
|
|
if self.current.get("permition", {}): |
|
|
|
embed.add_field( |
|
|
|
name="Права на сервере", |
|
|
|
value=f"{self.current['permition']['status']}", |
|
|
|
inline=True |
|
|
|
) |
|
|
|
embed.add_field( |
|
|
|
name="Назначены", |
|
|
|
value=f"{utime2human(self.current['permition']['u_timestamp']) if self.current['permition']['u_timestamp'] != 0 else 'с момента создания'}", |
|
|
|
inline=True |
|
|
|
) |
|
|
|
if self.current['permition'].get('amount', 0) and self.current['permition'].get("u_timestamp", 0): |
|
|
|
embed.add_field( |
|
|
|
name="Заканчиваются", |
|
|
|
value=f"{utime2human(self.current['permition']['u_timestamp'] + self.current['permition']['amount'])}", |
|
|
|
inline=True |
|
|
|
) |
|
|
|
|
|
|
|
#attached discord account |
|
|
|
if self.current.get("attached_discords", []): |
|
|
|
message_head = "" |
|
|
|
message = "" |
|
|
|
for d in self.current.get("attached_discords", []): |
|
|
|
if d['active'] == 1: |
|
|
|
message_head += f"<@{d['discord_id']}> | {utime2human(d['utime'])}\n" |
|
|
|
else: |
|
|
|
message += f"<@{d['discord_id']}> | {utime2human(d['utime'])}\n" |
|
|
|
|
|
|
|
if message_head: |
|
|
|
embed.add_field(name="Привязаный аккаунт Discord:", value=message_head, inline=False) |
|
|
|
if message: |
|
|
|
embed.add_field(name="История аккаунта Discord:", value=message, inline=False) |
|
|
|
|
|
|
|
return embed |
|
|
|
|
|
|
|
@property |
|
|
|
def embed(self) -> Embed: |
|
|
|
print("METHOD IS DEPRICATED") |
|
|
|
if not self.current: |
|
|
|
raise NotLoadProfile |
|
|
|
# build header |
|
|
|
@ -137,8 +225,33 @@ class Player: |
|
|
|
embed.add_field(name="История аккаунта Discord:", value=message, inline=False) |
|
|
|
|
|
|
|
return embed |
|
|
|
|
|
|
|
@property |
|
|
|
def hasAnyConnect(self): |
|
|
|
return self.current and self.current.get("lastplay", {}) |
|
|
|
|
|
|
|
# return bytes or raise exception if error or not found server |
|
|
|
async def getGametimeViaImage(self): |
|
|
|
if os.getenv("CHARTJS_URL"): |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
filtered_servers = {} |
|
|
|
for srv_id, data in self.stats["servers"].items(): |
|
|
|
filtered_servers[srv_id] = {"name": data["name"]} |
|
|
|
|
|
|
|
payload = { |
|
|
|
"servers": filtered_servers, |
|
|
|
"utc": 3 * 3600,#not need, but why not |
|
|
|
"lastplay": self.current.get("lastplay", {}), |
|
|
|
"gametime": self.current.get("gametime", {}) |
|
|
|
} |
|
|
|
async with session.post(os.getenv("CHARTJS_URL") + f"/api/chart/{self.steam64}.png", json=payload) as response: |
|
|
|
return await response.read() |
|
|
|
else: |
|
|
|
print("chart js server env not found, put url in env to CHARTJS_URL") |
|
|
|
raise Exception("CHARTJS_URL is not setted") |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
print("METHOD IS DEPRICATED") |
|
|
|
if not self.current: |
|
|
|
raise NotLoadProfile |
|
|
|
|
|
|
|
|