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