RSS → Mastodon Bot with Feediverse
How to create an RSS → Mastodon Bot with Feediverse
This guide is for Ubuntu/Linux Mint, other Distros will have different package names / installation commands.
1. Installation
First, install Python 3 and its pip packet manager:
Then we'll install some Python packages (these are the packages listed in Feediverse's setup.py):
We will use my Feediverse fork at github.com/gunchleoc/feediverse because I have added some features there.
EIther git clone the project or just download feediverse.py. For the rest of this guide, I will assume that you copied the file to your home directory.
Open a Terminal in your home directory. Mark feediverse.py as executable by running
2. Configuration
In order to be able to write to your Mastodon account, you will need an access token. Log into your Mastodon account and visit Settings > Development. Click on the New application button.
- Fill in the Application name, e.g. feediverse
- Application website is optional
- Leave the Redirect URI as it is
- In the Scopes section, uncheck everything except for write
- Click Submit
You will now see your new application listed. Click on it to reveal its data.
Leave the browser tab open and return to the Terminal. Call Feediverse with the command:
On first run, Feediverse will ask you for some information. Fill it out:
- What is your Mastodon Instance URL? https://name-of-your-instance.social
- Do you have your app credentials already? [y/n] y
The information from the application that you just created for your Mastodon account is next. Copy and paste it from your browser:
- What is your app's client id: Client key
- What is your client secret: Client secret
- access_token: Your access token
Now we enter the data source:
- RSS/Atom feed URL to watch: Enter the full URL. For Twitter bots, you can use https://nitter.net/your-twitter-handle/rss
- Shall already existing entries be tooted, too? [y/n] Answer as you like
You will now have a configuration file in your home directory called .feediverse. You may nee to switch on the display of hidden files to see it.
Now open the file in a text editor. It will look like this:
You can now tweak the template according to what your RSS source provides. You can also adjust the visibility. Check out the Readme for more information.
In my bots, I like to spread the load over multiple Nitter servers by adding the following lines:
For Twitter bots, the following template works well:
You can now make a dry run to test your configuration:
You can manipulate the date in the configuration file to get more posts from the past.
If you have multiple bots running, rename the configuration file and hand it to the program like this:
3. Automation
I'm using cron to fetch the RSS regularly. Execute the following command:
Now add this line to pull every 15 minutes:
If you want a different time interval, you can use crontab.cronhub.io to help you.
If you want to check whether cron has executed the program, run
This guide is for Ubuntu/Linux Mint, other Distros will have different package names / installation commands.
1. Installation
First, install Python 3 and its pip packet manager:
sudo apt install python3-pip
Then we'll install some Python packages (these are the packages listed in Feediverse's setup.py):
pip3 install beautifulsoup4 feedparser mastodon.py python-dateutil pyyaml
We will use my Feediverse fork at github.com/gunchleoc/feediverse because I have added some features there.
EIther git clone the project or just download feediverse.py. For the rest of this guide, I will assume that you copied the file to your home directory.
Open a Terminal in your home directory. Mark feediverse.py as executable by running
sudo chmod +x feediverse.py
2. Configuration
In order to be able to write to your Mastodon account, you will need an access token. Log into your Mastodon account and visit Settings > Development. Click on the New application button.
- Fill in the Application name, e.g. feediverse
- Application website is optional
- Leave the Redirect URI as it is
- In the Scopes section, uncheck everything except for write
- Click Submit
You will now see your new application listed. Click on it to reveal its data.
Leave the browser tab open and return to the Terminal. Call Feediverse with the command:
./feediverse.py
On first run, Feediverse will ask you for some information. Fill it out:
- What is your Mastodon Instance URL? https://name-of-your-instance.social
- Do you have your app credentials already? [y/n] y
The information from the application that you just created for your Mastodon account is next. Copy and paste it from your browser:
- What is your app's client id: Client key
- What is your client secret: Client secret
- access_token: Your access token
Now we enter the data source:
- RSS/Atom feed URL to watch: Enter the full URL. For Twitter bots, you can use https://nitter.net/your-twitter-handle/rss
- Shall already existing entries be tooted, too? [y/n] Answer as you like
You will now have a configuration file in your home directory called .feediverse. You may nee to switch on the display of hidden files to see it.
Now open the file in a text editor. It will look like this:
access_token: <Mastodon access token>
client_id: <Mastodon Client key>
client_secret: <Mastodon Client secret>
feeds:
- template: '{title} {url}'
url: https://nitter.net/your-twitter-handle/rss
name: feediverse
time: updated
updated: '2022-06-19T22:57:11.731269+00:00'
url: https://name-of-your-instance.social
visibility: unlisted
You can now tweak the template according to what your RSS source provides. You can also adjust the visibility. Check out the Readme for more information.
In my bots, I like to spread the load over multiple Nitter servers by adding the following lines:
rewrite_source:
- source: https://nitter.net/
targets:
- text: https://nitter.net/
- text: https://nitter.sethforprivacy.com/
- text: https://nitter.pussthecat.org/
- text: https://nitter.nixnet.services/
- text: https://nitter.namazso.eu/
- text: https://bird.trom.tf/
- text: https://nitter.grimneko.de/
- text: https://nitter.mstdn.social/
- text: https://nitter.weiler.rocks/
- text: https://tw.artemislena.eu/
- text: https://de.nttr.stream/
- text: https://nitter.privacy.com.de/
- text: https://nitter.notraxx.ch/
- text: https://nitter.lunar.icu/
- text: https://nitter.tiekoetter.com/
For Twitter bots, the following template works well:
- template: "{title} {hashtags} \u2022 Source: {link}"
You can now make a dry run to test your configuration:
feediverse --dry-run --verbose
You can manipulate the date in the configuration file to get more posts from the past.
If you have multiple bots running, rename the configuration file and hand it to the program like this:
/home/<username>/feediverse.py -c /home/<username>/.feediverse_special_bot
3. Automation
I'm using cron to fetch the RSS regularly. Execute the following command:
crontab -e
Now add this line to pull every 15 minutes:
*/15 * * * * /home/<username>/feediverse.py -c /home/<username>/.feediverse_special_bot
If you want a different time interval, you can use crontab.cronhub.io to help you.
If you want to check whether cron has executed the program, run
grep "feediverse" /var/log/syslog
teilten dies erneut