A Mastodon bot that uses the API from birds.bateleur.org to post a random bird of prey from Wikimedia Commons. https://birds.town/@botofprey
Go to file
Hexaitos fec31cedcc Add WIP file that saves files locally as well (json and jpg). 2024-11-13 23:20:15 +01:00
.env.example Add license, add README, improve code, add .env 2024-11-13 12:46:25 +01:00
.gitignore Add WIP file that saves files locally as well (json and jpg). 2024-11-13 23:20:15 +01:00
COPYING Add license, add README, improve code, add .env 2024-11-13 12:46:25 +01:00
Gemfile Add license, add README, improve code, add .env 2024-11-13 12:46:25 +01:00
Gemfile.lock Add license, add README, improve code, add .env 2024-11-13 12:46:25 +01:00
README.md Add license, add README, improve code, add .env 2024-11-13 12:46:25 +01:00
local.rb Add WIP file that saves files locally as well (json and jpg). 2024-11-13 23:20:15 +01:00
main.rb Add license, add README, improve code, add .env 2024-11-13 12:46:25 +01:00

README.md

Bot of Prey

Bot of Prey is a simple Mastodon / Fediverse bot that posts a random bird of prey taken from Wikimedia Commons. The bot makes an API call to my website, the source of which can also be found here.

Running the bot

You will need to have access to the bird API. You can either host it yourself or use the publically available one at birds.bateleur.org/api/random. You will also need an API token for a Fediverse instance. I have tried this with both Mastodon and GoToSocial, I do not know if any others work the same way.

You must then create a .env file within this directory and put the following lines into it:

API_KEY = "API_KEY_FOR_FEDIVERSE_INSTANCE"
INSTANCE_URL = "URL_TO_FEDIVERSE_INSTANCE"
BIRD_API_URL = "URL_TO_BIRD_API"

You can also copy the included .env.example to .env and place the correct values into the variables.

If you would then like for the bot to run every x hours, I would recommend either a systemd service or a simple cron job. You can also save Bot of Preys output to a file for logging. An example cron job (posts every six hours) could be as follows:

0 */6 * * * /home/user/bot_of_prey/main.rb >> /home/user/bot_of_prey.log 2>&1

You will also need to install all the requires gems. Make sure you have Bundler installed or install it with gem install bundler if needed. Afterwards, run the bundle install command, this should install all the required gems.