From b6d39f5ca585a89c8d2567e59bd8ef67c77c5674 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 19 Apr 2008 09:18:31 +0200 Subject: core/irclog: config option for max open files --- lib/rbot/core/irclog.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/rbot/core/irclog.rb b/lib/rbot/core/irclog.rb index 960dfa52..c4e9f590 100644 --- a/lib/rbot/core/irclog.rb +++ b/lib/rbot/core/irclog.rb @@ -9,7 +9,9 @@ class IrcLogModule < CoreBotModule - MAX_OPEN_FILES = 20 # XXX: maybe add a config value + Config.register Config::IntegerValue.new('irclog.max_open_files', + :default => 20, :validate => Proc.new { |v| v > 0 }, + :desc => "Maximum number of irclog files to keep open at any one time.") def initialize super @@ -36,10 +38,10 @@ class IrcLogModule < CoreBotModule where_str = where.downcase.gsub(/[:!?$*()\/\\<>|"']/, "_") end unless @logs.has_key? where_str - if @logs.size > MAX_OPEN_FILES + if @logs.size > @bot.config['irclog.max_open_files'] @logs.keys.sort do |a, b| @logs[a][0] <=> @logs[b][0] - end.slice(0, @logs.size - MAX_OPEN_FILES).each do |w| + end.slice(0, @logs.size - @bot.config['irclog.max_open_files']).each do |w| logfile_close w, "idle since #{@logs[w][0]}" end end -- cgit v1.2.3