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:
|
while True:
|
||||||
key = response.read_ascii()
|
key = response.read_ascii()
|
||||||
if key == "hostname":
|
if key == "hostname": # hostname is actually motd in the query protocol
|
||||||
name = re.search(b"(.*)\x00gametype", response.received, flags=re.DOTALL).group(1)
|
match = re.search(b"(.*)\x00gametype", response.received, flags=re.DOTALL)
|
||||||
# Since the query protocol does not properly support unicode, the hostname is still not resolved
|
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.
|
# 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
|
response.read(1) # ignore null byte
|
||||||
elif len(key) == 0:
|
elif len(key) == 0:
|
||||||
response.read(1)
|
response.read(1)
|
||||||
@@ -152,9 +153,9 @@ class QueryResponse:
|
|||||||
response.read(len("player_") + 1 + 1)
|
response.read(len("player_") + 1 + 1)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
name = response.read_ascii()
|
motd = response.read_ascii()
|
||||||
if len(name) == 0:
|
if len(motd) == 0:
|
||||||
break
|
break
|
||||||
players.append(name)
|
players.append(motd)
|
||||||
|
|
||||||
return cls(data, players)
|
return cls(data, players)
|
||||||
|
|||||||
Reference in New Issue
Block a user