mirror of
https://github.com/Llewellynvdm/CoinRate.git
synced 2024-11-28 13:06:28 +00:00
Added echo conroller to script, that will suppress the terminal output to make it quite
This commit is contained in:
parent
c8fdc4e1b7
commit
d6a4ad872c
28
getPrice.sh
28
getPrice.sh
@ -28,10 +28,12 @@ VDMHOME=~/
|
|||||||
|
|
||||||
# main function
|
# main function
|
||||||
function main () {
|
function main () {
|
||||||
|
if (( "$allowEcho" == 1 )); then
|
||||||
echo ".................................[ Vast Development Method ]...................................."
|
echo ".................................[ Vast Development Method ]...................................."
|
||||||
echo "...========================================================================| www.vdm.io |====..."
|
echo "...========================================================================| www.vdm.io |====..."
|
||||||
echoTweak "Getting the current price of $Currency in $Target"
|
echoTweak "Getting the current price of $Currency in $Target"
|
||||||
echo "...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~..."
|
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
|
||||||
|
if (( "$allowEcho" == 1 )); then
|
||||||
echo "...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~..."
|
echo "...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~..."
|
||||||
|
fi
|
||||||
# send Messages
|
# send Messages
|
||||||
sendMessages
|
sendMessages
|
||||||
|
if (( "$allowEcho" == 1 )); then
|
||||||
echo "...==========================================================================================..."
|
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,6 +414,7 @@ done
|
|||||||
|
|
||||||
# little echo tweak
|
# little echo tweak
|
||||||
function echoTweak () {
|
function echoTweak () {
|
||||||
|
if (( "$allowEcho" == 1 )); then
|
||||||
echoMessage="$1"
|
echoMessage="$1"
|
||||||
chrlen="${#echoMessage}"
|
chrlen="${#echoMessage}"
|
||||||
if [ $# -eq 2 ]
|
if [ $# -eq 2 ]
|
||||||
@ -415,6 +426,7 @@ function echoTweak () {
|
|||||||
increaseBy=$((20+mainlen-chrlen))
|
increaseBy=$((20+mainlen-chrlen))
|
||||||
tweaked=$(repeat "$increaseBy")
|
tweaked=$(repeat "$increaseBy")
|
||||||
echo ".... $echoMessage $tweaked"
|
echo ".... $echoMessage $tweaked"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# little repeater
|
# little repeater
|
||||||
|
Loading…
Reference in New Issue
Block a user