3.5 KiB
Mastodon Welcome Bot
This is a Mastodon bot that sends out a welcome toot (DM) to new users, brought to you by jawns.club.
Because Mastodon's API doesn't currently have a route for getting an array of accounts in an instance,
this bot queries the followers of an account and pages through for any have been created in the
last x days (see configuration below). This means that you'll want ACCOUNT_ID
to be an account
that is auto-followed by all new users.
Installation/Development
Requires:
- python3
- pip
Steps with Docker
git clone https://git.lattuga.net/ekardnam/mastodon-welcome-bot
cd mastodon-welcome-bot
cp .env.dist .env
- Fill in the env vars as required in the
.env
file (see definitions below) docker build -t . mastodon-welcome-message
- Run the app with
docker run -d mastodon-welcome-bot
Steps without Docker
git clone https://git.lattuga.net/ekardnam/mastodon-welcome-bot
cd mastodon-welcome-bot
virtualenv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.dist .env
- Fill in the env vars as required in the
.env
file (see definitions below) python3 run.py
Environment Variables
The application uses the following environment variables.
name | required | default | description |
---|---|---|---|
ACCESS_TOKEN | yes | n/a | the access token for the Mastodon account that you want the toots to come from |
DAYS_SINCE | no | 1 | how many days back of new users you want to go |
INSTANCE_BASE_URL | yes | n/a | the base url of the Mastodon instance you want to run this for (ex: "https://jawns.club") |
TOOT_TEMPLATE | yes | n/a | the template of the toot that you want to send out. Jinja2 syntax is used here and you can use any of the Account variables |
DEBUG | no | false | boolean (either "true" or "false") for debug mode. If true, won't actually send out the toots, will just print the message for each to stdout |
ACCOUNT_ID | yes | n/a | the account ID that you want to pull followers from |
Example Welcome Toot Template
This can be copy/pasted into the TOOT_TEMPLATE environment variable. Note that \n\n
denotes a line break, as the entire var must remain on one line. Total characters cannot exceed 500, including those line breaks.
@{{ username }} Hi, and welcome to jawns.club!\n\nHere are a few handy tips:\n\n- This is a great (non-technical) intro to the Mastodon platform: https://bit.ly/2zk8t8c\n\n- Our "local" timeline is the real magic of jawns.club: https://bit.ly/2PDYyl3\n\n- Some less obvious ways to find people: https://bit.ly/2MMN2Xz\n\n- Install a free mobile app! Many people like Tootdon (iOS and Android).\n\n- Asking questions is okay and encouraged! We (@mods) are here to help.\n\nEnjoy :)