a simple irc relay written in node.js
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.

bot.coffee 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. _ = require("./utils")
  2. fs = require("fs")
  3. settings = JSON.parse(fs.readFileSync("#{__dirname}/data/settings.json", "ascii"))
  4. Modules = require('./modules')
  5. {app, start_webserver} = require("./web/app")
  6. users = require("./model")
  7. modules = new Modules(users, settings, app)
  8. create_bot = require('./create_bot')
  9. users.on 'load', ->
  10. bot = create_bot(settings)
  11. _(users.listeners).each (l) -> bot.on l.type, l.listener
  12. modules.initialize(bot, app)
  13. start_webserver(settings.port)
  14. bot.on "error", (message) ->
  15. console.error "ERROR: #{settings["server"]} : #{message.command} : #{message.args.join(' ')}"
  16. bot.conn.setTimeout 180000, ->
  17. console.log "timeout"
  18. bot.conn.end()
  19. process.exit()
  20. # web = webserver(users, nick, settings["port"], ircToText, (from, message) ->
  21. # channel_say from + message
  22. # detectCommand from, message
  23. # )
  24. # exit_conditions = ['SIGHUP', 'SIGQUIT', 'SIGKILL', 'SIGINT', 'SIGTERM']
  25. exit_conditions = ["SIGHUP", "SIGQUIT", "SIGINT", "SIGTERM"]
  26. exit_conditions.push "uncaughtException" if settings["catch_all_exceptions"]
  27. _(exit_conditions).each (condition) ->
  28. process.on condition, (err) ->
  29. console.log condition, err
  30. process.exit()