diff --git a/player.py b/player.py index 9bb038a..3da5fea 100644 --- a/player.py +++ b/player.py @@ -70,26 +70,36 @@ class Player: url=self.current["steamids"]["community_url"]) # set image embed.set_thumbnail(url = self.current["steam_data"]["avatar"]) - # Последняя игра на сервере - if self.current.get("lastplay", {}): - message = "" + + #Последняя игра и игровое время + self.lastplayAndGametime = {} + if "lastplay" in self.current and self.current["lastplay"]: for maps in self.current["lastplay"].values(): for map_name, last_play in maps.items(): - message += f"{workshopmap2bsp(map_name)} - {utime2human(last_play)}\n" - embed.add_field(name="Последняя игра на серверах", value=message, inline=False) - # Игрокое время - if self.current.get("gametime", {}): - message = "" + if not workshopmap2bsp(map_name) in self.lastplayAndGametime: + self.lastplayAndGametime[workshopmap2bsp(map_name)] = {"total":0, "lastplay":0} + self.lastplayAndGametime[workshopmap2bsp(map_name)]['lastplay'] = last_play + + if "gametime" in self.current and self.current["gametime"]: for maps in self.current["gametime"].values(): for map_name, play_time in maps.items(): - message += f"{workshopmap2bsp(map_name)} - {human_TIME(play_time)}\n" - embed.add_field(name="Статистика по картам", value=message, inline=False) + if not workshopmap2bsp(map_name) in self.lastplayAndGametime: + self.lastplayAndGametime[workshopmap2bsp(map_name)] = {"total":0, "lastplay":0} + self.lastplayAndGametime[workshopmap2bsp(map_name)]["total"] = play_time + + if len(list(self.lastplayAndGametime.keys())) > 0: + message = "" + for map_name, values in self.lastplayAndGametime.items(): + message += f"{map_name}\n{human_TIME(values['total']) if values['total'] > 0 else 'Не играл'} / {utime2human(values['lastplay']) if values['lastplay'] > 0 else 'Не играл'}\n" + embed.add_field(name="Статистика игры", values=message, inline=False) + # Права if self.current.get("permition", {}): message = f"{self.current['permition']['status']} назначен {utime2human(self.current['permition']['u_timestamp']) if self.current['permition']['u_timestamp'] != 0 else 'с момента создания'}\n" if self.current['permition'].get('amount', 0) and self.current['permition'].get("u_timestamp", 0): message += f"окончание после {utime2human(self.current['permition']['u_timestamp'] + self.current['permition']['amount'])}\n" embed.add_field(name="Права на серверах", value=message, inline=False) + # Бан if self.current.get("ban", {}): message = f"Ник: {self.current['ban']['player_name']}\n" @@ -102,6 +112,15 @@ class Player: else: message += f"Дата разбана: {utime2human(self.current['ban']['ban_utime'] + self.current['ban']['ban_length_seconds'])}\n" embed.add_field(name="Имеется бан на сервере", value=message, inline=False) + + #Количество в бане + if "ban_list" in self.current and self.current["ban_list"]: + embed.add_field(name="Был в бане", value=f"{len(self.current['ban_list'])} раз", inline=False) + + #Репорты + if "reports" in self.current and self.current["reports"]: + embed.add_field(name="Репорты", value=f"Отправлено: {self.current.get('reports',{}).get('created', 0)}\nЖаловались {self.current.get('reports',{}).get('accepted', 0)} раз") + #Привязаные профили ранее if self.current.get("attached_discords", []): message_head = "" @@ -138,17 +157,17 @@ class Player: self.lastplayAndGametime[workshopmap2bsp(map_name)]['lastplay'] = last_play if "gametime" in self.current and self.current["gametime"]: - message += "Статистика по картам:\n" for maps in self.current["gametime"].values(): for map_name, play_time in maps.items(): if not workshopmap2bsp(map_name) in self.lastplayAndGametime: self.lastplayAndGametime[workshopmap2bsp(map_name)] = {"total":0, "lastplay":0} self.lastplayAndGametime[workshopmap2bsp(map_name)]["total"] = play_time - + if len(list(self.lastplayAndGametime.keys())) > 0: message += "Статистика игры:\n" for map_name, values in self.lastplayAndGametime.items(): - message += f"{map_name}\n{human_TIME(values['total']) if values['total'] > 0 else 'Не играл'} / {utime2human(values['lastplay']) if values['lastplay'] > 0 else 'Не играл'}\n\n" + message += f"{map_name}\n{human_TIME(values['total']) if values['total'] > 0 else 'Не играл'} / {utime2human(values['lastplay']) if values['lastplay'] > 0 else 'Не играл'}\n" + message += "\n" #Далее идут проверка прав if "permition" in self.current and self.current["permition"]: