# 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
justcheck = params[:justcheck]\r
\r
word = params[:word].downcase\r
- url = @dmwapurl % URI.escape(word)\r
+ url = @dmwapurl % CGI.escape(word)\r
xml = nil\r
info = @bot.httputil.get_response(url) rescue nil\r
xml = info.body if info\r
\r
word = params[:word].join\r
[word, word + "_1"].each { |check|\r
- url = @oxurl % URI.escape(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
justcheck = params[:justcheck]\r
\r
word = params[:word].to_s.downcase\r
- url = @chambersurl % URI.escape(word)\r
+ url = @chambersurl % CGI.escape(word)\r
xml = nil\r
info = @bot.httputil.get_response(url) rescue nil\r
xml = info.body if info\r
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