WeeChat, BitlBee, and the Evil Facebook


I have used WeeChat for a number of years. Previously I had been an Irssi user, but I kept being told of the wonders of WeeChat. After trying it, I was convinced; I now frequently proselytize others, as Weechat is Irssi+++. I think I've filled out a few punch cards, and can redeem a couple of sandwiches by now. :)

A small selection of the awesome things WeeChat has to offer:

  • Smartfilters
    • Can make join/part spam a thing of the past
    • You can toggle them off
  • Edit settings from inside WeeChat
    • Installing /iset makes it even better, as it explains settings
  • Vertical and horizontal splits
  • Nick list is built in
  • The buffers script
  • The script installation UI
  • I could go on...


BitlBee is a fancy way to connect to IM protocols (as well as twitter/FB). It is basically an IRCD that acts as a gateway. I use it with my tmux+WeeChat setup, to remain online 24/7/365. It works quite well.

Evil FB

In addition to my various IM accounts, I have BitlBee do twitter and FB (notice how I'm not acknowledging FB as an IM protocol :p). As much as it pains me to use FB, a few of my friends don't bother with real IMs anymore... TT__TT And at least this way it's my server connecting to FB.

Why don't I consider it a real IM protocol? Well, they started by using jabber, but have bastardized it over time. Now they are at the point where I need to compile a special plugin for my BitlBee to connect.

Irksome Expressive Pictures

FB has had their in-chat pictures for a while. Unfortunately, unless they are actual unicode, they end up being a link in BitlBee's chat window. Here is how I see a Thumbs Up in a chat.

2016-08-27 22:32:46     Name_here   https://fb-s-d-a.akamaihd.net/h-ak-xfa1/t39.1997-6/851557_369239266556155_759568595_n.png?_nc_ad=z-m

Worse is that the links are not consistent. They seem to both have duplicate locations and varying sizes...

2016-08-26 17:50:21     Name_here   https://scontent.xx.fbcdn.net/t39.1997-6/851557_369239266556155_759568595_n.png?_nc_ad=z-m

A Solution to my Madness

WeeChat has a fancy, and powerful, command call: /trigger. Among the things /trigger can do is replace text. Here is my current solution:

## The first is probably the most desired
/trigger addreplace fb_thumb modifier "weechat_print" "${tg_tags} =~ notify_private && ${tg_message} =~ 851557_369239266556155_759568595_n.png" "/(.*)/${tg_prefix}\t:thumbs: ${tg_message}" ""
/trigger addreplace fb_arg_cat modifier "weechat_print" "${tg_tags} =~ notify_private && ${tg_message} =~ 10541001_1498876623686801_1597277063_n.png" "/(.*)/${tg_prefix}\t:arg_cat: ${tg_message}" ""
/trigger addreplace fb_sleep_cat modifier "weechat_print" "${tg_tags} =~ notify_private && ${tg_message} =~ 10541016_1498876550353475_1185278857_n.png" "/(.*)/${tg_prefix}\t:sleepy_cat: ${tg_message}" ""
/trigger addreplace fb_strong_bunny modifier "weechat_print" "${tg_tags} =~ notify_private && ${tg_message} =~ 11891354_1659201864325047_1474050348_n.png" "/(.*)/${tg_prefix}\t:strong_bunny: ${tg_message}" ""

An Explanation

  • The :desc: ${tg_message} portion will display your added description, while still showing you the original message.
    • I chose this setup, as I initially had issues where the trigger would replace my own messages if they matched.
      • That was since corrected, upon my divining that I could add a ${tg_tags} =~ notify_private && to my "${tg_message} =~ 11891354_1659201864325047_1474050348_n.png".
  • It is also worth noting that I stuck to using the file_name.png as my regex.
    • I am told that the user can affect the size of a picture; I'm not going to bother to configure to account for size.
    • This means that it should catch all URL variations, but entropy is also slightly decreased.
      • What I mean there is that if someone, for some unknown reason, actually says 851557_369239266556155_759568595_n.png in a conversation you will trigger this...

The Result

2016-08-28 01:57:30     Name_here   :thumbs: https://fb-s-d-a.akamaihd.net/h-ak-xfa1/t39.1997-6/851557_369239266556155_759568595_n.png?_nc_ad=z-m

Alternatively, you could remove the last ${tg_message} and only get the replacement text.

/trigger addreplace fb_thumb modifier "weechat_print" "${tg_tags} =~ notify_private && ${tg_message} =~ 851557_369239266556155_759568595_n.png" "/(.*)/${tg_prefix}\t:thumbs:" ""

This would result in:

2016-08-28 01:57:30     Name_here   :thumbs:


- demure