mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 03:33:07 +01:00
move dbot.cleanNick to quotes.internalAPI.cleanRef [#270]
This commit is contained in:
parent
b08e12560f
commit
22704a2158
@ -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() {
|
||||
|
11
run.js
11
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();
|
||||
|
Loading…
Reference in New Issue
Block a user