fixed weather crashing when 404
This commit is contained in:
parent
27c0073d2a
commit
7d48fa6889
21
commands.py
21
commands.py
|
@ -236,11 +236,18 @@ class Command:
|
||||||
argsplit = cmd.split("?")[1].split()
|
argsplit = cmd.split("?")[1].split()
|
||||||
if "f" in argsplit or "u" in argsplit:
|
if "f" in argsplit or "u" in argsplit:
|
||||||
mf = "u" # farenheit
|
mf = "u" # farenheit
|
||||||
a = __import__("http.client").client.HTTPSConnection("wttr.in")
|
try:
|
||||||
x=__import__("urllib.parse").parse
|
a = __import__("http.client").client.HTTPSConnection("wttr.in")
|
||||||
y=x.urlsplit(f"https://wttr.in/{loc}?A&T&0&n&F&{mf}")
|
x = __import__("urllib.parse").parse
|
||||||
y=x.urlunsplit((y.scheme, y.netloc, x.quote(y.path), y.query, y.fragment))
|
y = x.urlsplit(f"https://wttr.in/{loc}?A&T&0&n&F&{mf}")
|
||||||
a=__import__("urllib.request").request.urlopen(y)
|
y = x.urlunsplit((y.scheme, y.netloc, x.quote(y.path), y.query, y.fragment))
|
||||||
b=a.read().decode("utf-8")
|
a = __import__("urllib.request").request.urlopen(y)
|
||||||
mesg(b.split("\n")[0].strip()+" "+" ".join(b.split("\n")[3].strip().split(" ")[-2:]))
|
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])
|
# mesg(cmd.split(" ", 1)[1])
|
||||||
|
|
Loading…
Reference in New Issue