<commit_before>package de.felk.twitchbot;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import de.felk.twitchbot.db.DBHelper;
import de.felk.twitchbot.db.DBUserHandler;
import de.felk.twitchbot.entities.Bet;
import de.felk.twitchbot.entities.Match;
import de.felk.twitchbot.entities.Pokemon;
import de.felk.twitchbot.entities.Team;
import de.felk.twitchbot.reaction.ReactionConditioned;
import de.felk.twitchbot.reaction.ReactionConditionedRegex;
import de.felk.twitchbot.reaction.ReactionResult;

public class Felkbot extends Twitchbot {

	public static void main(String[] args) {

		Felkbot.simulateLogMode = false;

		if (args.length < 2) {
			System.err.println("Need arguments: USER OAUTH");
			System.exit(-1);
		}

		if (args.length >= 3) {
			if (args[2].equalsIgnoreCase("simulate")) {
				Felkbot.simulateLogMode = true;
			}
		}

		System.setErr(System.out);

		PokemonFetcher fetcher = new PokemonFetcher(DBHelper.getConnection());
		DBHelper.pauseConnection();

		new Felkbot(args[0], args[1], fetcher);
	}

	private enum Phase {
		BETTING, BATTLE;
	}

	private Phase phase = Phase.BETTING;

	private PokemonFetcher pokemonFetcher;

	private HashMap<String, Integer> balances;
	private LinkedHashMap<String, Bet> betsBlue, betsRed;
	private List<Pokemon> pokemons = new ArrayList<>();
	private Date timeStart;
	private String lastMsgSender = "", lastMsgChannel = "";
	private ChatLogger chatLogger;

	private String[] messages = new String[] { "Here's the visualized overview: ", "Here you go: ", "Visualized overview: ", "Overview for the match: ", "Here's the tactical overview: ", "The tactical overview: ", "The match overview: ", "Your overview for this match: ",
			"Here you go, match visualization: ", "Helpful overview for this match: ", "Pre-calculated overview for this match: ", "Here's the precalculated overview: " };
	private final String tppChannel = "#twitchplayspokemon";

	public static boolean simulateLogMode = true;

	public Felkbot(String name, String oauth, PokemonFetcher fetcher) {
		super(name, oauth);
		this.pokemonFetcher = fetcher;
		this.betsBlue = new LinkedHashMap<String, Bet>();
		this.betsRed = new LinkedHashMap<String, Bet>();
		this.balances = new HashMap<String, Integer>();
		this.chatLogger = new ChatLogger();

		if (simulateLogMode) {
			DBHelper.setAutoCommit(false);
			DBHelper.setClosePausedConnections(false);
			// process log in 100k-entry-bulks
			int bulksize = 100_000;
			int offset = 0;
			int count;
			try {
				do {<commit_msg>log-simulate bulks of 100,000 were way too big... now 1000<commit_after>package de.felk.twitchbot;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import de.felk.twitchbot.db.DBHelper;
import de.felk.twitchbot.db.DBUserHandler;
import de.felk.twitchbot.entities.Bet;
import de.felk.twitchbot.entities.Match;
import de.felk.twitchbot.entities.Pokemon;
import de.felk.twitchbot.entities.Team;
import de.felk.twitchbot.reaction.ReactionConditioned;
import de.felk.twitchbot.reaction.ReactionConditionedRegex;
import de.felk.twitchbot.reaction.ReactionResult;

public class Felkbot extends Twitchbot {

	public static void main(String[] args) {

		Felkbot.simulateLogMode = false;

		if (args.length < 2) {
			System.err.println("Need arguments: USER OAUTH");
			System.exit(-1);
		}

		if (args.length >= 3) {
			if (args[2].equalsIgnoreCase("simulate")) {
				Felkbot.simulateLogMode = true;
			}
		}

		System.setErr(System.out);

		PokemonFetcher fetcher = new PokemonFetcher(DBHelper.getConnection());
		DBHelper.pauseConnection();

		new Felkbot(args[0], args[1], fetcher);
	}

	private enum Phase {
		BETTING, BATTLE;
	}

	private Phase phase = Phase.BETTING;

	private PokemonFetcher pokemonFetcher;

	private HashMap<String, Integer> balances;
	private LinkedHashMap<String, Bet> betsBlue, betsRed;
	private List<Pokemon> pokemons = new ArrayList<>();
	private Date timeStart;
	private String lastMsgSender = "", lastMsgChannel = "";
	private ChatLogger chatLogger;

	private String[] messages = new String[] { "Here's the visualized overview: ", "Here you go: ", "Visualized overview: ", "Overview for the match: ", "Here's the tactical overview: ", "The tactical overview: ", "The match overview: ", "Your overview for this match: ",
			"Here you go, match visualization: ", "Helpful overview for this match: ", "Pre-calculated overview for this match: ", "Here's the precalculated overview: " };
	private final String tppChannel = "#twitchplayspokemon";

	public static boolean simulateLogMode = true;

	public Felkbot(String name, String oauth, PokemonFetcher fetcher) {
		super(name, oauth);
		this.pokemonFetcher = fetcher;
		this.betsBlue = new LinkedHashMap<String, Bet>();
		this.betsRed = new LinkedHashMap<String, Bet>();
		this.balances = new HashMap<String, Integer>();
		this.chatLogger = new ChatLogger();

		if (simulateLogMode) {
			DBHelper.setAutoCommit(false);
			DBHelper.setClosePausedConnections(false);
			// process log in 100k-entry-bulks
			int bulksize = 1_000;
			int offset = 0;
			int count;
			try {
				do {
{'fraction_non_alphanumeric': 0.11777892740127609, 'fraction_numerical': 0.006897740989825832, 'mean_word_length': 4.858585858585859, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4323261', 'n_tokens_mistral': 2038, 'n_tokens_neox': 1872, 'n_words': 467}