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

check for raw["description"]["text"] for mc servers >= 1.9 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
9 changes: 7 additions & 2 deletions mcstatus/pinger.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,13 @@ 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"])
if "text" not in raw["description"]:

Choose a reason for hiding this comment

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

Wouldn't this attempt to subscript the value if raw["description"] was a string that contained the word "text"? I think an explicit type check may be safer in this case

self.description = raw["description"]
else:
self.description = raw["description"]["text"]

self.description_clean = re.sub(r'\u00A7.', '', self.description)


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