X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Furl.rb;h=7972037adf68d81123bd46bd9e486fe2ff890c14;hb=d63dac137c32c46b3c9b3c757ded2b9bd9d336be;hp=ced921330882844ee405aa74e49d820982788600;hpb=676dd61e6b0bea5f506d064039a685944aefd6fb;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb index ced92133..7972037a 100644 --- a/data/rbot/plugins/url.rb +++ b/data/rbot/plugins/url.rb @@ -1,6 +1,10 @@ Url = Struct.new("Url", :channel, :nick, :time, :url) class UrlPlugin < Plugin + BotConfig.register BotConfigIntegerValue.new('url.max_urls', + :default => 100, :validate => Proc.new{|v| v > 0}, + :desc => "Maximum number of urls to store. New urls replace oldest ones.") + def initialize super @registry.set_default(Array.new) @@ -22,7 +26,7 @@ class UrlPlugin < Plugin } url = Url.new(m.target, m.sourcenick, Time.new, urlstr) debug "#{list.length} urls so far" - if list.length > 50 # TODO make this configurable + if list.length > @bot.config['url.max_urls'] list.pop end debug "storing url #{url.url}"