forked from GitHub/dbot
		
	Fixed quotes
This commit is contained in:
		
							parent
							
								
									b09a962aa0
								
							
						
					
					
						commit
						9001cfefcf
					
				
							
								
								
									
										21
									
								
								run.js
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								run.js
									
									
									
									
									
								
							| @ -63,20 +63,17 @@ 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, quoteTree) { | ||||
|     if( quoteTree !== undefined && quoteTree.indexOf( key ) != -1 ) return '';  | ||||
|     if( quoteTree !== undefined && quoteTree.indexOf( key ) != -1 ) { console.log('nrll'); return ''; } | ||||
|     else if( quoteTree === undefined ) quoteTree = []; | ||||
|     var quoteString = this.db.quoteArrs[key].random(); | ||||
|     var quoteRefs; | ||||
|     while( (quoteRefs = quoteString.match(/~~([\d\w\s-]*)~~/)) ) { | ||||
|         quoteRefs = quoteRefs.slice(1); | ||||
|         for(var i=0;i<quoteRefs.length;i++) { | ||||
|             var cleanRef = this.cleanNick(quoteRefs[i].trim()); | ||||
|             if (this.db.quoteArrs.hasOwnProperty(cleanRef)) { | ||||
| 		quoteTree.push( cleanRef ); | ||||
| 		console.log( "Tree: " + quoteTree, "clean: " + cleanRef ); | ||||
|                 quoteString = quoteString.replace("~~"+cleanRef+"~~", this.interpolatedQuote(cleanRef, quoteTree.slice())); | ||||
| 		quoteTree.pop(); | ||||
|             } | ||||
|     var quoteRefs = quoteString.match(/~~([\d\w\s-]*)~~/g); | ||||
|     var thisRef; | ||||
|     while( quoteRefs && (thisRef = quoteRefs.shift()) !== undefined ) { | ||||
|         var cleanRef = this.cleanNick(thisRef.replace(/^~~/,'').replace(/~~$/,'').trim()); | ||||
|         if (this.db.quoteArrs.hasOwnProperty(cleanRef)) { | ||||
|             quoteTree.push( key ); | ||||
|             quoteString = quoteString.replace("~~"+cleanRef+"~~", this.interpolatedQuote(cleanRef, quoteTree.slice())); | ||||
|             quoteTree.pop(); | ||||
|         } | ||||
|     } | ||||
|     return quoteString; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Daniel Evans
						Daniel Evans