From 22704a21583a5bb8b4062f62ec9ea94c8c542225 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 30 Apr 2013 17:19:23 +0000 Subject: [PATCH] move dbot.cleanNick to quotes.internalAPI.cleanRef [#270] --- modules/quotes/quotes.js | 10 +++++++++- run.js | 11 ----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/modules/quotes/quotes.js b/modules/quotes/quotes.js index 1d0b842..0bc18c3 100644 --- a/modules/quotes/quotes.js +++ b/modules/quotes/quotes.js @@ -13,7 +13,7 @@ var quotes = function(dbot) { 'interpolatedQuote': function(server, channel, key, quote, callback) { var quoteRefs = quote.match(/~~([\d\w\s-]*)~~/g); if(quoteRefs) { - var ref = dbot.cleanNick(quoteRefs[0].replace(/^~~/,'').replace(/~~$/,'').trim()); + var ref = this.internalAPI.cleanRef(quoteRefs[0].replace(/^~~/,'').replace(/~~$/,'').trim()); if(ref === '-nicks-') { dbot.api.users.getRandomChannelUser(server, channel, function(user) { quote = quote.replace('~~' + ref + '~~', randomNick); @@ -33,6 +33,14 @@ var quotes = function(dbot) { } }.bind(this), + 'cleanRef': function(key) { + key = key.toLowerCase(); + while(key.endsWith("_")) { + key = key.substring(0, key.length-1); + } + return key; + }, + 'resetRemoveTimer': function(event, key, quote) { this.rmAllowed = false; setTimeout(function() { diff --git a/run.js b/run.js index 2af040c..ced9144 100644 --- a/run.js +++ b/run.js @@ -315,15 +315,4 @@ DBot.prototype.reloadModules = function() { this.save(); }; -DBot.prototype.cleanNick = function(key) { - key = key.toLowerCase(); - while(key.endsWith("_")) { - if(_.has(this.db.quoteArrs, key)) { - return key; - } - key = key.substring(0, key.length-1); - } - return key; -} - new DBot();