<commit_before>package com.mrpowergamerbr.loritta.listeners;

import com.mongodb.client.model.Filters;
import com.mrpowergamerbr.loritta.Loritta;
import com.mrpowergamerbr.loritta.LorittaLauncher;
import com.mrpowergamerbr.loritta.commands.CommandBase;
import com.mrpowergamerbr.loritta.commands.CommandContext;
import com.mrpowergamerbr.loritta.commands.CommandOptions;
import com.mrpowergamerbr.loritta.commands.nashorn.NashornCommand;
import com.mrpowergamerbr.loritta.userdata.LorittaProfile;
import com.mrpowergamerbr.loritta.userdata.LorittaServerUserData;
import com.mrpowergamerbr.loritta.userdata.ServerConfig;
import com.mrpowergamerbr.loritta.utils.LorittaUtils;
import com.mrpowergamerbr.loritta.utils.music.AudioTrackWrapper;
import net.dv8tion.jda.core.MessageBuilder;
import net.dv8tion.jda.core.entities.*;
import net.dv8tion.jda.core.entities.Message.Attachment;
import net.dv8tion.jda.core.events.guild.GuildLeaveEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberLeaveEvent;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.stream.Collectors;

public class DiscordListener extends ListenerAdapter {
    Loritta loritta;

    public DiscordListener(Loritta loritta) {
        this.loritta = loritta;
    }

    @Override
    public void onMessageReceived(MessageReceivedEvent event) {
        if (event.getAuthor().isBot()) {
            return;
        }
        if (event.isFromType(ChannelType.TEXT)) {
            loritta.getExecutor().execute(() -> {
                try {
                    ServerConfig conf = loritta.getServerConfigForGuild(event.getGuild().getId());
                    LorittaProfile profile = loritta.getLorittaProfileForUser(event.getMember().getUser().getId());

                    if (event.getMessage().getRawContent().replace("!", "").equals("<@297153970613387264>")) {
                        event.getTextChannel().sendMessage("Olá " + event.getMessage().getAuthor().getAsMention() + "! Meu prefixo neste servidor é `" + conf.commandPrefix() + "` Para ver o que eu posso fazer, use `" + conf.commandPrefix() + "ajuda`!").complete();
                    }

                    for (Role r : event.getMember().getRoles()) {
                        if (r.getName().equalsIgnoreCase("Inimigo da Loritta")) {
                            return;
                        }
                    }

                    LorittaProfile lorittaProfile = loritta.getLorittaProfileForUser(event.getAuthor().getId());<commit_msg>Fazer a Loritta automaticamente sair do servidor caso o dono do servidor esteja banido pela Loritta ("+lorittaban")<commit_after>package com.mrpowergamerbr.loritta.listeners;

import com.mongodb.client.model.Filters;
import com.mrpowergamerbr.loritta.Loritta;
import com.mrpowergamerbr.loritta.LorittaLauncher;
import com.mrpowergamerbr.loritta.commands.CommandBase;
import com.mrpowergamerbr.loritta.commands.CommandContext;
import com.mrpowergamerbr.loritta.commands.CommandOptions;
import com.mrpowergamerbr.loritta.commands.nashorn.NashornCommand;
import com.mrpowergamerbr.loritta.userdata.LorittaProfile;
import com.mrpowergamerbr.loritta.userdata.LorittaServerUserData;
import com.mrpowergamerbr.loritta.userdata.ServerConfig;
import com.mrpowergamerbr.loritta.utils.LorittaUtils;
import com.mrpowergamerbr.loritta.utils.music.AudioTrackWrapper;
import net.dv8tion.jda.core.MessageBuilder;
import net.dv8tion.jda.core.entities.*;
import net.dv8tion.jda.core.entities.Message.Attachment;
import net.dv8tion.jda.core.events.guild.GuildLeaveEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent;
import net.dv8tion.jda.core.events.guild.member.GuildMemberLeaveEvent;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.stream.Collectors;

public class DiscordListener extends ListenerAdapter {
    Loritta loritta;

    public DiscordListener(Loritta loritta) {
        this.loritta = loritta;
    }

    @Override
    public void onMessageReceived(MessageReceivedEvent event) {
        if (event.getAuthor().isBot()) {
            return;
        }
        if (event.isFromType(ChannelType.TEXT)) {
            loritta.getExecutor().execute(() -> {
                try {
                    ServerConfig conf = loritta.getServerConfigForGuild(event.getGuild().getId());
                    LorittaProfile profile = loritta.getLorittaProfileForUser(event.getMember().getUser().getId());
                    LorittaProfile ownerProfile = loritta.getLorittaProfileForUser(event.getGuild().getOwner().getUser().getId());

                    if (ownerProfile.isBanned()) { // Se o dono está banido...
                        if (!event.getMember().getUser().getId().equals(Loritta.getConfig().ownerId)) { // E ele não é o dono do bot!
                            event.getGuild().leave().complete(); // Então eu irei sair daqui, me recuso a ficar em um servidor que o dono está banido! ᕙ(⇀‸↼‶)ᕗ
                            return;
                        }
                    }

                    if (event.getMessage().getRawContent().replace("!", "").equals("<@297153970613387264>")) {
                        event.getTextChannel().sendMessage("Olá " + event.getMessage().getAuthor().getAsMention() + "! Meu prefixo neste servidor é `" + conf.commandPrefix() + "` Para ver o que eu posso fazer, use `" + conf.commandPrefix() + "ajuda`!").complete();
                    }

                    for (Role r : event.getMember().getRoles()) {
                        if (r.getName().equalsIgnoreCase("Inimigo da Loritta")) {
                            return;
                        }
                    }

                    LorittaProfile lorittaProfile = loritta.getLorittaProfileForUser(event.getAuthor().getId());
{'fraction_non_alphanumeric': 0.11279591520965496, 'fraction_numerical': 0.00835525297849296, 'mean_word_length': 3.2028608582574774, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3141924', 'n_tokens_mistral': 2028, 'n_tokens_neox': 1957, 'n_words': 293}