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) {
|
'~rq': function(event) {
|
||||||
var category = _.keys(quotes)[_.random(0, _.size(quotes) -1)];
|
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) {
|
'~link': function(event) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"dbKeys": [ "quoteArrs" ],
|
"dbKeys": [ "quoteArrs" ],
|
||||||
"dependencies": [ "command" ],
|
"dependencies": [ "command", "users" ],
|
||||||
"rmLimit": 10,
|
"rmLimit": 10,
|
||||||
"ignorable": true,
|
"ignorable": true,
|
||||||
"help": "http://github.com/reality/depressionbot/blob/master/modules/quotes/README.md"
|
"help": "http://github.com/reality/depressionbot/blob/master/modules/quotes/README.md"
|
||||||
|
@ -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(event, key, quoteTree) {
|
'interpolatedQuote': function(server, channel, 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)) {
|
||||||
@ -28,13 +28,13 @@ var quotes = function(dbot) {
|
|||||||
while(quoteRefs && (thisRef = quoteRefs.shift()) !== undefined) {
|
while(quoteRefs && (thisRef = quoteRefs.shift()) !== undefined) {
|
||||||
var cleanRef = dbot.cleanNick(thisRef.replace(/^~~/,'').replace(/~~$/,'').trim());
|
var cleanRef = dbot.cleanNick(thisRef.replace(/^~~/,'').replace(/~~$/,'').trim());
|
||||||
if(cleanRef === '-nicks-') {
|
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);
|
quoteString = quoteString.replace("~~" + cleanRef + "~~", randomNick);
|
||||||
quoteTree.pop();
|
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 + "~~",
|
||||||
interpolatedQuote(event, cleanRef, quoteTree.slice()));
|
this.internalAPI.interpolatedQuote(server, channel, cleanRef, quoteTree.slice()));
|
||||||
quoteTree.pop();
|
quoteTree.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,9 +76,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, key);
|
return this.internalAPI.interpolatedQuote(event.server, event.channel.name, key);
|
||||||
} else if(_.has(this.quotes, altKey)) {
|
} else if(_.has(this.quotes, altKey)) {
|
||||||
return this.internalAPI.interpolatedQuote(event, altKey);
|
return this.internalAPI.interpolatedQuote(event.server, event.channel.name, altKey);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user