Skip to content

Commit

Permalink
!asciisun
Browse files Browse the repository at this point in the history
  • Loading branch information
onewheelskyward committed Nov 20, 2015
1 parent c0617af commit 75362f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/lita/handlers/forecasts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def do_the_wind_direction_thing(forecast, wind_arrows, hours = 48)
return str, data_points
end

def do_the_sun_thing(forecast)
def do_the_sun_thing(forecast, chars)
key = 'cloudCover'
data_points = []
data = forecast['daily']['data']
Expand All @@ -178,7 +178,7 @@ def do_the_sun_thing(forecast)

differential = data_points.max - data_points.min

str = get_dot_str(ansi_chars, data, data_points.min, differential, key)
str = get_dot_str(chars, data, data_points.min, differential, key)

if config.colors
str = get_colored_string(data, key, str, get_sun_range_colors)
Expand Down
10 changes: 8 additions & 2 deletions lib/lita/handlers/irc_handlers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def handle_irc_all_the_things(response)
response.reply location.location_name + ' ' + ansi_rain_intensity_forecast(forecast)
response.reply location.location_name + ' ' + ansi_temp_forecast(forecast)
response.reply location.location_name + ' ' + ansi_wind_direction_forecast(forecast)
response.reply location.location_name + ' ' + do_the_sun_thing(forecast)
response.reply location.location_name + ' ' + do_the_sun_thing(forecast, ansi_chars)
response.reply location.location_name + ' ' + do_the_cloud_thing(forecast, ansi_chars)
response.reply location.location_name + ' ' + do_the_daily_rain_thing(forecast)
end
Expand Down Expand Up @@ -84,7 +84,13 @@ def handle_irc_alerts(response)
def handle_irc_ansisun(response)
location = geo_lookup(response.user, response.match_data[1])
forecast = get_forecast_io_results(response.user, location)
response.reply location.location_name + ' ' + do_the_sun_thing(forecast)
response.reply location.location_name + ' ' + do_the_sun_thing(forecast, ansi_chars)
end

def handle_irc_asciisun(response)
location = geo_lookup(response.user, response.match_data[1])
forecast = get_forecast_io_results(response.user, location)
response.reply location.location_name + ' ' + do_the_sun_thing(forecast, ascii_chars)
end

def handle_irc_ansicloud(response)
Expand Down
3 changes: 3 additions & 0 deletions lib/lita/handlers/onewheel_forecast_io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class OnewheelForecastIo < Handler
route(/^ansisun\s*$/i, :handle_irc_ansisun)
route(/^ansisun\s+(.+)/i, :handle_irc_ansisun,
help: { '!ansisun [location]' => '7 day chance-of-sun report for [location].'})
route(/^asciisun\s*$/i, :handle_irc_asciisun)
route(/^asciisun\s+(.+)/i, :handle_irc_asciisun,
help: { '!asciisun [location]' => '7 day chance-of-sun report for [location].'})

# Mun!

Expand Down

0 comments on commit 75362f1

Please sign in to comment.