forked from GitHub/dbot
~~-nick-~~
This commit is contained in:
parent
306b28bf93
commit
b1c41008ce
@ -18,7 +18,8 @@ var command = function(dbot) {
|
||||
if(!_.has(dbot.commands, commandName)) {
|
||||
if(_.has(dbot.modules, 'quotes')) {
|
||||
var key = event.message.substring(1);
|
||||
dbot.api.quotes.getInterpolatedQuote(event.server, event.channel.name, key, function(quote) {
|
||||
dbot.api.quotes.getInterpolatedQuote(event.server,
|
||||
event.channel.name, event.user, key, function(quote) {
|
||||
if(quote) {
|
||||
event.reply(key + ': ' + quote);
|
||||
} else if(_.has(dbot.modules, 'spelling')) {
|
||||
|
@ -34,7 +34,8 @@ var commands = function(dbot) {
|
||||
// Retrieve quote from a category in the database.
|
||||
'~q': function(event) {
|
||||
var key = event.input[1];
|
||||
this.api.getInterpolatedQuote(event.server, event.channel, key, function(quote) {
|
||||
this.api.getInterpolatedQuote(event.server, event.channel,
|
||||
event.user, key, function(quote) {
|
||||
if(quote) {
|
||||
event.reply(key + ': ' + quote);
|
||||
} else {
|
||||
|
@ -10,23 +10,29 @@ var quotes = function(dbot) {
|
||||
|
||||
this.internalAPI = {
|
||||
// Parse quote interpolations
|
||||
'interpolatedQuote': function(server, channel, key, quote, callback) {
|
||||
'interpolatedQuote': function(server, channel, username, key, quote, callback) {
|
||||
console.log(quote);
|
||||
var quoteRefs = quote.match(/~~([\d\w\s-]*)~~/g);
|
||||
if(quoteRefs) {
|
||||
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 + '~~', user.currentNick);
|
||||
this.internalAPI.interpolatedQuote(server, channel, key, quote, callback);
|
||||
this.internalAPI.interpolatedQuote(server, channel,
|
||||
username, key, quote, callback);
|
||||
}.bind(this));
|
||||
} else if(ref === '-nick-') {
|
||||
quote = quote.replace('~~' + ref + '~~', username);
|
||||
this.internalAPI.interpolatedQuote(server, channel,
|
||||
username, key, quote, callback);
|
||||
} else {
|
||||
this.api.getQuote(ref, function(interQuote) {
|
||||
if(!interQuote || ref == key) {
|
||||
interQuote = '';
|
||||
}
|
||||
quote = quote.replace('~~' + ref + '~~', interQuote);
|
||||
console.log('lol');
|
||||
this.internalAPI.interpolatedQuote(server, channel, key, quote, callback);
|
||||
this.internalAPI.interpolatedQuote(server, channel,
|
||||
username, key, quote, callback);
|
||||
}.bind(this));
|
||||
}
|
||||
} else {
|
||||
@ -110,12 +116,14 @@ var quotes = function(dbot) {
|
||||
});
|
||||
},
|
||||
|
||||
'getInterpolatedQuote': function(server, channel, key, callback) {
|
||||
'getInterpolatedQuote': function(server, channel, username, key, callback) {
|
||||
console.log(key);
|
||||
key = key.trim().toLowerCase(),
|
||||
|
||||
this.api.getQuote(key, function(quote) {
|
||||
if(quote) {
|
||||
this.internalAPI.interpolatedQuote(server, channel, key, quote, callback);
|
||||
this.internalAPI.interpolatedQuote(server, channel,
|
||||
username, key, quote, callback);
|
||||
} else {
|
||||
callback(quote);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user