Send LOVE now (1 DUG1 = 100 LOVE)

This commit is contained in:
qo-op 2020-04-29 22:34:05 +02:00
parent 04c6b7d2c4
commit 2206ed5378
1 changed files with 15 additions and 15 deletions

30
tip.sh
View File

@ -26,7 +26,7 @@ debugMsgMode=0
# If you don't want to wait # If you don't want to wait
readable=1 readable=1
minimumAmountPerLikeInUD="0.1" minimumAmountPerLikeInLOVE="10"
############################################################################################ ############################################################################################
@ -129,7 +129,7 @@ else
exit 1 exit 1
fi fi
printf "You have ${bold}%s LOVE${normal} on your Duniter Ğ1 wallet.\n\n" "$balance" printf "You have ${bold}%s LOVE${normal} on your Duniter Ğ1 wallet.\n\n" "$((balance * 100))"
if [[ $readable -eq 1 ]]; then sleep 2; fi if [[ $readable -eq 1 ]]; then sleep 2; fi
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"
if [[ $readable -eq 1 ]]; then sleep 3; fi if [[ $readable -eq 1 ]]; then sleep 3; fi
@ -274,22 +274,22 @@ tx_are_possible=0
while [[ $tx_are_possible -eq 0 ]] while [[ $tx_are_possible -eq 0 ]]
do do
printf "How many LOVE do you want to send per each like you gave? (minimum is ${bold}%s LOVE${normal}) " "$minimumAmountPerLikeInUD" printf "How many LOVE do you want to send per each like you gave? (minimum is ${bold}%s LOVE${normal}) " "$((minimumAmountPerLikeInLOVE))"
read a read a
printf "\n" printf "\n"
if [[ -z $a ]] if [[ -z $a ]]
then then
amountPerLikeInUD=$minimumAmountPerLikeInUD amountPerLikeInUD=$(bc -l <<< "scale=2; $minimumAmountPerLikeInLOVE / 100")
else else
amountPerLikeInUD=$a amountPerLikeInUD=$(bc -l <<< "scale=2; $a / 100")
fi fi
amountGiven=$(echo "$totalLikesGiven * $amountPerLikeInUD" | bc -l) amountGiven=$(echo "$totalLikesGiven * $amountPerLikeInUD" | bc -l)
has_enough_money=$(( $(echo "$amountGiven <= $balance" | bc -l) )) has_enough_money=$(( $(echo "$amountGiven <= $balance" | bc -l) ))
amountPerLike_is_enough=$(( $(echo "$amountPerLikeInUD >= $minimumAmountPerLikeInUD" | bc -l) )) amountPerLike_is_enough=$(( $(echo "$amountPerLikeInUD >= $minimumAmountPerLikeInLOVE" | bc -l) ))
tx_are_possible=$(( $has_enough_money && $amountPerLike_is_enough )) tx_are_possible=$(( $has_enough_money && $amountPerLike_is_enough ))
if [[ $readable -eq 1 ]]; then sleep 1; fi if [[ $readable -eq 1 ]]; then sleep 1; fi
@ -300,11 +300,11 @@ do
printf "You don't have enough LOVE to send all transactions.\n\n" printf "You don't have enough LOVE to send all transactions.\n\n"
if [[ $readable -eq 1 ]]; then sleep 1; fi if [[ $readable -eq 1 ]]; then sleep 1; fi
printf "${bold}%s LOVE${normal} are needed.\n\n" "$amountGiven" printf "${bold}%s LOVE${normal} are needed.\n\n" "$((amountGiven * 100))"
if [[ $readable -eq 1 ]]; then sleep 1; fi if [[ $readable -eq 1 ]]; then sleep 1; fi
elif [[ $amountPerLike_is_enough -eq 0 ]] ; then elif [[ $amountPerLike_is_enough -eq 0 ]] ; then
printf "Minimum amount per like is %s LOVE.\n\n" $minimumAmountPerLikeInUD printf "Minimum amount per like is %s LOVE.\n\n" $minimumAmountPerLikeInLOVE
if [[ $readable -eq 1 ]]; then sleep 1; fi if [[ $readable -eq 1 ]]; then sleep 1; fi
fi fi
@ -312,13 +312,13 @@ do
printf "Try again with a different amount per like.\n\n" printf "Try again with a different amount per like.\n\n"
maxAmountPerLike=$(awk -vp=$balance -vq=$totalLikesGiven 'BEGIN{printf "%.2f" ,p / q}') maxAmountPerLike=$(awk -vp=$balance -vq=$totalLikesGiven 'BEGIN{printf "%.2f" ,p / q}')
if [[ $readable -eq 1 ]]; then sleep 1; fi if [[ $readable -eq 1 ]]; then sleep 1; fi
printf "Maximum amount per like possible: ${bold}%s LOVE${normal}\n\n" "$maxAmountPerLike" printf "Maximum amount per like possible: ${bold}%s LOVE${normal}\n\n" "$((maxAmountPerLike * 100))"
if [[ $readable -eq 1 ]]; then sleep 1; fi if [[ $readable -eq 1 ]]; then sleep 1; fi
else else
newBalance=$(echo "$balance - $amountGiven" | bc -l) newBalance=$(echo "$balance - $amountGiven" | bc -l)
printf "${bold}%s LOVE${normal} will be given.\n\n" "$amountGiven" printf "${bold}%s LOVE${normal} will be given.\n\n" "$((amountGiven * 100))"
if [[ $readable -eq 1 ]]; then sleep 1; fi if [[ $readable -eq 1 ]]; then sleep 1; fi
printf "After sending transactions, your new balance will be ${bold}%s LOVE${normal}\n\n" "$newBalance" printf "After sending transactions, your new balance will be ${bold}%s LOVE${normal}\n\n" "$((newBalance * 100))"
if [[ $readable -eq 1 ]]; then sleep 1; fi if [[ $readable -eq 1 ]]; then sleep 1; fi
printf "Press ENTER to continue: " && read printf "Press ENTER to continue: " && read
printf "\n" printf "\n"
@ -410,7 +410,7 @@ do
done done
newLine+=$(printf "| %s LOVE " "$tipAmount") newLine+=$(printf "| %s LOVE " "$((tipAmount * 100))")
newLine+="|\n" newLine+="|\n"
@ -451,7 +451,7 @@ do
#printf '%s\n' "silkaj -af --file ~/.ssb/secret.dunikey tx --output $g1_author --amountUD $tipAmount --comment "Thx for your cool posts on ScuttleButt" #printf '%s\n' "silkaj -af --file ~/.ssb/secret.dunikey tx --output $g1_author --amountUD $tipAmount --comment "Thx for your cool posts on ScuttleButt"
silkaj -p "$duniter_server" -af --file ~/.ssb/secret.dunikey tx --output $g1_author --amountUD $tipAmount --comment "Thx for your cool posts on ScuttleButt" -y 2>/dev/null silkaj -p "$duniter_server" -af --file ~/.ssb/secret.dunikey tx --output $g1_author --amountUD $tipAmount --comment "Thx for your cool posts on ScuttleButt" -y 2>/dev/null
printf "\n${bold}%s LOVE${normal} sent to %s!\n\n" "$tipAmount" "$author_name" printf "\n${bold}%s LOVE${normal} sent to %s!\n\n" "$((tipAmount * 100))" "$author_name"
fi fi
(( authorNum++ )) (( authorNum++ ))
@ -473,7 +473,7 @@ then
fi fi
fi fi
printf "\n%s LOVE sent to %s butts!\n\n" "$amountGiven" "${#likesNbPerAuthor[@]}" printf "\n%s LOVE sent to %s butts!\n\n" "$((amountGiven * 100))" "${#likesNbPerAuthor[@]}"
# Let's publicly thank everyone! # Let's publicly thank everyone!
#echo -e "${tyPosts[$n]}" #echo -e "${tyPosts[$n]}"