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.
76 lines
2.2 KiB
76 lines
2.2 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,
|
|
chatlog : config.web.chatlog
|
|
});
|
|
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,
|
|
exchange : config.exchanges,
|
|
currency : config.currency.name
|
|
});
|
|
currency = require('./currency.js')(irc, db, commands, {
|
|
currency : config.currency.name,
|
|
payrate : config.currency.payrate,
|
|
subscribers : config.twitch.subscribers,
|
|
website : config.currency.website,
|
|
modpowers : config.currency.modpowers,
|
|
ignorelist : config.ignorelist,
|
|
exchanges : config.exchanges,
|
|
sub_ty_msg : config.currency.sub_ty_msg
|
|
});
|
|
web = require('./web.js')(db, currency, {
|
|
port : config.web.port,
|
|
title : config.twitch.channel,
|
|
currency : config.currency.name,
|
|
logo : config.web.logo,
|
|
twitter : config.web.twitter,
|
|
fanart : config.web.fanart,
|
|
statdir : config.twitch.channel
|
|
});
|
|
|
|
//-------- 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);
|
|
});
|
|
|
|
};
|