From 75362f14c4ba4cdebd01c45c7b0983b34a9cc24c Mon Sep 17 00:00:00 2001 From: Andrew Kreps Date: Fri, 20 Nov 2015 10:50:49 -0800 Subject: [PATCH] !asciisun --- lib/lita/handlers/forecasts.rb | 4 ++-- lib/lita/handlers/irc_handlers.rb | 10 ++++++++-- lib/lita/handlers/onewheel_forecast_io.rb | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/lita/handlers/forecasts.rb b/lib/lita/handlers/forecasts.rb index 0b165c5..70e97c2 100644 --- a/lib/lita/handlers/forecasts.rb +++ b/lib/lita/handlers/forecasts.rb @@ -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'] @@ -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) diff --git a/lib/lita/handlers/irc_handlers.rb b/lib/lita/handlers/irc_handlers.rb index f382c4e..cc8eca2 100644 --- a/lib/lita/handlers/irc_handlers.rb +++ b/lib/lita/handlers/irc_handlers.rb @@ -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 @@ -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) diff --git a/lib/lita/handlers/onewheel_forecast_io.rb b/lib/lita/handlers/onewheel_forecast_io.rb index 6644d66..2636513 100644 --- a/lib/lita/handlers/onewheel_forecast_io.rb +++ b/lib/lita/handlers/onewheel_forecast_io.rb @@ -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!