diff --git a/modules/quotes.js b/modules/quotes.js index 8d0061d..685df03 100644 --- a/modules/quotes.js +++ b/modules/quotes.js @@ -93,13 +93,18 @@ var quotes = function(dbot) { q[1] = q[1].toLowerCase(); if(!Object.isArray(quotes[q[1]])) { quotes[q[1]] = []; + } else { + if (q2 in quotes[q[1]]) { + dbot.say(data.channel, 'Quote already in DB. Initiate incineration.'); + return; + } } quotes[q[1]].push(q[2]); addStack.push(q[1]); rmAllowed = true; dbot.say(data.channel, 'Quote saved in \'' + q[1] + '\' (' + quotes[q[1]].length + ')'); } else { - dbot.say(data.channel, 'Invalid syntax, initiate incineration.'); + dbot.say(data.channel, 'Invalid syntax. Initiate incineration.'); } }, @@ -128,6 +133,14 @@ var quotes = function(dbot) { '~d': function(data, params) { dbot.say(data.channel, data.user + ': ' + dbot.db.quoteArrs['depressionbot'].random()); + }, + + '~link': function(data, params) { + if(params[1] === undefined || !quotes.hasOwnProperty(params[1])) { + dbot.say(data.channel, 'Syntax error. Commence incineration.'); + } else { + dbot.say(data.channel, 'Link to "'+params[1]+'" - http://nc.no.de:443/quotes/'+params[1]); + } } }; @@ -168,4 +181,4 @@ var quotes = function(dbot) { exports.fetch = function(dbot) { return quotes(dbot); -}; +}; \ No newline at end of file