def connect
begin
trap("SIGINT") { got_sig("SIGINT") }
trap("SIGTERM") { got_sig("SIGTERM") }
trap("SIGHUP") { got_sig("SIGHUP") }
rescue ArgumentError => e
debug "failed to trap signals (#{e.inspect}): running on Windows?"
rescue => e
debug "failed to trap signals: #{e.inspect}"
end
begin
quit if $interrupted > 0
@socket.connect
rescue => e
raise e.class, "failed to connect to IRC server at #{@config['server.name']} #{@config['server.port']}: " + e
end
@socket.emergency_puts "PASS " + @config['server.password'] if @config['server.password']
@socket.emergency_puts "NICK #{@nick}\nUSER #{@config['irc.user']} 4 #{@config['server.name']} :Ruby bot. (c) Tom Gilbert"
@capabilities = Hash.new
start_server_pings
end