3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-25 04:02:39 +01:00

move dbot.cleanNick to quotes.internalAPI.cleanRef [#270]

This commit is contained in:
reality 2013-04-30 17:19:23 +00:00
parent b08e12560f
commit 22704a2158
2 changed files with 9 additions and 12 deletions

View File

@ -13,7 +13,7 @@ var quotes = function(dbot) {
'interpolatedQuote': function(server, channel, key, quote, callback) { 'interpolatedQuote': function(server, channel, key, quote, callback) {
var quoteRefs = quote.match(/~~([\d\w\s-]*)~~/g); var quoteRefs = quote.match(/~~([\d\w\s-]*)~~/g);
if(quoteRefs) { if(quoteRefs) {
var ref = dbot.cleanNick(quoteRefs[0].replace(/^~~/,'').replace(/~~$/,'').trim()); var ref = this.internalAPI.cleanRef(quoteRefs[0].replace(/^~~/,'').replace(/~~$/,'').trim());
if(ref === '-nicks-') { if(ref === '-nicks-') {
dbot.api.users.getRandomChannelUser(server, channel, function(user) { dbot.api.users.getRandomChannelUser(server, channel, function(user) {
quote = quote.replace('~~' + ref + '~~', randomNick); quote = quote.replace('~~' + ref + '~~', randomNick);
@ -33,6 +33,14 @@ var quotes = function(dbot) {
} }
}.bind(this), }.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) { 'resetRemoveTimer': function(event, key, quote) {
this.rmAllowed = false; this.rmAllowed = false;
setTimeout(function() { setTimeout(function() {

11
run.js
View File

@ -315,15 +315,4 @@ DBot.prototype.reloadModules = function() {
this.save(); 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(); new DBot();