X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fgames%2Fshiritori.rb;h=84ee9620d869b566f258529345a0b8c566daad51;hb=1e41b1496490a9cd9d97b9196b65f162397570df;hp=111c914afa4d99431741d05c5c497cecb103203e;hpb=e271af52bf0a7ac9796bafb04052ee073cd40738;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/games/shiritori.rb b/data/rbot/plugins/games/shiritori.rb index 111c914a..84ee9620 100644 --- a/data/rbot/plugins/games/shiritori.rb +++ b/data/rbot/plugins/games/shiritori.rb @@ -15,6 +15,10 @@ # playing several games, each per channel. A game can be turn-based, where only new # players can interrupt a turn to join, or a free mode where anyone can speak at any # time. +# +# In Japanese mode, if present, the plugin can use normalize-japanese +# to allow +# katakana words be used like hiragana. # # TODO # * a system to describe settings, so they can be displayed, changed and saved @@ -367,7 +371,13 @@ class ShiritoriPlugin < Plugin :listen => /\A\S+\Z/u, :overlap_lengths => 1..4, :desc => 'Use Japanese words in hiragana; 1-4 kana at the beginning of the next word must overlap with those at the end of the previous word.', - # Optionally use a module to normalize Japanese words, enabling input in multiple writing systems + :normalize => + begin + require 'normalize-japanese' + lambda {|w| w.to_hiragana} + rescue LoadError + lambda {|w| w} + end } } end @@ -443,8 +453,7 @@ class ShiritoriPlugin < Plugin end # all messages from a channel is sent to its shiritori game if any - def listen(m) - return unless m.kind_of?(PrivMessage) + def message(m) return unless @games.has_key?(m.channel) # send the message to the game in the channel to handle it @games[m.channel].handle_message m