From b168d862d91fa82936abe8930c64804184a86e54 Mon Sep 17 00:00:00 2001 From: Boris Paing Date: Thu, 19 Mar 2020 10:55:02 +0100 Subject: [PATCH] Fixed default value of amount per like + fix output (duplicated links to post) --- process-likes-g1tx.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/process-likes-g1tx.sh b/process-likes-g1tx.sh index 64d4990..ad97efc 100755 --- a/process-likes-g1tx.sh +++ b/process-likes-g1tx.sh @@ -16,7 +16,7 @@ g1priv=$(cat ~/.ssb/secret.dunikey | grep "sec" | cut -d ' ' -f 2) # SSB pubkey ssbpub=$(cat ~/.ssb/secret | grep public\" | cut -d ' ' -f 4 | cut -d '.' -f 1 | sed s/\"//g) -amountPerLikeInUD="0.05" +defaultAmountPerLikeInUD="0.05" bold=$(tput bold) normal=$(tput sgr0) ssbMaxSize=8192 @@ -106,7 +106,7 @@ fi printf "You have ${bold}%s UDĞ1${normal} on your Duniter Ğ1 wallet.\n\n" "$balance" sleep 2 printf "Want to show your appreciation of your fellow butts' posts while helping spreading awareness about libre currencies?\n\n" -sleep 2 +sleep 3 # BEGIN timestamp computation @@ -238,21 +238,28 @@ fi printf "You gave ${bold}%s❤${normal} during the past %s days.\n\n" "$totalLikesGiven" "$days_from_last_tx" sleep 2 -printf "How many UDĞ1 do you want to send per each like you gave? (default is ${bold}%s UDĞ1${normal}) " "$amountPerLikeInUD" -read a -echo "" - tx_are_possible=0 while [[ $tx_are_possible -eq 0 ]] do - - amountPerLikeInUD=$a + + printf "How many UDĞ1 do you want to send per each like you gave? (default is ${bold}%s UDĞ1${normal}) " "$defaultAmountPerLikeInUD" + read a + printf "\n" + + if [[ -z $a ]] + then + amountPerLikeInUD=$defaultAmountPerLikeInUD + else + amountPerLikeInUD=$a + fi amountGiven=$(echo "$totalLikesGiven * $amountPerLikeInUD" | bc -l) tx_are_possible=$(( $(echo "$amountGiven <= $balance" | bc -l) )) - + + sleep 1 + if [[ $tx_are_possible -ne 0 ]] ; then newBalance=$(echo "$balance - $amountGiven" | bc -l) printf "${bold}%s UDĞ1${normal} will be given.\n\n" "$amountGiven" @@ -271,9 +278,6 @@ do sleep 1 printf "Maximum amount per like possible: ${bold}%s UDĞ1${normal}\n\n" "$maxAmountPerLike" sleep 1 - printf "How many UDĞ1 do you want to send per each like you gave? " - read a - echo "" fi done @@ -327,7 +331,6 @@ do fi newLine+=$(printf " %s❤" "${likesNbPerPost[$post_id]}") - newLine+=$(printf "[%s](%s)" "${post_id:0:9}" "$post_id") newLine+=$(printf "[\`%s\`](%s)" "${excerpts[$post_id]}" "$post_id") done @@ -420,7 +423,7 @@ fi sleep 2 -printf "Customize it to your needs to thank you fellow butts publicly and help spread awareness about libre currencies :-)\n\n" +printf "Customize it to your needs to thank your fellow butts publicly and help spread awareness about libre currencies :-)\n\n" sleep 3