server/irc/connection.js
function () {
    var that = this,
        connect_data;

    // Build up data to be used for webirc/etc detection
    connect_data = {
        connection: this,

        // Array of lines to be sent to the IRCd before anything else
        prepend_data: []
    };

    // Let the webirc/etc detection modify any required parameters
    connect_data = findWebIrc.call(this, connect_data);

    global.modules.emit('irc authorize', connect_data).then(function ircAuthorizeCb() {
        // Send any initial data for webirc/etc
        if (connect_data.prepend_data) {
            _.each(connect_data.prepend_data, function(data) {
                that.write(data);
            });
        }

        that.write('CAP LS');

        if (that.password) {
            that.write('PASS ' + that.password);
        }

        that.write('NICK ' + that.nick);
        that.write('USER ' + that.username + ' 0 0 :' + that.gecos);

        that.emit('connected');
    });
}
function () {
    var that = this,
        connect_data;

    // Build up data to be used for webirc/etc detection
    connect_data = {
        connection: this,

        // Array of lines to be sent to the IRCd before anything else
        prepend_data: []
    };

    // Let the webirc/etc detection modify any required parameters
    connect_data = findWebIrc.call(this, connect_data);

    global.modules.emit('irc authorize', connect_data).then(function ircAuthorizeCb() {
        // Send any initial data for webirc/etc
        if (connect_data.prepend_data) {
            _.each(connect_data.prepend_data, function(data) {
                that.write(data);
            });
        }

        that.write('CAP LS');

        if (that.password) {
            that.write('PASS ' + that.password);
        }

        that.write('NICK ' + that.nick);
        that.write('USER ' + that.username + ' 0 0 :' + that.gecos);

        that.emit('connected');
    });
}
function ( ) { var that = this , connect_data ; // Build up data to be used for webirc/etc detection connect_data = { connection : this , // Array of lines to be sent to the IRCd before anything else prepend_data : [ ] } ; // Let the webirc/etc detection modify any required parameters connect_data = findWebIrc . call ( this , connect_data ) ; global . modules . emit ( 'irc authorize' , connect_data ) . then ( function ircAuthorizeCb ( ) { // Send any initial data for webirc/etc if ( connect_data . prepend_data ) { _ . each ( connect_data . prepend_data , function ( data ) { that . write ( data ) ; } ) ; } that . write ( 'CAP LS' ) ; if ( that . password ) { that . write ( 'PASS ' + that . password ) ; } that . write ( 'NICK ' + that . nick ) ; that . write ( 'USER ' + that . username + ' 0 0 :' + that . gecos ) ; that . emit ( 'connected' ) ; } ) ; }
Handle the socket connect event, starting the IRCd registration
Handle the socket connect event starting the IRCd registration