3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-30 16:09:27 +01:00

Added ~link command. Links to the quote list page for that category.

This commit is contained in:
Samuel Clements 2011-11-08 13:42:22 +00:00
parent 23653665c2
commit bb0af1951e

View File

@ -93,13 +93,18 @@ var quotes = function(dbot) {
q[1] = q[1].toLowerCase(); q[1] = q[1].toLowerCase();
if(!Object.isArray(quotes[q[1]])) { if(!Object.isArray(quotes[q[1]])) {
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]); quotes[q[1]].push(q[2]);
addStack.push(q[1]); addStack.push(q[1]);
rmAllowed = true; rmAllowed = true;
dbot.say(data.channel, 'Quote saved in \'' + q[1] + '\' (' + quotes[q[1]].length + ')'); dbot.say(data.channel, 'Quote saved in \'' + q[1] + '\' (' + quotes[q[1]].length + ')');
} else { } 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) { '~d': function(data, params) {
dbot.say(data.channel, data.user + ': ' + dbot.db.quoteArrs['depressionbot'].random()); 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]);
}
} }
}; };