1
0
mirror of https://github.com/Llewellynvdm/CoinRate.git synced 2024-11-24 19:37:32 +00:00

Added echo conroller to script, that will suppress the terminal output to make it quite

This commit is contained in:
Llewellyn van der Merwe 2017-12-28 22:48:51 +02:00
parent c8fdc4e1b7
commit d6a4ad872c
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5

View File

@ -28,10 +28,12 @@ VDMHOME=~/
# main function # main function
function main () { function main () {
echo ".................................[ Vast Development Method ]...................................." if (( "$allowEcho" == 1 )); then
echo "...========================================================================| www.vdm.io |====..." echo ".................................[ Vast Development Method ]...................................."
echoTweak "Getting the current price of $Currency in $Target" echo "...========================================================================| www.vdm.io |====..."
echo "...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~..." echoTweak "Getting the current price of $Currency in $Target"
echo "...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~..."
fi
# get the price value # get the price value
value=$(get_Price "${API}${Currency}/${Target}") value=$(get_Price "${API}${Currency}/${Target}")
# set send key # set send key
@ -51,11 +53,15 @@ function main () {
then then
getTarget "$TargetBelowValue" "$value" 'setActionBelow' getTarget "$TargetBelowValue" "$value" 'setActionBelow'
fi fi
echo "...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~..." if (( "$allowEcho" == 1 )); then
echo "...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~..."
fi
# send Messages # send Messages
sendMessages sendMessages
echo "...==========================================================================================..." if (( "$allowEcho" == 1 )); then
echo "................................................................................................" echo "...==========================================================================================..."
echo "................................................................................................"
fi
} }
function getTarget() { function getTarget() {
@ -296,13 +302,14 @@ function get_Price () {
echo "${value}" echo "${value}"
} }
# Some defaults # Some global defaults
Currency="BTC" Currency="BTC"
Target="USD" Target="USD"
TargetValue="17000" TargetValue="17000"
TargetBelowValue=0 TargetBelowValue=0
TargetAboveValue=0 TargetAboveValue=0
sendKey=$(TZ=":ZULU" date +"%m/%d/%Y" ) sendKey=$(TZ=":ZULU" date +"%m/%d/%Y" )
allowEcho=1
send=0 send=0
sendSwitch=0 sendSwitch=0
BelowValue=0 BelowValue=0
@ -311,11 +318,10 @@ Telegram=0
LinuxNotice=0 LinuxNotice=0
SMS=0 SMS=0
# Some paths # API URL
API="https://cex.io/api/last_price/" API="https://cex.io/api/last_price/"
VDMHOME=~/
# Some arrays # Some Messages arrays
declare -A aboveMessages declare -A aboveMessages
declare -A belowMessages declare -A belowMessages
Messages=() Messages=()
@ -346,9 +352,10 @@ Getting Coin Value in Fiat Currency at set price
example: 14000 or 14000,15000 example: 14000 or 14000,15000
-b Send Notice below target value once a day -b Send Notice below target value once a day
-a Send Notice above target value once a day (default) -a Send Notice above target value once a day (default)
-t Send A Telegram Notice aswell (always sends comandline Notice) -q Quiet - Turn off terninal output
-s Send A SMS Notice aswell (always shows comandline Notice) -t Send A Telegram Notice
-l Show A Linux Notice aswell (always shows comandline Notice) -s Send A SMS Notice
-l Show A Linux Notice
EOF EOF
exit 1 exit 1
@ -359,7 +366,7 @@ exit 1
# http://mywiki.wooledge.org/BashFAQ/035 # http://mywiki.wooledge.org/BashFAQ/035
# http://wiki.bash-hackers.org/howto/getopts_tutorial # http://wiki.bash-hackers.org/howto/getopts_tutorial
while getopts ":c:C:h:v:A:B:b :a :t :s :l :" opt; do while getopts ":c:C:h:v:A:B:b :a :t :s :q :l :" opt; do
case $opt in case $opt in
c) c)
Currency=$OPTARG Currency=$OPTARG
@ -385,6 +392,9 @@ while getopts ":c:C:h:v:A:B:b :a :t :s :l :" opt; do
a) a)
AboveValue=1 AboveValue=1
;; ;;
q)
allowEcho=0
;;
t) t)
Telegram=1 Telegram=1
;; ;;
@ -404,17 +414,19 @@ done
# little echo tweak # little echo tweak
function echoTweak () { function echoTweak () {
echoMessage="$1" if (( "$allowEcho" == 1 )); then
chrlen="${#echoMessage}" echoMessage="$1"
if [ $# -eq 2 ] chrlen="${#echoMessage}"
then if [ $# -eq 2 ]
mainlen="$2" then
else mainlen="$2"
mainlen=70 else
fi mainlen=70
increaseBy=$((20+mainlen-chrlen)) fi
tweaked=$(repeat "$increaseBy") increaseBy=$((20+mainlen-chrlen))
echo ".... $echoMessage $tweaked" tweaked=$(repeat "$increaseBy")
echo ".... $echoMessage $tweaked"
fi
} }
# little repeater # little repeater