]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/dict.rb
dict: update oxford url
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / dict.rb
index c9bfabafadef5fb75491d6590f492d7ec8caa48a..9b8e2139d2f68daafe2b4dec194089a6ea6c12bc 100644 (file)
@@ -1,3 +1,4 @@
+# encoding: UTF-8
 #-- vim:sw=2:et
 #++
 #
@@ -57,7 +58,7 @@ class DictPlugin < Plugin
     @dmurlrx = %r{http://(?:www|old\.)?demauroparavia\.it/(\d+)}
     @dmwapurl = "http://wap.demauroparavia.it/index.php?lemma=%s"
     @dmwaplemma = "http://wap.demauroparavia.it/lemma.php?ID=%s"
-    @oxurl = "http://www.askoxford.com/concise_oed/%s"
+    @oxurl = "http://www.oxforddictionaries.com/definition/english/%s"
     @chambersurl = "http://www.chambersharrap.co.uk/chambers/features/chref/chref.py/main?query=%s&title=21st"
     @littreurl = "http://francois.gannaz.free.fr/Littre/xmlittre.php?requete=%s"
 
@@ -141,15 +142,20 @@ class DictPlugin < Plugin
         url << "?view=uk"
       end
       h = @bot.httputil.get(url, :max_redir => 5)
-      if h and h.match(/<h2>#{word}<\/h2>(.*)Perform/m)
-        m.reply("#{word} : #{url}") unless justcheck
-        defn = $1
+      if h
+       defs = h.split("<span class=\"definition\">")
+       defs = defs[1..-1].map {|d| d.split("</span>")[0]}
+        if defs.size == 0
+         return false if justcheck
+         m.reply "#{word} not found"
+         return false
+       end
+       m.reply("#{word}: #{url}") unless justcheck
+       defn = defs[0]
         m.reply("#{Bold}%s#{Bold}: %s" % [word, defn.ircify_html(:nbsp => :space)], :overlong => :truncate)
         return true
       end
     }
-    return false if justcheck
-    m.reply "#{word} not found"
   end
 
   def is_british?(word)