diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-11-17 00:30:36 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-11-17 00:30:36 +0100 |
commit | 64f0543749cfa675dcb519313430905810d22c04 (patch) | |
tree | 64715b5a2c403fd1c3949e6889ec47e03cb1287d | |
parent | 72f8838ffb1b752ebfb52e9c9907fb29d6780638 (diff) |
azgame plugin: show available languages and wordlists in help
-rw-r--r-- | data/rbot/plugins/games/azgame.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/data/rbot/plugins/games/azgame.rb b/data/rbot/plugins/games/azgame.rb index 2d524305..1df3c7b4 100644 --- a/data/rbot/plugins/games/azgame.rb +++ b/data/rbot/plugins/games/azgame.rb @@ -127,10 +127,12 @@ class AzGamePlugin < Plugin :listener => /^[a-z]+$/ }, } + + @wordlist_base = "#{@bot.botclass}/azgame/wordlist-" end def initialize_wordlist(lang) - wordlist = "#{@bot.botclass}/azgame/wordlist-#{lang}" + wordlist = @wordlist_base + lang if File.exist?(wordlist) words = File.readlines(wordlist).map {|line| line.strip}.uniq if(words.length >= 4) # something to guess @@ -564,7 +566,15 @@ class AzGamePlugin < Plugin when 'play' return _("az => start a game if none is running, show the current word range otherwise; you can say 'az <language>' if you want to play in a language different from the current bot default") end - return _("az topics: play, rules, cancel, manage, check") + offset = @wordlist_base.length + langs = @rules.keys + wls = Dir.glob(@wordlist_base + "*").map { |f| f[offset,f.length].intern rescue nil }.compact - langs + return [ + _("az topics: play, rules, cancel, manage, check"), + _("available languages: %{langs}") % { :langs => langs.join(", ") }, + wls.empty? ? nil : _("available wordlists: %{wls}") % { :wls => wls.join(", ") }, + ].compact.join(". ") + end end |