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.

72 lines
2.0 KiB

12 years ago
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. chatlog : config.web.chatlog
  19. });
  20. db = require('./mysql.js')({
  21. host : config.currency.host,
  22. user : config.currency.user,
  23. password : config.currency.password,
  24. database : config.currency.database
  25. });
  26. commands = require('./commands.js')(irc, db, {
  27. bot_name : config.twitch.bot.name,
  28. currency : config.currency.name
  29. });
  30. currency = require('./currency.js')(irc, db, {
  31. currency : config.currency.name,
  32. payrate : config.currency.payrate,
  33. subscribers : config.twitch.subscribers,
  34. website : config.currency.website,
  35. modpowers : config.currency.modpowers,
  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. statdir : config.web.statdir
  45. });
  46. //-------- Start -------
  47. irc.start();
  48. db.start();
  49. web.start();
  50. currency.start();
  51. if (config.commands === true) commands.start();
  52. irc.on('data', function (data) {
  53. console.log(data);
  54. irc.realtime(data);
  55. });
  56. irc.on('command', function (data) {
  57. currency.commands(data);
  58. if (config.commands === true) commands.commands(data);
  59. });
  60. irc.on('message', function (msg) {
  61. irc.queue(msg);
  62. });
  63. };