From 269d874e9dfc9e076eb45ca22397ad2f3715aa29 Mon Sep 17 00:00:00 2001 From: Matthias Hecker Date: Wed, 5 Mar 2014 13:04:47 +0100 Subject: [registry] use tc by-default if available --- lib/rbot/ircbot.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 02414a07..34c82926 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -435,8 +435,8 @@ 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", + :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: " + Registry::formats.join(', ')) @@ -822,6 +822,16 @@ class Bot end 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 -- cgit v1.2.3