<commit_before>/**
 * Module Name: Ignore
 * Description: Handles commands in which users can choose to ignore listeners
 * and commands from certain modules. It also populates the JSBot instance with
 * this information, since that actually performs the ignorance.
 */
var _ = require('underscore')._;

var ignore = function(dbot) {
    var commands = {
        '~ignore': function(event) {
            var user = dbot.api.users.resolveUser(event.server, event.user),
                module = event.params[1],
                ignorableModules = _.chain(dbot.modules)
                    .filter(function(module, name) {
                        return dbot.config[module].ignorable === true;
                    })
                    .pluck('name')
                    .value();

            if(_.isUndefined(module)) {
                event.reply(dbot.t('ignore_usage', {
                    'user': event.user, 
                    'modules': ignorableModules.join(', ')
                }));
            } else {
                if(_.include(ignorableModules, module)) {
                    if(_.has(dbot.db.ignores, user) && _.include(dbot.db.ignores[user], module)) {
                        event.reply(dbot.t('already_ignoring', { 'user': event.user }));
                    } else {
                        if(_.has(dbot.db.ignores, module)) {
                            dbot.db.ignores[user].push(module);
                        } else {
                            dbot.db.ignores[user] = [module];
                        }

                        dbot.instance.ignoreTag(event.user, module);
                        event.reply(dbot.t('ignored', {
                            'user': event.user, 
                            'module': module
                        }));
                    }
                } else {
                    event.reply(dbot.t('invalid_ignore', { 'user': event.user }));
                }
            }
        }, 

        '~unignore': function(event) {
            var user = dbot.api.users.resolveUser(event.server, event.user),
                module = event.params[1],
                ignoredModules = [];

            if(_.has(dbot.db.ignores, event.user)) {
                ignoredModules = dbot.db.ignores[user];
            }

            if(_.isUndefined(module)) {
                event.reply(dbot.t('unignore_usage', {
                    'user': event.user, 
                    'modules': ignoredModules.join(', ')
                }));
            } else {
                if(_.include(ignoredModules, module)) {
                    dbot.db.ignores[user].splice(dbot.db.ignores[user].indexOf(module), 1);
                    dbot.instance.removeIgnore(user, module)
                    event.reply(dbot.t('unignored', { 
                        'user': event.user, 
                        'module': module
                    }));
                } else {
                    event.reply(dbot.t('invalid_unignore', { 'user': event.user }));
                }
            }
        }
    };
    this.commands = commands;

    this.onLoad = function() {
        dbot.instance.clearIgnores();
        _.each(dbot.db.ignores, function(ignores, user) {
            _.each(ignores, function(ignore) {
                    dbot.instance.ignoreTag(user, ignore);
            }, this);
        }, this);
    };
};

exports.fetch = function(dbot) {
    return new ignore(dbot);
};<commit_msg>revert to older, non-broken ignore. whoops!<commit_after>/**
 * Module Name: Ignore
 * Description: Handles commands in which users can choose to ignore listeners
 * and commands from certain modules. It also populates the JSBot instance with
 * this information, since that actually performs the ignorance.
 */
var _ = require('underscore')._;

var ignore = function(dbot) {
    var commands = {
        '~ignore': function(event) {
            var module = event.params[1];
            var ignorableModules = _.chain(dbot.modules)
                .filter(function(module, name) {
                    return dbot.config[module].ignorable === true;
                })
                .pluck('name')
                .value();

            if(_.isUndefined(module)) {
                event.reply(dbot.t('ignore_usage', {
                    'user': event.user, 
                    'modules': ignorableModules.join(', ')
                }));
            } else {
                if(_.include(ignorableModules, module)) {
                    if(_.has(dbot.db.ignores, event.user) && _.include(dbot.db.ignores[event.user], module)) {
                        event.reply(dbot.t('already_ignoring', { 'user': event.user }));
                    } else {
                        if(_.has(dbot.db.ignores, module)) {
                            dbot.db.ignores[event.user].push(module);
                        } else {
                            dbot.db.ignores[event.user] = [module];
                        }

                        dbot.instance.ignoreTag(event.user, module);
                        event.reply(dbot.t('ignored', {
                            'user': event.user, 
                            'module': module
                        }));
                    }
                } else {
                    event.reply(dbot.t('invalid_ignore', { 'user': event.user }));
                }
            }
        }, 

        '~unignore': function(event) {
            var ignoredModules = [];
            if(_.has(dbot.db.ignores, event.user)) {
                ignoredModules = dbot.db.ignores[event.user];
            }
            var module = event.params[1];

            if(_.isUndefined(module)) {
                event.reply(dbot.t('unignore_usage', {
                    'user': event.user, 
                    'modules': ignoredModules.join(', ')
                }));
            } else {
                if(_.include(ignoredModules, module)) {
                    dbot.db.ignores[event.user].splice(dbot.db.ignores[event.user].indexOf(module), 1);
                    dbot.instance.removeIgnore(event.user, module)
                    event.reply(dbot.t('unignored', { 
                        'user': event.user, 
                        'module': module
                    }));
                } else {
                    event.reply(dbot.t('invalid_unignore', { 'user': event.user }));
                }
            }
        }
    };
    this.commands = commands;

    this.onLoad = function() {
        dbot.instance.clearIgnores();
        _.each(dbot.db.ignores, function(ignores, user) {
            _.each(ignores, function(ignore) {
                    dbot.instance.ignoreTag(user, ignore);
            }, this);
        }, this);
    };
};

exports.fetch = function(dbot) {
    return new ignore(dbot);
};
{'fraction_non_alphanumeric': 0.12910832719233603, 'fraction_numerical': 0.0008843036109064112, 'mean_word_length': 1.282542885973764, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6310531', 'n_tokens_mistral': 1847, 'n_tokens_neox': 1771, 'n_words': 295}