]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/dict.rb
* (plugins/ri) acknoledge the '!ri tell (whom)' command
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / dict.rb
index 149233d3b0871a0b39ea0ee00c1088e6859e1821..ef162215ef4ee5044363ba24ce4b11139d775832 100644 (file)
@@ -18,8 +18,6 @@
 #\r
 # TODO: cache results and reuse them if get_cached returns a cache copy\r
 \r
-require 'uri'\r
-\r
 DEMAURO_LEMMA = /<anchor>(.*?)(?: - (.*?))<go href="lemma.php\?ID=(\d+)"\/><\/anchor>/\r
 \r
 class DictPlugin < Plugin\r
@@ -57,9 +55,10 @@ class DictPlugin < Plugin
 \r
     word = params[:word].downcase\r
     url = @dmwapurl % URI.escape(word)\r
-    xml = @bot.httputil.get_cached(url)\r
+    xml = nil\r
+    info = @bot.httputil.get_response(url) rescue nil\r
+    xml = info.body if info\r
     if xml.nil?\r
-      info = @bot.httputil.last_response\r
       info = info ? " (#{info.code} - #{info.message})" : ""\r
       return false if justcheck\r
       m.reply "An error occurred while looking for #{word}#{info}"\r
@@ -92,7 +91,7 @@ class DictPlugin < Plugin
 \r
     return unless first_pars > 0\r
 \r
-    Utils.get_first_pars urls, first_pars, :http_util => @bot.httputil, :message => m,\r
+    Utils.get_first_pars urls, first_pars, :message => m,\r
       :strip => /^\S+\s+-\s+/\r
 \r
   end\r
@@ -108,7 +107,7 @@ class DictPlugin < Plugin
     word = params[:word].join\r
     [word, word + "_1"].each { |check|\r
       url = @oxurl % URI.escape(check)\r
-      h = @bot.httputil.head(url)\r
+      h = @bot.httputil.head(url, :max_redir => 5)\r
       if h\r
         m.reply("#{word} found: #{url}") unless justcheck\r
         return true\r
@@ -128,10 +127,11 @@ class DictPlugin < Plugin
 \r
     word = params[:word].to_s.downcase\r
     url = @chambersurl % URI.escape(word)\r
-    xml = @bot.httputil.get_cached(url)\r
+    xml = nil\r
+    info = @bot.httputil.get_response(url) rescue nil\r
+    xml = info.body if info\r
     case xml\r
     when nil\r
-      info = @bot.httputil.last_response\r
       info = info ? " (#{info.code} - #{info.message})" : ""\r
       return false if justcheck\r
       m.reply "An error occurred while looking for #{word}#{info}"\r