Class: Lita::Handlers::Reddim

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/reddim.rb

Constant Summary collapse

@@cache =
{}

Instance Method Summary collapse

Instance Method Details

#reddim(response) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/lita/handlers/reddim.rb', line 10

def reddim(response)
  subr = response.matches[0][0]
  response.reply(get_listing_from_sub(subr).sample)
rescue NoMethodError, JSON::ParserError
  response.reply("/r/#{subr} is not a subreddit")
rescue => e
  response.reply("Error: #{e}")
end