From b24e445b5aa1fa96295393a1b3e85a1bda3757bd Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Mon, 13 Nov 2023 17:36:44 -0500 Subject: [PATCH] discord will now use title over distinct name, when given both. --- crons/storage-alert.sh | 4 +++- discord.sh | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crons/storage-alert.sh b/crons/storage-alert.sh index 8e5106e..965ff9f 100755 --- a/crons/storage-alert.sh +++ b/crons/storage-alert.sh @@ -27,9 +27,11 @@ for index in "${!STORAGE_ALERT[@]}"; do fi done +title="Storage Update" if [[ "$warn" = true ]]; then purple="purple" + title="Storage Alert" fi printf "%s\n" "${messages[@]}" -printf "%s\n" "${messages[@]}" | "$scriptRoot/discord.sh" -c "${purple-blue}" -d "Storage Alert" +printf "%s\n" "${messages[@]}" | "$scriptRoot/discord.sh" -c "${purple-blue}" -d "Storage Alert" -t "$title" diff --git a/discord.sh b/discord.sh index 5154796..0e3c6cb 100755 --- a/discord.sh +++ b/discord.sh @@ -19,7 +19,7 @@ colors=( ) print_usage() { - echo "Usage: $0 [-h hook-url], [-c color], [-d [distinct-name] | -t title] (message... | -z | < file.msg)" + echo "Usage: $0 [-h hook-url], [-c color], [-d [distinct-name]] [-t title] (message... | -z | < file.msg)" } # handle all arguments provided @@ -164,7 +164,7 @@ if [[ -n "$color" ]]; then content="$content, \"color\": ${colors[$color]}" fi if [[ -n "$distinct" ]] || [[ -n "$title" ]]; then - content="$content, \"title\": $(echo "${distinct-$title}" | jq -aRs .)" + content="$content, \"title\": $(echo "${title-$distinct}" | jq -aRs .)" fi content="$content}]}" @@ -177,7 +177,7 @@ if [ -n "$extra" ]; then args=("-h" "$hookUrl") # when we call again, we convert distinct into a title if [[ -n "$distinct" ]] || [[ -n "$title" ]]; then - args+=("-t" "${distinct-$title}") + args+=("-t" "${title-$distinct}") fi if [[ -n "$color" ]]; then args+=("-c" "$color")