Added a temperature display for weather. Currently can't show negative temps

This commit is contained in:
Remy Moll
2020-11-09 12:10:49 +01:00
parent b4ce9eadf9
commit f5499c144b
6 changed files with 70 additions and 39 deletions

View File

@@ -17,12 +17,16 @@ def show_weather(location):
categories = {"Clouds": ":cloud:", "Rain": ":cloud_with_rain:", "Thunderstorm": "thunder_cloud_rain", "Drizzle": ":droplet:", "Snow": ":cloud_snow:", "Clear": ":sun:", "Mist": "Mist", "Smoke": "Smoke", "Haze": "Haze", "Dust": "Dust", "Fog": "Fog", "Sand": "Sand", "Dust": "Dust", "Ash": "Ash", "Squall": "Squall", "Tornado": "Tornado",}
now = weather["current"]
message = "<b>Today:</b> " + categories[now["weather"][0]["main"]] + "\n"
message = "<b>Now:</b> " + categories[now["weather"][0]["main"]] + "\n"
message += ":thermometer: " + str(int(now["temp"])) + "°\n\n"
for i, day in enumerate(weather["daily"]):
message += "<b>" + days[(today + i + 1) % 7] + ":</b> " + categories[day["weather"][0]["main"]] + "\n"
weather_days = weather["daily"]
for i, day in enumerate(weather_days):
if i == 0:
message += "<b>" + "Today" + ":</b> " + categories[day["weather"][0]["main"]] + "\n"
else:
message += "<b>" + days[(today + i + 1) % 7] + ":</b> " + categories[day["weather"][0]["main"]] + "\n"
message += ":thermometer: :fast_down_button: " + str(int(day["temp"]["min"])) + "° , :thermometer: :fast_up_button: " + str(int(day["temp"]["max"])) + "°\n\n"
return message