From e4b26a05d3f95ec2dfce77e8255d2463057bf40f Mon Sep 17 00:00:00 2001 From: SAKATA Sinji Date: Wed, 1 Jul 2020 04:07:42 +0900 Subject: [PATCH 1/7] Remove IRC codes --- .rubocop_todo.yml | 21 --- Gemfile | 8 -- Rakefile | 1 - bcdice.ini | 14 -- src/irc/ircBot.rb | 330 ---------------------------------------------- src/irc/ircLib.rb | 69 ---------- 6 files changed, 443 deletions(-) delete mode 100644 bcdice.ini delete mode 100755 src/irc/ircBot.rb delete mode 100755 src/irc/ircLib.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 41afb5dfd..eab5803b4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -13,23 +13,11 @@ Bundler/DuplicatedGem: Exclude: - 'Gemfile' -# Offense count: 1 -# Configuration parameters: AllowSafeAssignment. -Lint/AssignmentInCondition: - Exclude: - - 'src/irc/ircLib.rb' - # Offense count: 1 Lint/EmptyWhen: Exclude: - 'src/test.rb' -# Offense count: 1 -# Configuration parameters: AllowComments. -Lint/HandleExceptions: - Exclude: - - 'src/irc/ircLib.rb' - # Offense count: 1 # Cop supports --auto-correct. # Bug? @@ -37,11 +25,6 @@ Lint/LiteralInInterpolation: Exclude: - 'src/diceBot/GurpsFW.rb' -# Offense count: 3 -Lint/RescueException: - Exclude: - - 'src/irc/ircLib.rb' - # Offense count: 177 Lint/UselessAssignment: Enabled: false @@ -130,7 +113,6 @@ Naming/UncommunicativeMethodParamName: # SupportedStyles: inline, group Style/AccessModifierDeclarations: Exclude: - - 'src/irc/encode.rb' - 'src/test/DiceBotTest.rb' Style/BlockDelimiters: @@ -146,8 +128,6 @@ Style/CaseEquality: - src/bcdice.rb - src/TableFileData.rb - src/test/DiceBotTest.rb - - src/irc/ircLib.rb - - src/irc/encode.rb - src/diceBot/Kamigakari_Korean.rb - src/diceBot/HouraiGakuen.rb - src/diceBot/FilledWith.rb @@ -220,7 +200,6 @@ Style/GlobalVars: - src/test/others/testSecretDice.rb - src/test/others/testArgs.rb - src/test/others/testCard.rb - - src/irc/ircBot.rb - src/dice/AddDice.rb - src/dice/RerollDice.rb - src/diceBot/RecordOfSteam.rb diff --git a/Gemfile b/Gemfile index 2f7b69cc9..281c306c5 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,5 @@ source 'https://rubygems.org' -unless ENV['CI'] == 'true' - gem 'net-irc' - if RUBY_VERSION < '2.0' - gem 'wxruby-ruby19', '2.0.0' - end - gem 'ocra' -end - group :development, :test do if RUBY_VERSION < '1.9' gem 'rake', '~> 10.5' diff --git a/Rakefile b/Rakefile index 41966bee0..e52e9a910 100644 --- a/Rakefile +++ b/Rakefile @@ -64,7 +64,6 @@ namespace :test do t.libs = [ 'src/test', 'src/', - 'src/irc' ] unless RUBY_VERSION < '1.9' diff --git a/bcdice.ini b/bcdice.ini deleted file mode 100644 index afbee4a07..000000000 --- a/bcdice.ini +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- - -[ServerSet_デフォルト] -channel=#Dice_Test -characterCode=UTF-8 -extraCardFileText= -gameType=NonTitle -nickName=bcDICE -portNo=6667 -serverName=irc.trpg.net - -[default] -serverSet=デフォルト - diff --git a/src/irc/ircBot.rb b/src/irc/ircBot.rb deleted file mode 100755 index dd927c76e..000000000 --- a/src/irc/ircBot.rb +++ /dev/null @@ -1,330 +0,0 @@ -#!ruby -Ku -# -*- coding: utf-8 -*- - -require 'configBcDice.rb' -require 'ArgsAnalizer.rb' - -class IrcClient < Net::IRC::Client - def initialize(*args) - super - - host, port, *options = *args - - @bcdiceMarker = BCDiceMaker.new - - @loginChannelList = $defaultLoginChannelsText.split(',') - end - - def newBcDice - bcdice = @bcdiceMarker.newBcDice() - bcdice.setIrcClient(self) - return bcdice - end - - def readExtraCard(cardFileName) - bcdice = newBcDice() - bcdice.readExtraCard(cardFileName) - end - - def ownNick - @opts.nick - end - - def setRoom(room) - @room = room - end - - def setGameByTitle(game_type) - bcdice = newBcDice() - bcdice.setGameByTitle(game_type) - end - - def on_connected(*_args) - printText(' -> IRC server is connected.') - - channelNames = @loginChannelList.join(',') - channelNames = encode($ircCode, channelNames) - - join(channelNames) - topic(channelNames) - - printText("login to channels(#{channelNames}), so wait a moment...") - end - - def on_rpl_welcome(_message) - printText(' -> login to channel successed.') - # post JOIN, @room.encode($ircCode).force_encoding_maybe('external') - post(JOIN, encode($ircCode, @room)) - end - - def on_init(event) - args = event.args - - shift(args) - debug_out("*** #{args.ispect}\n") - end - - def on_part(event) - channel = getChannel(event) - - debug_out("*** %s has left channel %s\n", event.nick, channel) - end - - def on_join(event) - debug('on_join event', event) - - channel = getChannel(event) - nick_e = getNickEFromEvent(event) - host_j = event.prefix.host - - debug("join nick_e, host_j, channel", nick_e, host_j, channel) - - if host_j =~ /^someone\@somewhere\.else\.com$/ # Auto-ops anyone who - debug_out("Give to #{nick_e}\n") - mode(encode($ircCode, channel), "+o", nick_e); # matches hostmask. - end - end - - def on_invite(event) - channel = getChannel(event) - - debug_out("*** %s (%s) has invited me to channel %s\n", - event.nick, event.userhost, channel) - - addChannel(channel) - join(encode($ircCode, channel)) - topic(encode($ircCode, channel)) - end - - def on_kick(event) - channel = getChannel(event) - - mynick = nick - target = event.to[0] - - debug_out("%s Kicked on %s by %s.\n", target, channel) - if mynick == target - deleteChannel(channel) - end - end - - def on_msg(event) - debug('on_msg begin') - - nick_e = getNickEFromEvent(event) - channel = getChannel(event) - - arg = getArg(event) - tnick = "" - if /->/ =~ arg - arg, tnick, = arg.split(/->/) - end - - debug("nick_e, arg, tnick", nick_e, arg, tnick) - - bcdice = newBcDice() - bcdice.setMessage(arg) - bcdice.setChannel(channel) - bcdice.recieveMessage(nick_e, tnick) - end - - def on_privmsg(event) - debug("=============>on_privmsg begin event", event) - on_public(event) - end - - def on_public(event) - debug('on_public begin') - debug('on_public event', event) - debug('on_public begin ownNick', ownNick) - - channel = getChannel(event) - debug('on_public channel', channel) - - if channel == ownNick - return on_msg(event) - end - - arg = getArg(event) - - debug('on_public arg', arg) - - nick_e = getNickEFromEvent(event) - debug("on_public nick_e : #{nick_e}") - - bcdice = newBcDice() - bcdice.setMessage(arg) - bcdice.setChannel(channel) - bcdice.recievePublicMessage(nick_e) - end - - def getNickEFromEvent(event) - nick_e = event.prefix.nick.toutf8 - end - - def getChannel(event) - channel = event.params[0].toutf8 - end - - def getArg(event) - arg = event.params[1].toutf8 - end - - def setPrintFuction(func) - @printFunction = func - end - - def printText(text) - return if @printFunction.nil? - - @printFunction.call(text) - end - - def on_err_nicknameinuse(_event) - debug_out("on_err_nicknameinuse being !") - debug_out("@opts.nick", @opts.nick) - - oldNick = @opts.nick - newNick = getNewNick(oldNick) - @opts.nick = newNick - debug_out("newNick", newNick) - - printText(" -> nick \"#{oldNick}\" is already used, so change \"#{oldNick}\" -> \"#{newNick}\"") - - post(NICK, @opts.nick) - end - - def getNewNick(nick) - debug_out("getNewNick nick", nick) - - @nickIndex ||= 1 - @nickIndex += 1 - @log.debug("@nickIndex:#{@nickIndex}") - - nickIndexText = @nickIndex.to_s - @log.debug("nickIndexText:#{nickIndexText}") - - newNick = nick + nickIndexText - diff = newNick.length - $ircNickMaxLength - @log.debug("newNick:#{newNick}, newNick.length#{newNick.length}") - @log.debug("diff:#{diff}") - - if diff > 0 - nickBase = nick[0...(diff * -1)] - @log.debug("getNewNick nickBase:#{nickBase}") - newNick = nickBase + nickIndexText - end - - @log.debug("newNick:#{newNick}") - return newNick - end - - def isMaster - bcdice = newBcDice() - bcdice.isMaster - end - - def quit - debug('quitCommand') - debug('isMaster()', isMaster()) - - return unless isMaster() - - post(QUIT, encode($ircCode, 'さようなら')) - end - - def addChannel(add_ch) - @loginChannelList << add_ch - end - - def deleteChannel(del_ch) - @loginChannelList.delete_if { |i| i == del_ch } - end - - def sendMessageToChannels(message) - @loginChannelList.each do |channel| - sendMessage(channel, message) - end - end - - def sendMessageToOnlySender(nick_e, message) - sendMessage(nick_e, message) - end - - def sendMessage(to, message) - return if message.empty? - - debug('sendMessage to, message', to, message) - - # 長すぎる出力は"\n"を挟み、分割送信されるように。 - message = insertEnterToTooLongMessage(message) - - to = encode($ircCode, to) - encodedMessage = encode($ircCode, message) - - encodedMessage.each_line do |line| - debug('notice to, line', to, line) - notice(to, line) - sleep(1) - end - end - - def insertEnterToTooLongMessage(message) - if message.length <= $SEND_STR_MAX - return message - end - - result = "" - index = 1 - - message.chars do |ch| - result += ch - - if result.length > ($SEND_STR_MAX * index) - result += "\n" - index += 1 - end - end - - return result - end - - def notice(to, message) - post(NOTICE, to, encode($ircCode, message)) - end - - def privmsg(to, message) - post(PRIVMSG, to, encode($ircCode, message)) - end -end - -def getInitializedIrcBot() - ircBot = IrcClient.new($server, $port, { - :nick => $nick, :user => $userName, :real => $ircName - }) - debug("$server, $port, $nick, $userName, $ircName", $server, $port, $nick, $userName, $ircName) - - room = $defaultLoginChannelsText.split(',').first - ircBot.setRoom(room) - - ircBot.setGameByTitle($defaultGameType) - - unless $extraCardFileName.empty? - ircBot.readExtraCard($extraCardFileName) - end - - return ircBot -end - -def mainIrcBot(args = []) - argsAnalizer = ArgsAnalizer.new(args) - argsAnalizer.analize - - ircBot = getInitializedIrcBot() - - if argsAnalizer.isStartIrc - ircBot.start - end - - return ircBot -end diff --git a/src/irc/ircLib.rb b/src/irc/ircLib.rb deleted file mode 100755 index 94b865e65..000000000 --- a/src/irc/ircLib.rb +++ /dev/null @@ -1,69 +0,0 @@ -#!ruby -Ks -# -*- coding: utf-8 -*- - -# require 'rubygems' -require 'net/irc.rb' -require 'net/irc/client.rb' -require 'net/irc/message.rb' -require 'net/irc/message/serverconfig.rb' -require 'net/irc/message/modeparser.rb' -require 'socket.so' -require 'encode.rb' - -class Net - class IRC - class Client - # Connect to server and start loop. - def start - @log.debug "start begin" - # reset config - @server_config = Message::ServerConfig.new - @socket = TCPSocket.open(@host, @port) - @log.debug "on_connected calling.." - begin - @log.debug "call..." - on_connected - rescue Exception => e - @log.debug "error!!" - @log.debug e.to_s - @log.debug $!.inspect - @log.debug $@.join("\n") - end - @log.debug "on_connected passed" - - @log.debug "post PASS" - post PASS, @opts.pass if @opts.pass - @log.debug "post NICK" - post NICK, @opts.nick - @log.debug "post USER" - post USER, @opts.user, "0", "*", @opts.real - - @log.debug "while loop begin" - l = nil - loop do - begin - while l = @socket.gets - @log.debug "RECEIVE: #{l.chomp}" - m = Message.parse(l) - next if on_message(m) === true - - name = "on_#{(COMMANDS[m.command.upcase] || m.command).downcase}" - @log.debug "calling... on_xxx : #{name}" - send(name, m) if respond_to?(name) - end - rescue Message::InvalidMessage - @log.error "MessageParse Exception: " + l.inspect - rescue Exception => e - @log.error "Exception: " + e.inspect - warn e - warn e.backtrace.join("\r\t") - raise - end - end - rescue IOError - ensure - finish - end - end - end -end From c9d3e7adb8da0abd0997799399f0f88da30eeac3 Mon Sep 17 00:00:00 2001 From: ocha Date: Wed, 1 Jul 2020 22:29:08 +0900 Subject: [PATCH 2/7] =?UTF-8?q?ArgsAnalizer=E3=82=92=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ArgsAnalizer.rb | 97 ------------------------------------- src/test/others/testArgs.rb | 29 ----------- 2 files changed, 126 deletions(-) delete mode 100755 src/ArgsAnalizer.rb delete mode 100644 src/test/others/testArgs.rb diff --git a/src/ArgsAnalizer.rb b/src/ArgsAnalizer.rb deleted file mode 100755 index e6afd698e..000000000 --- a/src/ArgsAnalizer.rb +++ /dev/null @@ -1,97 +0,0 @@ -#!ruby -Ku -# -*- coding: utf-8 -*- - -class ArgsAnalizer - def initialize(args) - @args = args - @isStartIrc = true - end - - attr_reader :isStartIrc - - def analize - isAnalized = false - - @args.each do |arg| - result = analizeArg(arg) - checkArg(arg) - - if result - isAnalized = true - end - end - - return isAnalized - end - - def checkArg(arg) - if isCreateExeMode(arg) - @isStartIrc = false - end - end - - def isCreateExeMode(arg) - if arg == "createExe" - if File.exist?("__createExe__.txt") - return true - end - end - - return false - end - - def analizeArg(arg) - return false unless /^-([scngmeir])(.+)$/i =~ arg - - command = Regexp.last_match(1).downcase - @param = Regexp.last_match(2) - - case command - when "s" - setServer - when "c" - setChannel - when "n" - setNick - when "g" - setGame - when "m" - setMessageSendType - when "e" - readExtraCard - when "i" - setIrcServerCharacterCode - else - return false - end - - return true - end - - def setServer - # サーバ設定(Server:Port) - data = @param.split(/:/) - $server = data[0] - $port = data[1] if data[1] - end - - def setChannel - $defaultLoginChannelsText = decode($ircCode, @param) - end - - def setNick - $nick = @param - end - - def setGame - $defaultGameType = @param - end - - def readExtraCard - $extraCardFileName = @param - end - - def setIrcServerCharacterCode - $ircCode = param - end -end diff --git a/src/test/others/testArgs.rb b/src/test/others/testArgs.rb deleted file mode 100644 index d5a9aeb50..000000000 --- a/src/test/others/testArgs.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -$:.push(File.dirname(__FILE__) + "/..") - -require 'test/unit' -require 'log' -require 'bcdiceCore.rb' -require 'ArgsAnalizer.rb' - -class TestArgs < Test::Unit::TestCase - def setup - $isDebug = false - end - - def trace - $isDebug = true - end - - def test_args - argv = ['-sirc.trpg.net:6667', '-c#OnlineTRPG', '-gCthulhu', '-nfDICE_CoC'] - argsAnalizer = ArgsAnalizer.new(argv) - argsAnalizer.analize - assert_equal($server, 'irc.trpg.net') - assert_equal($port, '6667') - assert_equal($defaultLoginChannelsText, '#OnlineTRPG') - assert_equal($defaultGameType, 'Cthulhu') - assert_equal($nick, 'fDICE_CoC') - end -end From 14fa4a23c1bf41a55d9555d361c373f42fad0e30 Mon Sep 17 00:00:00 2001 From: ocha Date: Wed, 1 Jul 2020 22:55:44 +0900 Subject: [PATCH 3/7] =?UTF-8?q?test.rb:=20=E3=83=A9=E3=82=A4=E3=83=96?= =?UTF-8?q?=E3=83=A9=E3=83=AA=E3=83=91=E3=82=B9=E3=81=8B=E3=82=89=20src/ir?= =?UTF-8?q?c/=20=E3=82=92=E5=8F=96=E3=82=8A=E9=99=A4=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test.rb b/src/test.rb index 9763b2a52..9924c28a0 100644 --- a/src/test.rb +++ b/src/test.rb @@ -17,7 +17,6 @@ libPaths = [ "#{rootDir}/test", rootDir, - "#{rootDir}/irc" ] libPaths.each do |libPath| $:.push(libPath) From a8ca0fd0e3026c0da52bb62f3567e6eb1e2175e3 Mon Sep 17 00:00:00 2001 From: ocha Date: Wed, 1 Jul 2020 23:35:23 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E9=A0=85=E7=9B=AE=E3=82=92=E5=89=8A=E9=99=A4=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CardTrader.rb | 35 +++++++++++++++++-------------- src/configBcDice.rb | 17 ++------------- src/configBcDiceForSystem.rb | 7 ------- src/test/others/testPointer.rb | 1 - src/test/others/testSecretDice.rb | 1 - 5 files changed, 21 insertions(+), 40 deletions(-) delete mode 100644 src/configBcDiceForSystem.rb diff --git a/src/CardTrader.rb b/src/CardTrader.rb index 1db1ccdbd..09882f543 100755 --- a/src/CardTrader.rb +++ b/src/CardTrader.rb @@ -6,6 +6,9 @@ $ircNickRegExp = '[A-Za-z\d\-\[\]\\\'^{}_]+' class CardTrader + OK_RESULT = '_OK_'.freeze + NG_RESULT = '_NG_'.freeze + # カード置き場数。0なら無し。 # @return [Integer] attr_accessor :card_place @@ -401,7 +404,7 @@ def pickupCardByCards(cards) cards.each do |card| string = pickupOneCard(card) - if string == $okResult + if string == OK_RESULT okCount += 1 else ngCardList << string @@ -424,7 +427,7 @@ def pickupOneCard(card) if isDelete @deal_cards[destination] ||= [] @deal_cards[destination] << targetCard - return $okResult + return OK_RESULT else return targetCard; # 無かったカードを返す end @@ -467,7 +470,7 @@ def backCardByCommandSetAndPlace(commandset, place) cards.each do |card| string = backOneCard(card, destination, place) - if string == $okResult + if string == OK_RESULT okCount += 1 else ngCards << string @@ -487,7 +490,7 @@ def backOneCard(targetCard, destination, place) if @card_place > 0 # 場があるときのみ処理 string = transferOneCard(targetCard, "#{place}#{destination}", destination); # 場から手札への移動 - return $okResult if string == $okResult + return OK_RESULT if string == OK_RESULT end @deal_cards['card_played'] ||= [] @@ -496,7 +499,7 @@ def backOneCard(targetCard, destination, place) if isDelete @deal_cards[destination] << targetCard - return $okResult + return OK_RESULT end return "${targetCard}"; # 戻せるカードが無かったらNGのカードを返す @@ -628,7 +631,7 @@ def playCardByCardAndPlaceNo(card, place) result = playOneCard(card, place) debug("playOneCard result", result) - if result == $okResult + if result == OK_RESULT okList << card else ngList << result @@ -651,7 +654,7 @@ def playOneCard(card, place) result = discardOneCard(card, place, destination); # 場を使わないときは捨て札扱い end - if result == $okResult + if result == OK_RESULT return result else return card @@ -699,7 +702,7 @@ def discardCardsByCardsAndPlace(cards, place, destination) cards.each do |card| result = discardOneCard(card, place, destination) - if result == $okResult + if result == OK_RESULT okList << card else ngList << result @@ -737,7 +740,7 @@ def discardOneCard(card, place, destination) @deal_cards['card_played'] += this_cards debug("@deal_cards", @deal_cards) - return $okResult + return OK_RESULT else return card; # 指定のカードが無いので、無いカードを返す end @@ -847,9 +850,9 @@ def transferCardsByCards(cards, destination, nick_e) debug('transferOneCard result', result) case result - when $ngResult + when NG_RESULT return -1, ['渡す相手が登録されていません'] - when $okResult + when OK_RESULT okCount += 1 else ngCardList << result @@ -903,13 +906,13 @@ def transferOneCard(card, from, toSend) # debug('相手は未登録済み') isSuccess = transferTargetCardToNewMember(toSend, thisCard) debug('isSuccess', isSuccess) - return $ngResult unless isSuccess + return NG_RESULT unless isSuccess end @deal_cards[from] = restCards debug("transferOneCard @deal_cards", @deal_cards) - return $okResult + return OK_RESULT end def ejectOneCardRandomFromCards(cards) @@ -1043,9 +1046,9 @@ def getSendCardToTargetNickPlaceByCards(cards, destination, toSend) result = transferOneCard(card, destination, toSend) case result - when $ngResult + when NG_RESULT return -1, '渡す相手が登録されていません' - when $okResult + when OK_RESULT okCardList << card else ngCardList << result @@ -1145,7 +1148,7 @@ def tapOneCardByCardAndPlace(card, place, isUntap) @nick_e = nick_e_original - if result == $okResult + if result == OK_RESULT return card, nil else return nil, card diff --git a/src/configBcDice.rb b/src/configBcDice.rb index 4f6cd21f9..789e15de5 100644 --- a/src/configBcDice.rb +++ b/src/configBcDice.rb @@ -1,29 +1,16 @@ # -*- coding: utf-8 -*- -require 'kconv' -require 'configBcDiceForSystem.rb' - $isDebug = false $bcDiceVersion = "2.06.01" +# @deprecated IRCボット機能の削除に伴い廃止予定。 $SEND_STR_MAX = 405; # 最大送信文字数(本来は500byte上限) -$isRollVoidDiceAtAnyRecive = true; # 発言の度に空ダイスを振るか? + $DICE_MAXCNT = 200; # ダイスが振れる最大個数 $DICE_MAXNUM = 1000; # ダイスの最大面数 -$ircCode = Kconv::UTF8; # IRCサーバとの通信に使うコードをRuby::Kconv値で指定 $isHandSort = true; # 手札をソートする必要があるか? $OPEN_DICE = 'Open Dice!'; # シークレットダイスの出目表示コマンド $OPEN_PLOT = 'Open Plot!'; # プロットの表示コマンド $ADD_PLOT = 'PLOT'; # プロットの入力コマンド $READY_CMD = '#HERE'; # 自分の居るチャンネルの宣言コマンド - -# $server = "localhost"; # サーバー -$server = "irc.trpg.net"; # サーバー -$port = 6667; # ポート番号 -$defaultLoginChannelsText = "#Dice_Test"; # ボットが最初に参加するチャンネル名 -$nick = "bcDICE" -$userName = "v" + $bcDiceVersion # ユーザー名 -$ircName = "rubydice"; # IRCネーム -$defaultGameType = "" # デフォルトゲームタイプ -$extraCardFileName = "" # 拡張カードファイル名 diff --git a/src/configBcDiceForSystem.rb b/src/configBcDiceForSystem.rb deleted file mode 100644 index e247195a5..000000000 --- a/src/configBcDiceForSystem.rb +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- - -# この下の記述は内部識別用のため修正の必要無し -$okResult = '_OK_' -$ngResult = '_NG_' - -$ircNickMaxLength = 9 diff --git a/src/test/others/testPointer.rb b/src/test/others/testPointer.rb index f02ac5051..43944fcd3 100644 --- a/src/test/others/testPointer.rb +++ b/src/test/others/testPointer.rb @@ -11,7 +11,6 @@ class TestPointer < Test::Unit::TestCase def setup $isDebug = false - $isRollVoidDiceAtAnyRecive = false @nick = "test_nick" @channel = "test_channel" diff --git a/src/test/others/testSecretDice.rb b/src/test/others/testSecretDice.rb index cac8febb7..b66378ee5 100644 --- a/src/test/others/testSecretDice.rb +++ b/src/test/others/testSecretDice.rb @@ -11,7 +11,6 @@ class TestSecretDice < Test::Unit::TestCase def setup $isDebug = false - # $isRollVoidDiceAtAnyRecive = false @nick = "test_nick" @channel = "test_channel" From df5c9d84c0f8634481f7c4137860f8265a69b145 Mon Sep 17 00:00:00 2001 From: ocha Date: Wed, 1 Jul 2020 23:36:26 +0900 Subject: [PATCH 5/7] =?UTF-8?q?isIrcMode=E3=80=81sleepForIrc=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit IRCボット固有の処理だった。 --- src/bcdiceCore.rb | 13 ------------- src/cgiDiceBot.rb | 1 - 2 files changed, 14 deletions(-) diff --git a/src/bcdiceCore.rb b/src/bcdiceCore.rb index 6e0587d42..72d06c578 100755 --- a/src/bcdiceCore.rb +++ b/src/bcdiceCore.rb @@ -89,7 +89,6 @@ def initialize(parent, cardTrader, diceBot, counterInfos, tableFileData) @tnick = "" @rands = nil @isKeepSecretDice = true - @isIrcMode = true @collect_rand_results = false @rand_results = [] @@ -318,7 +317,6 @@ def printPlot else debug("message", message) sendMessage(@channel, message) - sleepForIrc 1 end end end @@ -345,7 +343,6 @@ def printSecretRoll next if diceResult.empty? sendMessage(@channel, diceResult) - sleepForIrc 1 end end @@ -1233,14 +1230,4 @@ def setGameByTitle(gameTitle) return message end - - def setIrcMode(mode) - @isIrcMode = mode - end - - def sleepForIrc(second) - if @isIrcMode - sleep(second) - end - end end diff --git a/src/cgiDiceBot.rb b/src/cgiDiceBot.rb index fb6de4dc8..0a775d281 100644 --- a/src/cgiDiceBot.rb +++ b/src/cgiDiceBot.rb @@ -107,7 +107,6 @@ def executeDiceBot(message, gameType, dir = nil, prefix = '', isNeedResult = fal bcdice.setTest(@isTest) bcdice.setCollectRandResult(isNeedResult) bcdice.setDir(dir, prefix) - bcdice.setIrcMode(false) if bcdice.getGameType != gameType bcdice.setGameByTitle(gameType) From e55cdc4cea52110fd79bee870a67091e65064446 Mon Sep 17 00:00:00 2001 From: ocha Date: Wed, 1 Jul 2020 23:46:00 +0900 Subject: [PATCH 6/7] =?UTF-8?q?decode/encode=E3=80=81kconv=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/TableFileData.rb | 2 -- src/bcdiceCore.rb | 11 +---------- src/test/others/testCard.rb | 1 - src/test/others/testPointer.rb | 1 - src/test/others/testSecretDice.rb | 1 - 5 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/TableFileData.rb b/src/TableFileData.rb index ba44753ce..d8ba3444c 100755 --- a/src/TableFileData.rb +++ b/src/TableFileData.rb @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- -require 'kconv' require 'fileutils' -require 'configBcDice.rb' # extratables ディレクトリに置かれたテーブル定義ファイルを読み込む。 # 詳細はREADME.txtの「7.オリジナルの表追加」を参照。 diff --git a/src/bcdiceCore.rb b/src/bcdiceCore.rb index 72d06c578..8a4b024a1 100755 --- a/src/bcdiceCore.rb +++ b/src/bcdiceCore.rb @@ -4,17 +4,8 @@ require 'log' require 'configBcDice.rb' require 'CountHolder.rb' -require 'kconv' require 'utils/ArithmeticEvaluator.rb' -def decode(code, str) - return str.kconv(code) -end - -def encode(code, str) - return Kconv.kconv(str, code) -end - # WindowsでかつRuby 1.9未満の環境であるかどうかを示す # 端末にShift_JISで出力する必要性の判定に用いる $RUBY18_WIN = RUBY_VERSION < '1.9' && @@ -1125,7 +1116,7 @@ def broadmsg(output, nick) end if nick == @nick_e - sendMessageToOnlySender(output) # encode($ircCode, output)) + sendMessageToOnlySender(output) else sendMessage(nick, output) end diff --git a/src/test/others/testCard.rb b/src/test/others/testCard.rb index 8b4baaf31..98f902828 100644 --- a/src/test/others/testCard.rb +++ b/src/test/others/testCard.rb @@ -3,7 +3,6 @@ $:.push(File.dirname(__FILE__) + "/..") require 'test/unit' require 'CardTrader' -require 'Kconv' require 'log' require 'BCDice_forTest' diff --git a/src/test/others/testPointer.rb b/src/test/others/testPointer.rb index 43944fcd3..211a829a5 100644 --- a/src/test/others/testPointer.rb +++ b/src/test/others/testPointer.rb @@ -2,7 +2,6 @@ $:.push(File.dirname(__FILE__) + "/..") require 'test/unit' -require 'Kconv' require 'log' require 'BCDice_forTest' diff --git a/src/test/others/testSecretDice.rb b/src/test/others/testSecretDice.rb index b66378ee5..bda2d1705 100644 --- a/src/test/others/testSecretDice.rb +++ b/src/test/others/testSecretDice.rb @@ -2,7 +2,6 @@ $:.push(File.dirname(__FILE__) + "/..") require 'test/unit' -require 'Kconv' require 'log' require 'BCDice_forTest' From ffb57d31d4680bcf13f7d1219db5f53ff8fc3232 Mon Sep 17 00:00:00 2001 From: ocha Date: Wed, 1 Jul 2020 23:47:01 +0900 Subject: [PATCH 7/7] =?UTF-8?q?BCDice#setIrcClient=E3=81=ABTODO=E3=82=B3?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bcdiceCore.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bcdiceCore.rb b/src/bcdiceCore.rb index 8a4b024a1..31ad5d690 100755 --- a/src/bcdiceCore.rb +++ b/src/bcdiceCore.rb @@ -110,6 +110,7 @@ def readExtraCard(cardFileName) @cardTrader.readExtraCard(cardFileName) end + # @todo ircClient経由でなく直接メッセージを返すようにする def setIrcClient(client) @ircClient = client end