A Twitch.tv viewer reward and games system.
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.
 
 
 

59 lines
1.6 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
});
//-------- Start -------
irc.start();
db.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);
});
};