Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed incorrect description type #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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:

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

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