]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/ircbot.rb
Whitespace cleanup
[user/henk/code/ruby/rbot.git] / lib / rbot / ircbot.rb
index 981a09a90a1a99f4e8d4df33519de379bb77aedb..b2c7a88f91b4cef106066ed3946f831684e1bb67 100644 (file)
@@ -124,6 +124,7 @@ class IrcBot
     
     botclass = "#{Etc.getpwuid(Process::Sys.geteuid)[:dir]}/.rbot" unless botclass
     #botclass = "#{ENV['HOME']}/.rbot" unless botclass
+    botclass = File.expand_path(botclass)
     @botclass = botclass.gsub(/\/$/, "")
 
     unless FileTest.directory? botclass
@@ -136,6 +137,7 @@ class IrcBot
     end
     
     Dir.mkdir("#{botclass}/logs") unless File.exist?("#{botclass}/logs")
+    Dir.mkdir("#{botclass}/registry") unless File.exist?("#{botclass}/registry")
 
     @ping_timer = nil
     @pong_timer = nil
@@ -463,15 +465,25 @@ class IrcBot
       debug "failed to trap signals, probably running on windows?"
     end
     message = @lang.get("quit") if (message.nil? || message.empty?)
+    debug "Clearing socket"
     @socket.clearq
+    debug "Saving"
     save
+    debug "Cleaning up"
     @plugins.cleanup
+    debug "Logging quits"
     @channels.each_value {|v|
       log "@ quit (#{message})", v.name
     }
-    @registry.close
+    # debug "Closing registries"
+    # @registry.close
+    debug "Cleaning up the db environment"
+    DBTree.cleanup_env
+    debug "Sending quit message"
     @socket.puts "QUIT :#{message}"
+    debug "Flushing socket"
     @socket.flush
+    debug "Shutting down socket"
     @socket.shutdown
     puts "rbot quit (#{message})"
   end
@@ -501,6 +513,7 @@ class IrcBot
     @keywords.save
     @auth.save
     @plugins.save
+    DBTree.cleanup_logs
   end
 
   # call the rescan method for the bot's lang, keywords and all plugins
@@ -570,7 +583,8 @@ class IrcBot
   def status
     secs_up = Time.new - @startup_time
     uptime = Utils.secs_to_string secs_up
-    return "Uptime #{uptime}, #{@plugins.length} plugins active, #{@registry.length} items stored in registry, #{@socket.lines_sent} lines sent, #{@socket.lines_received} received."
+    # return "Uptime #{uptime}, #{@plugins.length} plugins active, #{@registry.length} items stored in registry, #{@socket.lines_sent} lines sent, #{@socket.lines_received} received."
+    return "Uptime #{uptime}, #{@plugins.length} plugins active, #{@socket.lines_sent} lines sent, #{@socket.lines_received} received."
   end
 
   # we'll ping the server every 30 seconds or so, and expect a response