// Path: vilebot/src/main/java/com/oldterns/vilebot/util/BaseNick.java
// public class BaseNick
// {
//     // This would grab the leading x out of a nick that actually contains it
//     private static Pattern nickPattern = Pattern.compile( "(?:x|)([a-zA-Z0-9]+)(?:\\p{Punct}+[a-zA-Z0-9]*|)" );
// 
//     private static String primaryBotNick;
// 
//     private static Set<String> allBotNicks = new HashSet<>();
// 
//     public static String toBaseNick( String nick )
//     {
//         if ( allBotNicks.contains( nick ) )
//         {
//             nick = primaryBotNick;
//         }
//         else
//         {
//             Matcher nickMatcher = nickPattern.matcher( nick );
// 
//             if ( nickMatcher.find() )
//             {
//                 return nickMatcher.group( 1 );
//             }
//         }
//         return nick;
//     }
// 
//     public static String getPrimaryBotNick()
//     {
//         return primaryBotNick;
//     }
// 
//     public static void setPrimaryBotNick( String primaryNick )
//     {
//         primaryBotNick = primaryNick;
//     }
// 
//     public static Set<String> getBotNicks()
//     {
//         return allBotNicks;
//     }
// 
//     public static void addBotNick( String nick )
//     {
//         allBotNicks.add( nick );
//     }
// }


import com.oldterns.vilebot.Vilebot;
import com.oldterns.vilebot.db.KarmaDB;
import com.oldterns.vilebot.util.BaseNick;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.MessageEvent;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
    private void startTimer( final MessageEvent event )
    {
        timer.submit( () -> {
            try
            {
                Thread.sleep( TIMEOUT );
                timeoutTimer( event );
            }
            catch ( InterruptedException e )
            {
                e.printStackTrace();
            }
        } );
    }

    private void timeoutTimer( MessageEvent event )
    {
        String message = currentGame.getTimeoutString();
        event.respondWith( message );
        currentGame = null;
    }

    private void stopTimer()
    {
        timer.shutdownNow();
        timer = Executors.newFixedThreadPool( 1 );
    }

    private synchronized void finishGame( MessageEvent event, String answer )
    {
// Path: vilebot/src/main/java/com/oldterns/vilebot/util/BaseNick.java
// public class BaseNick
// {
//     // This would grab the leading x out of a nick that actually contains it
//     private static Pattern nickPattern = Pattern.compile( "(?:x|)([a-zA-Z0-9]+)(?:\\p{Punct}+[a-zA-Z0-9]*|)" );
// 
//     private static String primaryBotNick;
// 
//     private static Set<String> allBotNicks = new HashSet<>();
// 
//     public static String toBaseNick( String nick )
//     {
//         if ( allBotNicks.contains( nick ) )
//         {
//             nick = primaryBotNick;
//         }
//         else
//         {
//             Matcher nickMatcher = nickPattern.matcher( nick );
// 
//             if ( nickMatcher.find() )
//             {
//                 return nickMatcher.group( 1 );
//             }
//         }
//         return nick;
//     }
// 
//     public static String getPrimaryBotNick()
//     {
//         return primaryBotNick;
//     }
// 
//     public static void setPrimaryBotNick( String primaryNick )
//     {
//         primaryBotNick = primaryNick;
//     }
// 
//     public static Set<String> getBotNicks()
//     {
//         return allBotNicks;
//     }
// 
//     public static void addBotNick( String nick )
//     {
//         allBotNicks.add( nick );
//     }
// }


// Path: vilebot/src/main/java/com/oldterns/vilebot/handlers/user/Omgword.java
import com.oldterns.vilebot.Vilebot;
import com.oldterns.vilebot.db.KarmaDB;
import com.oldterns.vilebot.util.BaseNick;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.MessageEvent;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

    private void startTimer( final MessageEvent event )
    {
        timer.submit( () -> {
            try
            {
                Thread.sleep( TIMEOUT );
                timeoutTimer( event );
            }
            catch ( InterruptedException e )
            {
                e.printStackTrace();
            }
        } );
    }

    private void timeoutTimer( MessageEvent event )
    {
        String message = currentGame.getTimeoutString();
        event.respondWith( message );
        currentGame = null;
    }

    private void stopTimer()
    {
        timer.shutdownNow();
        timer = Executors.newFixedThreadPool( 1 );
    }

    private synchronized void finishGame( MessageEvent event, String answer )
    {
        String answerer = BaseNick.toBaseNick( Objects.requireNonNull( event.getUser() ).getNick() );