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:
parent
e56f287e1c
commit
6d5c6a5a78
20
run.js
20
run.js
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user