summaryrefslogtreecommitdiff
path: root/lib/rbot/ircbot.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbot/ircbot.rb')
-rw-r--r--lib/rbot/ircbot.rb21
1 files changed, 19 insertions, 2 deletions
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