package io.github.likcoras.ssbot;

import io.github.likcoras.ssbot.backends.BttHandler;
import io.github.likcoras.ssbot.backends.MuHandler;
import io.github.likcoras.ssbot.backends.SilentLatestHandler;
import io.github.likcoras.ssbot.backends.XmlHandler;
import io.github.likcoras.ssbot.bot.BotManager;
import io.github.likcoras.ssbot.core.BotCoreHandlers;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.log4j.Logger;
import org.pircbotx.exception.IrcException;
import org.xml.sax.SAXException;

public class SSBot {
	
	private static final Logger LOG = Logger.getLogger(SSBot.class);
	
	public static void main(final String[] args) {
		
		try {
			
			final ConfigParser config = new ConfigParser();
			config.parse();
			
			final BotCoreHandlers coreHandlers = new BotCoreHandlers(config);
			
			final BotManager bot = new BotManager(config, coreHandlers);
			registerHandlers(bot, config);
			
			bot.start();
			
		} catch (ClassNotFoundException | IOException | SAXException | ParserConfigurationException | IrcException e) {
			
			LOG.error("Error while executing bot", e);
			
		}
		
		LOG.info("Bot stopped, exiting.");
		
	}
	
	private static void registerHandlers(final BotManager bot,
		final ConfigParser config) throws ClassNotFoundException, IOException,
		SAXException, ParserConfigurationException {
		
		bot.registerHandler(new BttHandler(config));
		bot.registerHandler(new SilentLatestHandler(config));
		bot.registerHandler(new MuHandler(config));
		
		final XmlHandler xml = new XmlHandler(config);
		xml.update();
		
		bot.registerHandler(xml);
		
	}
	
}

@@ -351,16 +351,37 @@
 dlers;%0A%0A
+import java.io.File;%0A
 import j
@@ -779,21 +779,95 @@
 %0A%09%09%09
-config.parse(
+%0A%09%09%09if (args.length %3E 0)%0A%09%09%09%09config.parse();%0A%09%09%09else%0A%09%09%09%09config.parse(new File(args%5B0%5D)
 );%0A%09

Add support for specifying configuration file