轮盘node.js bot" Bot停止,代码为null"

时间:2016-05-11 10:52:07

标签: javascript mysql node.js

我的node.js bot到轮盘赌有问题。 Bot完全设置但是当我启动它时,它给了我错误" Bot停止了代码null"。有人可以帮我解决吗?

以下是错误截图:http://i.imgur.com/zfZoMD4.png

代码:

function login(err, sessionID, cookies, steamguard) {
    if(err) {
        logger.error('Auth error');
        logger.debug(err);
        if(err.message == "SteamGuardMobile") {
            account.twoFactorCode = SteamTotp.generateAuthCode(account.shared_secret);
            logger.warn('Error in auth: '+account.twoFactorCode);
            setTimeout(function() {
                community.login(account, login);
            }, 5000);
            return;
        }
        process.exit(0);
    }
    logger.trace('Sucesfully auth');
    account.sessionID = sessionID;
    account.cookies = cookies;
    community.getWebApiKey('csgobananas.com', webApiKey);
    community.startConfirmationChecker(10000, account.identity_secret);
}

function webApiKey(err, key) {
    if(err) {
        logger.error('Cant make apikey')
        logger.debug(err);
        process.exit(0);
        return;
    }
    account.key = key;
    logger.trace('API key bot '+account.accountName+' '+account.key);
    offersSetup();
    community.loggedIn(checkLoggedIn);
}

function offersSetup() {
    logger.trace('Loaded steam-tradeoffers');
    offers.setup({
        sessionID: account.sessionID,
        webCookie: account.cookies,
        APIKey: account.key
    });
}

function checkLoggedIn(err, loggedIn, familyView) {
    if((err) || (!loggedIn)) {
        logger.error('We arent logged in')
        process.exit(0);
    } else {
        logger.trace('Logged in');
        account.auth = true;

bot_manager.js代码:

var forever = require('forever-monitor');
var mysql = require('mysql');

var pool  = mysql.createPool({
    connectionLimit : 10,
    database: 'placeholder',
    host: 'placeholder',
    user: 'placeholder',
    password: 'placeholder'
});

query('SELECT * FROM `bots`', function(err, row) {
    if((err) || (!row.length)) {
        console.log('Failed request or empty bot table');
        console.log(err);
        return process.exit(0);
    }
    console.log('List of bots:');
    row.forEach(function(itm) {
        console.log('Launching bot# '+itm.id);
        var bot = new (forever.Monitor)('bot.js', {
            args: [itm.id]
        });
        bot.on('start', function(process, data) {
            console.log('Bot with ID '+itm.id+' started');
        });
        bot.on('exit:code', function(code) {
            console.log('Bot stopped with code '+code);
        });
        bot.on('stdout', function(data) {
            console.log(data);
        });
        bot.start();
    });
});

function query(sql, callback) {
    if (typeof callback === 'undefined') {
        callback = function() {};
    }
    pool.getConnection(function(err, connection) {
        if(err) return callback(err);
        console.info('Database connection ID: '+connection.threadId);
        connection.query(sql, function(err, rows) {
            if(err) return callback(err);
            connection.release();
            return callback(null, rows);
        });
    });
}

0 个答案:

没有答案