<commit_before>var config = require('.././config.json'),
    c = require('irc-colors'),
    pkg = require('.././package.json');

function score(score, max, end)
{
    max = max || 100;
    if(end === '%'){
        score = Number((parseFloat(score) * 100).toFixed(1));
    }

    var score_color = c.teal;

    if (score < (max * .25)) score_color = c.red;
    else if (score < (max * .50)) score_color = c.brown;
    else if (score < (max * .75)) score_color = c.olive;
    else if (score < (max * .95)) score_color = c.green;

    score_str = score_color(score + end);

    return score_str;
}

function er(err){ //error handling
    console.log(err);
    return c.red('Error: ' + err);
}

var respond = {
    "say_my_name": function(d){
        if(d[0] == '-version') {
            return 'verson: ' + pkg.version;
        } else if(d[0] == '-owner') {
            return 'owner: ' + c.rainbow(config.owner);
        } else if(d[0] == '-link') {
            return 'link: https://github.com/z0mbieparade/b0t';
        } else {
            return 'for more info try ' + c.teal(config.bot_nick) + ' -version|-owner|-link';
        }      

    },
    "err": function(d){
    },
    "syntax": function(d){
        return 'Please type ' + c.teal(d.syntax) + ' to ' + d.action;
    },
    "enter_room": function(d){  //on chat enter
        return 'holla'; 
    },
    "no_users_registered": function(d){
        return 'No users registered with ' + c.teal(d.label) + ' currently in the channel';
    },
    "not_registered": function(d){
        var register_syntax = config.command_prefix + d.col + ' <' + commands[d.cat][d.col].commands.join('> <') + '>'; 
        return 'Your ' + c.teal(d.label) + ' is not registered! Please type ' + c.teal(register_syntax) + ' to register it';
        
    },
    "cmd_help": function(d){
        var syntax = config.command_prefix + d;
        var command_data = {};
        for(var cat in commands){
            for(var cmd in commands[cat]){
                if(cmd === d) command_data = commands[cat][cmd];
            }
        }

        console.log(command_data);

        if(command_data.commands.length > 0) {
            syntax += ' <' + command_data.commands.join('> <') + '>';
        }
        if (syntax.indexOf('*') > -1) syntax += ' (* commands are optional)';

        var str = c.teal('Usage: ') + syntax + ' ';
        str += c.teal('Description: ') + command_data.action + '.';
        return str;
    }
}
exports.respond = respond;

var commands = {
    "other" : {
        "commands": {
            "action": "list all of the available bot commands.",
            "commands": ["*-list"],
            "format": function(d){
                var str = c.teal("Avaliable commands: ") + d.commands.join(', ');
                str += c.red(' (for more info, you can type any command followed by help)');
                return str;
            }
        },
        "set": {
            "action": "set the channel topic",
            "commands": ["topic"],
            "perm": "+",
            "format": function(d){ 
                return "Topic set!"; 
            }
        },
        "reg": {
            "action": "register a user for any service (lastfm, trakt, location, untappd)",
            "commands": ["service", "irc nick", "data"],
            "perm": "~",
            "format": function(d){ 
                var str = c.teal(d.irc_nick) + '\'s ' + d.label + ' has now been set';
                return str;
            }
        },
        "unreg": {
            "action": "unregister a user for any service (lastfm, trakt, location, untappd)",
            "commands": ["service", "irc nick"],
            "perm": "~",
            "format": function(d){ 
                var str = c.teal(d.irc_nick) + '\'s ' + d.label + ' has now been removed';
                return str;
            }
        },
        "updates": {
            "action": "check for updates to b0t script",
            "commands": [],
            "perm": "@",
            "format": function(d){ 
                if(d === pkg.version) return 'I am up to date!';

                return 'Please update me! My version: ' + pkg.version + ' Current version: ' + d;
            }
        }
    },
    "LastFM" : {
        "np" : {
            "action": "get your last scrobbled song from last.fm",
            "commands": [],
            "register": "lastfm",
            "format": function(d){
                var title = [];
                if(d.artist !== '') title.push(d.artist);
                if(d.name !== '') title.push(d.name);
                if(d.album !== '') title.push(d.album); 

                var str = c.teal(d.irc_nick) + ' ';
                str += d.now_playing ? 'is now playing: ' + c.green(title.join(' - ')) : 'last played: ' + c.gray(title.join(' - ')) 
                str += ' [' + d.play_count + 'x] ' + (d.loved ? c.red('♥') + ' (' : '('); 

                if(d.tags.length > 0){
                    var tags = d.tags.splice(0, 4); //max 4 tags
                    tags = tags.map(function(tag){ return c.teal(tag); });
                    str += tags.join(', ');
                } else {
                    str += c.gray('No Tags');
                }

                str += ')';

                return str;
            }
        },
        "yt": {
            "action": "get your last scrobbled song from last.fm and attempt to locate a youtube video of it",
            "commands": [],
            "register": "lastfm",
            "format": function(d){
                var str = c.teal(d.irc_nick) + ' ';
                str += d.now_playing ? 'is now playing: ' + c.green(title.join(' - ')) : 'last played: ';
                str += (d.title || '') + ' ' + d.link; 

                return str;
            }
        },
        "wp" : {
            "action": "get all users in current chan w/ registered last.fm nicks last scrobbled song",<commit_msg>title issues in np and yt<commit_after>var config = require('.././config.json'),
    c = require('irc-colors'),
    pkg = require('.././package.json');

function score(score, max, end)
{
    max = max || 100;
    if(end === '%'){
        score = Number((parseFloat(score) * 100).toFixed(1));
    }

    var score_color = c.teal;

    if (score < (max * .25)) score_color = c.red;
    else if (score < (max * .50)) score_color = c.brown;
    else if (score < (max * .75)) score_color = c.olive;
    else if (score < (max * .95)) score_color = c.green;

    score_str = score_color(score + end);

    return score_str;
}

function er(err){ //error handling
    console.log(err);
    return c.red('Error: ' + err);
}

var respond = {
    "say_my_name": function(d){
        if(d[0] == '-version') {
            return 'verson: ' + pkg.version;
        } else if(d[0] == '-owner') {
            return 'owner: ' + c.rainbow(config.owner);
        } else if(d[0] == '-link') {
            return 'link: https://github.com/z0mbieparade/b0t';
        } else {
            return 'for more info try ' + c.teal(config.bot_nick) + ' -version|-owner|-link';
        }      

    },
    "err": function(d){
    },
    "syntax": function(d){
        return 'Please type ' + c.teal(d.syntax) + ' to ' + d.action;
    },
    "enter_room": function(d){  //on chat enter
        return 'holla'; 
    },
    "no_users_registered": function(d){
        return 'No users registered with ' + c.teal(d.label) + ' currently in the channel';
    },
    "not_registered": function(d){
        var register_syntax = config.command_prefix + d.col + ' <' + commands[d.cat][d.col].commands.join('> <') + '>'; 
        return 'Your ' + c.teal(d.label) + ' is not registered! Please type ' + c.teal(register_syntax) + ' to register it';
        
    },
    "cmd_help": function(d){
        var syntax = config.command_prefix + d;
        var command_data = {};
        for(var cat in commands){
            for(var cmd in commands[cat]){
                if(cmd === d) command_data = commands[cat][cmd];
            }
        }

        console.log(command_data);

        if(command_data.commands.length > 0) {
            syntax += ' <' + command_data.commands.join('> <') + '>';
        }
        if (syntax.indexOf('*') > -1) syntax += ' (* commands are optional)';

        var str = c.teal('Usage: ') + syntax + ' ';
        str += c.teal('Description: ') + command_data.action + '.';
        return str;
    }
}
exports.respond = respond;

var commands = {
    "other" : {
        "commands": {
            "action": "list all of the available bot commands.",
            "commands": ["*-list"],
            "format": function(d){
                var str = c.teal("Avaliable commands: ") + d.commands.join(', ');
                str += c.red(' (for more info, you can type any command followed by help)');
                return str;
            }
        },
        "set": {
            "action": "set the channel topic",
            "commands": ["topic"],
            "perm": "+",
            "format": function(d){ 
                return "Topic set!"; 
            }
        },
        "reg": {
            "action": "register a user for any service (lastfm, trakt, location, untappd)",
            "commands": ["service", "irc nick", "data"],
            "perm": "~",
            "format": function(d){ 
                var str = c.teal(d.irc_nick) + '\'s ' + d.label + ' has now been set';
                return str;
            }
        },
        "unreg": {
            "action": "unregister a user for any service (lastfm, trakt, location, untappd)",
            "commands": ["service", "irc nick"],
            "perm": "~",
            "format": function(d){ 
                var str = c.teal(d.irc_nick) + '\'s ' + d.label + ' has now been removed';
                return str;
            }
        },
        "updates": {
            "action": "check for updates to b0t script",
            "commands": [],
            "perm": "@",
            "format": function(d){ 
                if(d === pkg.version) return 'I am up to date!';

                return 'Please update me! My version: ' + pkg.version + ' Current version: ' + d;
            }
        }
    },
    "LastFM" : {
        "np" : {
            "action": "get your last scrobbled song from last.fm",
            "commands": [],
            "register": "lastfm",
            "format": function(d){
                var title = [];
                if(d.artist !== '') title.push(d.artist);
                if(d.name !== '') title.push(d.name);
                var title_str = title.join(' - ');
                if(d.album !== '') title_str += ' (' + d.album + ')';


                var str = c.teal(d.irc_nick) + ' ';
                str += d.now_playing ? 'is now playing: ' + c.green(title_str) : 'last played: ' + c.gray(title_str); 
                str += ' [' + d.play_count + 'x] ' + (d.loved ? c.red('♥') + ' (' : '('); 

                if(d.tags.length > 0){
                    var tags = d.tags.splice(0, 4); //max 4 tags
                    tags = tags.map(function(tag){ return c.teal(tag); });
                    str += tags.join(', ');
                } else {
                    str += c.gray('No Tags');
                }

                str += ')';

                return str;
            }
        },
        "yt": {
            "action": "get your last scrobbled song from last.fm and attempt to locate a youtube video of it",
            "commands": [],
            "register": "lastfm",
            "format": function(d){
                var str = c.teal(d.irc_nick) + ' ';
                str += d.now_playing ? 'is now playing: ' + c.green(d.title || '') : 'last played: ' + c.gray(d.title || '');
                str += ' ' + d.link; 

                return str;
            }
        },
        "wp" : {
            "action": "get all users in current chan w/ registered last.fm nicks last scrobbled song",
{'fraction_non_alphanumeric': 0.17240221588047674, 'fraction_numerical': 0.004532482793352359, 'mean_word_length': 1.5767733564013842, 'pattern_counts': {'":': 82, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '4961477', 'n_tokens_mistral': 3808, 'n_tokens_neox': 3616, 'n_words': 884}