mirror of
https://github.com/aclist/dztui.git
synced 2026-08-28 10:47:15 +02:00
feat: parse server details
This commit is contained in:
parent
acc356d3a0
commit
51308e788e
@ -206,6 +206,19 @@ class Details:
|
||||
success: bool
|
||||
|
||||
|
||||
def is_passworded(ip: str, qport: int) -> bool:
|
||||
try:
|
||||
info = a2s.info((ip, qport))
|
||||
except TimeoutError:
|
||||
return False
|
||||
|
||||
try:
|
||||
password = info.password_protected
|
||||
except AttributeError:
|
||||
return False
|
||||
return password
|
||||
|
||||
|
||||
def details(ip: str, qport: int) -> Details:
|
||||
default_str = "None provided"
|
||||
|
||||
@ -237,6 +250,29 @@ def details(ip: str, qport: int) -> Details:
|
||||
night_accel = float(keyword.lstrip("entm"))
|
||||
night_accel = f"{night_accel:g}"
|
||||
|
||||
try:
|
||||
password = info.password_protected
|
||||
if password is False:
|
||||
password = "Disabled"
|
||||
else:
|
||||
password = "Enabled"
|
||||
except AttributeError:
|
||||
password = "-"
|
||||
|
||||
try:
|
||||
vac = info.vac_enabled
|
||||
if vac is False:
|
||||
vac = "Disabled"
|
||||
else:
|
||||
vac = "Enabled"
|
||||
except AttributeError:
|
||||
vac = "-"
|
||||
|
||||
try:
|
||||
version = info.version
|
||||
except AttributeError:
|
||||
version = "-"
|
||||
|
||||
try:
|
||||
dlc = rules.dlc_flags
|
||||
if dlc == 0:
|
||||
@ -263,11 +299,14 @@ def details(ip: str, qport: int) -> Details:
|
||||
description = default_str
|
||||
|
||||
rows = [
|
||||
["DLC", dlc],
|
||||
["Battleye", battleye],
|
||||
["Daytime acceleration", f"{day_accel}x"],
|
||||
["DLC", dlc],
|
||||
["Night-time acceleration", f"{night_accel}x"],
|
||||
["Password", password],
|
||||
["Platform", platform],
|
||||
["Valve Anti-Cheat", vac],
|
||||
["Version", version],
|
||||
]
|
||||
|
||||
return Details(rows, description, True)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user