@@ -70,22 +70,37 @@ def get_conditions(self, query, channel):
70
70
"Encountered an error contacting the OpenWeatherMap API" )
71
71
return
72
72
weather = r .json ()
73
- #print(weather)
73
+ # print(weather)
74
74
try :
75
75
# grab the relevant data we want for formatting
76
76
location = weather ['name' ]
77
77
conditions = weather ['weather' ][0 ]['main' ]
78
+
79
+ if conditions == "Clear" :
80
+ icon = '\N{sun} '
81
+ elif conditions == "Rain" or conditions == "Drizzle" :
82
+ icon = '\N{cloud with rain} '
83
+ elif conditions == "Thunderstorm" :
84
+ icon = '\N{cloud with lightning} '
85
+ elif conditions == "Clouds" :
86
+ icon = '\N{cloud} '
87
+ elif conditions == "Snow" :
88
+ icon = '\N{cloud with snow} '
89
+ else :
90
+ icon = '\N{fire} '
91
+
78
92
temp_f = round (weather ['main' ]['temp' ], 1 )
79
93
temp_c = round ((temp_f - 32 ) * (5.0 / 9.0 ), 1 )
80
- #sky = weather['weather'][0]['main']
81
- #print(sky)
94
+ # sky = weather['weather'][0]['main']
95
+ # print(sky)
82
96
except KeyError :
83
97
self .say (
84
98
channel ,
85
99
"Unable to get weather data from results. Sorry." )
86
100
return
87
101
# return the formatted string of weather data
88
- return location + ': ' + conditions + ', ' + \
102
+ # return location + ': ' + conditions + " 🌧️ " + ', ' + \
103
+ return location + ': ' + conditions + ' ' + icon + ', ' + \
89
104
str (temp_f ) + '°F (' + str (temp_c ) + '°C)'
90
105
91
106
def handle (self , event ):
0 commit comments