fedi-imagebot/README.md

36 lines
1.8 KiB
Markdown

# Mastodon Image Bot
This is a small program that posts an image from a given folder every time you call it.
## Setup
- [Install deno](https://deno.land/manual@v1.30.1/getting_started/installation)
- 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 `write:media` and `write:posts`.
- 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`.
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.
## Usage
You can call it like so:
``` bash
# 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.