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.

71 lines
2.0 KiB

12 years ago
12 years ago
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. ignorelist : config.ignorelist
  37. });
  38. web = require('./web.js')(db, {
  39. port : config.web.port,
  40. title : config.twitch.channel,
  41. slogan : config.web.slogan,
  42. logo : config.web.logo,
  43. twitter : config.web.twitter
  44. });
  45. //-------- Start -------
  46. irc.start();
  47. db.start();
  48. web.start();
  49. currency.start();
  50. if (config.commands === true) commands.start();
  51. irc.on('data', function (data) {
  52. console.log(data);
  53. irc.realtime(data);
  54. });
  55. irc.on('command', function (data) {
  56. currency.commands(data);
  57. if (config.commands === true) commands.commands(data);
  58. });
  59. irc.on('message', function (msg) {
  60. irc.queue(msg);
  61. });
  62. };