Skip to content

Instantly share code, notes, and snippets.

@thr3a
Created April 14, 2016 03:27
Show Gist options
  • Save thr3a/c9b618b017edcf966cacfacc40356144 to your computer and use it in GitHub Desktop.
Save thr3a/c9b618b017edcf966cacfacc40356144 to your computer and use it in GitHub Desktop.
slack-slot
require 'slack-ruby-bot'
class SlotBot < SlackRubyBot::Bot
match /slot/ do |client, data, match|
array = %w(:ulicknormanowen: :shausagi: :fire: :sushi:)
result = []
3.times do
result << array.sample
end
msg = "Start! =>"
msg << result.join(" ")
if result.group_by{|w|w}.count == 1
msg << " おめでとう! :grinning:"
else
msg << " 残念! :sweat:"
end
client.say(
channel: data.channel,
text: msg
)
end
end
SlotBot.run
@HaiTo
Copy link

HaiTo commented Apr 14, 2016

  match /slot/ do |client, data, _|
    array = %w(:ulicknormanowen: :shausagi: :fire: :sushi:)
    result = 3.times.each_with_object([]) {|_, ary|
      ary << array.sample
    }

    msg = "Start! => #{result.join(' ')}"
    msg << (result.group_by{|_|_}.count == 1 ? "おめでとう! :grining:" : "残念! :sweat:")

こんなんでどう?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment