3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 06:19:24 +01:00

Reality anecdote generation!

This commit is contained in:
Luke Slater 2011-08-17 13:52:01 +01:00
parent 97e5a8fc08
commit e56f287e1c

16
run.js
View File

@ -22,6 +22,8 @@ var instance = jsbot.createJSBot(name, 'elara.ivixor.net', 6667, function() {
instance.addListener('JOIN', function(data) {
if(data.user == 'Lamp') {
instance.say(data.channel, db.lampPuns.random());
} else if(data.user == 'Reality') {
instance.say(data.channel, db.realiPuns.random());
} else if(instance.inChannel(data.channel)) {
instance.say('aisbot', '.karma ' + data.user);
waitingForKarma = data.channel;
@ -111,6 +113,9 @@ instance.addListener('PRIVMSG', function(data) {
case '~lamp':
instance.say(data.channel, db.lampPuns.random());
break;
case '~reality':
instance.say(data.channel, db.realiPuns.random());
break;
case '~rq':
var rQuote = Object.keys(db.quotes).random();
instance.say(data.channel, rQuote + ': ' + db.quotes[rQuote]);
@ -118,3 +123,14 @@ instance.addListener('PRIVMSG', function(data) {
}
}
});
instance.addListener('PRIVMSG', function(data) {
if(data.user == 'reality') {
var once = data.message.match(/I ([\d\w\s]* once.)/);
if(once != null) {
db.realiPuns.push('reality ' + once[1]);
instance.say(data.channel, '\'reality ' + once[1] + '\' saved.');
fs.writeFile('db.json', JSON.stringify(db, null, ' '));
}
}
});