Fediverse Image Bot
This is a small program that posts image from a given folder to a Mastodon or Pixelfed server every time you call it. It aims to be easy to use and easy to set up. It has been tested and works with Mastodon 4.x and Pixelfed 0.11.x. Usage:
deno run -A main.ts [folder]
- Install deno
- Create an account on a bot-friendly mastodon instance and obtain an access token (see below)
- Create a folder somewhere on your computer
- Fill the folder with images you'd like to post
Obtaining an access token
An access token is required for this bot to log into an account and act on behalf of it, to upload images and create new posts. To set it up, go to the "New application" page on your mastodon instance (for example https://botsin.space/settings/applications/new).
- Give your bot a name
- Scroll down to "Scopes"; you can uncheck everything and check only
- Click submit. You will be redirected to https://botsin.space/settings/applications
- Click on the application you just created
- Copy the value in the row "your access token". It will be a sequence of letters and numbers that looks like
K3g57Yv4-wsg8I78VzegJIowGr-AS1HWmXO2tD9MmPu(for Pixelfed servers this will be longer)
Anybody with this access token can use the account to upload media and write posts, so take care to not publish it anywhere where a lot of people have access to it.
You can call it like so:
# for example MASTODON_INSTANCE_URL=https://botsin.space export MASTODON_INSTANCE_URL=... # for example MASTODON_ACCESS_TOKEN=K3g57Yv4-wsg8I78VzegJIowGr-AS1HWmXO2tD9MmPu export MASTODON_ACCESS_TOKEN=... deno run --allow-env --allow-net --allow-write --allow-read main.ts [folder]
It is best if you specify
folder as an
/absolute/path/like/so. You can also a
folder when calling the script, it will try to look for a
posts directory inside the folder where the script is located.