]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
core: refactor signal trapping, and call it from initialize()
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 23 Apr 2008 17:06:50 +0000 (19:06 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 23 Apr 2008 17:06:50 +0000 (19:06 +0200)
lib/rbot/ircbot.rb

index 9cbe7dcbedcc6bd661c1f7da72d84037485afa81..baf520056dc3dbfc92c69008c6a7400b02d23ba0 100644 (file)
@@ -704,6 +704,8 @@ class Bot
       :split_at => Regexp.new(@config['send.split_at']),
       :purge_split => @config['send.purge_split'],
       :truncate_text => @config['send.truncate_text'].dup
+
+    trap_sigs
   end
 
   def setup_plugins_path
@@ -773,8 +775,8 @@ class Bot
     end
   end
 
-  # connect the bot to IRC
-  def connect
+  # trap signals
+  def trap_sigs
     begin
       trap("SIGINT") { got_sig("SIGINT") }
       trap("SIGTERM") { got_sig("SIGTERM") }
@@ -784,6 +786,10 @@ class Bot
     rescue Exception => e
       debug "failed to trap signals: #{e.pretty_inspect}"
     end
+  end
+
+  # connect the bot to IRC
+  def connect
     begin
       quit if $interrupted > 0
       @socket.connect