module ForecastIo::IrcHandlers

Public Instance Methods

handle_http_windows(request, response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 256
def handle_http_windows(request, response)
  uri = config.api_uri + config.api_key + '/' + '45.535,-122.631'
  forecast = gimme_some_weather uri
  windows_data = do_the_windows_data_thing(forecast)
  response.write windows_data.to_json
end
handle_irc_alerts(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 97
def handle_irc_alerts(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  alerts = get_alerts(forecast)
  response.reply alerts
end
handle_irc_all_the_things(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 22
def handle_irc_all_the_things(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + forecast_text(forecast)
  response.reply location.location_name + ' ' + ansi_rain_forecast(forecast)
  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, 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)
  response.reply location.location_name + ' ' + do_the_humidity_thing(forecast, ansi_chars, 'humidity')
end
handle_irc_ansi_humidity(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 176
def handle_irc_ansi_humidity(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' 48hr humidity ' + ansi_humidity_forecast(forecast)
end
handle_irc_ansi_pressure(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 188
def handle_irc_ansi_pressure(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_pressure_thing(forecast)
end
handle_irc_ansicloud(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 122
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, ansi_chars)
end
handle_irc_ansifog(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 134
def handle_irc_ansifog(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_fog_thing(forecast, ansi_chars)
end
handle_irc_ansiozone(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 182
def handle_irc_ansiozone(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_ozone_thing(forecast)
end
handle_irc_ansirain(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 10
def handle_irc_ansirain(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + ansi_rain_forecast(forecast)
end
handle_irc_ansirain_intensity(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 36
def handle_irc_ansirain_intensity(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + ansi_rain_intensity_forecast(forecast)
end
handle_irc_ansisun(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 104
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, ansi_chars)
end
handle_irc_ansitemp(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 42
def handle_irc_ansitemp(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + ansi_temp_forecast(forecast)
end
handle_irc_ansitempapparent(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 48
def handle_irc_ansitempapparent(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + ansi_temp_forecast(forecast)
end
handle_irc_ansiwind(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 85
def handle_irc_ansiwind(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + ansi_wind_direction_forecast(forecast)
end
handle_irc_ansiwindchill(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 54
def handle_irc_ansiwindchill(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + ansi_windchill_forecast(forecast)
end
handle_irc_ascii_rain(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 16
def handle_irc_ascii_rain(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + ascii_rain_forecast(forecast)
end
handle_irc_ascii_temp(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 67
def handle_irc_ascii_temp(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + ascii_temp_forecast(forecast)
end
handle_irc_ascii_wind(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 91
def handle_irc_ascii_wind(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + ascii_wind_direction_forecast(forecast)
end
handle_irc_asciicloud(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 128
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
handle_irc_asciifog(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 140
def handle_irc_asciifog(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_fog_thing(forecast, ascii_chars)
end
handle_irc_asciisun(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 116
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
handle_irc_conditions(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 79
def handle_irc_conditions(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + conditions(forecast)
end
handle_irc_daily_humidity(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 170
def handle_irc_daily_humidity(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_daily_humidity_thing(forecast)
end
handle_irc_daily_pressure(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 194
def handle_irc_daily_pressure(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_daily_pressure_thing(forecast)
end
handle_irc_daily_rain(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 152
def handle_irc_daily_rain(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_daily_rain_thing(forecast)
end
handle_irc_daily_temp(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 73
def handle_irc_daily_temp(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + ansi_temp_forecast(forecast, 48)
end
handle_irc_daily_wind(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 164
def handle_irc_daily_wind(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_daily_wind_thing(forecast)
end
handle_irc_dailysun(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 110
def handle_irc_dailysun(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_daily_sun_thing(forecast, ansi_chars)
end
handle_irc_forecast(response) click to toggle source

-# Handlers

# File lib/lita/handlers/irc_handlers.rb, line 4
def handle_irc_forecast(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + forecast_text(forecast)
end
handle_irc_ieeetemp(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 60
def handle_irc_ieeetemp(response)
  @scale = 'k'
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' ' + ansi_temp_forecast(forecast)
end
handle_irc_neareststorm(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 219
def handle_irc_neareststorm(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  nearest_storm_distance, nearest_storm_bearing = do_the_nearest_storm_thing(forecast)

  if nearest_storm_distance == 0
    response.reply "You're in it!"
  else
    response.reply "The nearest storm is #{get_distance(nearest_storm_distance, get_scale(response.user))} to the #{get_cardinal_direction_from_bearing(nearest_storm_bearing)} of you."
  end

end
handle_irc_set_scale(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 200
def handle_irc_set_scale(response)
  key = response.user.name + '-scale'
  user_requested_scale = response.match_data[1].to_s.downcase
  reply = check_and_set_scale(key, user_requested_scale)
  response.reply reply
end
handle_irc_seven_day(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 146
def handle_irc_seven_day(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_seven_day_thing(forecast)
end
handle_irc_seven_day_rain(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 158
def handle_irc_seven_day_rain(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_seven_day_rain_thing(forecast)
end
handle_irc_sunrise(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 207
def handle_irc_sunrise(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' sunrise: ' + do_the_sunrise_thing(forecast)
end
handle_irc_sunset(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 213
def handle_irc_sunset(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  response.reply location.location_name + ' sunset: ' + do_the_sunset_thing(forecast)
end
handle_irc_today(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 240
def handle_irc_today(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location, Date.today.to_s + 'T00:00:00-0700')
  yesterday_weather = get_forecast_io_results(response.user, location, Date.today.prev_day.to_s + 'T00:00:00-0700')
  today_will_be = do_the_today_thing(forecast, yesterday_weather)
  Lita.logger.info "Response: Today will be #{today_will_be} yesterday."
  response.reply "Today will be #{today_will_be} yesterday."
end
handle_irc_tomorrow(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 232
def handle_irc_tomorrow(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  tomorrow_will_be = do_the_tomorrow_thing(forecast)
  Lita.logger.info "Response: Tomorrow will be #{tomorrow_will_be} today."
  response.reply "Tomorrow will be #{tomorrow_will_be} today."
end
handle_irc_uvindex(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 263
def handle_irc_uvindex(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  str = do_the_uvindex_thing(forecast)
  response.reply "UV Index for #{location.location_name} #{str} [48h forecast]"
end
handle_irc_windows(response) click to toggle source
# File lib/lita/handlers/irc_handlers.rb, line 249
def handle_irc_windows(response)
  location = geo_lookup(response.user, response.match_data[1])
  forecast = get_forecast_io_results(response.user, location)
  windows_time = do_the_windows_thing(forecast)
  response.reply "#{windows_time}"
end