差分

サーバー本体:見出しにクラス名を追加する
1行目: 1行目:  
[[どどんとふ]]からの[[BCDice]]の呼び出し方。このページでは、Rubyで書かれたどどんとふのサーバのダイス関連の処理を扱う。[https://github.com/torgtaitai/DodontoF/tree/d3e4cc374885986efc761cfabbb19e4b35e815e0 v1.49.04.01]のソースコードを参考にしている。
 
[[どどんとふ]]からの[[BCDice]]の呼び出し方。このページでは、Rubyで書かれたどどんとふのサーバのダイス関連の処理を扱う。[https://github.com/torgtaitai/DodontoF/tree/d3e4cc374885986efc761cfabbb19e4b35e815e0 v1.49.04.01]のソースコードを参考にしている。
   −
== ファイルの役割 ==
+
== 各ファイルの役割 ==
    
どどんとふのサーバでは、ダイスボットとの通信の処理は以下のファイルに記述されている。
 
どどんとふのサーバでは、ダイスボットとの通信の処理は以下のファイルに記述されている。
12行目: 12行目:     
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb
 +
 +
ダイスロールと関係していることがすぐに分かるファイル名だが、実は大部分は独自の表からの情報の読み出しやファイル管理の処理となっている。
    
=== L7-L10:<code>DiceAdapter#initialize</code> ===
 
=== L7-L10:<code>DiceAdapter#initialize</code> ===
64行目: 66行目:     
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L36-L45
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L36-L45
 +
 +
独自の表について、ゲームタイプ(ゲームの識別子)および含まれるコマンドの情報を返す。<code>CgiDiceBot#getGameCommandInfos</code> を経由して <code>TableFileData#getGameCommandInfos</code> を呼び出している。
    
<syntaxhighlight lang="ruby">
 
<syntaxhighlight lang="ruby">
75行目: 79行目:     
   return commandInfos
 
   return commandInfos
 +
end
 +
</syntaxhighlight>
 +
 +
=== L47-L63:<code>DiceAdapter#getBotTableInfosFromDir</code> ===
 +
 +
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L47-L63
 +
 +
独自の表についての情報を取得する。<code>getGameCommandInfos</code> と似ているが、こちらの方が返される情報が詳しい?
 +
 +
<syntaxhighlight lang="ruby">
 +
def getBotTableInfosFromDir
 +
  @logger.debug(@dir, 'getBotTableInfosFromDir dir')
 +
 +
  require 'TableFileData'
 +
 +
  isLoadCommonTable = false
 +
  tableFileData = TableFileData.new( isLoadCommonTable )
 +
  tableFileData.setDir(@dir, @diceBotTablePrefix)
 +
  tableInfos = tableFileData.getAllTableInfo
 +
 +
  @logger.debug(tableInfos, "getBotTableInfosFromDir tableInfos")
 +
  tableInfos.sort!{|a, b| a["command"].to_i <=> b["command"].to_i}
 +
 +
  @logger.debug(tableInfos, 'getBotTableInfosFromDir result tableInfos')
 +
 +
  return tableInfos
 +
end
 +
</syntaxhighlight>
 +
 +
=== L65-L84:<code>DiceAdapter#addBotTableMain</code> ===
 +
 +
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L65-L84
 +
 +
独自の表のファイルを保存する。
 +
 +
<syntaxhighlight lang="ruby">
 +
def addBotTableMain(params)
 +
  @logger.debug("addBotTableMain Begin")
 +
 +
  DodontoF::Utils.makeDir(@dir)
 +
 +
  require 'TableFileData'
 +
 +
  resultText = 'OK'
 +
  begin
 +
    creator = TableFileCreator.new(@dir, @diceBotTablePrefix, params)
 +
    creator.execute
 +
  rescue Exception => e
 +
    @logger.exception(e)
 +
    resultText = getLanguageKey( e.to_s )
 +
  end
 +
 +
  @logger.debug(resultText, "addBotTableMain End resultText")
 +
 +
  return resultText
 +
end
 +
</syntaxhighlight>
 +
 +
=== L86-L103:<code>DiceAdapter#changeBotTableMain</code> ===
 +
 +
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103
 +
 +
独自の表のファイルを更新する。
 +
 +
<syntaxhighlight lang="ruby">
 +
def changeBotTableMain(params)
 +
  @logger.debug("changeBotTableMain Begin")
 +
 +
  require 'TableFileData'
 +
 +
  resultText = 'OK'
 +
  begin
 +
    creator = TableFileEditer.new(@dir, @diceBotTablePrefix, params)
 +
    creator.execute
 +
  rescue Exception => e
 +
    @logger.exception(e)
 +
    resultText = getLanguageKey( e.to_s )
 +
  end
 +
 +
  @logger.debug(resultText, "changeBotTableMain End resultText")
 +
 +
  return resultText
 +
end
 +
</syntaxhighlight>
 +
 +
=== L105-L135:<code>DiceAdapter#removeBotTableMain</code> ===
 +
 +
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/src_ruby/dodontof/dice_adapter.rb#L86-L103
 +
 +
独自の表のファイルを削除する。
 +
 +
<syntaxhighlight lang="ruby">
 +
def removeBotTableMain(params)
 +
  @logger.debug("removeBotTableMain Begin")
 +
 +
  command = params["command"]
 +
 +
  require 'TableFileData'
 +
 +
  isLoadCommonTable = false
 +
  tableFileData = TableFileData.new( isLoadCommonTable )
 +
  tableFileData.setDir(@dir, @diceBotTablePrefix)
 +
  tableInfos = tableFileData.getAllTableInfo
 +
 +
  tableInfo = tableInfos.find{|i| i["command"] == command}
 +
  @logger.debug(tableInfo, "tableInfo")
 +
  return if( tableInfo.nil? )
 +
 +
  fileName = tableInfo["fileName"]
 +
  @logger.debug(fileName, "fileName")
 +
  return if( fileName.nil? )
 +
 +
  @logger.debug("isFile exist?")
 +
  return unless( File.exist?(fileName) )
 +
 +
  begin
 +
    File.delete(fileName)
 +
  rescue Exception => e
 +
    @logger.exception(e)
 +
  end
 +
 +
  @logger.debug("removeBotTableMain End")
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
211行目: 337行目:  
<code>getDiceBotExtraTableDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3727-L3729 L3727-L3729])では、<code>getRoomLocalSpaceDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3262-L3265 L3262-L3265])、<code>getRoomLocalSpaceDirNameByRoomNo</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3267-L3273 L3267-L3273])を経由して、<code>$imageUploadDir</code> の中の部屋固有のディレクトリを返す。
 
<code>getDiceBotExtraTableDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3727-L3729 L3727-L3729])では、<code>getRoomLocalSpaceDirName</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3262-L3265 L3262-L3265])、<code>getRoomLocalSpaceDirNameByRoomNo</code>([https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3267-L3273 L3267-L3273])を経由して、<code>$imageUploadDir</code> の中の部屋固有のディレクトリを返す。
   −
=== L1193-L1210:<code>getWebIfServerInfo</code> ===
+
=== L1193-L1210:<code>DodontoFServer#getWebIfServerInfo</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L1193-L1210
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L1193-L1210
238行目: 364行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L2090:<code>getLoginInfo</code> ===
+
=== L2090:<code>DodontoFServer#getLoginInfo</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2090
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2090
248行目: 374行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L2266-L2280:<code>getDiceBotInfos</code> ===
+
=== L2266-L2280:<code>DodontoFServer#getDiceBotInfos</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2266-L2280
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2266-L2280
272行目: 398行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L2542-2556:<code>save</code>, <code>getDiceTableData</code> ===
+
=== L2542-2556:<code>DodontoFServer#save</code>, <code>getDiceTableData</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2542-2556
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2542-2556
296行目: 422行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L2806-L2817:<code>getBotTableInfos</code> ===
+
=== L2806-L2817:<code>DodontoFServer#getBotTableInfos</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2806-L2817
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2806-L2817
317行目: 443行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L2819-L2835:<code>addBotTable</code> ===
+
=== L2819-L2835:<code>DodontoFServer#addBotTable</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2819-L2835
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2819-L2835
343行目: 469行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L2837-L2849:<code>changeBotTable</code> ===
+
=== L2837-L2849:<code>DodontoFServer#changeBotTable</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2837-L2849
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2837-L2849
365行目: 491行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L2851-L2855:<code>removeBotTable</code> ===
+
=== L2851-L2855:<code>DodontoFServer#removeBotTable</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2851-L2855
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L2851-L2855
379行目: 505行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L3458-L3459:<code>loadSaveFileDataFilterByTargets</code> ===
+
=== L3458-L3459:<code>DodontoFServer#loadSaveFileDataFilterByTargets</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3458-L3459
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3458-L3459
390行目: 516行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L3511-L3531:<code>loadDiceBotTable</code>, <code>getDiceBotTableString</code> ===
+
=== L3511-L3531:<code>DodontoFServer#loadDiceBotTable</code>, <code>DodontoFServer#getDiceBotTableString</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3511-L3531
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3511-L3531
420行目: 546行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L3632-L3657:<code>sendDiceBotChatMessage</code> ===
+
=== L3632-L3657:<code>DodontoFServer#sendDiceBotChatMessage</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3632-L3657
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3632-L3657
455行目: 581行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L3659-L3669:<code>getDiceBotRepeatCount</code> ===
+
=== L3659-L3669:<code>DodontoFServer#getDiceBotRepeatCount</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3659-L3669
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3659-L3669
475行目: 601行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L3672-L3709:<code>sendDiceBotChatMessageOnece</code> ===
+
=== L3672-L3709:<code>DodontoFServer#sendDiceBotChatMessageOnece</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709
522行目: 648行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L3672-L3725:<code>getRollDiceResult</code> ===
+
=== L3672-L3725:<code>DodontoFServer#getRollDiceResult</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3672-L3709
546行目: 672行目:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
=== L3732-L3762:<code>getRolledMessage</code> ===
+
=== L3732-L3762:<code>DodontoFServer#getRolledMessage</code> ===
    
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3732-L3709
 
https://github.com/torgtaitai/DodontoF/blob/d3e4cc374885986efc761cfabbb19e4b35e815e0/DodontoFServer.rb#L3732-L3709