Skip to content

Instantly share code, notes, and snippets.

@tomayac
Last active December 16, 2015 21:59
Show Gist options
  • Save tomayac/5504148 to your computer and use it in GitHub Desktop.
Save tomayac/5504148 to your computer and use it in GitHub Desktop.
Sample app created for Barcelona.js
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