From b09a962aa0353f4890e91f0eb98cf9b0a52baca9 Mon Sep 17 00:00:00 2001 From: Daniel Evans Date: Mon, 12 Mar 2012 21:29:29 +0000 Subject: [PATCH] Made interpolateQuote recursive --- run.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/run.js b/run.js index 8401192..609b825 100644 --- a/run.js +++ b/run.js @@ -62,7 +62,9 @@ var DBot = function(timers) { }; // Retrieve a random quote from a given category, interpolating any quote references (~~QUOTE CATEGORY~~) within it -DBot.prototype.interpolatedQuote = function(key) { +DBot.prototype.interpolatedQuote = function(key, quoteTree) { + if( quoteTree !== undefined && quoteTree.indexOf( key ) != -1 ) return ''; + else if( quoteTree === undefined ) quoteTree = []; var quoteString = this.db.quoteArrs[key].random(); var quoteRefs; while( (quoteRefs = quoteString.match(/~~([\d\w\s-]*)~~/)) ) { @@ -70,7 +72,10 @@ DBot.prototype.interpolatedQuote = function(key) { for(var i=0;i