discord will now use title over distinct name, when given both.

This commit is contained in:
2023-11-13 17:36:44 -05:00
parent e7c751826d
commit b24e445b5a
2 changed files with 6 additions and 4 deletions
+3 -1
View File
@@ -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"
+3 -3
View File
@@ -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")