From 47fd0312cf67aab35ba3cfd3ef898f83b09a7f0f Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 8 Jul 2007 19:08:39 +0000 Subject: dict plugin: echo definitions from chambers --- data/rbot/plugins/dict.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'data') diff --git a/data/rbot/plugins/dict.rb b/data/rbot/plugins/dict.rb index 30cfc5fe..95d9fe2e 100644 --- a/data/rbot/plugins/dict.rb +++ b/data/rbot/plugins/dict.rb @@ -19,6 +19,7 @@ # TODO: cache results and reuse them if get_cached returns a cache copy DEMAURO_LEMMA = /(.*?)(?: - (.*?))<\/anchor>/ +CHAMBERS_LEMMA = /

(.*?)<\/span> (.*?)<\/span>(.*?)<\/p>/ class DictPlugin < Plugin BotConfig.register BotConfigIntegerValue.new('dict.hits', @@ -143,10 +144,16 @@ class DictPlugin < Plugin when /No exact matches for .*?<\/b>, but the following may be helpful./ return false if justcheck m.reply "Nothing found for #{word}, but see #{url} for possible suggestions" - else - return true if justcheck - m.reply "#{word}: #{url}" + return end + # Else, we have a hit + return true if justcheck + m.reply "#{word}: #{url}" + entries = xml.scan(CHAMBERS_LEMMA) + hits = @bot.config['dict.hits'] + entries[0...hits].map { |ar| + m.reply(("#{Bold}%s#{Bold} #{Underline}%s#{Underline}%s" % ar).ircify_html, :overlong => :truncate) + } end def is_english?(word) -- cgit v1.2.3