summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-01-27 22:16:56 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-01-27 22:16:56 +0100
commitb0a372c2e93194a5573197e173c3e8409df5e25a (patch)
treeba06c0019a012832074571736171c48d930bff5a /data
parent3b294f9aa35c975b00c4f11d090526eb4ff9c34c (diff)
azgame plugin: use Wordlist provider
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/games/azgame.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/data/rbot/plugins/games/azgame.rb b/data/rbot/plugins/games/azgame.rb
index 6fb3f670..cb95228d 100644
--- a/data/rbot/plugins/games/azgame.rb
+++ b/data/rbot/plugins/games/azgame.rb
@@ -150,18 +150,16 @@ class AzGamePlugin < Plugin
},
}
- @wordlist_base = "#{@bot.botclass}/azgame/wordlist-"
@autoadd_base = "#{@bot.botclass}/azgame/autoadd-"
end
def initialize_wordlist(params)
lang = params[:lang]
addlang = params[:addlang]
- wordlist = @wordlist_base + lang.to_s
autoadd = @autoadd_base + addlang.to_s
- if File.exist?(wordlist)
+ if Wordlist.exist?(lang)
# wordlists are assumed to be UTF-8, but we need to strip the BOM, if present
- words = File.readlines(wordlist).map {|line| line.sub("\xef\xbb\xbf",'').strip}
+ words = Wordlist.get(lang)
if addlang and File.exist?(autoadd)
word += File.readlines(autoadd).map {|line| line.sub("\xef\xbb\xbf",'').strip}
end
@@ -600,9 +598,8 @@ 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
- offset = @wordlist_base.length
langs = @rules.keys
- wls = Dir.glob(@wordlist_base + "*").map { |f| f[offset,f.length].intern rescue nil }.compact - langs
+ wls = Wordlist.list
return [
_("az topics: play, rules, cancel, manage, check"),
_("available languages: %{langs}") % { :langs => langs.join(", ") },