From 64f0543749cfa675dcb519313430905810d22c04 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 17 Nov 2008 00:30:36 +0100 Subject: azgame plugin: show available languages and wordlists in help --- data/rbot/plugins/games/azgame.rb | 14 ++++++++++++-- 1 file 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 ' 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 -- cgit v1.2.3