Hack and / - What Really IRCs Me: Twitter

by Kyle Rankin

In last month's column, I talked about the fact that I thought IRC was the ideal interface for quick communication with my friends. I keep an IRC session running at all times within a screen session, so I can continuously lurk in all of my channels. Because many of my friends use IM instead of IRC though, I've had to figure out ways to manage all of my communication without having a ton of different programs open. Last month, I discussed how I used Bitlbee so I could access all sorts of IM services from my IRC client, and I promised that in the follow-up column, I would talk about how to do something similar for Twitter.

A Quick Twitter Rant

In case you didn't read last month's Point/Counterpoint column, let me summarize my opinion here. I don't see the point of Twitter. I think everything people use Twitter for already could be achieved with IRC and instant messaging without the character limits. Again, IRC is my ideal way to communicate, but now some of my friends (ahem Bill) talk more on Twitter than they do on IRC. So after much prodding from Bill, I bit the bullet and registered a Twitter account so I could see what the fuss was about.

Now, just because I had a Twitter account didn't mean I was going to flood the Internet with every meal and traffic jam in my life. My main requirement for setting up the account at all was that I could access everything via IRC. That way, Twitter was nothing more than another IRC channel, only with higher latency and lower stability. To be honest, I mostly use it in “read-only” mode and just read other people's tweets.

tircd to the Rescue

It turns out I'm not the only one who wanted to access Twitter over IRC, and in fact, quite a few different programs out there provide a local IRC gateway to Twitter. Unfortunately, none of the programs have been packaged for my distribution yet, so after struggling to get a few running, I finally found one with a reasonably simple install that worked: tircd.

tircd is a simple Perl script that works much like Bitlbee. When you start the program, it creates a new IRC server on your local machine that you can connect to with an IRC client. The only difference is that it interfaces with your Twitter account, so people you follow show up as users in the channel, and their tweets show up as normal chat messages. Once you are in the channel, everything you type becomes a new Twitter message as well, so it behaves much like any other IRC channel.

To install tircd, first go to the main project page at code.google.com/p/tircd, and download the latest version. As with many Perl scripts, tircd makes use of some CPAN modules you might not have on your system, so dust off your Perl programmer hat, and type the following command as root to install the CPAN modules:

# cpan -i POE POE::Filter::IRCD Net::Twitter

If this is the first time you've used CPAN on your system, you first will have to go through a basic CPAN configuration process, so it knows which mirrors to use and whether you have any proxies in place. Apart from when you choose the mirrors, the default settings should be fine, and when you select the mirrors, simply pick a few that might be close by.

Once the CPAN modules are installed, extract the tircd package in some directory (your home directory works), and then change to that directory. You'll see that only a few files are inside:

$ tar xzvf tircd_v0.7.tar.gz
$ cd tircd
$ ls
ARTISTIC  GPL  tircd.cfg  tircd.pl  tircd.pod

tircd includes a sample configuration file that is heavily commented, so you can see what each option does. The default settings should work in most situations, unless you already run a local IRC server (such as Bitlbee in my case). If you do run another IRC server, change the port setting in the file from port 6667 to port 6668 so it won't conflict.

Start and Connect to tircd

To start tircd, simply execute the tircd.pl script and pass the path to the tircd.cfg file as an argument. Because I was already in the tircd directory, I could type:

$ ./tircd.pl ./tircd.cfg

You should see a number of log messages scroll by in the terminal, and if you want to use the terminal for something else, don't forget to add the & character at the end to start this in the background. Now you might be wondering how you enter your account information. All of this is set when you connect to the local server. Just use your Twitter user name and password as authentication. For instance, on most command-line IRC clients, you would type:

/server localhost 6667 twitter_password twitter_username

In my case, as I already had Bitlbee running on port 6667, I connected to port 6668:

/server localhost 6668 twitter_password twitter_username

Once you are connected to the tircd server, join the #twitter channel. tircd automatically imports everyone you are following, so they show up as users in the channel, and you also will see their recent posts. Any users that follow you back are voiced (+v).

Using IRC Commands with tircd

tircd works with a subset of traditional IRC commands, so it is pretty intuitive if you already are familiar with IRC. Your last Twitter status shows up as the topic of the #twitter channel, and if you want to update your status, all you have to do is type a message in the channel. If you want to send a direct message to other users, simply send them a private message. Likewise, if they send you a direct message, it shows up as a private message in IRC.

There are two different ways to follow or remove users. First, you can follow or remove them from the Twitter site or from any other Twitter client, and you will see those users join or leave your #twitter channel. Second, you can use the /invite IRC command followed by the users' Twitter user names to follow them. To remove them, all you have to do is /kick them from the channel. If you want to block users completely, just use /ban, and use /unban to unblock them. If you want to get information about a user, you can use the standard IRC /whois command.

Advanced Twitter Channels

One of the more interesting aspects of tircd is that you can set up multiple channels with only certain users in it. This can be useful if you follow a large number of accounts and want to organize them. Simply /join a new channel on the tircd server, and use /invite to add those particular users to that channel. Now, whenever those users update their status, it appears both in #twitter and in this new channel.

You also can use new channels for custom search queries. Again, /join a new channel of any name, and then use the /topic command to change the topic to the Twitter search query you want to use. All of the results of your search then appear in the channel.

Okay, I admit it, Twitter isn't so bad when you can access it inside IRC. I still think it's easier and faster to chat with people over IRC, but with tircd, I can find out what Larry King and Oprah had for lunch in my localhost #twitter channel and chat with all the great people in the official #linuxjournal channel all from the same client.

Kyle Rankin is a Senior Systems Administrator in the San Francisco Bay Area and the author of a number of books, including Knoppix Hacks and Ubuntu Hacks for O'Reilly Media. He is currently the president of the North Bay Linux Users' Group.

Load Disqus comments

Firstwave Cloud