Refactoring

This commit is contained in:
Mattias Erming 2014-09-13 10:10:32 -07:00
parent 221ed4b980
commit b3b36282aa
3 changed files with 25 additions and 27 deletions

View file

@ -1,7 +1,7 @@
module.exports = { module.exports = {
public: true, public: true,
host: "0.0.0.0", host: "0.0.0.0",
port: 9090, port: 9000,
theme: "themes/example.css", theme: "themes/example.css",
home: "", home: "",
debug: false debug: false

View file

@ -54,15 +54,12 @@ function Client(sockets, config) {
}); });
if (config) { if (config) {
var client = this; var client = this;
var wait_total = 0; var delay = 0;
_.each(config.networks || [], function(n) { (config.networks || []).forEach(function(n) {
if (wait_total == 0)
client.connect(n);
else
setTimeout(function() { setTimeout(function() {
client.connect(n); client.connect(n);
}, wait_total); }, delay);
wait_total += 500; delay += 1000;
}); });
} }
} }
@ -96,11 +93,12 @@ Client.prototype.find = function(id) {
Client.prototype.connect = function(args) { Client.prototype.connect = function(args) {
var client = this; var client = this;
var server = _.defaults(_.pick(args, ['host', 'port', 'rejectUnauthorized', 'name']), { var server = {
host: "irc.freenode.org", host: args.host || "irc.freenode.org",
port: args.tls ? 6697 : 6667, port: args.port || (args.tls ? 6697 : 6667),
name: args.name || "",
rejectUnauthorized: false rejectUnauthorized: false
}); };
var stream = args.tls ? tls.connect(server) : net.connect(server); var stream = args.tls ? tls.connect(server) : net.connect(server);
stream.on("error", function(e) { stream.on("error", function(e) {

View file

@ -7,9 +7,9 @@ var Helper = module.exports = {
getHomeDirectory: function () { getHomeDirectory: function () {
return ( return (
this.getConfig().home || this.getConfig().home
process.env.SHOUT_HOME || || process.env.SHOUT_HOME
path.resolve(process.env.HOME, ".shout") || path.resolve(process.env.HOME, ".shout")
); );
}, },