]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/dict.rb
+ added a translator plugin
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / dict.rb
index 30cfc5feefb9eefba7259c667b7e6619a26d6a8e..95d9fe2e08cd9cb7605dbc9a2e2a807a0761e5ac 100644 (file)
@@ -19,6 +19,7 @@
 # TODO: cache results and reuse them if get_cached returns a cache copy\r
 \r
 DEMAURO_LEMMA = /<anchor>(.*?)(?: - (.*?))<go href="lemma.php\?ID=(\d+)"\/><\/anchor>/\r
+CHAMBERS_LEMMA = /<p><span class="hwd">(.*?)<\/span> <span class="psa">(.*?)<\/span>(.*?)<\/p>/\r
 \r
 class DictPlugin < Plugin\r
   BotConfig.register BotConfigIntegerValue.new('dict.hits',\r
@@ -143,10 +144,16 @@ class DictPlugin < Plugin
     when /No exact matches for <b>.*?<\/b>, but the following may be helpful./\r
       return false if justcheck\r
       m.reply "Nothing found for #{word}, but see #{url} for possible suggestions"\r
-    else\r
-      return true if justcheck\r
-      m.reply "#{word}: #{url}"\r
+      return\r
     end\r
+    # Else, we have a hit\r
+    return true if justcheck\r
+    m.reply "#{word}: #{url}"\r
+    entries = xml.scan(CHAMBERS_LEMMA)\r
+    hits = @bot.config['dict.hits']\r
+    entries[0...hits].map { |ar|\r
+      m.reply(("#{Bold}%s#{Bold} #{Underline}%s#{Underline}%s" % ar).ircify_html, :overlong => :truncate)\r
+    }\r
   end\r
 \r
   def is_english?(word)\r