Image of the glider from the Game of Life by John Conway
Skip to content

Facebook Chat In Bitlbee

It's no surprise that Bitlbee is my chat client of choice. After all, I've blogged about it before. So, when I heard rumors that Facebook would be releasing their chat to outside clients over XMPP, I was excited to see the day when I could add it to my running Bitlbee instance. Lo and behold, that day has come.

Adding your Facebook account to Bitlbee is rather painless, as it is with any other account. The only catch, is you have to have a Facebook username set before you can continue. Once that is set, in Bitlbee, from your "&btilbee" status window, you can add the account:

account add jabber <username>@chat.facebook.com <password>
save
account on

That's it! You should be up and running with a new XMPP connection to the Facebook chat. However, rather quickly, you'll notice that the usernames in your "blist" roster are their user identification number on Facebook, rather than their name. Something like "u123456789". Who is that you wonder? Well, in your "&bitlbee" window, you could run:

info u123456789

Then, using that information, you could rename them one-by-one as they login. However, this is a pain. Fortunately, if you're running Bitlbee with Irssi, then there is an Irssi Perl script for renaming these automatically for you, as they login. You can find that script here. Save it as "bitlbee_rename.pl" in your "~/.irssi/scripts directory, create a symlink in the autorun directory, load it, and you're set. Here's what you would do behind the command line:

wget -O ~/.irssi/scripts/bitlbee_rename.pl http://browsingtheinternet.com/temp/bitlbee_rename.txt
ln -s ~/.irssi/scripts/bitlbee_rename.pl ~/.irssi/scripts/autorun/bitlbee_rename.pl

Now in Irssi, load it:

/RUN bitlbee_rename.pl

Now, each of your Facebook buddies will have their user ID number renamed to "FirstnameLastname" format. The script only works for Facebook chat, so no worries about it mucking up other XMPP connections, and it only renames buddies that haven't already been renamed. It also saves it to your Bitlbee config (which is /var/lib/bitlbee/username.xml) every time it renames a buddy.

So, there you go. Bitlbee, XMPP and now Facebook, married together. What a beautiful relationship.

{ 31 } Comments

  1. Daniel Wiberg using Google Chrome 5.0.307.5 on GNU/Linux | February 13, 2010 at 10:52 am | Permalink

    It renames people as they they come online, so an 'account off' and 'account on' triggered the rename of users already online. Great script, thanks!

  2. Ash using Opera 9.80 on GNU/Linux | February 17, 2010 at 3:58 pm | Permalink

    Not at all related to your irssi script (which I'm looking forward to trying), but I'm having no end of trouble trying to just connect to Facebook chat over XMPP with bitlbee. Without fail, following the above account creation instructions, I get this every time:

    09:53 JABBER(username@chat.f - Logging in: Connecting
    09:53 JABBER(username@chat.f - Logging in: Connected
    09:53 JABBER(username@chat.f - Logging in: Requesting Authentication Method
    09:53 JABBER(username@chat.f - Logged out: Connection lost
    09:53 JABBER(username@chat.f - Signing off..

    I've replaced my real username with "username" in the output above, obviously. Don't suppose any readers have any ideas what it might be...?

  3. Aaron using Google Chrome 4.0.249.89 on Windows XP | February 17, 2010 at 4:39 pm | Permalink

    @Ash What did you type when setting up your account? And, are you sure you're using the right username, as found at that link, and your password that you use to login to the site?

  4. Ramen using Shiretoko 3.5.5 on GNU/Linux | February 18, 2010 at 10:38 pm | Permalink

    I've been experiencing the same problem as Ash... good to know it's not just me, at least. I've added the account as I would any other jabber account:

    account add jabber ramen@chat.facebook.com apassword

    I'm using my correct facebook username, and I'm using the correct password as well. I've even made sure that I've logged into facebook from the same IP as the bitlbee server, per a random slashdot comment. No dice.

    I'm coming from a private bitlbee server, which might make a difference? The error message isn't helpful, and I'm not sure where to look for any logs or more useful information.

  5. Utopiah using Firefox 3.6 on Windows XP | February 19, 2010 at 9:57 am | Permalink

    Some renaming seems to fail the saving process, some friends seems to randomly loose their name and thus info/save have to be done repetitively :/

    Any idea? Suggestions?

    PS : for people having trouble connecting, if you just created your username, do disconnect AND reconnect from your account. The IP test is not correct as I did succeed in connecting from a remote bitlbee server that did not connect through FB first.

  6. Utopiah using Firefox 3.6 on Windows XP | February 19, 2010 at 11:48 am | Permalink

    Example :

    19:41 -!- u12345678 [u12345678@chat.facebook.com] has joined &bitlbee
    19:41 rename u12345678 FriendName
    19:41 save
    19:41 Nick `FriendName' already exists
    19:41 Configuration saved
    19:41 -!- u12345678 [u12345678@chat.facebook.com] has quit [Leaving...]
    19:42 -!- u12345678 [u12345678@chat.facebook.com] has joined &bitlbee
    19:42 -!- ServerMode/&bitlbee [+v u12345678] by seedea.org
    19:42 rename u12345678 FriendName
    19:42 save
    19:42 Nick `FriendName' already exists
    19:42 Configuration saved

  7. Aaron using Google Chrome 5.0.322.2 on GNU/Linux | February 19, 2010 at 2:49 pm | Permalink

    @Utopia- Are you connected to another service? If so, do you already have your friends saved in that service's roster? Or are you connected to a Jabber MUC where these names are currently in use? If so, that is why. You can see everyone in your roster with 'blist all' for any troubleshooting, should it be needed.

  8. Utopiah using Firefox 3.6 on Windows XP | February 23, 2010 at 12:18 pm | Permalink

    Indeed Aaron, I just understood that today when a contact had her NameSurename on Gtalk which is the same format Facebook is using. I came back here to say so but it seems you figured that out already.

    Maybe the script could be changed to rename by appending [Facebook] if the renaming fails.

    Cheers and thanks for your quick reply :)

  9. piousminion using Firefox 3.6 on Windows XP | February 24, 2010 at 9:26 pm | Permalink

    Very nice.
    Although, I have to admit I didn't want to trust the script at first because it wasn't at scriptsirssi.org

    Thanks. :)

  10. Aaron using Google Chrome 5.0.322.2 on GNU/Linux 64 bits | February 25, 2010 at 6:29 am | Permalink

    @piousminion- That's a bit naive, trusting any and all scripts at scripts.irssi.org. Anyone and everyone can write an Irssi script, and submit it to scripts.irssi.org. The script might go through a light review process, but they're certainly not scrutinized for security.

    Further, the script I linked to isn't long, and isn't complicated. You can easily read the script and see that it's doing exactly as advertised. There is nothing shady going on.

  11. Ash using Opera 9.80 on GNU/Linux | March 20, 2010 at 2:19 am | Permalink

    @Aaron - I typed your instructions as above, both when I first tried it based on Facebook's instructions, and then based on yours, but still no dice. And I was using the correct username and password. It turns out (I think) that the version of bitlbee that I was using was too old to support Facebook chat, for whatever reason. I'm running irssi/bitlbee on an ASUS router running OpenWRT (long story - work proxy issues), however I've just set up an old laptop with the latest Ubuntu distro, and tried irssi/bitlbee on that, with your instructions, and it's worked a treat. So I'm tipping that it is just a bitlbee version issue (although I'm not really sure how). Still... I can now access Facebook chat through the proxy at work (Facebook is blocked) once I do some fancy port forwarding. Got there in the end!

  12. singleuser using Unknown on Unknown O.S. | April 16, 2010 at 9:31 pm | Permalink

    I've been using bitlbee for years too. :)

  13. Austin Seraphin using Lynx 2.8.7rel.1 on Unknown O.S. | April 22, 2010 at 4:35 pm | Permalink

    I can't seem to get authenticated. I use the latest bitlbee version 1.2.51. My girlfriend also tried. She could connect, but couldn't get her buddy list to work. She went into the bitlbee support channel, and they said that Facebook needs to correct some things on their end, and that it has to do wit the ip address last used to log into Facebook.
    I also tried it with emacs-jabber, and had the same problem.

  14. Aaron using Google Chrome 5.0.342.9 on Windows XP | April 22, 2010 at 4:44 pm | Permalink

    Yeah, right now it's spotty, at best.Some clients authenticate, some don't. Sometimes, the same client will authenticate, then it won't. It's entirely in Facebook's hands. Additionally, when you get connected, you'll learn that you can't set your away status with an external client. So, even though you told Bitlbee you're away, you'll still appear ready to chat to your friends logging into the web interface.

    Long story short, Facebook needs to seriously work on it.

  15. Ash using Opera 9.80 on GNU/Linux | May 11, 2010 at 5:13 pm | Permalink

    I noticed as of this morning that all of the Facebook user identification numbers are now prefixed with a hyphen, so the script is no longer working, and none of the saved names are recognised. And even more annoyingly, you can't use irssi to initiate a conversation with someone because of this hyphen - you just get a "Not enough parameters given" error, as presumably it's expecting some kind of option flag. Has anyone else spotted this, or is it just my setup...? Hopefully it's just a temporary thing with Facebook and things return to normal soon.

  16. Aaron using Google Chrome 5.0.375.29 on GNU/Linux | May 11, 2010 at 9:09 pm | Permalink

    @Ash- I don't have that problem. All of my friends that are currently logged in, do not a hyphen prefixed to their JID. Further, the script is continuing to rename nicks for me just fine. Also, I just initiated a chat with a friend, and everything worked as expected. So, I'm guessing you have something seriously broken with your setup.

  17. Ash using Opera 9.80 on GNU/Linux | May 11, 2010 at 10:56 pm | Permalink

    Hmmm... yes, I may have to investigate my setup a little further. It's weird that it just started happening out of the blue, though, without me making any changes. If anyone else reading this is experiencing the same problem with the hyphen in irssi, I have come up with a way around sending people messages. If you enclose the hyphen + number in quotation marks, it will accept the username and send the message without any problem. Hopefully I can get this sorted as having to run a /who and change windows every time someone logs on is getting rather frustrating... ;)

  18. james using Firefox 3.6.3 on Windows XP | May 12, 2010 at 10:02 am | Permalink

    Yeah, Ash, this started happening to me too. I think that Facebook changed the way their Jabber implementation works, because it started for me on exactly the same day. I'm disabling FB in bitlbee until either one gets an upgrade.

  19. Aaron using Firefox 3.0.19 on GNU/Linux | May 12, 2010 at 11:26 am | Permalink

    There must be an issue then. It's still working just great for me. No issues that I've seen yet. Makes me a bit worried though.

  20. Ash using Opera 9.80 on GNU/Linux | May 12, 2010 at 7:40 pm | Permalink

    Well I guess I'm kind of glad to know that I'm not the only one with this issue. I've tried quite a few things to figure out what might be causing the problem, but to no avail. Which is making me think, as James suggested, that it might be at Facebook's end. But that still doesn't explain why yours is fine, Aaron. If it is at Facebook's end, then I guess we'll just keep having to put up with it until it fixes itself. Hopefully the quotation marks fix helped you James!

  21. Utopiah using Firefox 3.6.3 on Windows XP | May 13, 2010 at 6:26 am | Permalink

    Same problem for me too, "5:19 -!- -123456789 [-123456789@chat.facebook.com] has quit [Leaving...]"

    I didn't change anything and it happened overnight so I reloaded the script, just in case, nothing changed, still can't rename.

  22. tom using Google Chrome 6.0.400.0 on GNU/Linux 64 bits | May 15, 2010 at 7:55 am | Permalink

    Easy enough to fix. In the script, just change

    if($channel =~ m/($bitlbeeChannel)/ and $nick =~ m/$username/ and $nick =~ m/^u\d+/ and $host =~ m/($facebookhostname)/ )

    to:

    if($channel =~ m/($bitlbeeChannel)/ and $nick =~ m/$username/ and $nick =~ m/^\-\d+/ and $host =~ m/($facebookhostname)/ )

    (note the uXXXXXXXX@ changed to -XXXXXXXX@, so we replace u with \-)

    and

    $server->command("whois $nick");

    to:

    $server->command("whois \"$nick\"");

    To escape the new '-'s. Hopefully they won't change things around again.

  23. Ash using Opera 9.80 on GNU/Linux | May 16, 2010 at 4:24 pm | Permalink

    Nice one Tom, that worked a treat. I tried to give it a go myself, but my programming knowledge doesn't extend much further than bash scripting. But now that you've shown the changes, of course it makes perfect sense. Cheers!

  24. Ash using Opera 9.80 on GNU/Linux | May 16, 2010 at 4:46 pm | Permalink

    Now I just have to put up with all my contacts being re-saved every time they come online (very small price to pay, though!). If anyone reading this also uses bitlbee for MSN, like I do, you might have noticed problems authenticating passports. This has been rectified in the latest version. If you're running a Debian-based Linux distribution, the debs are available here:

    http://code.bitlbee.org/debian/devel/

  25. Aaron using Google Chrome 5.0.375.38 on GNU/Linux | May 16, 2010 at 7:15 pm | Permalink

    So, I've been faced with this now, as well. Thank you Facebook! However, the latest bitlbee, 1.2.7, has support for renaming Facebook nicknames directly. Worth giving a shot.

  26. stringz using Google Chrome 5.0.342.9 on GNU/Linux | May 19, 2010 at 6:41 am | Permalink

    Is it just me or is anyone else getting multiple instances of each user? I get -12345, -12345_, -12345__, and so on. They all get renamed, (every time, and like Ash said, "small price to pay"). My PROBLEM is, when someone initiates a chat with me, it shows up in seperate windows for each -12345_. So I'm basically chatting to the same person on 4 or 5 windows.

    Is it just me?

  27. Aaron using Google Chrome 5.0.375.38 on Windows XP | May 19, 2010 at 7:02 am | Permalink

    @stringz- No, you're not the only one. This is because those people are signing in multiple times to their Facebook account, or they are in a chat room with you, using their Facebook account. That's bitlbee for you. :)

  28. Wilmer using Debian IceWeasel 3.5.9 on GNU/Linux 64 bits | June 14, 2010 at 1:10 am | Permalink

    Since this post is one of the first results in a Google query for "bitlbee facebook", I should probably mention that the rename script is not required anymore for recent BitlBee versions. You can just use the nick_source setting instead. Something like this should work:

    account set facebook/nick_source full_name

    (And "set lcnicks off" if you want them CamelCased.)

    If you've already used the rename script you *may* have to re-add your Facebook account before this will take effect.

    Also I'm trying to make http://wiki.bitlbee.org/HowtoFacebook the canonical source of information on BitlBee + Facebook. Trying to centralize BitlBee docs a little bit better.

  29. quintopia using Firefox 3.6.3 on Ubuntu | November 5, 2010 at 11:34 am | Permalink

    Annoyed at the way the rename script indiscriminately tossed away all special characters from my friend's names, I added the following lines to my copy (which should basically cover every reasonable person's name and more):

    $ircname =~ s/Æ/Ae/g;
    $ircname =~ s/æ/ae/g;
    $ircname =~ s/Ð/Dh/g;
    $ircname =~ s/ð/dh/g;
    $ircname =~ s/þ/th/g;
    $ircname =~ s/Þ/Th/g;
    $ircname =~ s/ß/ss/g;
    $ircname =~ tr/[á,à,ä,å,ã,â,Á,À,Ä,Å,Ã,Â,ç,Ç,é,è,ë,ê,É,È,Ë,Ê,í,ì,ï,î,Í,Ì,Ï,Î,ñ,Ñ,ó,ò,ö,ô,õ,ø,Ó,Ò,Ö,Ô,Õ,Ø,ú,ù,ü,û,Ú,Ù,Ü,Û,ý,Ý,ÿ]/[a,a,a,a,a,a,A,A,A,A,A,A,c,C,e,e,e,e,E,E,E,E,i,i,i,i,I,I,I,I,m,M,o,o,o,o,o,o,O,O,O,O,O,O,u,u,u,u,U,U,U,U,y,Y,y]/;

    Should be fairly obvious where it goes...right before the line that smashes all the characters it's trying to preserve :D

  30. algo using Internet Explorer 9.0 on Windows 7 | July 21, 2011 at 8:37 am | Permalink

    Using Tom's changes at post 22:

    16:37 "use" not allowed in expression at (eval 234) line 10, at end of line
    16:37 syntax error at (eval 234) line 10, near "use strict"
    16:37 BEGIN not safe after errors--compilation aborted at (eval 234) line 11.

    Got this error, can anyone give me a hand here? :)

  31. Eric using Firefox 18.0 on Ubuntu 64 bits | January 26, 2013 at 1:54 am | Permalink

    This isn't working for me and I'm not sure why. I probably did something wrong but the script just isn't doing anything. All people are still numbers.

    I'm still quite new to doing any kind of stripting with linux but followed what you said to do and still am not getting much of anywhere.

    Any help is appreciated if this is still active.

{ 3 } Trackbacks

  1. [...] the original post: Aaron Toponce : Facebook Chat In Bitlbee Share and [...]

  2. [...] Facebook Chat In Bitlbee [...]

  3. [...] Facebook Chat In Bitlbee [...]

Post a Comment

Your email is never published nor shared.

Switch to our mobile site