mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
parent
aa4a8b8527
commit
4555e12eaa
@ -188,7 +188,7 @@ var commands = function(dbot) {
|
||||
|
||||
'~rq': function(event) {
|
||||
var category = _.keys(quotes)[_.random(0, _.size(quotes) -1)];
|
||||
event.reply(category + ': ' + this.internalAPI.interpolatedQuote(event, category));
|
||||
event.reply(category + ': ' + this.internalAPI.interpolatedQuote(event.server, event.channel.name, category));
|
||||
},
|
||||
|
||||
'~link': function(event) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"dbKeys": [ "quoteArrs" ],
|
||||
"dependencies": [ "command" ],
|
||||
"dependencies": [ "command", "users" ],
|
||||
"rmLimit": 10,
|
||||
"ignorable": true,
|
||||
"help": "http://github.com/reality/depressionbot/blob/master/modules/quotes/README.md"
|
||||
|
@ -11,7 +11,7 @@ var quotes = function(dbot) {
|
||||
this.internalAPI = {
|
||||
// Retrieve a random quote from a given category, interpolating any quote
|
||||
// references (~~QUOTE CATEGORY~~) within it
|
||||
'interpolatedQuote': function(event, key, quoteTree) {
|
||||
'interpolatedQuote': function(server, channel, key, quoteTree) {
|
||||
if(!_.isUndefined(quoteTree) && quoteTree.indexOf(key) != -1) {
|
||||
return '';
|
||||
} else if(_.isUndefined(quoteTree)) {
|
||||
@ -28,13 +28,13 @@ var quotes = function(dbot) {
|
||||
while(quoteRefs && (thisRef = quoteRefs.shift()) !== undefined) {
|
||||
var cleanRef = dbot.cleanNick(thisRef.replace(/^~~/,'').replace(/~~$/,'').trim());
|
||||
if(cleanRef === '-nicks-') {
|
||||
var randomNick = _.keys(event.channel.nicks)[_.random(0, _.size(event.channel.nicks) -1)];
|
||||
var randomNick = dbot.api.users.getRandomChannelUser(server, channel);
|
||||
quoteString = quoteString.replace("~~" + cleanRef + "~~", randomNick);
|
||||
quoteTree.pop();
|
||||
} else if(_.has(this.quotes, cleanRef)) {
|
||||
quoteTree.push(key);
|
||||
quoteString = quoteString.replace("~~" + cleanRef + "~~",
|
||||
interpolatedQuote(event, cleanRef, quoteTree.slice()));
|
||||
this.internalAPI.interpolatedQuote(server, channel, cleanRef, quoteTree.slice()));
|
||||
quoteTree.pop();
|
||||
}
|
||||
}
|
||||
@ -76,9 +76,9 @@ var quotes = function(dbot) {
|
||||
|
||||
if(key.charAt(0) !== '_') { // lol
|
||||
if(_.has(this.quotes, key)) {
|
||||
return this.internalAPI.interpolatedQuote(event, key);
|
||||
return this.internalAPI.interpolatedQuote(event.server, event.channel.name, key);
|
||||
} else if(_.has(this.quotes, altKey)) {
|
||||
return this.internalAPI.interpolatedQuote(event, altKey);
|
||||
return this.internalAPI.interpolatedQuote(event.server, event.channel.name, altKey);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user