Merge branch 'weather' into 'master'
Weather See merge request ldooks/dragon-bot!47
This commit is contained in:
commit
1cd1a148f4
@ -23,10 +23,9 @@ def get_weather(message):
|
||||
"""
|
||||
get_weather(location)
|
||||
|
||||
Returns the weather forecast for the selected location. Uses PythonOWM to
|
||||
make life super easy.
|
||||
Returns the weather forecast for the selected location. Uses PythonOWM.
|
||||
|
||||
TODO: Replace basic code block with nice looking, bold text w/ emojis
|
||||
TODO: Create a list of weather preferences - rain > sun, snow > rain, etc.
|
||||
"""
|
||||
try:
|
||||
forecaster = openweathermap.three_hours_forecast(message)
|
||||
@ -36,11 +35,12 @@ def get_weather(message):
|
||||
location = forecast.get_location().get_name()
|
||||
indicator = int(reg.get_reference_time(timeformat='iso')[11:13]) // 3
|
||||
|
||||
curr_stat = '{}{}{}{}{}'.format(' \n***Status in ', location, ':*** *',
|
||||
reg.get_detailed_status().title(), '*\n')
|
||||
curr_temp = '{}{}{}'.format('**Current Temperature:** *',
|
||||
str(reg.get_temperature('fahrenheit').get('temp')),
|
||||
'F*\n\n__**3 day forecast:**__\n')
|
||||
curr_stat = ' \n***Status in {}:*** *{}* {}\n'.format(
|
||||
location,
|
||||
reg.get_detailed_status().title(),
|
||||
emojis[reg.get_detailed_status()])
|
||||
curr_temp = '**Currently:** *{}F*\n\n__**3 day forecast:**__\n'.format(
|
||||
str(reg.get_temperature('fahrenheit').get('temp')))
|
||||
forecast_str = '{}{}'.format(curr_stat, curr_temp)
|
||||
|
||||
ind = 0
|
||||
@ -55,18 +55,21 @@ def get_weather(message):
|
||||
temps = day.get_temperature('fahrenheit')
|
||||
h = temps.get('temp_max')
|
||||
l = temps.get('temp_min')
|
||||
print(forecast.get(i + j).get_detailed_status())
|
||||
# print(forecast.get(i + j).get_detailed_status())
|
||||
if high < h:
|
||||
high = h
|
||||
if low > l:
|
||||
low = l
|
||||
|
||||
day = '{}{}{}'.format('***', days_from_ind.get(ind), '***\n')
|
||||
weather_stat = '{}{}{}{}{}'.format('**Status:** *',
|
||||
day = '***{}***\n'.format(
|
||||
days_from_ind.get(ind))
|
||||
weather_stat = '**Status:** *{}* {}\n'.format(
|
||||
forecast.get(i).get_detailed_status().title(),
|
||||
'* ', emojis.get(forecast.get(i).get_detailed_status()), '\n')
|
||||
high_temp = '{}{}{}'.format('**High:** *', str(high), 'F*\n')
|
||||
low_temp = '{}{}{}'.format('**Low:** *', str(low), 'F*\n\n')
|
||||
emojis[forecast.get(i).get_detailed_status()])
|
||||
high_temp = '**High:** *{}F*\n'.format(
|
||||
str(high))
|
||||
low_temp = '**Low:** *{}F*\n\n'.format(
|
||||
str(low))
|
||||
forecast_str = '{}{}{}{}{}'.format(
|
||||
forecast_str, day, weather_stat, high_temp, low_temp)
|
||||
ind += 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user