You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

50 lines
1.1 KiB

from pydantic import BaseModel
from steam.steamid import SteamID
import re
class BotPlayer(Exception):
pass
def GetSteam(steamid):
steam_obj = SteamID(steamid)
return {
"steam3":steam_obj.as_steam3,
"steam2":steam_obj.as_steam2_zero,
"steam64":steam_obj.as_64,
"account_id":steam_obj.as_32,
"community_url":steam_obj.community_url
}
class RCONPlayer:
#DefaultPlayer
name: str
score: int
id: int = 0
steam: dict
#RCONPlayer
duration: str
ip: str
loss: int
ping: int
state: str
#Backcomp
steam2: str = ""
def __init__(self, status_line:str):
splited = re.split(r"\s+", status_line)
len = splited.__len__()
try:
self.id = int(splited[1])
self.ip = splited[len - 1]
self.state = splited[len - 2]
if self.state == "BOT":
raise BotPlayer()
self.loss = int(splited[len - 3])
self.ping = int(splited[len - 4])
self.duration = splited[len - 5]
self.steam2 = splited[len - 6]
self.name = " ".join(splited[2:len-6])[1:-1]
self.steam = GetSteam(self.steam2)
except ValueError as err:
print(splited)
raise err