summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-03-10 12:55:33 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-03-10 12:55:33 +0000
commitb3c5f4953a0a1c5eca225ef33a58943a6c60f63a (patch)
tree83b4fab141ab031e3495abb59fcff94bb6f0b7c0 /lib/rbot
parent4bbc1b813729b01c51ae5922e994325f27c5c1ed (diff)
Allow customization of the plugins load path
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/ircbot.rb23
-rw-r--r--lib/rbot/plugins.rb5
2 files changed, 24 insertions, 4 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 7c0af845..aee426b3 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -242,6 +242,12 @@ class Bot
:validate => Proc.new { |v| v > 0 },
:desc => "Maximum console messages logfile size (in megabytes)")
+ BotConfig.register BotConfigArrayValue.new('plugins.path',
+ :wizard => true, :default => ['(default)', '(default)/contrib'],
+ :requires_restart => false,
+ :on_change => Proc.new { |bot, v| bot.setup_plugins_path },
+ :desc => "Where the bot should look for plugin. List multiple directories using commas to separate. Use '(default)' for default prepackaged plugins collection, '(default)/contrib' for prepackaged unsupported plugins collection")
+
BotConfig.register BotConfigEnumValue.new('send.newlines',
:values => ['split', 'join'], :default => 'split',
:on_change => Proc.new { |bot, v|
@@ -433,10 +439,7 @@ class Bot
Dir.mkdir("#{botclass}/plugins") unless File.exist?("#{botclass}/plugins")
@plugins = Plugins::pluginmanager
@plugins.bot_associate(self)
- @plugins.add_botmodule_dir(Config::coredir + "/utils")
- @plugins.add_botmodule_dir(Config::coredir)
- @plugins.add_botmodule_dir("#{botclass}/plugins")
- @plugins.add_botmodule_dir(Config::datadir + "/plugins")
+ setup_plugins_path()
@plugins.scan
Utils.set_safe_save_dir("#{botclass}/safe_save")
@@ -631,6 +634,18 @@ class Bot
:truncate_text => @config['send.truncate_text'].dup
end
+ def setup_plugins_path
+ @plugins.clear_botmodule_dirs
+ @plugins.add_botmodule_dir(Config::coredir + "/utils")
+ @plugins.add_botmodule_dir(Config::coredir)
+ @plugins.add_botmodule_dir("#{botclass}/plugins")
+
+ @config['plugins.path'].each do |_|
+ path = _.sub(/^\(default\)/, Config::datadir + '/plugins')
+ @plugins.add_botmodule_dir(path)
+ end
+ end
+
def set_default_send_options(opts={})
# Default send options for NOTICE and PRIVMSG
unless defined? @default_send_options
diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb
index e101e627..d29d21c1 100644
--- a/lib/rbot/plugins.rb
+++ b/lib/rbot/plugins.rb
@@ -390,6 +390,11 @@ module Plugins
debug "Botmodule loading path: #{@dirs.join(', ')}"
end
+ def clear_botmodule_dirs
+ @dirs.clear
+ debug "Botmodule loading path cleared"
+ end
+
# load plugins from pre-assigned list of directories
def scan
@failed.clear