From 50e575752d86fe96010e16f0be2b72e40641fcd6 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 6 Sep 2012 07:16:56 +1200 Subject: [PATCH] mcstatus catches errors --- plugins/mctools.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/mctools.py b/plugins/mctools.py index 3ac3eb1..87412f7 100755 --- a/plugins/mctools.py +++ b/plugins/mctools.py @@ -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 = []