From 7cec5c6878a45d799cade49dc6773d05d679bcc4 Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Thu, 5 Oct 2023 00:53:41 +0000 Subject: [PATCH] discord will no longer send message if it was empty. --- discord-if-distinct.sh | 14 ++++++++++++-- discord.sh | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/discord-if-distinct.sh b/discord-if-distinct.sh index 9f1bd2b..f28ca9f 100755 --- a/discord-if-distinct.sh +++ b/discord-if-distinct.sh @@ -8,11 +8,21 @@ if [[ $# -gt 2 ]]; then HOOK_ARG="$1" BOBBY="$2" # sed removes spaces before each line - MESSAGE=`echo "${@:3}" | sed 's/^ *//'` + MESSAGE=`echo "${@:3}" | sed 's/^ *//' | sed 's/ *$//'` else BOBBY="$1" # sed removes spaces before each line - MESSAGE=`echo "${@:2}" | sed 's/^ *//'` + MESSAGE=`echo "${@:2}" | sed 's/^ *//' | sed 's/ *$//'` + + if [[ "$MESSAGE" == "general" ]] || [[ "$MESSAGE" == "block" ]] || [[ "$MESSAGE" == "restake" ]] || [[ "$MESSAGE" == "storage" ]]; then + HOOK_ARG="$MESSAGE" + MESSAGE='' + fi +fi + +if [[ -z "$MESSAGE" ]]; then + echo 'no message provided' + exit 0 fi # sed removes blank lines from the end of the message diff --git a/discord.sh b/discord.sh index 065694f..d61c9b4 100755 --- a/discord.sh +++ b/discord.sh @@ -7,10 +7,20 @@ source "${LOCATION}/config.sh" if [[ $# -gt 1 ]]; then HOOK_ARG="$1" # sed removes spaces before each line - MESSAGE=`echo "${@:2}" | sed 's/^ *//'` + MESSAGE=`echo "${@:2}" | sed 's/^ *//' | sed 's/ *$//'` else # sed removes spaces before each line - MESSAGE=`echo "${@}" | sed 's/^ *//'` + MESSAGE=`echo "${@}" | sed 's/^ *//' | sed 's/ *$//'` + + if [[ "$MESSAGE" == "general" ]] || [[ "$MESSAGE" == "block" ]] || [[ "$MESSAGE" == "restake" ]] || [[ "$MESSAGE" == "storage" ]]; then + HOOK_ARG="$MESSAGE" + MESSAGE='' + fi +fi + +if [[ -z "$MESSAGE" ]]; then + echo 'no message provided' + exit 0 fi # if message is too long, split it, and after curl, recursively call with remainder