import asyncio
import html
import a2s
async def main() -> None:
input_server_ip: str = input("Server IP: ")
input_server_port: int = int(input("Server Port: "))
try:
result = await a2s.ainfo((input_server_ip, input_server_port))
result_players = await a2s.aplayers((input_server_ip, input_server_port))
result_message = f"Сервер - {result.server_name}\n" \
f"Карта - {result.map_name}\n" \
f"Количество игроков - {result.player_count}\n" \
f"Максимум игроков - {result.max_players}\n" \
f"Количество ботов - {result.bot_count}\n"
for idx, player in enumerate(result_players):
result_message += f"{idx + 1} | {html.escape(s=player.name, quote=True)} | {player.duration} | {player.score}"
print(result_message)
except Exception as e:
print(f"Ошибка при получении данных - {e}")
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
pass