Skip to content

Instantly share code, notes, and snippets.

@ochaochaocha3
Created July 1, 2017 11:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ochaochaocha3/f68fee24371f079a400f81ee7fed73ae to your computer and use it in GitHub Desktop.
bcdice-apiの全ダイスボットの情報収集処理を簡単にする
# frozen_string_literal: true
require "bcdiceCore"
require "diceBot/DiceBot"
require "diceBot/DiceBotLoader"
class BCDice
VERSION = "2.02.70"
# BCDiceのコミット11ee56c以降で可能
# @see https://github.com/torgtaitai/BCDice/commit/11ee56c8dfdb00ac232c8b5cbf87a963d37df974
DICEBOTS = DiceBotLoader.collectDiceBots.
map { |diceBot| [diceBot.gameType, diceBot] }.
to_h.
freeze
SYSTEMS = DICEBOTS.keys.
sort.
freeze
def dice_command # ダイスコマンドの分岐処理
arg = @message.upcase
debug('dice_command arg', arg)
output, secret = @diceBot.dice_command(@message, @nick_e)
return output, secret if( output != '1' )
output, secret = rollD66(arg)
return output, secret unless( output.nil? )
output, secret = checkAddRoll(arg)
return output, secret unless( output.nil? )
output, secret = checkBDice(arg)
return output, secret unless( output.nil? )
output, secret = checkRnDice(arg)
return output, secret unless( output.nil? )
output, secret = checkUpperRoll(arg)
return output, secret unless( output.nil? )
output, secret = checkChoiceCommand(arg)
return output, secret unless( output.nil? )
output, secret = getTableDataResult(arg)
return output, secret unless( output.nil? )
output = nil #BCDiceからの変更点
secret = nil
return output, secret
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment