Last active
March 23, 2023 18:29
-
-
Save nothub/3e55e70ae53468e949d4491c77e4c51f to your computer and use it in GitHub Desktop.
fetch and bundle factorio community banlists
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
#!/usr/bin/env bash | |
set -euo pipefail | |
output=${1:-"config/server-banlist.json"} | |
dl() { | |
local arr | |
arr=("$(curl --silent --show-error --fail --location "${1}" | jq "${2}")") | |
echo "${arr[@]}" | |
printf "fetched %4s bans from %s\n" "$(echo "${arr[@]}" | wc -l)" "${1}" >&2 | |
} | |
declare -a bans | |
if [[ -r "bans.json" ]]; then | |
# shellcheck disable=SC2002,SC2207 | |
bans+=($(cat "bans.json" | jq '.[].username')) | |
printf "loaded %5s bans from bans.json\n" "${#bans[@]}" >&2 | |
fi | |
bans+=("$(dl "https://getcomfy.eu/api/v1/ban/get/all" '.[][].username')") | |
bans+=("$(dl "https://m45sci.xyz:8443/server-banlist.json" '.[].username')") | |
bans+=("$(dl "https://m45sci.xyz/old-server-banlist.json" '.[].username')") | |
mkdir -vp "$(dirname "${output}")" | |
echo "${bans[@]}" | sort -u | jq -s >"${output}" | |
printf "file saved to: %s\n" "${output}" >&2 |
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
[ | |
{ | |
"username": "0000000000000000", | |
"reason": "test" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment