-
Notifications
You must be signed in to change notification settings - Fork 0
/
weather.py
33 lines (26 loc) · 842 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
import discord
key_features = {
'temp': 'Temperature',
'feels_like': 'Feels Like',
'temp_min': 'Low',
'temp_max': 'High'
}
def parse_data(data):
data = data['main']
del data['pressure']
del data['humidity']
return data
def weather_message(data, location):
location = location.title()
message = discord.Embed(
title=f'{location} Weather',
description=f'Here is the weather data for {location}.',
color=0x4F5D73 # navyblue
)
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=0xDB2323)