From 7e825f736390757fa8d987e6c14dc0872ea2f237 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Mon, 8 Jun 2015 21:30:07 +0200 Subject: [PATCH] weather plugin works now --- plugins/weather.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/plugins/weather.lua b/plugins/weather.lua index 2a669df..ce7ef8a 100644 --- a/plugins/weather.lua +++ b/plugins/weather.lua @@ -2,7 +2,6 @@ do local BASE_URL = "http://api.openweathermap.org/data/2.5/weather" - local function get_weather(location) print("Finde Wetter in ", location) local url = BASE_URL @@ -15,23 +14,22 @@ local function get_weather(location) local weather = json:decode(b) local city = weather.name local country = weather.sys.country - local dot_temperature = round(weather.main.temp, 2) - local temperature = string.gsub(dot_temperature, "%.", "%,") local temp = 'Die Temperatur in '..city ..' (' ..country..')' - ..' beträgt '..temperature..'°C' + ..' beträgt '..weather.main.temp..'°C' local conditions = 'Die aktuelle Wetterlage ist: ' .. weather.weather[1].description - + if weather.weather[1].main == 'Clear' then - conditions = conditions .. ' ☀' + conditions = conditions .. ' ☀' elseif weather.weather[1].main == 'Clouds' then - conditions = conditions .. ' ☁☁' + conditions = conditions .. ' ☁☁' elseif weather.weather[1].main == 'Rain' then conditions = conditions .. ' ☔' elseif weather.weather[1].main == 'Thunderstorm' then - conditions = conditions .. ' ☔☔☔☔' + conditions = conditions .. ' ☔☔☔☔' end + return temp .. '\n' .. conditions end @@ -43,7 +41,7 @@ local function run(msg, matches) end local text = get_weather(city) if not text then - text = 'Konnte das Wetter von dieser Stadt nicht bekommen.' + text = 'Konnte das Wetter dieser Stadt nicht bekommen.' end return text end