<commit_before>package mnm.mods.tabbychat.filters;

import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

import mnm.mods.tabbychat.TabbyChat;
import mnm.mods.tabbychat.api.Channel;
import mnm.mods.tabbychat.api.TabbyAPI;
import mnm.mods.tabbychat.api.filters.Filter;
import mnm.mods.tabbychat.api.filters.FilterEvent;
import mnm.mods.tabbychat.util.MessagePatterns;

/**
 * Base class for filters that just need to set the
 */
public class MessageFilter extends TabFilter {


    @Override
    public Pattern getPattern() {
        try {
            // Quickly update the pattern
            MessagePatterns messege =
                    TabbyChat.getInstance().serverSettings.messegePattern.getValue();
            String pattern =
                    String.format("(?:%s|%s)", messege.getOutgoing(), messege.getIncoming());
            setPattern(pattern);
        } catch (PatternSyntaxException e) {
            TabbyChat.getLogger().error(e);
        }
        return super.getPattern();
    }

    @Override
    public void action(Filter filter, FilterEvent event) {
        String player = event.matcher.group(1);
        Channel dest = TabbyAPI.getAPI().getChat().getChannel(player);
        if (dest.getPrefix().isEmpty()) {
            dest.setPrefix("/msg " + player);
        }
        event.channels.add(dest);
    }
}
<commit_msg>Fix for incoming PM matches always being null.<commit_after>package mnm.mods.tabbychat.filters;

import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

import mnm.mods.tabbychat.TabbyChat;
import mnm.mods.tabbychat.api.Channel;
import mnm.mods.tabbychat.api.TabbyAPI;
import mnm.mods.tabbychat.api.filters.Filter;
import mnm.mods.tabbychat.api.filters.FilterEvent;
import mnm.mods.tabbychat.util.MessagePatterns;

/**
 * Base class for filters that just need to set the
 */
public class MessageFilter extends TabFilter {


    @Override
    public Pattern getPattern() {
        try {
            // Quickly update the pattern
            MessagePatterns messege =
                    TabbyChat.getInstance().serverSettings.messegePattern.getValue();
            String pattern =
                    String.format("(?:%s|%s)", messege.getOutgoing(), messege.getIncoming());
            setPattern(pattern);
        } catch (PatternSyntaxException e) {
            TabbyChat.getLogger().error(e);
        }
        return super.getPattern();
    }

    @Override
    public void action(Filter filter, FilterEvent event) {
        // 0 = whole message, 1 = outgoing recipient, 2 = incoming recipient
        String player = event.matcher.group(1);
        // For when it's an incoming message.
        if (player == null) {
            player = event.matcher.group(2);
        }
        Channel dest = TabbyAPI.getAPI().getChat().getChannel(player);
        if (dest.getPrefix().isEmpty()) {
            dest.setPrefix("/msg " + player);
        }
        event.channels.add(dest);
    }
}

{'fraction_non_alphanumeric': 0.11457286432160804, 'fraction_numerical': 0.0020100502512562816, 'mean_word_length': 2.5846338535414164, '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': '4937916', 'n_tokens_mistral': 878, 'n_tokens_neox': 862, 'n_words': 177}