<commit_before>/*
 * LoggerModule.java
 *
 * Created on June 25, 2005, 10:29 PM
 */

package uk.co.uwcs.choob.modules;

import uk.co.uwcs.choob.*;
import java.sql.*;
import uk.co.uwcs.choob.support.*;
import uk.co.uwcs.choob.support.events.*;
import java.security.*;
import java.util.List;
import java.util.ArrayList;

/**
 * Logs lines from IRC to the database.
 * @author sadiq
 */
public final class HistoryModule
{
	private DbConnectionBroker dbBroker;

	/** Creates a new instance of LoggerModule */
	HistoryModule(DbConnectionBroker dbBroker)
	{
		this.dbBroker = dbBroker;
	}

	/**
	 * Logs a line from IRC to the database.
	 * @param mes {@link IRCEvent} object representing the line from IRC.
	 * @throws Exception Thrown from the database access, potential SQL or IO exceptions.
	 */

	public void addLog( IRCEvent ev )
	{
		if (ev instanceof Message && ((Message)ev).getSynthLevel() > 0)
			return;

		AccessController.checkPermission(new ChoobPermission("history.add"));

		Connection dbConnection = null;

		PreparedStatement insertLine = null;

		try
		{
			dbConnection = dbBroker.getConnection();

			insertLine = dbConnection.prepareStatement("INSERT INTO History VALUES(NULL,?,?,?,?,?,?,?)");

			if (ev instanceof Message)
			{
				Message mes = (Message)ev;
				insertLine.setString(1, mes.getClass().getName());
				insertLine.setString(2, mes.getNick());
				insertLine.setString(3, mes.getLogin()+"@"+mes.getHostname());

				String chan = null;
				if (mes instanceof ChannelEvent)
					chan = ((ChannelEvent)mes).getChannel();

				insertLine.setString(4, chan);
				insertLine.setString(5, mes.getMessage());
				insertLine.setLong(6, mes.getMillis());
				insertLine.setInt(7, mes.getRandom());<commit_msg>Hack to make addLog accept messages. No idea why it doesn't. This fixes alias.<commit_after>/*
 * LoggerModule.java
 *
 * Created on June 25, 2005, 10:29 PM
 */

package uk.co.uwcs.choob.modules;

import uk.co.uwcs.choob.*;
import java.sql.*;
import uk.co.uwcs.choob.support.*;
import uk.co.uwcs.choob.support.events.*;
import java.security.*;
import java.util.List;
import java.util.ArrayList;

/**
 * Logs lines from IRC to the database.
 * @author sadiq
 */
public final class HistoryModule
{
	private DbConnectionBroker dbBroker;

	/** Creates a new instance of LoggerModule */
	HistoryModule(DbConnectionBroker dbBroker)
	{
		this.dbBroker = dbBroker;
	}

	public void addLog (Message m)
	{
		addLog((Event)m);
	}

	/**
	 * Logs a line from IRC to the database.
	 * @param mes {@link IRCEvent} object representing the line from IRC.
	 * @throws Exception Thrown from the database access, potential SQL or IO exceptions.
	 */

	public void addLog( Event ev )
	{
		if (ev instanceof Message && ((Message)ev).getSynthLevel() > 0)
			return;

		AccessController.checkPermission(new ChoobPermission("history.add"));

		Connection dbConnection = null;

		PreparedStatement insertLine = null;

		try
		{
			dbConnection = dbBroker.getConnection();

			insertLine = dbConnection.prepareStatement("INSERT INTO History VALUES(NULL,?,?,?,?,?,?,?)");

			if (ev instanceof Message)
			{
				Message mes = (Message)ev;
				insertLine.setString(1, mes.getClass().getName());
				insertLine.setString(2, mes.getNick());
				insertLine.setString(3, mes.getLogin()+"@"+mes.getHostname());

				String chan = null;
				if (mes instanceof ChannelEvent)
					chan = ((ChannelEvent)mes).getChannel();

				insertLine.setString(4, chan);
				insertLine.setString(5, mes.getMessage());
				insertLine.setLong(6, mes.getMillis());
				insertLine.setInt(7, mes.getRandom());
{'fraction_non_alphanumeric': 0.13521048229718427, 'fraction_numerical': 0.010036241984945637, 'mean_word_length': 4.00418410041841, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '927140', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1115, 'n_words': 296}