Skip to content

Instantly share code, notes, and snippets.

@mohemohe
Last active June 8, 2020 14:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohemohe/cac9b0de8f951295d1f3d1acd5d14e5b to your computer and use it in GitHub Desktop.
Save mohemohe/cac9b0de8f951295d1f3d1acd5d14e5b to your computer and use it in GitHub Desktop.
ユーザー作成スパムをsuspendする
#!/bin/bash
#### require
# curl
# jq
# seq
#### config
# 最後に/を含めない
MASTODON_BASE_URL=https://mstdn.plusminus.io
# 開発ページで適当に発行する read admin:read admin:write が必要
MASTODON_ADMIN_ACCESS_TOKEN=oP7TRn6EM3nrFPpqpv0kNDrr_eUceUUDf3nQaOBmw5g
# ユーザー名
BASE_USERNAME=nippon
###################################################################################################
ACCOUNTS="$(curl -s -H "Authorization: Bearer ${MASTODON_ADMIN_ACCESS_TOKEN}" "${MASTODON_BASE_URL}/api/v1/admin/accounts?username=${BASE_USERNAME}&remote=l")"
ACCOUNTS_COUNT="$(echo "${ACCOUNTS}" | jq -r 'length')"
for I in $(seq 0 $((ACCOUNTS_COUNT - 1))); do {
ACCOUNT_ID="$(echo "${ACCOUNTS}" | jq -r ".[${I}].id")"
ACCOUNT_ACCT="$(echo "${ACCOUNTS}" | jq -r ".[${I}].account.acct")"
RESULT="$(curl -X POST -s -H "Authorization: Bearer ${MASTODON_ADMIN_ACCESS_TOKEN}" -H 'content-type: application/x-www-form-urlencoded' --data 'type=suspend&report_id=&warning_preset_id=&text=suspend%20by%20deny_pom.sh&send_email_notification=false' "${MASTODON_BASE_URL}/api/v1/admin/accounts/${ACCOUNT_ID}/action" | jq '.error')"
if [[ "${RESULT}" == "null" ]]; then {
echo "suspend "${ACCOUNT_ACCT}": success" 1>&2
} else {
echo "suspend "${ACCOUNT_ACCT}": failed" 1>&2
} fi
} done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment