<commit_before>/*
 * Copyright (c) 2017 <NAME>.
 *  You may use, distribute and modify this code under the terms of the MIT licence.
 *  You should have obtained a copy of the MIT licence with this software,
 *  if not please obtain one from https://opensource.org/licences/MIT
 *
 *
 *
 */

package org.frostbite.karren.interactions.Tags;

import org.frostbite.karren.Database.Objects.DbGuildUser;
import org.frostbite.karren.Karren;
import org.frostbite.karren.interactions.Interaction;
import org.frostbite.karren.interactions.Tag;
import sx.blah.discord.handle.impl.events.guild.channel.message.MessageReceivedEvent;
import sx.blah.discord.handle.obj.IUser;
import sx.blah.discord.util.MessageBuilder;

public class SetFilter implements Tag {
    @Override
    public String handleTemplate(String msg, Interaction interaction, MessageBuilder response, MessageReceivedEvent event) {
        if(interaction.getMentionedUsers().size()>0){
            IUser user = interaction.getMentionedUsers().get(0);
            if(!user.equals(event.getAuthor())){
                DbGuildUser dbGuildUser = Karren.bot.getSql().getGuildUser(event.getGuild(), event.getAuthor());
                if(dbGuildUser.isIgnoreCommands()){
                    dbGuildUser.setIgnoreCommands(false);
                    msg = msg.replace("%setting", "disabled");
                } else {
                    dbGuildUser.setIgnoreCommands(true);
                    msg = msg.replace("%setting", "enabled");
                }
                msg = msg.replace("%user", user.getName());
                dbGuildUser.update();
            } else {
                msg = interaction.getRandomTemplatesFail();
            }
        }
        return msg;
    }
}
<commit_msg>Fixed set filter to actually filter the target<commit_after>/*
 * Copyright (c) 2017 <NAME>.
 *  You may use, distribute and modify this code under the terms of the MIT licence.
 *  You should have obtained a copy of the MIT licence with this software,
 *  if not please obtain one from https://opensource.org/licences/MIT
 *
 *
 *
 */

package org.frostbite.karren.interactions.Tags;

import org.frostbite.karren.Database.Objects.DbGuildUser;
import org.frostbite.karren.Karren;
import org.frostbite.karren.interactions.Interaction;
import org.frostbite.karren.interactions.Tag;
import sx.blah.discord.handle.impl.events.guild.channel.message.MessageReceivedEvent;
import sx.blah.discord.handle.obj.IUser;
import sx.blah.discord.util.MessageBuilder;

public class SetFilter implements Tag {
    @Override
    public String handleTemplate(String msg, Interaction interaction, MessageBuilder response, MessageReceivedEvent event) {
        if(interaction.getMentionedUsers().size()>0){
            IUser user = interaction.getMentionedUsers().get(0);
            if(!user.equals(event.getAuthor())){
                DbGuildUser dbGuildUser = Karren.bot.getSql().getGuildUser(event.getGuild(), user);
                if(dbGuildUser.isIgnoreCommands()){
                    dbGuildUser.setIgnoreCommands(false);
                    msg = msg.replace("%setting", "disabled");
                } else {
                    dbGuildUser.setIgnoreCommands(true);
                    msg = msg.replace("%setting", "enabled");
                }
                msg = msg.replace("%user", user.getName());
                dbGuildUser.update();
            } else {
                msg = interaction.getRandomTemplatesFail();
            }
        }
        return msg;
    }
}

{'fraction_non_alphanumeric': 0.10911680911680911, 'fraction_numerical': 0.003418803418803419, 'mean_word_length': 2.615859938208033, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3432812', 'n_tokens_mistral': 1021, 'n_tokens_neox': 986, 'n_words': 207}