]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/urban.rb
dict.rb plugin: fixes the oxford parser so it doesn't spit out a bunch of extra crap
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / urban.rb
index 5aae26c6d47cc10566c7a9fc5eb50f1fc387ad6b..a24ac072091f7ed3d4d75031da89460060d94829 100644 (file)
@@ -26,13 +26,13 @@ class UrbanPlugin < Plugin
 
     rv = Array.new
 
-    s.scan(%r{<td class="def_number"[^>]*>(\d+)\.</td>.*?<td class="def_word">(?:<a.*?>)?([^>]+)(?:</a>)?</td>.*?<div class="def_p">.*?<p>(.+?)</p>.*?<p style=".*?>(.+?)</p>}m) do |num, wrd, desc, ex|
-      rv << [num.to_i, wrd, desc, ex]
+    s.scan(%r{<td class='index'[^>]*>.*?(\d+)\..*?</td>.*?<td class='word'>(?:<a.*?>)?([^>]+)(?:</a>)?</td>.*?<div class='definition'>(.+?)</div>.*?<div class='example'>(.+?)</div>}m) do |num, wrd, desc, ex|
+      rv << [num.to_i, wrd.strip, desc.strip, ex.strip]
     end
 
     total ||= rv.size
 
-    return m.reply "#{Bold}#{word}#{Bold} not found" if rv.empty?
+    return m.reply("#{Bold}#{word}#{Bold} not found") if rv.empty?
 
     if notfound
       suggestions = rv.map { |s| Underline + s[1] + Underline }.uniq.join ', '