Fixed default value of amount per like + fix output (duplicated links to post)

This commit is contained in:
Boris Paing 2020-03-19 10:55:02 +01:00
parent ba28469412
commit b168d862d9
1 changed files with 17 additions and 14 deletions

View File

@ -16,7 +16,7 @@ g1priv=$(cat ~/.ssb/secret.dunikey | grep "sec" | cut -d ' ' -f 2)
# SSB pubkey # SSB pubkey
ssbpub=$(cat ~/.ssb/secret | grep public\" | cut -d ' ' -f 4 | cut -d '.' -f 1 | sed s/\"//g) 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) bold=$(tput bold)
normal=$(tput sgr0) normal=$(tput sgr0)
ssbMaxSize=8192 ssbMaxSize=8192
@ -106,7 +106,7 @@ fi
printf "You have ${bold}%s UDĞ1${normal} on your Duniter Ğ1 wallet.\n\n" "$balance" printf "You have ${bold}%s UDĞ1${normal} on your Duniter Ğ1 wallet.\n\n" "$balance"
sleep 2 sleep 2
printf "Want to show your appreciation of your fellow butts' posts while helping spreading awareness about libre currencies?\n\n" 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 # 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" printf "You gave ${bold}%s❤${normal} during the past %s days.\n\n" "$totalLikesGiven" "$days_from_last_tx"
sleep 2 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 tx_are_possible=0
while [[ $tx_are_possible -eq 0 ]] while [[ $tx_are_possible -eq 0 ]]
do 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) amountGiven=$(echo "$totalLikesGiven * $amountPerLikeInUD" | bc -l)
tx_are_possible=$(( $(echo "$amountGiven <= $balance" | bc -l) )) tx_are_possible=$(( $(echo "$amountGiven <= $balance" | bc -l) ))
sleep 1
if [[ $tx_are_possible -ne 0 ]] ; then if [[ $tx_are_possible -ne 0 ]] ; then
newBalance=$(echo "$balance - $amountGiven" | bc -l) newBalance=$(echo "$balance - $amountGiven" | bc -l)
printf "${bold}%s UDĞ1${normal} will be given.\n\n" "$amountGiven" printf "${bold}%s UDĞ1${normal} will be given.\n\n" "$amountGiven"
@ -271,9 +278,6 @@ do
sleep 1 sleep 1
printf "Maximum amount per like possible: ${bold}%s UDĞ1${normal}\n\n" "$maxAmountPerLike" printf "Maximum amount per like possible: ${bold}%s UDĞ1${normal}\n\n" "$maxAmountPerLike"
sleep 1 sleep 1
printf "How many UDĞ1 do you want to send per each like you gave? "
read a
echo ""
fi fi
done done
@ -327,7 +331,6 @@ do
fi fi
newLine+=$(printf " %s❤" "${likesNbPerPost[$post_id]}") 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") newLine+=$(printf "[\`%s\`](%s)" "${excerpts[$post_id]}" "$post_id")
done done
@ -420,7 +423,7 @@ fi
sleep 2 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 sleep 3