var irc = require("irc");
var repl = require("repl");
var fs = require("fs");

var config = JSON.parse(fs.readFileSync("config.json"));
var defcfg = {
	autoRejoin: false,
	channels: [],
	messageSplit: 300,
};
config.__proto__ = defcfg;

var bot = new irc.Client(config.server, config.nick, config);

bot.conn.setTimeout(180 * 1000);
bot.conn.on("timeout", function() {
	bot.conn.destroy();
	//bot.connect();
});

bot.on("error", function(message) {
	console.log(message);
});

bot.on("registered", function(message) {
	bot.send("UMODE2", "+B");
});

bot.plugins = require("./plugins");

fs.readFile("autoload.json", function(err, data) {
	var autoload = JSON.parse(data).autoload;
	for (var i = 0; i < autoload.length; i++) {
		console.log(autoload[i]);
		bot.plugins.load(autoload[i]);
	}
});

if (config.saveinterval) {
	bot.saver = setInterval(function() {
		for (var name in bot.plugins) {
			if (bot.plugins[name].name) {
				bot.plugins.save(name);
			}
		}
	}, config.saveinterval * 60 * 1000);
}

process.on("SIGINT", function() {
	for (var name in bot.plugins) {
		if (bot.plugins[name].name) {
			bot.plugins.unload(name);
		}
	}
	process.exit(0);
});

process.on("uncaughtException", function(e) {
	console.trace("ERROR process uncaught: " + e);
});

repl.start({
	useGlobal: true
}).context.bot = bot;


@@ -70,16 +70,48 @@
 e(%22fs%22);
+%0Avar clc = require(%22cli-color%22);
 %0A%0Avar co
@@ -323,16 +323,30 @@
 config);
+%0Abot.out = %7B%7D;
 %0A%0Abot.co
@@ -372,16 +372,693 @@
  1000);%0A
+bot.out.log = function(module, message) %7B%0A%09var c = clc.cyan;%0A%09console.log(c(%22%5BLOG:%22) + c.bold(module) + c(%22%5D %22) + message);%0A%7D;%0A%0Abot.out.ok = function(module, message) %7B%0A%09var c = clc.greenBright;%0A%09console.log(c(%22%5BOK:%22) + c.bold(module) + c(%22%5D %22) + message);%0A%7D;%0A%0Abot.out.debug = function(module, message) %7B%0A%09var c = clc.magentaBright;%0A%09console.log(c(%22%5BDEBUG:%22) + c.bold(module) + c(%22%5D %22) + message);%0A%7D;%0A%0Abot.out.warn = function(module, message) %7B%0A%09var c = clc.yellowBright;%0A%09console.log(c(%22%5BWARN:%22) + c.bold(module) + c(%22%5D %22) + message);%0A%7D;%0A%0Abot.out.error = function(module, message) %7B%0A%09var c = clc.redBright;%0A%09console.log(c(%22%5BERROR:%22) + c.bold(module) + c(%22%5D %22) + message);%0A%7D;%0A%0A
 bot.conn

Add nice colored terminal output