When I came to #Mastodon I directly engaged with the bot possibilities, and so I started my own RSS feed bridge to publish in the #fediverse. This is around a year and a half ago.

Since then, my EchoBot evolved quite a lot in stability and functionalities, but moved a bit away from the initial idea of having a personal companion that pings me when new content has published.

Recently I took its last version, stripped out everything not meant to be in a RSS feed reader, and added mentions interaction, to give birth to a new bot: the Masto-Feed.

Today I just finished the last details after seeing it working nice for the last month, and I am proud to present it to you in this blog post.

Masto-Feed RSS feed reader that posts updates in Mastodon API

Why do we need yet another RSS-Mastodon bridge?


In my case I wanted a bot that I can deploy to an account and bridge content. EchoBot does an excellent job bringing content from RSS feeds and Telegram channels as can be seen in the Ajuntament de Talamanca bot, the Regional news bot and the Ràdio bot.

While the run is smooth and elegant, the maintenance is a bit cumbersome as it reads from a config file. For static accounts this is fine (they don’t update the sources often) but for a more personal RSS reader it is really not ideal, as one needs to ssh into the host and update the config for any new addition.

And this is actually the birth of the new Masto-Feed bot: including a listener for the mentions so that I can interact with it adding and updating sources on the go.

Wait what? Do you talk to your bot?

Yes, that’s the idea.

To simplify the concept, the bot understands a set of instructions and reacts on them. This way I can directly tell him to add a new source, change it or remove it, list me the sources I have or show me the available commands.

He’s even polite enough to say “Hi” when anyone mentions him without a direct command.

Give me an example!

So at this point there is an instance of the bot at my nerdy Mastodon instance. Visiting its timeline you will see that he’s publishing the content that comes from the RSS feed sources that he’s currently monitoring. And this is the account I follow then.

Using your own Fediverse account, ask him directly to list the sources he has registered:

@feeder@social.arnaus.net list

...and he’ll answer with a list of URLs and their feeds.

Tell him “hello” and he’ll answer with a welcome message:

@feeder@social.arnaus.net hello


Very nice! Which commands does he understand?

In this first version, he understands the basics to add, update list and remove feed sources. Please visit the Commands reference page in GitHub to get to know them better, but let me enumerate them here:

💬 hello

This command is an initial help command that explains itself and enumerates the available commands.

💬 list

This command lists the feeds currently registered.

💬 test

This command tests a given Site URL, by running all validations and trying to find the Feed URL (RSS, Atom, ...) that will be used to gather the content.

💬 add

This command adds a given Site URL into the records, so the content will be gathered and processed.

💬 update

This command updates an existing record's parameters. The only parameter that can't be changed is the alias, at it works as ID. All given values will overwrite the previous ones.

💬 remove

This command deletes an existing record.

And how do I install it?

This is a Mastodon bot. The very first step is to have an account in any Mastodon server for it. Then you’ll need a host anywhere to clone the repository, install the Python dependencies, run the listener and add the main program into the host's crontab.

I’ve detailed all the steps in the main README file of the GitHub repository, so it should be easy.

I’m a nerd, tell me a little more about the technicalities

First of all, this is a Python 3.9 app managed with Poetry. The readme explains how to install it from scratch.

It has 2 main entry points, one for the main application running scheduled that reads the configuration, gets the possible content from the sources, feeds a queue and publishes according to the setup, and another that stays running in the background listening the streaming Mastodon endpoint for mentions to the account, and it’s responsible for applying the direct actions and answers.

The whole application runs without databases, only file based using Yaml files as storage. The configuration files are over-commented intending to make really easy to maintain.

Some of the functionalities that I am proud of are:

  • Feed URL discovery: The bot analyses the HTML of the given Site URL searching for the Feed URL (usually in the head or in a selector in the body). This makes it very easy to add new sources comfortably.
  • The logging is dense to easy the debug, but also respects the common log levels to make it quieter. It also makes use of colors so reading logs becomes easy.
  • The Dry Run mode allows you to set up the bot but avoid publishing anything until the configuration is 100% ready
  • There is a command line tool to facilitate the testing and running of the app. From the root of the cloned repository directory try bin/mastofeed commands to see the available commands
  • The publishing of the content also has an anti-flooding feature, so all gathered content gets queued and in every scheduled run the bot publishes only one entry, avoiding filling the Local timeline in one shot.
  • Of course the images support, that get downloaded and re-uploaded and support alt-text if the source comes with.

Take a look at the README of the repository to get to know them!

Anything else?

The bot is now in its debut version v0.0.1. I am sure that it will evolve, receive fixes and new features. Let me know if you use it, and ask me anything about the installation or the running, or for any feedback you may have: I’m always at @xavi@social.arnaus.net

Masto-Feed RSS feed reader that posts updates in Mastodon API

Previous Post Next Post