class Ruboty::Handlers::Kokodeikku

Constants

DEFAULT_PREFIX

Public Instance Methods

kokodeikku(message) click to toggle source
# File lib/ruboty/handlers/kokodeikku.rb, line 21
def kokodeikku(message)
  return if channels && !channels.include?(message.to)

  if message.from != robot.name && !message.body.start_with?("#{prefix} ") && (song = reviewer.find(message.body))
    message.reply("#{prefix} #{song.phrases.map(&:join).join(' ')}")
  end
end

Private Instance Methods

channels() click to toggle source
# File lib/ruboty/handlers/kokodeikku.rb, line 31
def channels
  if ENV['KOKODEIKKU_CHANNEL']
    @channels ||= ENV['KOKODEIKKU_CHANNEL'].split(',')
  else
    nil
  end
end
prefix() click to toggle source
# File lib/ruboty/handlers/kokodeikku.rb, line 39
def prefix
  ENV["KOKODEIKKU_PREFIX"] || DEFAULT_PREFIX
end
reviewer() click to toggle source
# File lib/ruboty/handlers/kokodeikku.rb, line 43
def reviewer
  @reviewer ||= Ikku::Reviewer.new(rule: rule)
end
rule() click to toggle source
# File lib/ruboty/handlers/kokodeikku.rb, line 47
def rule
  if ENV["KOKODEIKKU_RULE"]
    ENV["KOKODEIKKU_RULE"].split(",").map(&:to_i)
  end
end