]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/ircbot.rb
* (timer) stop the bot timer for shutdown / rescan
[user/henk/code/ruby/rbot.git] / lib / rbot / ircbot.rb
index 87d4f3eb40edfcb702941b809380afb2919395b2..46d5e902dc1066b33ba25c89ae1281a998c4c3d0 100644 (file)
@@ -436,7 +436,7 @@ class Bot
 
     @registry = BotRegistry.new self
 
-    @timer = Timer::Timer.new(1.0) # only need per-second granularity
+    @timer = Timer.new
     @save_mutex = Mutex.new
     if @config['core.save_every'] > 0
       @save_timer = @timer.add(@config['core.save_every']) { save }
@@ -448,7 +448,7 @@ class Bot
     @logs = Hash.new
 
     @plugins = nil
-    @lang = Language::Language.new(self, @config['core.language'])
+    @lang = Language.new(self, @config['core.language'])
 
     begin
       @auth = Auth::authmanager
@@ -770,7 +770,6 @@ class Bot
       begin
         quit if $interrupted > 0
         connect
-        @timer.start
 
         quit_msg = nil
         while @socket.connected?
@@ -1046,14 +1045,16 @@ class Bot
       # end
       debug "\tdisconnecting..."
       disconnect(message)
+      debug "\tstopping timer..."
+      @timer.stop
       debug "\tsaving ..."
       save
       debug "\tcleaning up ..."
       @save_mutex.synchronize do
         @plugins.cleanup
       end
-      debug "\tstopping timers ..."
-      @timer.stop
+      debug "\tstopping timers ..."
+      @timer.stop
       # debug "Closing registries"
       # @registry.close
       debug "\t\tcleaning up the db environment ..."
@@ -1101,10 +1102,13 @@ class Bot
 
   # call the rescan method for all of the botmodules
   def rescan
+    debug "\tstopping timer..."
+    @timer.stop
     @save_mutex.synchronize do
       @lang.rescan
       @plugins.rescan
     end
+    @timer.start
   end
 
   # channel:: channel to join