Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions mcstatus/pinger.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,18 @@ def __init__(self, raw):

if "description" not in raw:
raise ValueError("Invalid status object (no 'description' value)")
self.description = raw["description"]
self.description_clean = re.sub(r'\u00A7.', '', raw["description"])
# for newer versions of minecraft

if type(raw["description"]) is str:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to isinstance() checks may be better, and using string_types instead of str would be more version compatible

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also fix the build errors

self.description = raw["description"]
self.description_clean = re.sub(r'\u00A7.', '', raw["description"])

elif type(raw["description"]) is dict:
self.description = raw["description"]["text"]
self.description_clean = re.sub(r'\u00A7.', '', raw["description"]["text"])

else:
raise ValueError("Invalid status object (unknown 'description' type)")

if "favicon" in raw:
self.favicon = raw["favicon"]
Expand Down