summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-23 19:06:50 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-23 19:06:50 +0200
commitf5f14237c4099ca854a817288c526366f26a070d (patch)
treea4dfe00a6e44bea7a987d5b55bc55ac7893d6f73
parent2c7bb309e9b81c18665c7d6e09c2a68ea5e1180e (diff)
core: refactor signal trapping, and call it from initialize()
-rw-r--r--lib/rbot/ircbot.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 9cbe7dcb..baf52005 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -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