<commit_before>package com.kantenkugel.discordbot;

import com.kantenkugel.discordbot.listener.MessageEvent;
import net.dv8tion.jda.entities.Guild;
import net.dv8tion.jda.entities.User;
import net.dv8tion.jda.utils.SimpleLog;

import java.sql.*;
import java.sql.Date;
import java.time.OffsetDateTime;
import java.util.*;

public class DbEngine {
    private static final SimpleLog LOG = SimpleLog.getLog("DB");

    private static boolean initialized = false;
    private static Connection conn;
    private static PreparedStatement messageInsert, messageUpdate, messageDelete;
    private static PreparedStatement userUpdate;
    private static PreparedStatement banAdd, banLookup;

    public static synchronized void init() {
        if(initialized)
            return;
        try {
            Class.forName("org.hsqldb.jdbcDriver");
            conn = DriverManager.getConnection("jdbc:hsqldb:file:db/kanzedb", "SA", "");
            if(createTables())
                createStatements();
            initialized = true;
        } catch(SQLException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static void handleMessage(MessageEvent e) {
        if(!initialized || e.isPrivate())
            return;
        if(e.isEdit()) {
            try {
                messageUpdate.setString(1, e.getMessage().getId());
                messageUpdate.setString(2, e.getMessage().getContent());
                messageUpdate.setDate(3, new Date(e.getMessage().getEditedTimestamp().toEpochSecond() * 1000));
                messageUpdate.executeUpdate();
            } catch(SQLException ignored) {
                //message is older than db of that channel
            }
        } else {
            try {
                updateUser(e.getAuthor());
                messageInsert.setString(1, e.getMessage().getId());
                messageInsert.setString(2, e.getGuild().getId());
                messageInsert.setString(3, e.getTextChannel().getId());
                messageInsert.setString(4, e.getAuthor().getId());
                messageInsert.setString(5, e.getAuthor().getUsername());
                messageInsert.setString(6, e.getMessage().getContent());
                messageInsert.setDate(7, new Date(e.getMessage().getTime().toEpochSecond() * 1000));<commit_msg>now adding RawContent to db<commit_after>package com.kantenkugel.discordbot;

import com.kantenkugel.discordbot.listener.MessageEvent;
import net.dv8tion.jda.entities.Guild;
import net.dv8tion.jda.entities.User;
import net.dv8tion.jda.utils.SimpleLog;

import java.sql.*;
import java.sql.Date;
import java.time.OffsetDateTime;
import java.util.*;

public class DbEngine {
    private static final SimpleLog LOG = SimpleLog.getLog("DB");

    private static boolean initialized = false;
    private static Connection conn;
    private static PreparedStatement messageInsert, messageUpdate, messageDelete;
    private static PreparedStatement userUpdate;
    private static PreparedStatement banAdd, banLookup;

    public static synchronized void init() {
        if(initialized)
            return;
        try {
            Class.forName("org.hsqldb.jdbcDriver");
            conn = DriverManager.getConnection("jdbc:hsqldb:file:db/kanzedb", "SA", "");
            if(createTables())
                createStatements();
            initialized = true;
        } catch(SQLException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static void handleMessage(MessageEvent e) {
        if(!initialized || e.isPrivate())
            return;
        if(e.isEdit()) {
            try {
                messageUpdate.setString(1, e.getMessage().getId());
                messageUpdate.setString(2, e.getMessage().getRawContent());
                messageUpdate.setDate(3, new Date(e.getMessage().getEditedTimestamp().toEpochSecond() * 1000));
                messageUpdate.executeUpdate();
            } catch(SQLException ignored) {
                //message is older than db of that channel
            }
        } else {
            try {
                updateUser(e.getAuthor());
                messageInsert.setString(1, e.getMessage().getId());
                messageInsert.setString(2, e.getGuild().getId());
                messageInsert.setString(3, e.getTextChannel().getId());
                messageInsert.setString(4, e.getAuthor().getId());
                messageInsert.setString(5, e.getAuthor().getUsername());
                messageInsert.setString(6, e.getMessage().getRawContent());
                messageInsert.setDate(7, new Date(e.getMessage().getTime().toEpochSecond() * 1000));
{'fraction_non_alphanumeric': 0.11578044596912522, 'fraction_numerical': 0.009005145797598629, 'mean_word_length': 2.4787472035794185, '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': '7381973', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1241, 'n_words': 241}