main.js
function start(basedir, connectionCompleteCallback) {
    var defaultConfig = require("./config/defaults.json");
    var config = Config.create(basedir, defaultConfig);

    var globalObject = { config: config };

    var loginCompleteCallback = function(bot) {
        globalObject.bot = bot;
        bot.connect(config.DubBotBase.roomName);

        LOG.info("Connect request sent. Waiting 5 seconds for the connection to be established.");
        var innerConnectionCompleteCallback = function() {
            StateTracker.init(globalObject, function() {
                // Connect before registering anything, because StateTracker depends on being connected
                var commands = _registerCommands(basedir, globalObject);
                var eventListeners = _registerEventListeners(basedir, globalObject);

                // Hook our own event listener in to chat, for the command framework
                bot.on(Event.CHAT, _createCommandHandler(commands));

                if (connectionCompleteCallback) {
                    connectionCompleteCallback(globalObject);
                }
            });
        };

        setTimeout(innerConnectionCompleteCallback, 5000);
    };

    new Dubtrack.Bot({
        username: config.DubBotBase.botEmail,
        password: config.DubBotBase.botPassword
    }, globalObject, loginCompleteCallback);

    return globalObject;
}
function start(basedir, connectionCompleteCallback) {
    var defaultConfig = require("./config/defaults.json");
    var config = Config.create(basedir, defaultConfig);

    var globalObject = { config: config };

    var loginCompleteCallback = function(bot) {
        globalObject.bot = bot;
        bot.connect(config.DubBotBase.roomName);

        LOG.info("Connect request sent. Waiting 5 seconds for the connection to be established.");
        var innerConnectionCompleteCallback = function() {
            StateTracker.init(globalObject, function() {
                // Connect before registering anything, because StateTracker depends on being connected
                var commands = _registerCommands(basedir, globalObject);
                var eventListeners = _registerEventListeners(basedir, globalObject);

                // Hook our own event listener in to chat, for the command framework
                bot.on(Event.CHAT, _createCommandHandler(commands));

                if (connectionCompleteCallback) {
                    connectionCompleteCallback(globalObject);
                }
            });
        };

        setTimeout(innerConnectionCompleteCallback, 5000);
    };

    new Dubtrack.Bot({
        username: config.DubBotBase.botEmail,
        password: config.DubBotBase.botPassword
    }, globalObject, loginCompleteCallback);

    return globalObject;
}
function start ( basedir , connectionCompleteCallback ) { var defaultConfig = require ( "./config/defaults.json" ) ; var config = Config . create ( basedir , defaultConfig ) ; var globalObject = { config : config } ; var loginCompleteCallback = function ( bot ) { globalObject . bot = bot ; bot . connect ( config . DubBotBase . roomName ) ; LOG . info ( "Connect request sent. Waiting 5 seconds for the connection to be established." ) ; var innerConnectionCompleteCallback = function ( ) { StateTracker . init ( globalObject , function ( ) { // Connect before registering anything, because StateTracker depends on being connected var commands = _registerCommands ( basedir , globalObject ) ; var eventListeners = _registerEventListeners ( basedir , globalObject ) ; // Hook our own event listener in to chat, for the command framework bot . on ( Event . CHAT , _createCommandHandler ( commands ) ) ; if ( connectionCompleteCallback ) { connectionCompleteCallback ( globalObject ) ; } } ) ; } ; setTimeout ( innerConnectionCompleteCallback , 5000 ) ; } ; new Dubtrack . Bot ( { username : config . DubBotBase . botEmail , password : config . DubBotBase . botPassword } , globalObject , loginCompleteCallback ) ; return globalObject ; }
Starts up the bot, registering all commands and event listeners.

@param {string} basedir - The base directory containing the commands/ and event_listeners/ subdirectories
@param {function} connectionCompleteCallback - A function to be called once the bot has connected to the room and is ready to use
@returns {object} The global object which contains a reference to the bot
Starts up the bot registering all commands and event listeners .