Last active
December 16, 2015 21:59
-
-
Save tomayac/5504148 to your computer and use it in GitHub Desktop.
Sample app created for Barcelona.js
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
var irc = require('irc'); | |
var request = require('request'); | |
var express = require('express'); | |
var http = require('http'); | |
var app = express(); | |
var server = http.createServer(app); | |
// IRC details for the recent changes live updates | |
var IRC_SERVER = 'irc.wikimedia.org'; | |
var IRC_NICK = 'YOUR_APP_NAME_HERE'; | |
var IRC_CHANNELS = [ | |
'#ca.wikipedia', | |
'#eu.wikipedia', | |
'#an.wikipedia', | |
'#es.wikipedia', | |
'#ast.wikipedia', | |
'#gl.wikipedia', | |
'#ext.wikipedia']; | |
var client = new irc.Client( | |
IRC_SERVER, | |
IRC_NICK, | |
{ | |
channels: IRC_CHANNELS | |
}); | |
app.get('/', function(req, res) { | |
res.header({ | |
'Access-Control-Allow-Origin': '*', | |
Connection: 'Keep Alive', | |
'Content-Type': 'text/event-stream' | |
}); | |
// fires whenever a new IRC message arrives on any of the IRC rooms | |
client.addListener('message', function(from, to, message) { | |
console.log(message); | |
res.write('data: ' + message + '\n\n'); | |
}); | |
}); | |
// start the server | |
var port = process.env.PORT || 8080; | |
console.log('GET me if you can! (' + port + ')'); | |
server.listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment