What Really IRCs Me: Mastodon

Learn how to use the Mastodon social network platform from the comfort of your regular IRC client.

When it comes to sending text between people, I've found IRC (in particular, a text-based IRC client) works best. I've been using it to chat for decades while other chat protocols and clients come and go. When my friends have picked other chat clients through the years, I've used the amazing IRC gateway Bitlbee to connect with them on their chat client using the same IRC interface I've always used. Bitlbee provides an IRC gateway to many different chat protocols, so you can connect to Bitlbee using your IRC client, and it will handle any translation necessary to connect you to the remote chat clients it supports. I've written about Bitlbee a number of times in the past, and I've used it to connect to other instant messengers, Twitter and Slack. In this article, I describe how I use it to connect to yet another service on the internet: Mastodon.

Like Twitter, Mastodon is a social network platform, but unlike Twitter, Mastodon runs on free software and is decentralized, much like IRC or email. Being decentralized means it works similar to email, and you can create your own instance or create an account on any number of existing Mastodon networks and then follow people either on the same Mastodon network or any other instance, as long as you know the person's user name (which behaves much like an email address).

I've found Bitlbee to be a great interface for keeping track of social media on Twitter, because I treat reading Twitter like I was the operator for a specific IRC room. The people I follow are like those I've invited and given voice to, and I can read what they say chronologically in my IRC room. Since I keep my IRC instance running at all times, I can reconnect to it and catch up with the backlog whenever I want. Since I'm reading Twitter over a purely text-based IRC client, this does mean that instead of animated gifs, I just see URLs that point to the image, but honestly, I consider that a feature!

Since Mastodon behaves in many ways like Twitter, using it with Bitlbee works just as well. Like with Twitter over Bitlbee, it does mean you'll need to learn some extra commands so that you can perform Mastodon-specific functions, like boosting a post (Mastodon's version of retweet) or replying to a post so that your comment goes into the proper thread. I'll cover those commands in a bit.

Installing the Mastodon Bitlbee Plugin

The first step is to install the Mastodon Bitlbee Plugin. This plugin is already packaged for Debian and other distributions—look for the bitlbee-mastodon package. In that case, you can just install it with your package manager. Otherwise, you'll need to clone the source code from the plugin's git repo and build it from source:


git clone https://alexschroeder.ch/cgit/bitlbee-mastodon
cd bitlbee-mastodon
./autogen.sh
./configure
make
sudo make install

Note that if you build it from source, you need to have the Bitlbee development package installed on your distribution (usually called bitlbee-dev or bitlbee-devel).

Configure Mastodon

Once you have installed the plugin, restart the bitlbee service (sudo service bitlbee restart should work on most distributions these days). Then when you connect to Bitlbee with your IRC client, make sure you are in the specific &bitlbee IRC channel it creates. From that room, you'll be able to register your new account using the standard account tools within Bitlbee. For this example, let's assume I want to connect to my @kyle@librem.one Mastodon account:


@greenfly| account add mastodon @kyle
@    root| Account successfully added with tag mastodon

This creates a new Mastodon account in Bitlbee and names it "mastodon", but note that if I already had a Mastodon account present, it would have started adding numbers at the end, such as "mastodon2" instead. Pay attention to this tag, as you will use it in the next command to configure this Mastodon account to point it at your particular Mastodon network:


@greenfly| account mastodon set base_url
 ↪https://social.librem.one/api/v1
@    root| base_url = `https://social.librem.one/api/v1'
@greenfly| account mastodon on

At this point, Bitlbee will connect to Mastodon, and you'll need to authenticate this client. You'll get a private message from the mastodon_oauth user that will send you a URL to visit in a browser. When you visit the URL, you'll see a long string of text that you'll need to copy and then paste back as a reply to the mastodon_oauth user:


mastodon_oauth| Open this URL in your browser to authenticate:
https://social.librem.one/...
mastodon_oauth| Respond to this message with the returned
 ↪authorization token.
      greenfly| somelongstringoftext

After you complete this authentication step, you can go back to the main &bitlbee channel, and you'll see that your login has completed. From this point on, your Bitlbee Mastodon account will have an authentication token it can use to log in in the future, so in that &bitlbee window, be sure to save your configuration:


@greenfly| save
@   root | Configuration saved

Using Mastodon

If you are familiar with using Twitter on Bitlbee, using Mastodon is similar. Bitlbee will open a new IRC channel for your Mastodon account, and anything anyone posts will show up there. Anything you type into the channel will be posted on your Mastodon account by default. If you want to restrict that so it posts things only when you explicitly use the post command, you'll need to set your Mastodon account to strict mode, so inside the main &bitlbee control channel, type:


@greenfly| account mastodon set commands strict

To revert to the default behavior, type:


@greenfly| account mastodon set commands true

To post something, either just type the message and press Enter, like any other IRC channel, or if you have enabled strict commands, preface the post with the post command:


post My first toot from Bitlbee!

Each post in your Mastodon channel will be prefaced with a hexadecimal ID. You can use that ID if you want to boost, favorite or reply to that status. For instance, if you saw a post like the following:


kyle| [15] My first toot from Bitlbee!

You would use the ID "15" to interact with it:


favorite 15
boost 15
reply 15 The Mastodon Bitlbee plugin is the best!

If you decide you want to remove that last reply, you can use either the undo command to undo your last action or the del command to delete a particular status based on ID. You can also unfavorite and unboost to undo those commands.

To follow an account, use the follow command along with the person's Mastodon account ID (for instance @kyle@librem.one), and use unfollow along with the account ID to unfollow someone. You can block, unblock, mute and unmute someone using the commands with the same names. You also can mute a particular conversation by specifying the post's ID. Finally, you can use the report command to a particular status for moderation.

Searches

You can perform Mastodon searches and create whole rooms that follow hashtags from within Bitlbee as well. The search command lets you search for users, hashtags and the URL for a particular status. If you want to follow a hashtag in its own room, you need to perform a series of Bitlbee commands to create the chat room. For instance, if you wanted to follow the hashtag #linuxjournal you would type:


chat add mastodon hashtag #linuxjournal
channel #linuxjournal set auto_join true
/join #linuxjournal

The first command sets that hashtag search in the account named "mastodon", but if you have multiple Mastodon accounts, replace "mastodon" with "mastodon2" or whatever the appropriate account is labeled. The second command creates the specific channel related to that hashtag search, and the /join command will connect to that channel.

Conclusion

Reading social media from IRC makes following lots of people much easier and feels more like a regular chat room. Although it's true that you can't immediately see images, some people probably would consider that as a feature. Even better, it means you can channel yet another communication medium through IRC and not have to learn the quirks of a new client.

Kyle Rankin is a Tech Editor and columnist at Linux Journal and the Chief Security Officer at Purism. He is the author of Linux Hardening in Hostile Networks, DevOps Troubleshooting, The Official Ubuntu Server Book, Knoppix Hacks, Knoppix Pocket Reference, Linux Multimedia Hacks and Ubuntu Hacks, and also a contributor to a number of other O'Reilly books. Rankin speaks frequently on security and open-source software including at BsidesLV, O'Reilly Security Conference, OSCON, SCALE, CactusCon, Linux World Expo and Penguicon. You can follow him at @kylerankin.

Load Disqus comments