Dorada za vreme funckiju

- samo slova smeju u ime grada
- dodao i englesku verziju `!weather`
This commit is contained in:
svitvojimilioni 2024-02-07 17:47:36 -05:00
parent 63044c545f
commit 328329eb9a
2 changed files with 5 additions and 2 deletions

View File

@ -16,6 +16,7 @@ def command(msg, rcpt):
response += "!ai [message] Ask llama2" + "\n" response += "!ai [message] Ask llama2" + "\n"
response += "!wiki [message] Ask wiki\n" response += "!wiki [message] Ask wiki\n"
response += "!tasks Show active tasks from the taskmanager\n" response += "!tasks Show active tasks from the taskmanager\n"
response += "!vreme [city] | !prognoza [city] | !weather [city] Show weather for [city]\n"
return response return response
elif msg.startswith("!ai"): elif msg.startswith("!ai"):
client = ollama.Client(host='https://ollama.krov.dmz.rs') client = ollama.Client(host='https://ollama.krov.dmz.rs')
@ -27,7 +28,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"): elif msg.startswith("!vreme") or msg.startswith("!prognoza") or msg.startswith("!weather"):
_, query = msg.split(" ", 1) _, query = msg.split(" ", 1)
content = sf.get_weather(query) return sf.get_weather(query)

View File

@ -51,5 +51,7 @@ def getDmzTasks(url):
def get_weather(city:str) -> str: def get_weather(city:str) -> str:
url = f"https://wttr.in/{city}?format=3" url = f"https://wttr.in/{city}?format=3"
if not city.isalpha():
return "no such city"
resp = requests.get(url) resp = requests.get(url)
return resp.content.decode("utf-8").strip() return resp.content.decode("utf-8").strip()