mirror of
https://github.com/reality/dbot.git
synced 2024-11-24 04:49:25 +01:00
user interpolation for quotes
This commit is contained in:
parent
7303fd6a01
commit
553d3afccc
@ -11,7 +11,7 @@ var quotes = function(dbot) {
|
|||||||
this.internalAPI = {
|
this.internalAPI = {
|
||||||
// Retrieve a random quote from a given category, interpolating any quote
|
// Retrieve a random quote from a given category, interpolating any quote
|
||||||
// references (~~QUOTE CATEGORY~~) within it
|
// references (~~QUOTE CATEGORY~~) within it
|
||||||
'interpolatedQuote': function(server, channel, key, quoteTree) {
|
'interpolatedQuote': function(server, channel, user, key, quoteTree) {
|
||||||
if(!_.isUndefined(quoteTree) && quoteTree.indexOf(key) != -1) {
|
if(!_.isUndefined(quoteTree) && quoteTree.indexOf(key) != -1) {
|
||||||
return '';
|
return '';
|
||||||
} else if(_.isUndefined(quoteTree)) {
|
} else if(_.isUndefined(quoteTree)) {
|
||||||
@ -31,10 +31,13 @@ var quotes = function(dbot) {
|
|||||||
var randomNick = dbot.api.users.getRandomChannelUser(server, channel);
|
var randomNick = dbot.api.users.getRandomChannelUser(server, channel);
|
||||||
quoteString = quoteString.replace("~~" + cleanRef + "~~", randomNick);
|
quoteString = quoteString.replace("~~" + cleanRef + "~~", randomNick);
|
||||||
quoteTree.pop();
|
quoteTree.pop();
|
||||||
|
} else if(cleanRef === '-user-') {
|
||||||
|
quoteString = quoteString.replace("~~" + cleanRef + "~~", user);
|
||||||
|
quoteTree.pop();
|
||||||
} else if(_.has(this.quotes, cleanRef)) {
|
} else if(_.has(this.quotes, cleanRef)) {
|
||||||
quoteTree.push(key);
|
quoteTree.push(key);
|
||||||
quoteString = quoteString.replace("~~" + cleanRef + "~~",
|
quoteString = quoteString.replace("~~" + cleanRef + "~~",
|
||||||
this.internalAPI.interpolatedQuote(server, channel, cleanRef, quoteTree.slice()));
|
this.internalAPI.interpolatedQuote(server, channel, user, cleanRef, quoteTree.slice()));
|
||||||
quoteTree.pop();
|
quoteTree.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,9 +79,9 @@ var quotes = function(dbot) {
|
|||||||
|
|
||||||
if(key.charAt(0) !== '_') { // lol
|
if(key.charAt(0) !== '_') { // lol
|
||||||
if(_.has(this.quotes, key)) {
|
if(_.has(this.quotes, key)) {
|
||||||
return this.internalAPI.interpolatedQuote(event.server, event.channel.name, key);
|
return this.internalAPI.interpolatedQuote(event.server, event.channel.name, event.user, key);
|
||||||
} else if(_.has(this.quotes, altKey)) {
|
} else if(_.has(this.quotes, altKey)) {
|
||||||
return this.internalAPI.interpolatedQuote(event.server, event.channel.name, altKey);
|
return this.internalAPI.interpolatedQuote(event.server, event.channel.name, event.user, altKey);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user