3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 12:29:26 +01:00

Quote arrays. Perhaps needs a bit of cleaning up.

This commit is contained in:
Luke Slater 2011-08-17 17:02:38 +01:00
parent e56f287e1c
commit 6d5c6a5a78

20
run.js
View File

@ -110,6 +110,26 @@ instance.addListener('PRIVMSG', function(data) {
var q = data.message.match(/~q ([\d\w\s]*)/)[1].trim();
instance.say(data.channel, q + ': ' + db.quotes[q]);
break;
case '~qa':
var q = data.message.match(/~qa ([\d\w\s]*)/)[1].trim();
if(db.quoteArrs[q] != undefined) {
instance.say(data.channel, q + ': ' + db.quoteArrs[q].random());
}
break;
case '~qadd':
var qadd = data.message.match(/~qadd ([\d\w\s]*)=(.+)$/);
if(qadd != null && qadd.length >= 3) {
if(Object.isArray(db.quoteArrs[qadd[1]])) {
db.quoteArrs[qadd[1]].push(qadd[2]);
} else {
db.quoteArrs[qadd[1]] = [qadd[2]];
}
instance.say(data.channel, 'Quote saved in \'' + qadd[1] + '\'');
fs.writeFile('db.json', JSON.stringify(db, null, ' '));
} else {
instance.say(data.channel, 'Burn the invalid syntax!');
}
break;
case '~lamp':
instance.say(data.channel, db.lampPuns.random());
break;