Now add the spinnable part of the text in parens at the end.

This commit is contained in:
Storm Dragon 2020-08-03 19:09:13 -04:00
parent ae2088b301
commit 96c4bf8c24

View File

@ -5,20 +5,23 @@ shift
chan="$1"
shift
message="${*}"
spinPlus="${message##*(}"
spinPlus="${spinPlus%)}"
message="${message% (*)}"
spin="${message##*[[:space:]]}"
if [[ "$spinPlus" == "$message" ]]; then
if [[ "$spin" =~ [aeiou].$ ]]; then
spinPlus="${spin: -1}${spin: -1}"
else
spinPlus="${spin: -2}"
fi
fi
message="${message} $spin $spin $spin "
spinCount=$((RANDOM % 7 + 7))
if [[ "$spin" =~ [aeiou].$ ]]; then
for i in $(seq $spinCount) ; do
spin+="${spin: -1}${spin: -1}"
message+="$spin "
done
else
for i in $(seq $spinCount) ; do
spin+="${spin: -2}"
message+="$spin "
for i in $(seq $spinCount) ; do
spin+="$spinPlus"
message+="$spin "
done
fi
msg "$chan" "$message"