Skip to content

Commit

Permalink
!asciicloud, fixes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
onewheelskyward committed Nov 20, 2015
1 parent 5c25948 commit 56daf06
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This Lita handler takes location-based queries and returns interesting data abou
Add lita-onewheel-forecast-io to your Lita instance's Gemfile, from github since it's currently unpublished:

``` ruby
gem 'lita-onewheel-forecast-io', github: 'onewheelskyward/lita-onewheel-forecast-io', branch: :master
gem 'lita-onewheel-forecast-io', '~> 0.0'
```

## Configuration
Expand Down
4 changes: 2 additions & 2 deletions lib/lita/handlers/forecasts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ def do_the_sun_thing(forecast)
"8 day sun forecast |#{str}|"
end

def do_the_cloud_thing(forecast)
def do_the_cloud_thing(forecast, chars)
# O ◎ ]
data = forecast['hourly']['data'].slice(0,23)

str = get_dot_str(ansi_chars, data, 0, 1, 'cloudCover')
str = get_dot_str(chars, data, 0, 1, 'cloudCover')

"24h cloud cover |#{str}|"
end
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 @@ -28,7 +28,7 @@ def handle_irc_all_the_things(response)
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_cloud_thing(forecast)
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 @@ -90,7 +90,13 @@ def handle_irc_ansisun(response)
def handle_irc_ansicloud(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_cloud_thing(forecast)
response.reply location.location_name + ' ' + do_the_cloud_thing(forecast, ansi_chars)
end

def handle_irc_asciicloud(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_cloud_thing(forecast, ascii_chars)
end

def handle_irc_seven_day(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 @@ -135,6 +135,9 @@ class OnewheelForecastIo < Handler
help: { '!dailywind [location]' => '7 day wind speed/direction report for [location].'})

# Cloud cover
route(/^asciicloud\s+(.+)/i, :handle_irc_asciicloud)
route(/^asciicloud\s*$/i, :handle_irc_asciicloud,
help: { '!asciicloud [location]' => '24h cloud cover report for [location].'})
route(/^ansicloud\s*$/i, :handle_irc_ansicloud)
route(/^ansicloud\s+(.+)/i, :handle_irc_ansicloud,
help: { '!ansicloud [location]' => '24h cloud cover report for [location].'})
Expand Down

0 comments on commit 56daf06

Please sign in to comment.