diff --git a/mc-ntfy-notify.v1.sh b/mc-ntfy-notify.v1.sh index fbb5d62..fcd1c5a 100644 --- a/mc-ntfy-notify.v1.sh +++ b/mc-ntfy-notify.v1.sh @@ -4,9 +4,9 @@ # Autor: Patrick Asmus # Web: https://www.cleveradmin.de # Repository: https://git.techniverse.net/scriptos/minecraft-ntfy-notify -# Version: 1.1 +# Version: 1.2 # Datum: 18.09.2025 -# Modifikation: ANSI/MC-Farbcodes strippen, robustes Schreiben der Playerliste +# Modifikation: Spielername in Meldungen in Anführungszeichen gesetzt; Sanitizing beibehalten ##################################################### set -euo pipefail @@ -69,7 +69,6 @@ ensure_state() { # Strippt ANSI-Escape-Sequenzen, MC-Farbcodes (§x), CR und Steuerzeichen sanitize() { - # stdin -> stdout sed -E $'s/\x1B\\[[0-9;]*[A-Za-z]//g' \ | sed -E 's/§[0-9A-FK-ORa-fk-or]//g' \ | tr -d '\r' \ @@ -83,14 +82,11 @@ get_players() { fi dbg "RAW: $out" - # Normalisieren & Farbcodes raus out="$(printf '%s' "$out" | sanitize)" - # Erwartete Muster: # "There are 0 of a max of 20 players online" # "There are 2 of a max of 20 players online: Alice, Bob" if ! grep -q "players online:" <<<"$out"; then - # Kein Spieler gelistet, aber kein Fehler return 0 fi @@ -100,7 +96,6 @@ get_players() { return 0 fi - # Namen splitten, trimmen, doppelte raus, sortiert liefern printf '%s\n' "$names" \ | tr ',' '\n' \ | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' \ @@ -150,7 +145,7 @@ while :; do while IFS= read -r name; do [[ -z "$name" ]] && continue ntfy_notify "${NTFY_TITLE_PREFIX}: Join" \ - "Player ${name} ist beigetreten." \ + "Player \"${name}\" ist beigetreten." \ "${NTFY_TAGS_BASE},join" "$NTFY_PRIORITY_JOIN" || true done <<<"$joined" fi @@ -158,7 +153,7 @@ while :; do while IFS= read -r name; do [[ -z "$name" ]] && continue ntfy_notify "${NTFY_TITLE_PREFIX}: Leave" \ - "Player ${name} hat den Server verlassen." \ + "Player \"${name}\" hat den Server verlassen." \ "${NTFY_TAGS_BASE},leave" "$NTFY_PRIORITY_LEAVE" || true done <<<"$left" fi