X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fircbot.rb;h=b954e3b5c63c2306b0668f03a3a947c3fef0321b;hb=c10364437a7182bbb731627169dafce67b01a912;hp=a342e8c136151c0ed2e26422f3930a0ecd9f91db;hpb=ba5aaf073e5467b0b71adede32051f9b38c50a19;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index a342e8c1..b954e3b5 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -153,6 +153,7 @@ require 'rbot/rfc2812' require 'rbot/ircsocket' require 'rbot/botuser' require 'rbot/timer' +require 'rbot/registry' require 'rbot/plugins' require 'rbot/message' require 'rbot/language' @@ -195,6 +196,12 @@ class Bot # proxies etc as defined by the bot configuration/environment attr_accessor :httputil + # mechanize agent factory + attr_accessor :agent + + # loads and opens new registry databases, used by the plugins + attr_accessor :registry_factory + # server we are connected to # TODO multiserver def server @@ -285,7 +292,7 @@ class Bot :desc => "The CA file used to verify the SSL connection.", :wizard => true) Config.register Config::StringValue.new('server.ssl_ca_path', - :default => '', :requires_restart => true, + :default => default_ssl_ca_path, :requires_restart => true, :desc => "Alternativly a directory that includes CA PEM files used to verify the SSL connection.", :wizard => true) Config.register Config::StringValue.new('server.password', @@ -428,11 +435,11 @@ class Bot }, :desc => "Percentage of IRC penalty to consider when sending messages to prevent being disconnected for excess flood. Set to 0 to disable penalty control.") Config.register Config::StringValue.new('core.db', - :default => "dbm", - :wizard => true, :default => "dbm", - :validate => Proc.new { |v| ["dbm", "daybreak"].include? v }, + :default => default_db, + :wizard => true, + :validate => Proc.new { |v| Registry::formats.include? v }, :requires_restart => true, - :desc => "DB adaptor to use for storing the plugin data/registries. Options: dbm (included in ruby), daybreak") + :desc => "DB adaptor to use for storing the plugin data/registries. Options: " + Registry::formats.join(', ')) @argv = params[:argv] @run_dir = params[:run_dir] || Dir.pwd @@ -496,14 +503,7 @@ class Bot $daemonize = true end - case @config["core.db"] - when "dbm" - require 'rbot/registry/dbm' - when "daybreak" - require 'rbot/registry/daybreak' - else - raise _("Unknown DB adaptor: %s") % @config["core.db"] - end + @registry_factory = Registry.new @config['core.db'] @logfile = @config['log.file'] if @logfile.class!=String || @logfile.empty? @@ -822,6 +822,21 @@ class Bot end end + def default_ssl_ca_path + file = default_ssl_ca_file + File.dirname file if file + end + + # Determine if tokyocabinet is installed, if it is use it as a default. + def default_db + begin + require 'tokyocabinet' + return 'tc' + rescue LoadError + return 'dbm' + end + end + def repopulate_botclass_directory template_dir = File.join Config::datadir, 'templates' if FileTest.directory? @botclass