Created
November 12, 2013 15:37
-
-
Save mlebkowski/7432979 to your computer and use it in GitHub Desktop.
This file contains 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/local/bin/node | |
var irc = require('irc'); | |
var http = require('http'); | |
var opts = { | |
userName: 'docplanner', | |
realName: 'Doctor Planner', | |
autoRejoin: false, | |
channels: ['#docplanner'], | |
} | |
var client = new irc.Client('irc.freenode.net', 'DocPlanner', opts); | |
var flood = false, server = http.createServer(function (request, response) { | |
if (flood) { | |
response.writeHead(509); | |
response.end(); | |
return; | |
} | |
response.writeHead(200, {'Content-Type': 'text/plain'}); | |
flood = true; | |
setTimeout(function () { flood = false; }, 1500); | |
var post = ""; | |
request.on('data', function (data) { post += data; }); | |
request.on('end', function () { | |
client.say('#docplanner', post.substr(0,150)); | |
response.end(""); | |
}); | |
}).listen(2080); | |
client.addListener('message', function (from, to, message) { | |
var myNick = this.opt.nick.toLowerCase(); | |
if (message.substr(0,myNick.length+1).toLowerCase() == myNick + ":") { | |
message = message.substr(myNick.length+1); | |
this.say(to, from + ": Spierdalaj"); | |
} | |
}); | |
client.addListener('error', function(message) { | |
console.log('error: ', message); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment