<commit_before>package pokeraidbot.jda;

import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.MessageChannel;
import net.dv8tion.jda.core.events.Event;
import net.dv8tion.jda.core.events.ReadyEvent;
import net.dv8tion.jda.core.exceptions.ErrorResponseException;
import net.dv8tion.jda.core.hooks.EventListener;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pokeraidbot.commands.RaidOverviewCommand;
import pokeraidbot.domain.config.ClockService;
import pokeraidbot.domain.config.LocaleService;
import pokeraidbot.domain.errors.UserMessedUpException;
import pokeraidbot.domain.raid.RaidRepository;
import pokeraidbot.infrastructure.jpa.config.Config;
import pokeraidbot.infrastructure.jpa.config.ServerConfigRepository;

import java.util.List;
import java.util.concurrent.*;

public class StartUpEventListener implements EventListener{
    private static final Logger LOGGER = LoggerFactory.getLogger(StartUpEventListener.class);
    private ServerConfigRepository serverConfigRepository;
    private final RaidRepository raidRepository;
    private final LocaleService localeService;
    private final ClockService clockService;
    protected static final ExecutorService executorService = new ThreadPoolExecutor(0, 200,
            65L, TimeUnit.SECONDS,
            new LinkedTransferQueue<>());

    // todo: pass thread pool as an argument, so we have the same pool for all worker threads
    public StartUpEventListener(ServerConfigRepository serverConfigRepository,
                                RaidRepository raidRepository, LocaleService localeService,
                                ClockService clockService) {
        this.serverConfigRepository = serverConfigRepository;
        this.raidRepository = raidRepository;
        this.localeService = localeService;
        this.clockService = clockService;
    }

    @Override
    public void onEvent(Event event) {
        if (event instanceof ReadyEvent) {
            final List<Guild> guilds = event.getJDA().getGuilds();
            for (Guild guild : guilds) {
                Config config = serverConfigRepository.getConfigForServer(guild.getName().trim().toLowerCase());
                if (config != null) {
                    final String messageId = config.getOverviewMessageId();
                    if (!StringUtils.isEmpty(messageId)) {
                        for (MessageChannel channel : guild.getTextChannels()) {
                            try {
                                if (channel.getMessageById(messageId).complete() != null) {
                                    final Callable<Boolean> overviewTask =
                                            RaidOverviewCommand.getMessageRefreshingTaskToSchedule(
                                                    null, config, messageId, localeService, serverConfigRepository,
                                                    raidRepository, clockService, channel,
                                                    executorService);
                                    executorService.submit(overviewTask);
                                    LOGGER.info("Found overview message for channel " + channel.getName() +
                                            " (server " + guild.getName() + "). Attaching to it.");
                                    if (guild.getDefaultChannel() != null) {
                                        guild.getDefaultChannel().sendMessage(
                                                localeService.getMessageFor(LocaleService.OVERVIEW_ATTACH,
                                                        config.getLocale(),
                                                        channel.getName())).queue();
                                    }
                                    return;
                                }
                            } catch (UserMessedUpException e) {
                                channel.sendMessage(e.getMessage()).queue();
                            } catch (ErrorResponseException e) {
                                // We couldn't find the message in this channel or had permission issues, ignore
                            } catch (Throwable e) {
                                // Ignore any other error and try the other server channels
                            }
                        }
                    }
                }
            }
        }
    }
}
<commit_msg>More than one overview message should work :p<commit_after>package pokeraidbot.jda;

import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.MessageChannel;
import net.dv8tion.jda.core.events.Event;
import net.dv8tion.jda.core.events.ReadyEvent;
import net.dv8tion.jda.core.exceptions.ErrorResponseException;
import net.dv8tion.jda.core.hooks.EventListener;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pokeraidbot.commands.RaidOverviewCommand;
import pokeraidbot.domain.config.ClockService;
import pokeraidbot.domain.config.LocaleService;
import pokeraidbot.domain.errors.UserMessedUpException;
import pokeraidbot.domain.raid.RaidRepository;
import pokeraidbot.infrastructure.jpa.config.Config;
import pokeraidbot.infrastructure.jpa.config.ServerConfigRepository;

import java.util.List;
import java.util.concurrent.*;

public class StartUpEventListener implements EventListener{
    private static final Logger LOGGER = LoggerFactory.getLogger(StartUpEventListener.class);
    private ServerConfigRepository serverConfigRepository;
    private final RaidRepository raidRepository;
    private final LocaleService localeService;
    private final ClockService clockService;
    protected static final ExecutorService executorService = new ThreadPoolExecutor(100, Integer.MAX_VALUE,
            65L, TimeUnit.SECONDS,
            new LinkedTransferQueue<>());

    // todo: pass thread pool as an argument, so we have the same pool for all worker threads
    public StartUpEventListener(ServerConfigRepository serverConfigRepository,
                                RaidRepository raidRepository, LocaleService localeService,
                                ClockService clockService) {
        this.serverConfigRepository = serverConfigRepository;
        this.raidRepository = raidRepository;
        this.localeService = localeService;
        this.clockService = clockService;
    }

    @Override
    public void onEvent(Event event) {
        if (event instanceof ReadyEvent) {
            final List<Guild> guilds = event.getJDA().getGuilds();
            for (Guild guild : guilds) {
                Config config = serverConfigRepository.getConfigForServer(guild.getName().trim().toLowerCase());
                if (config != null) {
                    final String messageId = config.getOverviewMessageId();
                    if (!StringUtils.isEmpty(messageId)) {
                        for (MessageChannel channel : guild.getTextChannels()) {
                            getAndAttachToOverviewMessageIfExists(guild, config, messageId, channel);
                        }
                    }
                }
            }
        }
    }

    private boolean getAndAttachToOverviewMessageIfExists(Guild guild, Config config, String messageId, MessageChannel channel) {
        try {
            if (channel.getMessageById(messageId).complete() != null) {
                final Callable<Boolean> overviewTask =
                        RaidOverviewCommand.getMessageRefreshingTaskToSchedule(
                                null, config, messageId, localeService, serverConfigRepository,
                                raidRepository, clockService, channel,
                                executorService);
                executorService.submit(overviewTask);
                LOGGER.info("Found overview message for channel " + channel.getName() +
                        " (server " + guild.getName() + "). Attaching to it.");
                if (guild.getDefaultChannel() != null) {
                    guild.getDefaultChannel().sendMessage(
                            localeService.getMessageFor(LocaleService.OVERVIEW_ATTACH,
                                    config.getLocale(),
                                    channel.getName())).queue();
                }
                return true;
            }
        } catch (UserMessedUpException e) {
            channel.sendMessage(e.getMessage()).queue();
        } catch (ErrorResponseException e) {
            // We couldn't find the message in this channel or had permission issues, ignore
        } catch (Throwable e) {
            // Ignore any other error and try the other server channels
        }
        return false;
    }
}

{'fraction_non_alphanumeric': 0.07435197817189632, 'fraction_numerical': 0.0032969531605275123, 'mean_word_length': 1.9294039294039294, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4666318', 'n_tokens_mistral': 2068, 'n_tokens_neox': 1994, 'n_words': 450}