diff --git a/commands.py b/commands.py index a2eb736..3301479 100644 --- a/commands.py +++ b/commands.py @@ -236,11 +236,18 @@ class Command: argsplit = cmd.split("?")[1].split() if "f" in argsplit or "u" in argsplit: mf = "u" # farenheit - a = __import__("http.client").client.HTTPSConnection("wttr.in") - x=__import__("urllib.parse").parse - y=x.urlsplit(f"https://wttr.in/{loc}?A&T&0&n&F&{mf}") - y=x.urlunsplit((y.scheme, y.netloc, x.quote(y.path), y.query, y.fragment)) - a=__import__("urllib.request").request.urlopen(y) - b=a.read().decode("utf-8") - mesg(b.split("\n")[0].strip()+" "+" ".join(b.split("\n")[3].strip().split(" ")[-2:])) + try: + a = __import__("http.client").client.HTTPSConnection("wttr.in") + x = __import__("urllib.parse").parse + y = x.urlsplit(f"https://wttr.in/{loc}?A&T&0&n&F&{mf}") + y = x.urlunsplit((y.scheme, y.netloc, x.quote(y.path), y.query, y.fragment)) + a = __import__("urllib.request").request.urlopen(y) + b = a.read().decode("utf-8") + mesg( + b.split("\n")[0].strip() + + " " + + " ".join(b.split("\n")[3].strip().split(" ")[-2:]) + ) + except Exception as e: + mesg(f"{type(e).__name__} was raised: {e}") # mesg(cmd.split(" ", 1)[1])