-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathweather.py
36 lines (32 loc) · 871 Bytes
/
weather.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import discord
color = 0x0099ff
key_features = {
'temp' : 'Temperature',
'feels_like' : 'Feels Like',
'temp_min' : 'Minimum Temperature',
'temp_max' : 'Maximum Temperature'
}
def parse_data(data):
del data['humidity']
del data['pressure']
return data
def weather_message(data, location):
location = location.title()
message = discord.Embed(
title=f'Weather in {location}',
color=color
)
for key in data:
message.add_field(
name=key_features[key],
value=str(data[key]),
inline=False
)
return message
def error_message(location):
location = location.title()
return discord.Embed(
title='Error',
description=f'There was an error retrieving weather data for {location}',
color=color
)