From e68cf45e65c7d5358c9fd3dc29ff4d37a6ccbcfe Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 12 Jan 2013 10:38:40 +0000 Subject: [PATCH] Few tests and that --- run.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/run.js b/run.js index 22e7e0b..7f36b9b 100644 --- a/run.js +++ b/run.js @@ -1,6 +1,7 @@ -var fs = require('fs'); -var timers = require('./timer'); -var jsbot = require('./jsbot/jsbot'); +var fs = require('fs'), + _ = require('underscore')._, + timers = require('./timer'), + jsbot = require('./jsbot/jsbot'); require('./snippets'); var DBot = function(timers) { @@ -17,13 +18,13 @@ var DBot = function(timers) { process.exit(); } } - requiredConfigKeys.each(function(key) { - if(!this.config.hasOwnProperty(key)) { + _.each(requiredConfigKeys, function(key) { + if(!_.has(this.config, key)) { console.log('Error: Please set a value for ' + key + ' in ' + 'config.json. Stopping.'); process.exit(); } - }.bind(this)); + }, this); var rawDB; try { @@ -58,7 +59,7 @@ var DBot = function(timers) { // Create JSBot and connect to each server this.instance = jsbot.createJSBot(this.config.name); for(var name in this.config.servers) { - if(this.config.servers.hasOwnProperty(name)) { + if(_.has(this.config.servers, name)) { var server = this.config.servers[name]; this.instance.addConnection(name, server.server, server.port, this.config.admin, function(event) {