class Ruboty::Actions::IconRoulette

Attributes

bots[RW]

Public Class Methods

new(message) click to toggle source
Calls superclass method
# File lib/ruboty/actions/icon_roulette.rb, line 12
def initialize(message)
  super
  validate
end

Public Instance Methods

call() click to toggle source
# File lib/ruboty/actions/icon_roulette.rb, line 17
def call
  case message.robot.adapter.class.name
  when 'Ruboty::Adapters::Idobata'
    client.update_bot_icon(id: bot['id'], file_path: icon_paths.sample)
    message.reply('lol')
  else
    message.reply("aahhhhhh, can't change icon!!!")
  end
end

Private Instance Methods

bot() click to toggle source
# File lib/ruboty/actions/icon_roulette.rb, line 43
def bot
  client.list_bots.body.bots.detect {|b| b['api_token'] == idobata_api_token }
end
client() click to toggle source
# File lib/ruboty/actions/icon_roulette.rb, line 39
def client
  @client ||= Atabodi::Client.new(api_token: idobata_api_token)
end
icon_paths() click to toggle source
# File lib/ruboty/actions/icon_roulette.rb, line 29
def icon_paths
  Dir[ENV['ICON_PATHS']].select do |path|
    File.file?(path)
  end
end
idobata_api_token() click to toggle source
# File lib/ruboty/actions/icon_roulette.rb, line 35
def idobata_api_token
  message.robot.adapter.idobata_api_token
end