Created
May 24, 2012 13:08
-
-
Save Floby/2781452 to your computer and use it in GitHub Desktop.
BiduleChose bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// installer les packages `format` et `irc` depuis npm | |
var chan = '#zftalk-fr' | |
var irc = require('irc'); | |
var format = require('format'); | |
var client = new irc.Client('irc.freenode.net', 'BiduleChose', { | |
channels: [chan] | |
}); | |
client.on('message', function(from, to, message) { | |
console.log('got message from %s to %s: %s', from, to, message); | |
}); | |
client.on('message#octaveoctave', function(from, message) { | |
if('floby' != from) { | |
if(/bidulechose/i.test(message)) { | |
client.say(chan, format.format('%s: Je ne parle qu\'à floby', from)); | |
} | |
} | |
else return answerFloby(message); | |
}); | |
function answerFloby (message) { | |
if(!/bidulechose/i.test(message)) { | |
return; | |
} | |
if(/Merci|Kick/i.test(message)) { | |
client.say(chan, 'floby: mais de rien, je vais me recoucher maintenant'); | |
client.part(chan, function() { | |
process.exit(); | |
}) | |
} | |
else if(/^bidulechose/i.test(message)) { | |
if(/non/i.test(message)) { | |
client.say(chan, 'au temps pour moi'); | |
} | |
else { | |
client.say(chan, 'OH MON DIEU, MAITRE FLOBY S\'ADRESSE A MOI. Ayez pitié de moi'); | |
} | |
} | |
else { | |
client.say(chan, 'on parle de moi?'); | |
} | |
} | |
client.on('error', function(err) { | |
console.log(err); | |
}); | |
setInterval(function() { | |
client.say(chan, "Floby: Hé gros, c'est l'heure du thé"); | |
}, 60000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment