Archive

Archive for February, 2012

BitlBee and Irssi

February 26, 2012 3 comments

If you are a real geek and want to do your chatting (IRC or IM) on text mode instead of using a GUI then this entry is for you.

After searching the Internet and trying some nice applications for chatting using the command line (e.g. CenterIM) my choice is the pair BitlBee/Irssi. The setup described in this entry has been tested on my Kubuntu Oneiric laptop.

BitlBee is an IRC gateway program for MSN, ICQ, AIM, Jabber and Google Talk. It behaves as a IRC server, creates a IRC channel with all your contacts and allows you to talk to them as if they were normal IRC users. So it must be combined with a IRC client such as Irss  (other cool combination you can try is done with web browser IRC clients such as cgi-irc).

BitlBee can be used in two different ways, via its public servers or installing it on your computer. Using a public server does involve a security risk, where as running your own BitlBee server does not. So my advice is to install your own server locally and run it via xinetd as it seems the safer option.

I’ve installed the following packages:

  • xinetd
  • bitlbee
  • irssi
  • irssi-scripts

It is recommended to run bitlbee via xinetd but the bitlbee package doesn’t provide/create the right file under /etc/xinetd.d/ so we have to add it by hand. The filename is bitlbee and its contents are:

service ircd
{
socket_type = stream
protocol = tcp
wait = no
user = bitlbee
server = /usr/sbin/bitlbee
port = 6667
disable = no
bind = localhost # prevent non-local access by binding to the loopback device
}

At this point one should stop the bitlbee daemon if it is running and restart the xinetd:

# /etc/init.d/bitlbee stop
# /etc/init.d/xinetd restart

The next step is to configure the BitlBee server. You have to launch irss and connect it to the BitlBee server:

$ irssi
/connect localhost

This is done in the status window (which prompt is [(status)]). If everything goes fine the control channel window (which prompt is [&bitlbee]) will be created. Change to the control channel window with the command:

/window 2

or with ALT+2 (you can cycle between windows using ALT+left/right arrow). Then you register yourself in the server using a password:

register your_password

(note that this is not an IRC command but a BitlBee one so it is not prefixed with a slash). After registering all your IM settings (passwords, contacts, etc.) will be saved on the BitlBee server. Finally you add your IM accounts. For instance, if you want to add a Google Talk account enter the following command:

account add jabber example@gmail.com

Then you will be asked to use the /OPER command to enter the account password. Do it:

/OPER

At the prompt, enter your account password (it won’t be visible). That’s all, the account has been added.

Once you’ve created all your accounts you’ll need to activate them. The following command does it:

account on

Lastly, save the settings on your account and quit the program:

save
/quit

Now that the basic BitlBee setup is done let’s see how a typical session is run. On your favorite terminal launch the Irssi client:

$ irssi

A new Irssi session will be started and you will see the status window (with prompt [(status)]). Type the command:

/connect localhost

A message saying that the connection has been established should be displayed. Change to the bitlbee control channel pressing ALT+2 or typing the command:

/window 2

The prompt on this window is [&bitlbee]. Now identify yourself with the password used for registering in the BitlBee server:

identify your_password

Now you are recognized and logged on to all your IM accounts automatically. In the bitlbee control channel there are 2 users now, @your_nick and @root. You can see the list of IM accounts you’re connected to:

account list

Or you can see the list of all your contacts (buddies):

blist

You can chat with your buddies on the bitlbee control channel:

buddy_nick: Hi, how are you?

If you prefer to create a dedicated window for private chatting you can use the /msg or /query IRC commands:

/msg buddy_nick Hi, how are you?

Move to the just created window (which will have a [buddy_nick] prompt) and chat normally.
You can close this window with the /q command or with the /wc command (which is useful too for parting channels on disconnected networks).

Irssi can handle multiple IRC connections simultaneously, thus it is possible to be active in channels on different networks at the same time. So being connected to your Google Talk account you can move to the status window, connect to, let’s say, the Freenode network, switch to that network and join to the #ubuntu channel:

/connect irc.freenode.net
CTRL+X
/join #ubuntu

You can use Ctrl-X to switch between network connections and see which the active network is by looking at the status bar.

As expected, you can leave a given channel on a connected network using /part, disconnect from a network using /disconnect and quit your IRC session using /quit.

This has been just a brief introduction to BitlBee/Irssi but there are lots of things you can do yet: customise your Irssi instalation, enhance it via themes and scripts, run it in a screen session (this is really cool :-)…