Skip to content

Instantly share code, notes, and snippets.

@mlebkowski
Created November 12, 2013 15:37
Show Gist options
  • Save mlebkowski/7432979 to your computer and use it in GitHub Desktop.
Save mlebkowski/7432979 to your computer and use it in GitHub Desktop.
#!/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