1
0
mirror of https://github.com/Llewellynvdm/CoinRate.git synced 2024-05-31 15:00:47 +00:00

Echo error but do not stop

This commit is contained in:
Llewellyn van der Merwe 2017-12-31 14:00:27 +02:00
parent e5bc8cf187
commit 6cf42ef064
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
3 changed files with 46 additions and 28 deletions

View File

@ -111,22 +111,25 @@ function getActiveCurrencyTarget () {
get_Price get_Price
# get the price value # get the price value
value="${CurrencyPair[${Currency}${Target}]}" value="${CurrencyPair[${Currency}${Target}]}"
# set send key # check that we have a value
setSendKey if [ "${value}" != "null" ]; then
# set target values and perform action if only TargetValue given # set send key
if (( "$TargetAll" == 1 && "$TargetBelow" == 0 && "$TargetAbove" == 0)); setSendKey
then # set target values and perform action if only TargetValue given
getTarget "$TargetValue" "$value" 'setAction' if (( "$TargetAll" == 1 && "$TargetBelow" == 0 && "$TargetAbove" == 0));
fi then
# set target values and perform action if TargetBelowValue given getTarget "$TargetValue" "$value" 'setAction'
if (( "$TargetAbove" == 1 )); fi
then # set target values and perform action if TargetBelowValue given
getTarget "$TargetAboveValue" "$value" 'setActionAbove' if (( "$TargetAbove" == 1 ));
fi then
# set target values and perform action if TargetBelowValue given getTarget "$TargetAboveValue" "$value" 'setActionAbove'
if (( "$TargetBelow" == 1 )); fi
then # set target values and perform action if TargetBelowValue given
getTarget "$TargetBelowValue" "$value" 'setActionBelow' if (( "$TargetBelow" == 1 ));
then
getTarget "$TargetBelowValue" "$value" 'setActionBelow'
fi
fi fi
} }
@ -211,7 +214,11 @@ function setMessage () {
local current_value="$2" local current_value="$2"
local target_value="$3" local target_value="$3"
# build message # build message
message="${Currency} is ${target_type} ${target_value} ${Target} at ${current_value} ${Target}" && if (( "$showAB" == 1 )); then
message="${Currency} is ${target_type} ${target_value} ${Target} at ${current_value} ${Target}"
else
message="${Currency} at ${current_value} ${Target}"
fi
# first send to comand line # first send to comand line
echoTweak "${message} - ${Datetimenow} " && echoTweak "${message} - ${Datetimenow} " &&
# is it send time # is it send time
@ -405,17 +412,23 @@ function get_Price () {
# check if we have and error # check if we have and error
local error=($( echo "$json" | jq -r '.error')) local error=($( echo "$json" | jq -r '.error'))
if [ "${error}" != "null" ]; then if [ "${error}" != "null" ]; then
echo "Currency Pair: $error" if (( "$allowEcho" == 1 )); then
exit 1 echo "...!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!..."
echoTweak "${json}"
echo "...!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!..."
fi
# no currency pair found
CurrencyPair["${Currency}${Target}"]='null'
else
# set the value
if [ "${API_target}" == "cex" ]; then
local value=($( echo "$json" | jq -r '.lprice'))
elif [ "${API_target}" == "shapeshift" ]; then
local value=($( echo "$json" | jq -r '.rate'))
fi
# add value to global bucket
CurrencyPair["${Currency}${Target}"]="$value"
fi fi
# set the value
if [ "${API_target}" == "cex" ]; then
local value=($( echo "$json" | jq -r '.lprice'))
elif [ "${API_target}" == "shapeshift" ]; then
local value=($( echo "$json" | jq -r '.rate'))
fi
# add value to global bucket
CurrencyPair["${Currency}${Target}"]="$value"
fi fi
} }

View File

@ -70,6 +70,7 @@ 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)
-k hide the above and below from result string
Advance options (factory option) Advance options (factory option)
====================================================== ======================================================
@ -100,7 +101,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 hc:C:o:v:B:A:baqtT:sS:M:lf:I: opt; do while getopts hc:C:o:v:B:A:baqtT:sS:M:lf:I:k opt; do
case $opt in case $opt in
I) I)
if (( "$OPTARG" == 2 )); then if (( "$OPTARG" == 2 )); then
@ -141,6 +142,9 @@ while getopts hc:C:o:v:B:A:baqtT:sS:M:lf:I: opt; do
a) a)
AboveValue=1 AboveValue=1
;; ;;
k)
showAB=0
;;
q) q)
allowEcho=0 allowEcho=0
;; ;;

View File

@ -55,6 +55,7 @@ AboveValue=0
# message settings # message settings
send=0 send=0
sendSwitch=2 sendSwitch=2
showAB=1
sendKey=$(TZ=":ZULU" date +"%m/%d/%Y" ) sendKey=$(TZ=":ZULU" date +"%m/%d/%Y" )
allowEcho=1 allowEcho=1
Telegram=0 Telegram=0