Last active
June 8, 2020 14:20
-
-
Save mohemohe/cac9b0de8f951295d1f3d1acd5d14e5b to your computer and use it in GitHub Desktop.
ユーザー作成スパムをsuspendする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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