class Ruboty::Gekiron::Actions::Topic
Public Instance Methods
call()
click to toggle source
# File lib/ruboty/gekiron/actions/topic.rb, line 8 def call message.reply(gekiron_topic) rescue => e message.reply(e.message) end
Private Instance Methods
first_letter()
click to toggle source
# File lib/ruboty/gekiron/actions/topic.rb, line 21 def first_letter # 小文字, 濁音, ['を', 'ん'] を除く [*'ア'..'ワ'].map{ |chr| NKF.nkf('-h1w', NKF.nkf('-Xw', chr)) }.sample end
gekiron_topic()
click to toggle source
# File lib/ruboty/gekiron/actions/topic.rb, line 26 def gekiron_topic if topic.nil? 'Topic does not exist :cry: (default path: ./config/topics.yml)' else "「#{first_letter}」から始まる、#{topic}は?" end end
topic()
click to toggle source
# File lib/ruboty/gekiron/actions/topic.rb, line 16 def topic path = File.expand_path(ENV['TOPICS_YAML_FILE_PATH'] || './config/topics.yml') YAML.load_file(path).sample if File.exist?(path) end