Skip to content

Commit

Permalink
Fixing windows language
Browse files Browse the repository at this point in the history
  • Loading branch information
onewheelskyward committed Sep 23, 2020
1 parent 40b693e commit 372f87b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/lita/handlers/forecasts.rb
Expand Up @@ -564,6 +564,7 @@ def do_the_windows_thing(forecast, response)
window_close_temp = 0
high_temp = 0
last_temp = 0
output = ''

forecast['hourly']['data'].each_with_index do |hour, index|
if hour['temperature'] > high_temp
Expand All @@ -589,27 +590,27 @@ def do_the_windows_thing(forecast, response)

# Return some meta here and let the caller decide the text.
if time_to_close_the_windows.nil?
"Leave 'em open, no excess heat today(#{get_temperature high_temp})."
output = "Leave 'em open, no excess heat today(#{get_temperature high_temp})."
if high_temp <= 18 and high_temp > 15
"Open them up mid-day, high temp #{get_temperature high_temp}."
output = "Open them up mid-day, high temp #{get_temperature high_temp}."
elsif high_temp <= 18
"Best leave 'em shut, high temp #{get_temperature high_temp}."
output = "Best leave 'em shut, high temp #{get_temperature high_temp}."
end
else
# Todo: base timezone on requested location.
timezone = TZInfo::Timezone.get('America/Los_Angeles')
if time_to_close_the_windows == 'now'
output = "Close the windows now! It is #{get_temperature window_close_temp}. "
output = "Close the windows now! It is #{get_temperature window_close_temp}."
else
time_at = Time.at(time_to_close_the_windows).to_datetime
local_time = timezone.utc_to_local(time_at)
output = "Close the windows at #{local_time.strftime('%k:%M')}, it will be #{get_temperature window_close_temp}. "
output = "Close the windows at #{local_time.strftime('%k:%M')}, it will be #{get_temperature window_close_temp}."
end
if time_to_open_the_windows
open_time = timezone.utc_to_local(Time.at(time_to_open_the_windows).to_datetime)
output += "Open them back up at #{open_time.strftime('%H:%M')}. "
output += " Open them back up at #{open_time.strftime('%H:%M')}."
end
output += "The high today will be #{get_temperature high_temp}."
output += " The high today will be #{get_temperature high_temp}."
end

# Insert aqi check here
Expand All @@ -633,7 +634,7 @@ def do_the_windows_thing(forecast, response)
when 500..9999
aqi_desc = 'unbelievable.'
end
output = "Close the windows now! The AQI is #{stats[:v]}, #{aqi_desc}"
output = " Close the windows now! The AQI is #{stats[:v]}, #{aqi_desc}"
else
output += " Today's AQI is #{stats[:v].to_i}."
end
Expand Down

0 comments on commit 372f87b

Please sign in to comment.