<commit_before>package com.mniip.bananapeel;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class IRCCommandHandler
{
	@Retention(RetentionPolicy.RUNTIME)
	private @interface Hook { }

	public static void handle(Server srv, IRCMessage msg)
	{
		String methodName = "handle" + msg.command.toUpperCase();
		Method m;
		try
		{
			m = IRCCommandHandler.class.getDeclaredMethod(methodName, Server.class, IRCMessage.class);
			if(m.getAnnotation(Hook.class) != null)
				m.invoke(null, srv, msg);
		}
		catch(NoSuchMethodException e)
		{
			handleUnhandled(srv, msg);
		}
		catch(IllegalAccessException e) { }
		catch(InvocationTargetException e)
		{
			if(e.getCause() instanceof RuntimeException)
				throw (RuntimeException)e.getCause();
		}
	}

	@IRCCommandHandler.Hook
	private static void handleJOIN(Server srv, IRCMessage msg)
	{
		if(msg.args.length >= 1 && msg.source != null)
		{
			String nick = msg.getNick();
			String channel = msg.args[0];
			Tab tab;
			if(nick.equals(srv.ourNick))
				tab = srv.getService().createTab(srv.getTab(), channel);
			else
				tab = srv.getService().findTab(srv.getTab(), channel);
			if(tab != null)
				tab.putLine("* " + nick + " joined " + channel);

		}
	}

	@IRCCommandHandler.Hook
	private static void handlePRIVMSG(Server srv, IRCMessage msg)
	{
		if(msg.args.length >= 2)
		{
			String nick = msg.getNick();
			String target = msg.args[0];
			String text = msg.args[1];
			String location = target.equals(srv.ourNick) ? nick : target;
			Tab tab = srv.getService().findTab(srv.getTab(), location);
			if(tab == null)
				tab = srv.getService().createTab(srv.getTab(), nick);
			tab.putLine("<" + nick + "> " + text);
		}
	}

	private static void handleUnhandled(Server srv, IRCMessage msg)
	{<commit_msg>Added handlePING<commit_after>package com.mniip.bananapeel;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class IRCCommandHandler
{
	@Retention(RetentionPolicy.RUNTIME)
	private @interface Hook { }

	public static void handle(Server srv, IRCMessage msg)
	{
		String methodName = "handle" + msg.command.toUpperCase();
		Method m;
		try
		{
			m = IRCCommandHandler.class.getDeclaredMethod(methodName, Server.class, IRCMessage.class);
			if(m.getAnnotation(Hook.class) != null)
				m.invoke(null, srv, msg);
		}
		catch(NoSuchMethodException e)
		{
			handleUnhandled(srv, msg);
		}
		catch(IllegalAccessException e) { }
		catch(InvocationTargetException e)
		{
			if(e.getCause() instanceof RuntimeException)
				throw (RuntimeException)e.getCause();
		}
	}

	@IRCCommandHandler.Hook
	private static void handleJOIN(Server srv, IRCMessage msg)
	{
		if(msg.args.length >= 1 && msg.source != null)
		{
			String nick = msg.getNick();
			String channel = msg.args[0];
			Tab tab;
			if(nick.equals(srv.ourNick))
				tab = srv.getService().createTab(srv.getTab(), channel);
			else
				tab = srv.getService().findTab(srv.getTab(), channel);
			if(tab != null)
				tab.putLine("* " + nick + " joined " + channel);

		}
	}

	@IRCCommandHandler.Hook
	private static void handlePING(Server srv, IRCMessage msg)
	{
		srv.send(new IRCMessage("PONG", msg.args));
	}

	@IRCCommandHandler.Hook
	private static void handlePRIVMSG(Server srv, IRCMessage msg)
	{
		if(msg.args.length >= 2)
		{
			String nick = msg.getNick();
			String target = msg.args[0];
			String text = msg.args[1];
			String location = target.equals(srv.ourNick) ? nick : target;
			Tab tab = srv.getService().findTab(srv.getTab(), location);
			if(tab == null)
				tab = srv.getService().createTab(srv.getTab(), nick);
			tab.putLine("<" + nick + "> " + text);
		}
	}

	private static void handleUnhandled(Server srv, IRCMessage msg)
	{
{'fraction_non_alphanumeric': 0.13635200818623688, 'fraction_numerical': 0.0025581990278843694, 'mean_word_length': 4.0713359273670555, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3228957', 'n_tokens_mistral': 1524, 'n_tokens_neox': 1353, 'n_words': 272}