<commit_before>var request = require('request');
var sprintf = require('sprintf').sprintf;
var async = require('async');

/*
 * DOGE Plugin, queries cryptsy for current 
 * doge/btc price
 */

var DOGE = function () {
    this.commands = ['doge', 'btc', 'dc'];
    this.usage = {
        doge: 'ex : !doge . Gets market prices for DOGE',
        btc: 'ex : !btc . Gets market prices for BTC',
        dc: 'ex : !dc <amount>. Convert DOGE to USD, default 1000'
    };
};


/* Vicurex 1 / value
 * https://api.vircurex.com/api/get_last_trade.json?base=BTC&alt=DOGE
 *  1 / value
 */
var VICUREX = function (callback) {
    var url = 'https://api.vircurex.com/api/get_last_trade.json?base=BTC&alt=DOGE',
        retObj = {};
    retObj.label = 'Vicurex';

    request(url, function(err, res, body) {
        if (!body) {
            retObj.value = 'such no body';
        } else {
            try {
                data = JSON.parse(body);
                retObj.value = (1 / data.value).toPrecision(3);
            } catch (err) {
                retObj.value = 'very confuse';
            }
        }
        callback(null, retObj);
    });
};

/* Coinex
 * https://coinex.pw/api/v2/trade_pairs
 * need pair 46
 * last_price / 100000000
 */
var COINEX = function (callback) {
    var url = 'https://coinex.pw/api/v2/trade_pairs',
        retObj = {};
    retObj.label = 'Coinex';

    request(url, function(err, res, body) {
        if (!body) {
            retObj.value = 'such no body';
        } else {
            try {
                data = JSON.parse(body);
                data.trade_pairs.forEach(function(each) {
                    if (each.id === 46) {
                        retObj.value = each.last_price / 100000000;
                    }
                });
            } catch (err) {
                retObj.value = 'very confuse';
            }
        }
        callback(null, retObj);
    });
};

/* Cryptsy
 * http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132
 *
 */
var CRYPTSY = function (callback) {
    var url = 'http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132',
        retObj = {};
    retObj.label = 'Cryptsy';

    request(url, function(err, res, body) {
        if (!body) {
            retObj.value = 'such no body';
        } else {
            try {
                data = JSON.parse(body);
                retObj.value = data.return.markets.DOGE.lasttradeprice;
            } catch (err) {
                retObj.value = 'very confuse';
            }
        }
        callback(null, retObj);
    });
};

var MTGOX = function (callback) {
    var url = 'http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast',
        retObj = {};
    retObj.label = 'MtGox';

    request(url, function(err, res, body) {
        if (!body) {
            retObj.value = 'such no body';
        } else {
            try {
                data = JSON.parse(body);
                retObj.value = data.data.sell.value;
            } catch (err) {
                retObj.value = 'very confuse';
            }
        }
        callback(null, retObj);
    });
};

var COINBASE = function (callback) {
    var url = 'https://coinbase.com/api/v1/prices/sell',
        retObj = {};
    retObj.label = 'Coinbase';

    request(url, function(err, res, body) {
        if (!body) {
            retObj.value = 'such no body';
        } else {
            try {
                data = JSON.parse(body);
                retObj.value = data.amount;
            } catch (err) {
                retObj.value = 'very confuse';
            }
        }
        callback(null, retObj);
    });
};

/*
 * primary doge command
 */

DOGE.prototype.doge = function (bot, to, from, msg, callback) {
    var msgOut = '';
    async.parallel([CRYPTSY, COINEX, VICUREX], function(err, results) {
        msgOut += "DOGE: ";
        results.forEach(function (each) {
            msgOut += each.label + ": " + each.value + " "
        });

        bot.say(to, msgOut);
        callback();
    });
};

DOGE.prototype.btc = function (bot, to, from, msg, callback) {
    var msgOut = '';
    async.parallel([MTGOX, COINBASE], function(err, results) {
        msgOut += "BTC: ";
        results.forEach(function (each) {
            msgOut += each.label + ": " + each.value + " "
        });

        bot.say(to, msgOut);
        callback();
    });
};

DOGE.prototype.dc = function (bot, to, from, msg, callback)
{
    var msgOut = '',
        amount = 1000,
        raw = msg.replace(',', '');

    if (!(raw === '') && !isNaN(raw))
    {
        amount = parseFloat(raw);
    }

    async.parallel([CRYPTSY, COINBASE], function(err, results) {
        if (isNaN(results[0].value)) {
            msgOut = 'Cannot do conversion at this moment.';
        } else {
            msgOut = 'Đ' + amount + ' is $' + ((amount * results[0].value) * results[1].value).toFixed(2);
        }
        bot.say(to, msgOut);
        callback();
    });
};

exports.Plugin = DOGE;<commit_msg>Confusing use of not, namespace collision on 'err', missing semicolons<commit_after>var request = require('request');
var sprintf = require('sprintf').sprintf;
var async = require('async');

/*
 * DOGE Plugin, queries cryptsy for current 
 * doge/btc price
 */

var DOGE = function () {
    this.commands = ['doge', 'btc', 'dc'];
    this.usage = {
        doge: 'ex : !doge . Gets market prices for DOGE',
        btc: 'ex : !btc . Gets market prices for BTC',
        dc: 'ex : !dc <amount>. Convert DOGE to USD, default 1000'
    };
};


/* Vicurex 1 / value
 * https://api.vircurex.com/api/get_last_trade.json?base=BTC&alt=DOGE
 *  1 / value
 */
var VICUREX = function (callback) {
    var url = 'https://api.vircurex.com/api/get_last_trade.json?base=BTC&alt=DOGE',
        retObj = {};
    retObj.label = 'Vicurex';

    request(url, function(err, res, body) {
        if (!body) {
            retObj.value = 'such no body';
        } else {
            try {
                data = JSON.parse(body);
                retObj.value = (1 / data.value).toPrecision(3);
            } catch (exception) {
                retObj.value = 'very confuse';
            }
        }
        callback(null, retObj);
    });
};

/* Coinex
 * https://coinex.pw/api/v2/trade_pairs
 * need pair 46
 * last_price / 100000000
 */
var COINEX = function (callback) {
    var url = 'https://coinex.pw/api/v2/trade_pairs',
        retObj = {};
    retObj.label = 'Coinex';

    request(url, function(err, res, body) {
        if (!body) {
            retObj.value = 'such no body';
        } else {
            try {
                data = JSON.parse(body);
                data.trade_pairs.forEach(function(each) {
                    if (each.id === 46) {
                        retObj.value = each.last_price / 100000000;
                    }
                });
            } catch (exception) {
                retObj.value = 'very confuse';
            }
        }
        callback(null, retObj);
    });
};

/* Cryptsy
 * http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132
 *
 */
var CRYPTSY = function (callback) {
    var url = 'http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132',
        retObj = {};
    retObj.label = 'Cryptsy';

    request(url, function(err, res, body) {
        if (!body) {
            retObj.value = 'such no body';
        } else {
            try {
                data = JSON.parse(body);
                retObj.value = data.return.markets.DOGE.lasttradeprice;
            } catch (exception) {
                retObj.value = 'very confuse';
            }
        }
        callback(null, retObj);
    });
};

var MTGOX = function (callback) {
    var url = 'http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast',
        retObj = {};
    retObj.label = 'MtGox';

    request(url, function(err, res, body) {
        if (!body) {
            retObj.value = 'such no body';
        } else {
            try {
                data = JSON.parse(body);
                retObj.value = data.data.sell.value;
            } catch (exception) {
                retObj.value = 'very confuse';
            }
        }
        callback(null, retObj);
    });
};

var COINBASE = function (callback) {
    var url = 'https://coinbase.com/api/v1/prices/sell',
        retObj = {};
    retObj.label = 'Coinbase';

    request(url, function(err, res, body) {
        if (!body) {
            retObj.value = 'such no body';
        } else {
            try {
                data = JSON.parse(body);
                retObj.value = data.amount;
            } catch (exception) {
                retObj.value = 'very confuse';
            }
        }
        callback(null, retObj);
    });
};

/*
 * primary doge command
 */

DOGE.prototype.doge = function (bot, to, from, msg, callback) {
    var msgOut = '';
    async.parallel([CRYPTSY, COINEX, VICUREX], function(err, results) {
        msgOut += "DOGE: ";
        results.forEach(function (each) {
            msgOut += each.label + ": " + each.value + " ";
        });

        bot.say(to, msgOut);
        callback();
    });
};

DOGE.prototype.btc = function (bot, to, from, msg, callback) {
    var msgOut = '';
    async.parallel([MTGOX, COINBASE], function(err, results) {
        msgOut += "BTC: ";
        results.forEach(function (each) {
            msgOut += each.label + ": " + each.value + " ";
        });

        bot.say(to, msgOut);
        callback();
    });
};

DOGE.prototype.dc = function (bot, to, from, msg, callback)
{
    var msgOut = '',
        amount = 1000,
        raw = msg.replace(',', '');

    if ((raw !== '') && !isNaN(raw))
    {
        amount = parseFloat(raw);
    }

    async.parallel([CRYPTSY, COINBASE], function(err, results) {
        if (isNaN(results[0].value)) {
            msgOut = 'Cannot do conversion at this moment.';
        } else {
            msgOut = 'Đ' + amount + ' is $' + ((amount * results[0].value) * results[1].value).toFixed(2);
        }
        bot.say(to, msgOut);
        callback();
    });
};

exports.Plugin = DOGE;
{'fraction_non_alphanumeric': 0.15476898671425737, 'fraction_numerical': 0.009518143961927425, 'mean_word_length': 1.7276906435911303, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3342472', 'n_tokens_mistral': 3382, 'n_tokens_neox': 3200, 'n_words': 672}