diff options
author | Raine Virta <rane@kapsi.fi> | 2009-02-28 01:34:50 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-02-28 01:43:45 +0100 |
commit | 24aaf8420ae97367db50b00277bee1f2fa08174c (patch) | |
tree | d05b72865ea74b26c5ec6b415fc41f0882c437d8 | |
parent | be5d914984e767ce1a718b84d0bad1c88d9f8ea3 (diff) |
plugins: allow plugins whitelisting
If the whitelist is not empty, only load the specified plugins.
-rwxr-xr-x | lib/rbot/plugins.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index 00fc4234..e7905c50 100755 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -10,6 +10,9 @@ class Bot Config.register Config::ArrayValue.new('plugins.blacklist', :default => [], :wizard => false, :requires_rescan => true, :desc => "Plugins that should not be loaded") + Config.register Config::ArrayValue.new('plugins.whitelist', + :default => [], :wizard => false, :requires_rescan => true, + :desc => "Only whitelisted plugins will be loaded unless the list is empty") module Plugins require 'rbot/messagemapper' @@ -614,6 +617,10 @@ module Plugins pn = p + ".rb" processed[pn.intern] = :blacklisted } + + whitelist = @bot.config['plugins.whitelist'].map { |p| + p + ".rb" + } end dirs.each do |dir| @@ -625,7 +632,10 @@ module Plugins case type when :plugins - if processed.has_key?(file.intern) + if !whitelist.empty? && !whitelist.include?(file) + @ignored << {:name => file, :dir => dir, :reason => :"not whitelisted" } + next + elsif processed.has_key?(file.intern) @ignored << {:name => file, :dir => dir, :reason => processed[file.intern]} next end |