diff --git a/modules/quotes/commands.js b/modules/quotes/commands.js index fe3fc3e..e8205c7 100644 --- a/modules/quotes/commands.js +++ b/modules/quotes/commands.js @@ -12,11 +12,15 @@ var commands = function(dbot) { quote = event.input[2]; this.api.addQuote(key, quote, event.user, function(newCount) { - dbot.api.event.emit('~qadd', [ key, quote ]); - event.reply(dbot.t('quote_saved', { - 'category': key, - 'count': newCount - })); + if(newCount) { + dbot.api.event.emit('~qadd', [ key, quote ]); + event.reply(dbot.t('quote_saved', { + 'category': key, + 'count': newCount + })); + } else { + event.reply(dbot.t('quote_exists')); + } }); }, diff --git a/modules/quotes/quotes.js b/modules/quotes/quotes.js index e61ca15..36287f1 100644 --- a/modules/quotes/quotes.js +++ b/modules/quotes/quotes.js @@ -76,11 +76,15 @@ var quotes = function(dbot) { }; } - newCount = category.quotes.push(quote); - this.db.save('quote_category', category.id, category, function(err) { - this.rmAllowed = true; - callback(newCount); - }.bind(this)); + if(_.include(category.quotes, quote)) { + callback(false); + } else { + newCount = category.quotes.push(quote); + this.db.save('quote_category', category.id, category, function(err) { + this.rmAllowed = true; + callback(newCount); + }.bind(this)); + } }.bind(this)); },