mirror of
https://github.com/Dinnerbone/mcstatus.git
synced 2026-04-05 11:31:23 +08:00
Fix typing error and small rename
This commit is contained in:
@@ -136,11 +136,12 @@ class QueryResponse:
|
||||
|
||||
while True:
|
||||
key = response.read_ascii()
|
||||
if key == "hostname":
|
||||
name = re.search(b"(.*)\x00gametype", response.received, flags=re.DOTALL).group(1)
|
||||
# Since the query protocol does not properly support unicode, the hostname is still not resolved
|
||||
if key == "hostname": # hostname is actually motd in the query protocol
|
||||
match = re.search(b"(.*)\x00gametype", response.received, flags=re.DOTALL)
|
||||
motd = match.group(1) if match else ""
|
||||
# Since the query protocol does not properly support unicode, the motd is still not resolved
|
||||
# correctly; however, this will avoid other parameter parsing errors.
|
||||
data[key] = response.read(len(name)).decode("ISO-8859-1")
|
||||
data[key] = response.read(len(motd)).decode("ISO-8859-1")
|
||||
response.read(1) # ignore null byte
|
||||
elif len(key) == 0:
|
||||
response.read(1)
|
||||
@@ -152,9 +153,9 @@ class QueryResponse:
|
||||
response.read(len("player_") + 1 + 1)
|
||||
|
||||
while True:
|
||||
name = response.read_ascii()
|
||||
if len(name) == 0:
|
||||
motd = response.read_ascii()
|
||||
if len(motd) == 0:
|
||||
break
|
||||
players.append(name)
|
||||
players.append(motd)
|
||||
|
||||
return cls(data, players)
|
||||
|
||||
Reference in New Issue
Block a user