Module: ForecastIo::IrcHandlers
- Included in:
- Lita::Handlers::OnewheelForecastIo
- Defined in:
- lib/lita/handlers/irc_handlers.rb
Instance Method Summary collapse
- #handle_http_windows(request, response) ⇒ Object
- #handle_irc_alerts(response) ⇒ Object
- #handle_irc_all_the_things(response) ⇒ Object
- #handle_irc_ansi_humidity(response) ⇒ Object
- #handle_irc_ansi_pressure(response) ⇒ Object
- #handle_irc_ansicloud(response) ⇒ Object
- #handle_irc_ansifog(response) ⇒ Object
- #handle_irc_ansiozone(response) ⇒ Object
- #handle_irc_ansirain(response) ⇒ Object
- #handle_irc_ansirain_intensity(response) ⇒ Object
- #handle_irc_ansisun(response) ⇒ Object
- #handle_irc_ansitemp(response) ⇒ Object
- #handle_irc_ansitempapparent(response) ⇒ Object
- #handle_irc_ansiwind(response) ⇒ Object
- #handle_irc_ansiwindchill(response) ⇒ Object
- #handle_irc_ascii_rain(response) ⇒ Object
- #handle_irc_ascii_temp(response) ⇒ Object
- #handle_irc_ascii_wind(response) ⇒ Object
- #handle_irc_asciicloud(response) ⇒ Object
- #handle_irc_asciifog(response) ⇒ Object
- #handle_irc_asciisun(response) ⇒ Object
- #handle_irc_conditions(response) ⇒ Object
- #handle_irc_daily_humidity(response) ⇒ Object
- #handle_irc_daily_pressure(response) ⇒ Object
- #handle_irc_daily_rain(response) ⇒ Object
- #handle_irc_daily_temp(response) ⇒ Object
- #handle_irc_daily_wind(response) ⇒ Object
- #handle_irc_dailysun(response) ⇒ Object
-
#handle_irc_forecast(response) ⇒ Object
-# Handlers.
- #handle_irc_ieeetemp(response) ⇒ Object
- #handle_irc_neareststorm(response) ⇒ Object
- #handle_irc_set_scale(response) ⇒ Object
- #handle_irc_seven_day(response) ⇒ Object
- #handle_irc_seven_day_rain(response) ⇒ Object
- #handle_irc_sunrise(response) ⇒ Object
- #handle_irc_sunset(response) ⇒ Object
- #handle_irc_today(response) ⇒ Object
- #handle_irc_tomorrow(response) ⇒ Object
- #handle_irc_uvindex(response) ⇒ Object
- #handle_irc_windows(response) ⇒ Object
Instance Method Details
#handle_http_windows(request, response) ⇒ Object
256 257 258 259 260 261 |
# 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) ⇒ Object
97 98 99 100 101 102 |
# 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) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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) ⇒ Object
176 177 178 179 180 |
# 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) ⇒ Object
188 189 190 191 192 |
# 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) ⇒ Object
122 123 124 125 126 |
# 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) ⇒ Object
134 135 136 137 138 |
# 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) ⇒ Object
182 183 184 185 186 |
# 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) ⇒ Object
10 11 12 13 14 |
# 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) ⇒ Object
36 37 38 39 40 |
# 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) ⇒ Object
104 105 106 107 108 |
# 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) ⇒ Object
42 43 44 45 46 |
# 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) ⇒ Object
48 49 50 51 52 |
# 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) ⇒ Object
85 86 87 88 89 |
# 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) ⇒ Object
54 55 56 57 58 |
# 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) ⇒ Object
16 17 18 19 20 |
# 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) ⇒ Object
67 68 69 70 71 |
# 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) ⇒ Object
91 92 93 94 95 |
# 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) ⇒ Object
128 129 130 131 132 |
# 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) ⇒ Object
140 141 142 143 144 |
# 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) ⇒ Object
116 117 118 119 120 |
# 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) ⇒ Object
79 80 81 82 83 |
# 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) ⇒ Object
170 171 172 173 174 |
# 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) ⇒ Object
194 195 196 197 198 |
# 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) ⇒ Object
152 153 154 155 156 |
# 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) ⇒ Object
73 74 75 76 77 |
# 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) ⇒ Object
164 165 166 167 168 |
# 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) ⇒ Object
110 111 112 113 114 |
# 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) ⇒ Object
-# Handlers
4 5 6 7 8 |
# 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) ⇒ Object
60 61 62 63 64 65 |
# 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) ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 230 |
# 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) ⇒ Object
200 201 202 203 204 205 |
# 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) ⇒ Object
146 147 148 149 150 |
# 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) ⇒ Object
158 159 160 161 162 |
# 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) ⇒ Object
207 208 209 210 211 |
# 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) ⇒ Object
213 214 215 216 217 |
# 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) ⇒ Object
240 241 242 243 244 245 246 247 |
# 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) ⇒ Object
232 233 234 235 236 237 238 |
# 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) ⇒ Object
263 264 265 266 267 268 |
# 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) ⇒ Object
249 250 251 252 253 254 |
# 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 |