class Ruboty::Mstr::Actions::Mstr

Constants

MSTR_ENDPOINT_URL

Public Instance Methods

call() click to toggle source
# File lib/ruboty/mstr/actions/mstr.rb, line 10
def call
  message.reply((mstr_photos.sample(message[:count].to_i) + ['source: https://mstr.in/']).join($/))
rescue
  message.reply("mstr fail: #{$!}")
end
mstr_photos() click to toggle source
# File lib/ruboty/mstr/actions/mstr.rb, line 16
def mstr_photos
  @mstr_photos ||= JSON.parse(OpenURI.open_uri(MSTR_ENDPOINT_URL).read)['photos'].map do |mstr|
    "https://pic.mstr.in/images/#{mstr['uid']}.jpg"
  end
end