From 372c03f6aff451ddc0e1b0b9df1a76bba8f25025 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Wed, 9 Nov 2011 21:54:16 +0000 Subject: [PATCH 1/2] Now uses an external configuration file. --- run.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/run.js b/run.js index 70c25d3..41103ec 100644 --- a/run.js +++ b/run.js @@ -6,18 +6,21 @@ require('./snippets'); var modules = ['spelling', 'web', 'modehate', 'user', 'admin', 'puns', 'kick', 'karma', 'youare', 'quotes']; var DBot = function(dModules, timers) { - this.admin = 'reality'; - this.name = 'depressionbot'; - + this.config = JSON.parse(fs.readFileSync('config.json', 'utf-8')); this.db = JSON.parse(fs.readFileSync('db.json', 'utf-8')); - this.timers = timers.create(); + this.admin = this.config.admin || 'reality'; + this.name = this.config.name || 'depressionbot'; + + this.timers = timers.create(); this.waitingForKarma = false; this.instance = jsbot.createJSBot(this.name, 'elara.ivixor.net', 6667, this, function() { - this.instance.join('#42'); - this.instance.join('#not42'); - this.instance.join('#itonlygetsworse'); + if(this.config.hasOwnProperty('channels')) { + for(channel in this.config.channels) { + this.instance.join(channel); + } + } }.bind(this)); this.moduleNames = dModules; From 5e039c814aa7e4d4fe0e2e7be0232c581f87640d Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Wed, 9 Nov 2011 22:06:22 +0000 Subject: [PATCH 2/2] different join --- run.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.js b/run.js index 41103ec..109701c 100644 --- a/run.js +++ b/run.js @@ -17,9 +17,9 @@ var DBot = function(dModules, timers) { this.instance = jsbot.createJSBot(this.name, 'elara.ivixor.net', 6667, this, function() { if(this.config.hasOwnProperty('channels')) { - for(channel in this.config.channels) { + this.config.channels.each(function(channel) { this.instance.join(channel); - } + }.bind(this)); } }.bind(this));