Skip to content

Instantly share code, notes, and snippets.

@nothub
Last active March 23, 2023 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nothub/3e55e70ae53468e949d4491c77e4c51f to your computer and use it in GitHub Desktop.
Save nothub/3e55e70ae53468e949d4491c77e4c51f to your computer and use it in GitHub Desktop.
fetch and bundle factorio community banlists
#!/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
[
{
"username": "0000000000000000",
"reason": "test"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment