]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/games/azgame.rb
refactor: wordlist shouldn't use bot singleton #35
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / games / azgame.rb
index 572684d912d68c1fc1d5ae2ea8faa16f666b3deb..b4dbabc1b73a03573c8883112b89c3e8246119df 100644 (file)
@@ -145,7 +145,7 @@ class AzGamePlugin < Plugin
       :good => /(?:singular )?noun|verb|adj/,
       :first => 'abacus',
       :last => 'zuni',
-      :url => "http://www.chambersharrap.co.uk/chambers/features/chref/chref.py/main?query=%s&title=21st",
+      :url => "http://www.chambers.co.uk/search.php?query=%s&title=21st",
       :listener => /^[a-z]+$/
     },
     }
@@ -157,9 +157,9 @@ class AzGamePlugin < Plugin
     lang = params[:lang]
     addlang = params[:addlang]
     autoadd = @autoadd_base + addlang.to_s
-    if Wordlist.exist?(lang)
+    if Wordlist.exist?(@bot, lang)
       # wordlists are assumed to be UTF-8, but we need to strip the BOM, if present
-      words = Wordlist.get(lang)
+      words = Wordlist.get(@bot, lang)
       if addlang and File.exist?(autoadd)
         word += File.readlines(autoadd).map {|line| line.sub("\xef\xbb\xbf",'').strip}
       end
@@ -560,6 +560,7 @@ class AzGamePlugin < Plugin
         debug "getting random word from dictionary, matching #{random}"
         p = @bot.httputil.get(rules[:url] % CGI.escape(random))
         debug p
+        raise 'unable to get search results' if not p.match /id="fullsearchresults"/i
         lemmi = Array.new
         good = rules[:good]
         # We look for a lemma composed by a single word and of length at least two
@@ -599,7 +600,7 @@ class AzGamePlugin < Plugin
       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
     langs = @rules.keys
-    wls = Wordlist.list
+    wls = Wordlist.list(@bot)
     return [
       _("az topics: play, rules, cancel, manage, check"),
       _("available languages: %{langs}") % { :langs => langs.join(", ") },