DEMAURO_LEMMA = /<anchor>(.*?)(?: - (.*?))<go href="lemma.php\?ID=(\d+)"\/><\/anchor>/\r
\r
class DictPlugin < Plugin\r
+ BotConfig.register BotConfigIntegerValue.new('dict.hits',\r
+ :default => 3,\r
+ :desc => "Number of hits to return from a dictionary lookup")\r
+ BotConfig.register BotConfigIntegerValue.new('dict.first_par',\r
+ :default => 0,\r
+ :desc => "When set to n > 0, the bot will return the first paragraph from the first n dictionary hits")\r
+\r
def initialize\r
super\r
@dmurl = "http://www.demauroparavia.it/"\r
return true if justcheck\r
text += ": "\r
n = 0\r
- text += entries[0...5].map { |ar|\r
+ hits = @bot.config['dict.hits']\r
+ text += entries[0...hits].map { |ar|\r
n += 1\r
urls << @dmwaplemma % ar[2]\r
"#{n}. #{Bold}#{ar[0]}#{Bold} - #{ar[1].gsub(/<\/?em>/,'')}: #{@dmurl}#{ar[2]}"\r
}.join(" | ")\r
m.reply text\r
\r
- Utils.get_first_pars urls, 5, :http_util => @bot.httputil, :message => m\r
+ first_pars = @bot.config['dict.first_par']\r
+\r
+ return unless first_pars > 0\r
+\r
+ Utils.get_first_pars urls, first_pars, :http_util => @bot.httputil, :message => m\r
\r
end\r
\r
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