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 the price value
value="${CurrencyPair[${Currency}${Target}]}"
# set send key
setSendKey
# set target values and perform action if only TargetValue given
if (( "$TargetAll" == 1 && "$TargetBelow" == 0 && "$TargetAbove" == 0));
then
getTarget "$TargetValue" "$value" 'setAction'
fi
# set target values and perform action if TargetBelowValue given
if (( "$TargetAbove" == 1 ));
then
getTarget "$TargetAboveValue" "$value" 'setActionAbove'
fi
# set target values and perform action if TargetBelowValue given
if (( "$TargetBelow" == 1 ));
then
getTarget "$TargetBelowValue" "$value" 'setActionBelow'
# check that we have a value
if [ "${value}" != "null" ]; then
# set send key
setSendKey
# set target values and perform action if only TargetValue given
if (( "$TargetAll" == 1 && "$TargetBelow" == 0 && "$TargetAbove" == 0));
then
getTarget "$TargetValue" "$value" 'setAction'
fi
# set target values and perform action if TargetBelowValue given
if (( "$TargetAbove" == 1 ));
then
getTarget "$TargetAboveValue" "$value" 'setActionAbove'
fi
# set target values and perform action if TargetBelowValue given
if (( "$TargetBelow" == 1 ));
then
getTarget "$TargetBelowValue" "$value" 'setActionBelow'
fi
fi
}
@ -211,7 +214,11 @@ function setMessage () {
local current_value="$2"
local target_value="$3"
# 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
echoTweak "${message} - ${Datetimenow} " &&
# is it send time
@ -405,17 +412,23 @@ function get_Price () {
# check if we have and error
local error=($( echo "$json" | jq -r '.error'))
if [ "${error}" != "null" ]; then
echo "Currency Pair: $error"
exit 1
if (( "$allowEcho" == 1 )); then
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
# 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
}

View File

@ -70,6 +70,7 @@ Getting Coin Value in Fiat Currency at set price
example: 14000 or 14000,15000
-b Send Notice below target value once a day
-a Send Notice above target value once a day (default)
-k hide the above and below from result string
Advance options (factory option)
======================================================
@ -100,7 +101,7 @@ exit 1
# http://mywiki.wooledge.org/BashFAQ/035
# 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
I)
if (( "$OPTARG" == 2 )); then
@ -141,6 +142,9 @@ while getopts hc:C:o:v:B:A:baqtT:sS:M:lf:I: opt; do
a)
AboveValue=1
;;
k)
showAB=0
;;
q)
allowEcho=0
;;

View File

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