#!/bin/sh set -eu Instance=https://mstdn.isometry.group if ! test -f access_token; then echo 'No access_token!' >&2 exit 1 fi access_token=$(cat access_token) account_id=$( curl -Ss \ -H "Authorization: Bearer ${access_token}" \ ${Instance}/api/v1/accounts/verify_credentials | jq -r .id ) # XXX: no pagination because I don't expect this to ever have over 80 followers followers=$( curl -Ss \ -H "Authorization: Bearer ${access_token}" \ "${Instance}/api/v1/accounts/${account_id}/followers?limit=80" | jq -r 'map(select(.acct | contains("@") | not)) | .[].id' ) for follower_id in $followers; do account=$( curl -Ss \ -H "Authorization: Bearer ${access_token}" \ ${Instance}/api/v1/accounts/${follower_id} ) username=$(printf '%s' "${account}" | jq -r .username) pronouns=$( printf '%s' "${account}" | jq -r ' .fields | map(select(.name | test("^pronouns?[?]?$"; "i"))) | .[].value ' ) if ! test -f $follower_id; then printf '%s' "${pronouns}" >$follower_id continue fi old_pronouns=$(cat $follower_id) if [ "${pronouns}" != "${old_pronouns}" ]; then curl -Ss -X POST \ -H "Authorization: Bearer ${access_token}" \ -F visibility=unlisted \ --form-string \ "status=@${username} has changed pronouns to: ${pronouns}" \ ${Instance}/api/v1/statuses >/dev/null printf '%s' "${pronouns}" >$follower_id fi done