-
Notifications
You must be signed in to change notification settings - Fork 0
/
weather.py
41 lines (34 loc) · 974 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
37
38
39
40
41
import discord
color = 0x2F7FCC
keyFeatures = {
'temp': 'Temperature in Celsius',
'feels_like': 'Feels like',
'temp_min': 'Minimum Temperature',
'temp_max': 'Maximum Temperature'
}
def parseData(data):
data = data['main']
del data['humidity']
del data['pressure']
return data
def weatherMessage(data, location):
location = location.title()
message = discord.Embed(
title=f'{location} Weather',
description=f'Here is the weather data for {location}.',
color=color
)
for key in data:
message.add_field(
name=keyFeatures[key],
value=str(data[key]),
inline=False
)
return message
def errorMessage(location):
location = location.title()
return discord.Embed(
title='Error!',
description=f'There was an error retrieving weather data for {location}. Please input w.[location] to perform query.',
color=color
)