Read RSS feeds on Mastodon

       578 words, 3 minutes

My daily routine when it comes to staying informed of what happens in the world is to read RSS feeds from various sources. To do so, I created an account on Feedly and use their iOS App. But I noticed that I often “forget” to launch the app ; whereas I check Mastodon several times a day. So I decided to configure a Bot that will parse my RSS feeds and publish them on my Masto Home page.

Create a Bot account

A Bot account is a “normal” Mastodon account. Depending on your instance policy, it may be allowed or not. The instance I live in accepts such account as soon as it behave kindly regarding API calls and privacy settings. But I was also pointed at botsin.space ; a Mastodon instance dedicated to hosting Bots.

I created an account on https://botsin.space/ and configured the account to indicate it was a Bot ; in the Profile section.

In the Developpement section, I also created an Application token. It will be used to clean old toots automatically.

Install, configure and run the Bot software

On one of my OpenBSD server instance, I installed feed2toot . It is quite straight forward as it runs using Python:

# pkg_add py3-pip

$ pip3.8 install feed2toot

The software needs to authenticate itself on the Mastodon account. Simply run the register command:

$ mkdir ~/.config/feed2toot
$ chmod 0700 ~/.config/feed2toot
$ cd ~/.config/feed2toot
$ ~/.local/bin/register_feed2toot_app

The authentication process will leave files on your disk. So store them somewhere safe. I write all the stuff in ~/.config/feed2toot.

To configure visibility to private and tell the software what to parse, edit the ini file and the feed list file:

[EDIT 2022-04-19 Use full pathnames to avoid time data does not match format errors ]

$ cat feed2toot.ini
[mastodon]
instance_url=https://botsin.space
user_credentials=feed2toot_usercred.txt
client_credentials=feed2toot_clientcred.txt
toot_visibility=private

[cache]
cachefile=~/.config/feed2toot/cache.db
cache_limit=10000

[lock]
lock_file=~/.config/feed2toot/feed2toot.lock
lock_timeout=120

[rss]
uri_list=~/.config/feed2toot/rsslist.txt
toot={title} {link}

[hashtaglist]
several_words_hashtags_list=hashtags.txt

$ cat rsslist.txt
http://feeds.feedburner.com/ItsFoss
http://undeadly.org/cgi?action=rss
https://www.zdnet.fr/feeds/rss/
http://www.numerama.com/rss/news.rss
https://dataswamp.org/~solene/rss.xml
https://jcs.org/rss/writings
https://nextcloud.com/blogfeed/
https://www.tumfatig.net/index.xml

Full documentation is available here

A dry-run is possible using the followinf command:

$ ~/.local/bin/feed2toot -c ~/.config/feed2toot/feed2toot.ini -l 5 -dn

If it runs OK, crontab will periodically start the process:

$ cat /home/scripts/feed2toot
#!/bin/sh

cd $HOME/.config/feed2toot
$HOME/.local/bin/feed2toot -c feed2toot.ini \
  --syslog WARN 1>/dev/null 2>&1

exit 0
#EOF

$ crontab -l
*/5 * * * * -s /home/scripts/feed2toot

Connecting to the account will confirm that the feeds items are being tooted.

If faced a weird issue when feed2toot will work when started from the CLI but not via cron. It turned out something weird happens if you don’t run feed2toot from the directory when the credential files are. This is why I ended up writing and running it using the shell script.

Clean the news

I don’t need to access old news. So the toots will be deleted after 7 days. This will be done with another software ; that can be installed from OpenBSD packages:

# pkg_add ephemetoot

The configuration will be stored in feed2toot directory. And the cleaning will happen once a day.

$ cat ~/.config/feed2toot/ephemetoot.yaml
-
  access_token:  <secret token you generated above>
  username: <your bot account>
  base_url: botsin.space
  days_to_keep: 7
  keep_pinned: true

$ crontab -l
0~15 1 * * * /usr/local/bin/ephemetoot             \
  --config $HOME/.config/feed2toot/ephemetoot.yaml \
  --pace

Read the news

The Bot publications are set private. This means only Followers can view them. And boost are not possible. To view the toot, look for the Bot account and follow it. All the toots will start appearing in your Mastodon Home section.