diff --git a/config.js b/config.js index 5f486c2c..bf0043f1 100644 --- a/config.js +++ b/config.js @@ -1,7 +1,7 @@ module.exports = { public: true, host: "0.0.0.0", - port: 9090, + port: 9000, theme: "themes/example.css", home: "", debug: false diff --git a/src/client.js b/src/client.js index 7734fc26..fd7fe6d0 100644 --- a/src/client.js +++ b/src/client.js @@ -54,15 +54,12 @@ function Client(sockets, config) { }); if (config) { var client = this; - var wait_total = 0; - _.each(config.networks || [], function(n) { - if (wait_total == 0) + var delay = 0; + (config.networks || []).forEach(function(n) { + setTimeout(function() { client.connect(n); - else - setTimeout(function() { - client.connect(n); - }, wait_total); - wait_total += 500; + }, delay); + delay += 1000; }); } } @@ -96,11 +93,12 @@ Client.prototype.find = function(id) { Client.prototype.connect = function(args) { var client = this; - var server = _.defaults(_.pick(args, ['host', 'port', 'rejectUnauthorized', 'name']), { - host: "irc.freenode.org", - port: args.tls ? 6697 : 6667, + var server = { + host: args.host || "irc.freenode.org", + port: args.port || (args.tls ? 6697 : 6667), + name: args.name || "", rejectUnauthorized: false - }); + }; var stream = args.tls ? tls.connect(server) : net.connect(server); stream.on("error", function(e) { diff --git a/src/helper.js b/src/helper.js index 85e1603d..d616592b 100644 --- a/src/helper.js +++ b/src/helper.js @@ -1,22 +1,22 @@ var path = require("path"); var Helper = module.exports = { - getConfig: function () { - return require(path.resolve(__dirname, "..", "config")); - }, + getConfig: function () { + return require(path.resolve(__dirname, "..", "config")); + }, - getHomeDirectory: function () { - return ( - this.getConfig().home || - process.env.SHOUT_HOME || - path.resolve(process.env.HOME, ".shout") - ); - }, + getHomeDirectory: function () { + return ( + this.getConfig().home + || process.env.SHOUT_HOME + || path.resolve(process.env.HOME, ".shout") + ); + }, - resolveHomePath: function () { - var fragments = [ Helper.HOME ].concat([].slice.apply(arguments)); - return path.resolve.apply(path, fragments); - } + resolveHomePath: function () { + var fragments = [ Helper.HOME ].concat([].slice.apply(arguments)); + return path.resolve.apply(path, fragments); + } }; Helper.HOME = Helper.getHomeDirectory()