forked from Decentrala/chatbot
Dorada za vreme funckiju
- samo slova smeju u ime grada - dodao i englesku verziju `!weather`
This commit is contained in:
parent
63044c545f
commit
328329eb9a
@ -16,6 +16,7 @@ def command(msg, rcpt):
|
||||
response += "!ai [message] Ask llama2" + "\n"
|
||||
response += "!wiki [message] Ask wiki\n"
|
||||
response += "!tasks Show active tasks from the taskmanager\n"
|
||||
response += "!vreme [city] | !prognoza [city] | !weather [city] Show weather for [city]\n"
|
||||
return response
|
||||
elif msg.startswith("!ai"):
|
||||
client = ollama.Client(host='https://ollama.krov.dmz.rs')
|
||||
@ -27,7 +28,7 @@ def command(msg, rcpt):
|
||||
elif msg.startswith("!tasks"):
|
||||
content = sf.getDmzTasks("https://todo.dmz.rs/")
|
||||
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)
|
||||
content = sf.get_weather(query)
|
||||
return sf.get_weather(query)
|
||||
|
||||
|
@ -51,5 +51,7 @@ def getDmzTasks(url):
|
||||
|
||||
def get_weather(city:str) -> str:
|
||||
url = f"https://wttr.in/{city}?format=3"
|
||||
if not city.isalpha():
|
||||
return "no such city"
|
||||
resp = requests.get(url)
|
||||
return resp.content.decode("utf-8").strip()
|
||||
|
Loading…
Reference in New Issue
Block a user