Class: Lita::Handlers::CustomMeme
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::CustomMeme
- Defined in:
- lib/lita/handlers/custom_meme.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.default_config(config) ⇒ Object
11 12 13 14 |
# File 'lib/lita/handlers/custom_meme.rb', line 11 def self.default_config(config) config.memes = {} config.command_only = false end |
Instance Method Details
#define_routes(payload) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lita/handlers/custom_meme.rb', line 16 def define_routes(payload) return if Lita.config.handlers.custom_meme.memes.empty? memelist = Lita.config.handlers.custom_meme.memes.keys.join("|") # This picks up the images in chat unless Lita.config.handlers.custom_meme.command_only self.class.route( %r{\((#{memelist})\)}i, :meme_image ) end end |
#meme_image(response) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lita/handlers/custom_meme.rb', line 30 def meme_image(response) output = [] response.matches.each do |match| term = match[0].downcase if Lita.config.handlers.custom_meme.memes[term] output << Lita.config.handlers.custom_meme.memes[term] end end if output.size > 0 response.reply *output end end |