Skip to content

Instantly share code, notes, and snippets.

@codysoyland
Created August 25, 2010 03:28
Show Gist options
  • Save codysoyland/548789 to your computer and use it in GitHub Desktop.
Save codysoyland/548789 to your computer and use it in GitHub Desktop.
/*
twirc.js
========
Automating Twitter messages to IRC. BSD license.
Installation:
-------------
* brew install node
* brew install npm
* npm install irc
* npm install twitter-node
Run ``node twirc.js``.
*/
var irc = require('irc');
var log = require('sys').log;
var twitter = require('twitter-node');
var config = {
irc: {
server: 'irc.freenode.net',
channel: '#twirc',
nick: 'twircbot'
},
twitter: {
user: '',
password: '',
topics: ['obama'],
}
}
var ircClient = new irc.Client(config.irc.server, config.irc.nick, {
channels: [config.irc.channel],
realName: config.irc.nick
});
var twitterClient = new twitter.TwitterNode({
user: config.twitter.user,
password: config.twitter.password,
track: config.twitter.topics,
});
ircClient.addListener('join', function() {
twitterClient.addListener('tweet', function(tweet) {
ircClient.say(config.irc.channel, '@'+tweet.user.screen_name+': '+tweet.text);
}).stream();
});
//// Logging:
//ircClient.addListener('message', function(from, to, message) {
// log('From: '+from+' - To: '+to+' - Message: '+message);
//});
//twitterClient.addListener('tweet', function(tweet) {
// log("@" + tweet.user.screen_name + ": " + tweet.text);
//});
//ircClient.addListener('join', function() {
// log('Joined chat room.');
//});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment