You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.0 KiB
71 lines
2.0 KiB
var file = require('fs');
|
|
|
|
//create logs directory
|
|
file.exists('./../logs', function (exists) {
|
|
if (!exists) {
|
|
file.mkdir('./../logs');
|
|
}
|
|
});
|
|
|
|
process.on('uncaughtException', function(err) {
|
|
file.appendFile('./../logs/error-log.txt', err.message + '\r\n' + err.stack + '\r\n', function() {});
|
|
});
|
|
|
|
exports.initialize = function(options) {
|
|
var config = options || {}, db, irc, commands, dashboard, currency;
|
|
|
|
//-------- Setup -------
|
|
irc = require('./irc.js')({
|
|
name : config.twitch.bot.name,
|
|
pass : config.twitch.bot.password,
|
|
channel : '#' + config.twitch.channel
|
|
});
|
|
db = require('./mysql.js')({
|
|
host : config.currency.host,
|
|
user : config.currency.user,
|
|
password : config.currency.password,
|
|
database : config.currency.database
|
|
});
|
|
commands = require('./commands.js')(irc, db, {
|
|
bot_name : config.twitch.bot.name,
|
|
currency : config.currency.name
|
|
});
|
|
currency = require('./currency.js')(irc, db, {
|
|
currency : config.currency.name,
|
|
payrate : config.currency.payrate,
|
|
subscribers : config.twitch.subscribers,
|
|
website : config.currency.website,
|
|
modpowers : config.currency.modpowers,
|
|
chatterbonus: config.currency.chatterbonus,
|
|
ignorelist : config.ignorelist
|
|
});
|
|
web = require('./web.js')(db, {
|
|
port : config.web.port,
|
|
title : config.twitch.channel,
|
|
slogan : config.web.slogan,
|
|
logo : config.web.logo,
|
|
twitter : config.web.twitter
|
|
});
|
|
|
|
//-------- Start -------
|
|
irc.start();
|
|
db.start();
|
|
web.start();
|
|
currency.start();
|
|
if (config.commands === true) commands.start();
|
|
|
|
irc.on('data', function (data) {
|
|
console.log(data);
|
|
irc.realtime(data);
|
|
});
|
|
|
|
irc.on('command', function (data) {
|
|
currency.commands(data);
|
|
if (config.commands === true) commands.commands(data);
|
|
});
|
|
|
|
irc.on('message', function (msg) {
|
|
irc.queue(msg);
|
|
});
|
|
|
|
};
|