added crude weather command and youtube module handles livestream timestamps

This commit is contained in:
jan6 2022-02-07 05:55:19 +02:00
parent 5f78254e63
commit 956e4290cd
2 changed files with 19 additions and 0 deletions

View File

@ -98,6 +98,8 @@ class Command:
command = "help"
elif cmd.startswith("echo "):
command = "echo"
elif cmd.startswith("w ") or cmd.startswith("weather "):
command = "weather"
elif cmd.startswith("me "):
command = "me"
elif cmd == "dbg" or cmd.startswith("dbg "):
@ -222,3 +224,19 @@ class Command:
mesg(f'no help available for "{topic}"...')
except Exception as e:
mesg(str(e.__class__) + " " + str(e))
@cmd
def weather(self, prefix, cmd, pm, line, admin, mesg):
"""crude weather command"""
cmd=" ".join(cmd.split(" ", 1)[1:])
loc=cmd.split("?")[0].strip()
mf="m" #celsius by default
if(len(cmd.split("?"))>=2):
argsplit=cmd.split("?")[1].split()
if "f" in argsplit or "u" in argsplit: mf="u" #farenheit
a=__import__("http.client").client.HTTPSConnection("wttr.in")
a.request("GET",f"/{loc}?A&T&0&n&F&{mf}")
b=a.getresponse().read().decode("utf-8")
mesg(" ".join(b.split("\n")[3].strip().split(" ")[-2:]))
#mesg(cmd.split(" ", 1)[1])

View File

@ -29,6 +29,7 @@ class YouTube:
h = m // 60
m = round((m / 60 - h) * 60)
return f"{h}h {m}m {s}s"
elif h==0 and m==0 and s==0: return "LIVE"
else:
return f"{m}m {s}s"