Sha256: 45d94f27f1f516d9bd7654135220e25a5f8e9d56c5271d0987b87b6590003599

Contents?: true

Size: 935 Bytes

Versions: 2

Compression:

Stored size: 935 Bytes

Contents

require 'meme'

# A simple plugin that wraps meme_generator. Requires the
# 'meme_generator' gem.
class Robut::Plugin::Meme < Robut::Plugin::Base

  # This plugin is activated when robut is sent a message starting
  # with the name of a meme. The list of generators can be discovered
  # by running
  # 
  #   meme list
  #
  # from the command line. Example:
  #
  #   @robut h_mermaid look at this stuff, isn't it neat; my vinyl collection is almost complete
  #
  # Send message to the specified meme generator. If the meme requires
  # more than one line of text, lines should be separated with a semicolon.
  def handle(time, sender_nick, message)
    word = words(message).first
    if sent_to_me?(message) && Meme::GENERATORS.has_key?(word.upcase)
      words = words(message)
      g = Meme.new(words.shift.upcase)
      line1, line2 = words.join(' ').split(';')
    
      reply(g.generate(line1, line2))
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
robut-0.2.1 lib/robut/plugin/meme.rb
robut-0.2.0 lib/robut/plugin/meme.rb