]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/dict.rb
lart plugin: replace "me" with sourcenick
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / dict.rb
index dc52dbd9eb991867309a1abd8170cb7cc627d34d..ca5f25882147c94cb7c268cb5d27e31dda216fa6 100644 (file)
@@ -73,7 +73,7 @@ class DictPlugin < Plugin
     entries = xml.scan(DEMAURO_LEMMA)\r
     text = word\r
     urls = []\r
-    if !entries.assoc(word) and !entries.assoc(word.upcase)\r
+    if not entries.transpose.first.grep(/\b#{word}\b/)\r
       return false if justcheck\r
       text += " not found. Similar words"\r
     end\r
@@ -93,7 +93,7 @@ class DictPlugin < Plugin
     return unless first_pars > 0\r
 \r
     Utils.get_first_pars urls, first_pars, :message => m,\r
-      :strip => /^\S+\s+-\s+/\r
+      :strip => /^.+?\s+-\s+/\r
 \r
   end\r
 \r
@@ -108,9 +108,14 @@ class DictPlugin < Plugin
     word = params[:word].join\r
     [word, word + "_1"].each { |check|\r
       url = @oxurl % CGI.escape(check)\r
-      h = @bot.httputil.head(url, :max_redir => 5)\r
-      if h\r
-        m.reply("#{word} found: #{url}") unless justcheck\r
+      if params[:british]\r
+        url << "?view=uk"\r
+      end\r
+      h = @bot.httputil.get(url, :max_redir => 5)\r
+      if h and h.match(%r!<h2>#{word}(?:<sup>1</sup>)?</h2>!)\r
+        m.reply("#{word} : #{url}") unless justcheck\r
+        defn = $'\r
+        m.reply("#{Bold}%s#{Bold}: %s" % [word, defn.ircify_html(:nbsp => :space)], :overlong => :truncate)\r
         return true\r
       end\r
     }\r
@@ -119,7 +124,7 @@ class DictPlugin < Plugin
   end\r
 \r
   def is_british?(word)\r
-    return oxford(nil, :word => word, :justcheck => true)\r
+    return oxford(nil, :word => word, :justcheck => true, :british => true)\r
   end\r
 \r
 \r