From b1c41008ce64d15e05e441b0cabb794c7d779a19 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 31 Aug 2013 22:57:29 +0000 Subject: [PATCH] ~~-nick-~~ --- modules/command/command.js | 3 ++- modules/quotes/commands.js | 3 ++- modules/quotes/quotes.js | 20 ++++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/modules/command/command.js b/modules/command/command.js index c72430c..35c7347 100644 --- a/modules/command/command.js +++ b/modules/command/command.js @@ -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')) { diff --git a/modules/quotes/commands.js b/modules/quotes/commands.js index 81d2043..0728426 100644 --- a/modules/quotes/commands.js +++ b/modules/quotes/commands.js @@ -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 { diff --git a/modules/quotes/quotes.js b/modules/quotes/quotes.js index 8232888..3c325d4 100644 --- a/modules/quotes/quotes.js +++ b/modules/quotes/quotes.js @@ -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); }