X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fircbot.rb;h=b2c7a88f91b4cef106066ed3946f831684e1bb67;hb=1676abaf61c9b6c40714e00d6637e3a73d8b527b;hp=981a09a90a1a99f4e8d4df33519de379bb77aedb;hpb=e0ae5e3a02ef7c85e9af8c4f476c72f149ab8b32;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 981a09a9..b2c7a88f 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -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