summaryrefslogtreecommitdiff
path: root/data/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2011-10-24 10:49:22 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2011-10-24 10:49:22 +0200
commit445929f77007a1240ce19dfe7a8d623806841d96 (patch)
tree139f01c457e51ab70a377777d6e7ea1f3931a5bc /data/rbot
parent00a72a8bb44dc85fa4d7abf4ac9b9813c26ecfcd (diff)
dict: oxford fix from AndrewNTH
See tracker issue #79
Diffstat (limited to 'data/rbot')
-rw-r--r--data/rbot/plugins/dict.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/data/rbot/plugins/dict.rb b/data/rbot/plugins/dict.rb
index c9bfabaf..13c15b71 100644
--- a/data/rbot/plugins/dict.rb
+++ b/data/rbot/plugins/dict.rb
@@ -141,15 +141,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)