diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-02-06 16:56:27 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-02-06 16:56:27 +0000 |
commit | f5abcb7eff07f436904ad5d88c0651e197c5914c (patch) | |
tree | 0e0aecb744d81b688df20524a85637ec8910de2c /data/rbot | |
parent | cf804763ed6377010257f73effd32a37969ad604 (diff) |
dict plugin: options to set number of hits and first_pars which will be displayed, similar to the ones found in search
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/dict.rb | 16 | ||||
-rw-r--r-- | data/rbot/plugins/search.rb | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/data/rbot/plugins/dict.rb b/data/rbot/plugins/dict.rb index a948fd06..d23df81f 100644 --- a/data/rbot/plugins/dict.rb +++ b/data/rbot/plugins/dict.rb @@ -18,6 +18,13 @@ require 'uri' DEMAURO_LEMMA = /<anchor>(.*?)(?: - (.*?))<go href="lemma.php\?ID=(\d+)"\/><\/anchor>/
class DictPlugin < Plugin
+ BotConfig.register BotConfigIntegerValue.new('dict.hits',
+ :default => 3,
+ :desc => "Number of hits to return from a dictionary lookup")
+ BotConfig.register BotConfigIntegerValue.new('dict.first_par',
+ :default => 0,
+ :desc => "When set to n > 0, the bot will return the first paragraph from the first n dictionary hits")
+
def initialize
super
@dmurl = "http://www.demauroparavia.it/"
@@ -68,14 +75,19 @@ class DictPlugin < Plugin return true if justcheck
text += ": "
n = 0
- text += entries[0...5].map { |ar|
+ hits = @bot.config['dict.hits']
+ text += entries[0...hits].map { |ar|
n += 1
urls << @dmwaplemma % ar[2]
"#{n}. #{Bold}#{ar[0]}#{Bold} - #{ar[1].gsub(/<\/?em>/,'')}: #{@dmurl}#{ar[2]}"
}.join(" | ")
m.reply text
- Utils.get_first_pars urls, 5, :http_util => @bot.httputil, :message => m
+ first_pars = @bot.config['dict.first_par']
+
+ return unless first_pars > 0
+
+ Utils.get_first_pars urls, first_pars, :http_util => @bot.httputil, :message => m
end
diff --git a/data/rbot/plugins/search.rb b/data/rbot/plugins/search.rb index a10853bf..becfafc2 100644 --- a/data/rbot/plugins/search.rb +++ b/data/rbot/plugins/search.rb @@ -74,6 +74,8 @@ class SearchPlugin < Plugin first_pars = params[:firstpar] || @bot.config['google.first_par'] + return unless first_pars > 0 + Utils.get_first_pars urls, first_pars, :http_util => @bot.httputil, :message => m end |