class Lita::Handlers::Dice_bag
Public Instance Methods
diceroll(response)
click to toggle source
# File lib/lita/handlers/dicebag.rb, line 16 def diceroll(response) dstr, _ = response.matches.first log.info "Dice Roll #{dstr}" if dstr.nil? then return end dice = DiceBag::Roll.new(dstr) result = dice.result() output_a = [result, '||'] result.each do |section| if output_a.length > 2 output_a << '#' end case section when DiceBag::RollPart output_a << "#{section.total}(#{section.tally.join(',')})" when DiceBag::StaticPart output_a << "#{section}(#{section.total})" else log.info "Encountered unhandled option #{section.class}" end end response.reply "#{response.user.name} rolled #{output_a.join(' ')}" end