]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/dict.rb
hangman: IRCify HTML in definitions
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / dict.rb
index edadd3c7cbb877a08ad104af2d8ff66280c46006..c9bfabafadef5fb75491d6590f492d7ec8caa48a 100644 (file)
@@ -53,8 +53,8 @@ class DictPlugin < Plugin
 
   def initialize
     super
-    @dmurl = "http://www.demauroparavia.it/"
-    @dmurlrx = %r{http://(?:www\.)?demauroparavia\.it/(\d+)}
+    @dmurl = "http://old.demauroparavia.it/"
+    @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"
@@ -112,7 +112,8 @@ class DictPlugin < Plugin
     text += entries[0...hits].map { |ar|
       n += 1
       urls << @dmwaplemma % ar[2]
-      "#{n}. #{Bold}#{ar[0]}#{Bold} - #{ar[1].gsub(/<\/?em>/,'')}: #{@dmurl}#{ar[2]}"
+      key = ar[1].ircify_html
+      "#{n}. #{Bold}#{ar[0]}#{Bold} - #{key}: #{@dmurl}#{ar[2]}"
     }.join(" | ")
     m.reply text
 
@@ -140,9 +141,9 @@ class DictPlugin < Plugin
         url << "?view=uk"
       end
       h = @bot.httputil.get(url, :max_redir => 5)
-      if h and h.match(%r!<h2>#{word}(?:<sup>1</sup>)?</h2>!)
+      if h and h.match(/<h2>#{word}<\/h2>(.*)Perform/m)
         m.reply("#{word} : #{url}") unless justcheck
-        defn = $'
+        defn = $1
         m.reply("#{Bold}%s#{Bold}: %s" % [word, defn.ircify_html(:nbsp => :space)], :overlong => :truncate)
         return true
       end