Last active
August 29, 2015 14:22
-
-
Save june29/90d6e7efe42c3a46d8a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gem::Specification.new do |spec| | |
spec.name = "ruboty-omikuji" | |
spec.version = "0.0.2" | |
spec.authors = ["Jun OHWADA"] | |
spec.email = ["[email protected]"] | |
spec.summary = "Omikuji" | |
spec.files = ["ruboty-omikuji.rb"] | |
spec.require_path = "." | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ruboty | |
module Handlers | |
class Omikuji < Base | |
on( | |
/omikuji/i, | |
name: "omikuji", | |
description: "Array#sample" | |
) | |
def omikuji(message) | |
prefix = ENV['OMIKUJI_PREFIX'] | |
sampled = ENV['OMIKUJI_ITEMS'].split(',').sample | |
suffix = ENV['OMIKUJI_SUFFIX'] | |
text = [prefix, sampled, suffix].compact.select { |e| e.length > 0 }.join(" ") | |
message.reply(text) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment