diff --git a/functions.py b/functions.py index 1b3465a..6d5a17b 100644 --- a/functions.py +++ b/functions.py @@ -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) diff --git a/scraper_functions.py b/scraper_functions.py index cd70c39..467dacc 100644 --- a/scraper_functions.py +++ b/scraper_functions.py @@ -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()