Sometimes the best things are just the simple things.
This repository contains a simple RSS bot for Mastodon, implemented in C# using .NET, works in linux/windows/macos. The bot is designed to fetch RSS feeds and post articles to a Mastodon instance.
All the interface is a very simple command-line, and the database is just a local sqlite file. This is the code behind of @msftdevblogs, and it is scheduled in a very small random linux box with a crontab.
- Fetch and process RSS feeds from specified URLs.
- Post articles to a Mastodon instance.
- Configurable options for access token, Mastodon host, RSS URL, and limit on posts to publish.
Download a precompiled binaries from the releases page, decompress it, and optionally add the pat to your system variables.
Clone the repository to your local machine:
git clone https://github.com/mahomedalid/mastodon-rss-dotnet-bot.git
Navigate to the repository directory and build the project:
cd mastodon-rss-dotnet-bot
dotnet build
Pull the image
docker pull ghcr.io/mahomedalid/fediverse/mastodon-rss-bot:latest
Start the container specifiying the env variables for feeds (comma separated), instance of the bot and access token, ex.
docker run \
-e "RSSBOT_FEEDS=https://www.youtube.com/feeds/videos.xml?channel_id=UCVvpATOqqanu2jD5-ttRYLQ;https://devblogs.microsoft.com/dotnet/category/csharp/feed/" \
-e "RSSBOT_INSTANCEHOST=dotnet.social" \
-e "RSSBOT_ACCESSTOKEN=<myaccesstoken>"
-d rssbot
The default image is configured to do one post per hour, and two fetch posts daily. If you want to force the pull:
docker exec -it <containerid> bash
root@containerid:/opt/rssbot# ./fetch_env.sh
If you want to test the post:
docker exec -it <containerid> bash
root@containerid:/opt/rssbot# ./post.sh
Run the bot using the CLI interface. Here's an example command to fetch and process an RSS endpoint:
dotnet run fetch-rss --rssUrl <RSS_URL>
Replace <RSS_URL>
with the URL of the RSS feed you want to fetch.
I have added a util script to fetch from multiple sources in a simple txt file, see scripts/fetcher.sh.
To post articles to Mastodon, use the following command:
dotnet run post --accessToken <ACCESS_TOKEN> --host <MASTODON_HOST> --top <NUMBER_OF_POSTS>
Replace <ACCESS_TOKEN>
with your Mastodon access token, <MASTODON_HOST>
with the Mastodon instance host, and <NUMBER_OF_POSTS>
with the number of posts to publish.
Bunch of TODOS to fix, look into the code, including templating, configurable hashtags, skip old posts, tag authors, etc.
Contributions are welcome! If you encounter any bugs or have suggestions for improvements, please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.