summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-07-08 19:08:39 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-07-08 19:08:39 +0000
commit47fd0312cf67aab35ba3cfd3ef898f83b09a7f0f (patch)
treea990ea91ce93fd752dc92e93d24e62a98a2dbc93
parentbec794ba32bc6fe8fbb688da7a1f140b33485dba (diff)
dict plugin: echo definitions from chambers
-rw-r--r--data/rbot/plugins/dict.rb13
1 files changed, 10 insertions, 3 deletions
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>(.*?)(?: - (.*?))<go href="lemma.php\?ID=(\d+)"\/><\/anchor>/
+CHAMBERS_LEMMA = /<p><span class="hwd">(.*?)<\/span> <span class="psa">(.*?)<\/span>(.*?)<\/p>/
class DictPlugin < Plugin
BotConfig.register BotConfigIntegerValue.new('dict.hits',
@@ -143,10 +144,16 @@ class DictPlugin < Plugin
when /No exact matches for <b>.*?<\/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)