This is a small Mastodon bot, running on GitHub actions, that re-posts any ‘toots’ by anybody from a list of allowed accounts that mention one configurable account.
Retooter is written in Python and depends on the Mastodon.py package to interact with the server-side API.
-
Enable actions for this repository Limit the actions to ‘Allow [repo-name], and select non-[repo-name], actions and reusable workflows’, and check the ‘Allow actions created by GitHub’ box
-
Define some action variables:
RETOOTER_ACCOUNT_NAME
: set to the account that should retoot when it is mentioned. Omit the leading@
, be sure to include the domain name (e.g.,digigeolab@mastodon.online
)RETOOTER_ALLOWED_ACCOUNTS
: a list of accounts, one per line, whose posts are re-tooted if they mentionRETOOTER_ACCOUNT_NAME
- (optional)
RETOOTER_API_BASE_URL
: if the API base url of the account’s instance differs fromhttps://
+ the domain part of theRETOOTER_ACCOUNT_NAME
(e.g.,https://mastodon.online
), define it manually, here - (option)
RETOOTER_DRY_RUN
: if this variable is set toTRUE
, retooter will not actually re-post any messages, but rather print them to stdout (which can be read from the log output of a GitHub action)
-
Create a new set of authentication keys. This is a multi-step process that includes running the script once locally, or in an interactive environment, in which you can copy and paste text from and to the script
-
Install this project locally, e.g., in a virtual environment
pip install git+https://github.com/DigitalGeographyLab/retooter.git
-
Locally define the
RETOOTER_ACCOUNT_NAME
(and possiblyRETOOTER_API_BASE_URL
( you set above as an environment variable: if you use BASH or a similar shell, useexport
:export RETOOTER_ACCOUNT_NAME="digigeolab@mastodon.online" export RETOOTER_API_BASE_URL="https://mastodon.online"
-
Run the package:
python -m retooter
-
The script will prompt you to open a web address (on the account‘s instance), login and authenticate there, and copy and paste the response back to the script.
-
Then, it will print three variables:
CLIENT_ID
,CLIENT_SECRET
, andACCESS_TOKEN
. Copy these and define them as GitHub action secrets.
-