summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-19 09:18:31 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-19 09:18:31 +0200
commitb6d39f5ca585a89c8d2567e59bd8ef67c77c5674 (patch)
tree9c072558ee33177cc9f96b44be369988d315545b /lib
parent96d13521d82d4fa4355faf9dd3b8aace86171c87 (diff)
core/irclog: config option for max open files
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/core/irclog.rb8
1 files 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