]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/games/azgame.rb
remove whitespace
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / games / azgame.rb
index 6fb3f670d3d3bc963c8aaf9ef7aceedcecae505b..572684d912d68c1fc1d5ae2ea8faa16f666b3deb 100644 (file)
@@ -150,18 +150,16 @@ class AzGamePlugin < Plugin
     },
     }
 
-    @wordlist_base = "#{@bot.botclass}/azgame/wordlist-"
-    @autoadd_base = "#{@bot.botclass}/azgame/autoadd-"
+    @autoadd_base = datafile "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
@@ -357,10 +355,10 @@ class AzGamePlugin < Plugin
       if wc[word].key?(:when)
         tr = _("%{word} learned from %{user} on %{date}") % {:word => word, :user => wc[word][:who], :date => wc[word][:when]}
       else
-        tr = _("%{word} learned from %{user}") % {:word => word, :user => wc[word][:who]} 
+        tr = _("%{word} learned from %{user}") % {:word => word, :user => wc[word][:who]}
       end
       m.reply tr
-    when :delete 
+    when :delete
       if pars.empty?
         m.reply _("provide a word")
         return
@@ -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(", ") },