<commit_before>/**
 * Listens to all text channels
 */
package kuroodo.discordbot.listeners;

import kuroodo.discordbot.Init;
import kuroodo.discordbot.entities.JDAListener;
import kuroodo.discordbot.helpers.ChatLogger;
import net.dv8tion.jda.entities.User;
import net.dv8tion.jda.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.events.message.priv.PrivateMessageReceivedEvent;

public class ChatListener extends JDAListener {

	public void update(float delta) {
	}

	@Override
	public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
		try {
			// Use some magic to remove uneccesary characters. Only get letters
			String channelName = event.getChannel().toString().replaceAll("[^A-za-z]+", "");

			String message = "[" + event.getGuild().getName() + " [" + channelName + "]" + "] " + event.getAuthorName()
					+ ":" + event.getMessage().getContent();

			System.out.printf(message);
			ChatLogger.logMessage(message);

		} catch (StringIndexOutOfBoundsException e) {
			System.out.println("[" + event.getChannel().getName() + "]" + "[" + event.getAuthor().getUsername() + "] "
					+ " has sent an image/file or some other form of media or unsupported text");
		}
	}

	@Override
	public void onPrivateMessageReceived(PrivateMessageReceivedEvent event) {
		super.onPrivateMessageReceived(event);

		// Check if enter authorization password and if already authorized
		try {
			if (event.getMessage().getRawContent().equals(Init.SUPERUSER_PASSWORD)) {
				for (User authorizedUser : Init.SUPER_USERS) {
					if (authorizedUser == event.getAuthor()) {
						event.getChannel().sendMessageAsync("You're already an authorized user!", null);
						break;
					} else {<commit_msg>Fix null pointer instance if super user password was empty<commit_after>/**
 * Listens to all text channels
 */
package kuroodo.discordbot.listeners;

import kuroodo.discordbot.Init;
import kuroodo.discordbot.entities.JDAListener;
import kuroodo.discordbot.helpers.ChatLogger;
import net.dv8tion.jda.entities.User;
import net.dv8tion.jda.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.events.message.priv.PrivateMessageReceivedEvent;

public class ChatListener extends JDAListener {

	public void update(float delta) {
	}

	@Override
	public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
		try {
			// Use some magic to remove uneccesary characters. Only get letters
			String channelName = event.getChannel().toString().replaceAll("[^A-za-z]+", "");

			String message = "[" + event.getGuild().getName() + " [" + channelName + "]" + "] " + event.getAuthorName()
					+ ":" + event.getMessage().getContent();

			System.out.printf(message);
			ChatLogger.logMessage(message);

		} catch (StringIndexOutOfBoundsException e) {
			System.out.println("[" + event.getChannel().getName() + "]" + "[" + event.getAuthor().getUsername() + "] "
					+ " has sent an image/file or some other form of media or unsupported text");
		}
	}

	@Override
	public void onPrivateMessageReceived(PrivateMessageReceivedEvent event) {
		super.onPrivateMessageReceived(event);

		// Check if enter authorization password and if already authorized
		try {
			if (!Init.SUPERUSER_PASSWORD.isEmpty()
					&& event.getMessage().getRawContent().equals(Init.SUPERUSER_PASSWORD)) {
				for (User authorizedUser : Init.SUPER_USERS) {
					if (authorizedUser == event.getAuthor()) {
						event.getChannel().sendMessageAsync("You're already an authorized user!", null);
						break;
					} else {
{'fraction_non_alphanumeric': 0.128125, 'fraction_numerical': 0.0017045454545454545, 'mean_word_length': 4.562401263823065, 'pattern_counts': {'":': 2, '<': 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': '3311063', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1049, 'n_words': 226}