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.

61 lines
1.7 KiB

12 years ago
12 years ago
  1. var file = require('fs');
  2. //create logs directory
  3. file.exists('./../logs', function (exists) {
  4. if (!exists) {
  5. file.mkdir('./../logs');
  6. }
  7. });
  8. process.on('uncaughtException', function(err) {
  9. file.appendFile('./../logs/error-log.txt', err.message + '\r\n' + err.stack + '\r\n', function() {});
  10. });
  11. exports.initialize = function(options) {
  12. var config = options || {}, db, irc, commands, dashboard, currency;
  13. //-------- Setup -------
  14. irc = require('./irc.js')({
  15. name : config.twitch.bot.name,
  16. pass : config.twitch.bot.password,
  17. channel : '#' + config.twitch.channel
  18. });
  19. db = require('./mysql.js')({
  20. host : config.currency.host,
  21. user : config.currency.user,
  22. password : config.currency.password,
  23. database : config.currency.database
  24. });
  25. commands = require('./commands.js')(irc, db, {
  26. bot_name : config.twitch.bot.name,
  27. currency : config.currency.name
  28. });
  29. currency = require('./currency.js')(irc, db, {
  30. currency : config.currency.name,
  31. payrate : config.currency.payrate,
  32. subscribers : config.twitch.subscribers,
  33. website : config.currency.website,
  34. modpowers : config.currency.modpowers,
  35. chatterbonus: config.currency.chatterbonus
  36. });
  37. //-------- Start -------
  38. irc.start();
  39. db.start();
  40. currency.start();
  41. if (config.commands === true) commands.start();
  42. irc.on('data', function (data) {
  43. console.log(data);
  44. irc.realtime(data);
  45. });
  46. irc.on('command', function (data) {
  47. currency.commands(data);
  48. if (config.commands === true) commands.commands(data);
  49. });
  50. irc.on('message', function (msg) {
  51. irc.queue(msg);
  52. });
  53. };