mcstatus catches errors
This commit is contained in:
parent
9112fed2f6
commit
50e575752d
1 changed files with 6 additions and 2 deletions
|
@ -45,9 +45,13 @@ def mclogin(inp, bot=None):
|
|||
@hook.command(autohelp=False)
|
||||
def mcstatus(inp, say=None):
|
||||
"mcstatus -- Checks the status various Mojang servers."
|
||||
request = http.get("http://status.mojang.com/check")
|
||||
|
||||
# make the shitty json less shitty, cbf parsing it normally
|
||||
try:
|
||||
request = http.get("http://status.mojang.com/check")
|
||||
except (http.URLError, http.HTTPError) as e:
|
||||
return "Unable to get minecraft server status: %s" % e
|
||||
|
||||
# change the json from a list of dictionaies to a dictionary
|
||||
data = json.loads(request.replace("}", "").replace("{", "").replace("]", "}").replace("[", "{"))
|
||||
|
||||
out = []
|
||||
|
|
Reference in a new issue