forked from Decentrala/chatbot
Dodao funkciju za vreme
Upotreba: !vreme <ime_grada> - koristi wttr.in api - vraca liniju jednu, lakse je nego da se parsira json - reaguje i na prognoza
This commit is contained in:
parent
5382b876e2
commit
63044c545f
@ -27,4 +27,7 @@ def command(msg, rcpt):
|
|||||||
elif msg.startswith("!tasks"):
|
elif msg.startswith("!tasks"):
|
||||||
content = sf.getDmzTasks("https://todo.dmz.rs/")
|
content = sf.getDmzTasks("https://todo.dmz.rs/")
|
||||||
return content
|
return content
|
||||||
|
elif msg.startswith("!vreme") or msg.startswith("!prognoza"):
|
||||||
|
_, query = msg.split(" ", 1)
|
||||||
|
content = sf.get_weather(query)
|
||||||
|
|
||||||
|
@ -48,3 +48,8 @@ def getDmzTasks(url):
|
|||||||
return result
|
return result
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return e
|
return e
|
||||||
|
|
||||||
|
def get_weather(city:str) -> str:
|
||||||
|
url = f"https://wttr.in/{city}?format=3"
|
||||||
|
resp = requests.get(url)
|
||||||
|
return resp.content.decode("utf-8").strip()
|
||||||
|
Loading…
Reference in New Issue
Block a user