diff options
author | Tom Gilbert <tom@linuxbrit.co.uk> | 2005-07-27 17:50:27 +0000 |
---|---|---|
committer | Tom Gilbert <tom@linuxbrit.co.uk> | 2005-07-27 17:50:27 +0000 |
commit | 67dc860e5fbcdac31ccdbc1d561a4e583dd5a084 (patch) | |
tree | ceba82a29ef8c7656a0ff8c0900393906a85aa9a /lib | |
parent | 20b78c45b2e514c9c022e25c7c1d6b0cb0f3769c (diff) |
more work on packaging, use Irc::Config module for storing configuration set
by install.rb
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/config.rb | 2 | ||||
-rw-r--r-- | lib/rbot/ircbot.rb | 21 | ||||
-rw-r--r-- | lib/rbot/language.rb | 5 | ||||
-rw-r--r-- | lib/rbot/plugins.rb | 2 |
4 files changed, 23 insertions, 7 deletions
diff --git a/lib/rbot/config.rb b/lib/rbot/config.rb index f021d827..a193e8c3 100644 --- a/lib/rbot/config.rb +++ b/lib/rbot/config.rb @@ -143,7 +143,7 @@ module Irc :prompt => "Language", :key => "core.language", :type => :enum, - :items => Dir.new(@bot.datadir + "/languages").collect {|f| + :items => Dir.new(CONFIG::DATADIR + "/languages").collect {|f| f =~ /\.lang$/ ? f.gsub(/\.lang$/, "") : nil }.compact }, diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 844231dd..89746af3 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -20,6 +20,8 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'thread' +require 'etc' +require 'fileutils' require 'rbot/rfc2812' require 'rbot/keywords' @@ -35,6 +37,7 @@ require 'rbot/language' require 'rbot/dbhash' require 'rbot/registry' require 'rbot/httputil' +require 'rbot/rbotconfig' module Irc @@ -77,12 +80,26 @@ class IrcBot # create a new IrcBot with botclass +botclass+ def initialize(botclass) + unless Config::DATA_DIR && FileTest.directory? Config::DATA_DIR + puts "no data directory '#{Config::DATA_DIR}' found, did you run install.rb?" + exit 2 + end + + botclass = "/home/#{Etc.getlogin}/.rbot" unless botclass @botclass = botclass.gsub(/\/$/, "") - @startup_time = Time.new + + unless FileTest.directory? botclass + puts "no #{botclass} directory found, creating from templates.." + if FileTest.exist? botclass + puts "Error: file #{botclass} exists but isn't a directory" + exit 2 + end + FileUtils.cp_r Config::DATA_DIR+'/templates', botclass + end - Dir.mkdir("#{botclass}") if(!File.exist?("#{botclass}")) Dir.mkdir("#{botclass}/logs") if(!File.exist?("#{botclass}/logs")) + @startup_time = Time.new @config = Irc::BotConfig.new(self) @timer = Timer::Timer.new @registry = BotRegistry.new self diff --git a/lib/rbot/language.rb b/lib/rbot/language.rb index 75885a51..64555248 100644 --- a/lib/rbot/language.rb +++ b/lib/rbot/language.rb @@ -1,11 +1,10 @@ module Irc class Language - def initialize(bot, language, file="") - @bot = bot + def initialize(language, file="") @language = language if file.empty? - file = bot.datadir + "/languages/#{@language}.lang" + file = Config::DATADIR + "/languages/#{@language}.lang" end unless(FileTest.exist?(file)) raise "no such language: #{@language} (no such file #{file})" diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index d239c5e6..9f88d0c3 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -170,7 +170,7 @@ module Irc # load plugins from pre-assigned list of directories def scan dirs = Array.new - dirs << @bot.datadir + "/plugins" + dirs << CONFIG::DATADIR + "/plugins" dirs += @dirs dirs.each {|dir| if(FileTest.directory?(dir)) |