Added the option to send to multiple telegram,sms users

This commit is contained in:
Llewellyn van der Merwe 2017-12-31 13:46:10 +02:00
parent 9e4a3af4a0
commit e5bc8cf187
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
6 changed files with 35 additions and 7 deletions

View File

@ -111,7 +111,7 @@ Message options
**To use shapeshift API add the `-I 2` command:** **To use shapeshift API add the `-I 2` command:**
```bash ```bash
# Get Linux & SMS & Telegram notice when BTC is above 10000 USD (every time command is run) # Get Linux notice when BTC is above 16 ETH (every time command is run)
./getPrice.sh -c BTC -C ETH -av 16 -l -I 2 ./getPrice.sh -c BTC -C ETH -av 16 -l -I 2
``` ```

View File

@ -351,7 +351,7 @@ function sendTime () {
local target_type="$1" local target_type="$1"
local target_value="$2" local target_value="$2"
# build key send time # build key send time
keySendTime=$(echo -n "${target_type}${target_value}${sendKey}" | md5sum) keySendTime=$(echo -n "${target_type}${target_value}${sendKey}" | md5sum | sed 's/ .*$//')
# check if we should send # check if we should send
if (( "$sendSwitch" == 2 )) if (( "$sendSwitch" == 2 ))
then then

View File

@ -80,7 +80,10 @@ Getting Coin Value in Fiat Currency at set price
====================================================== ======================================================
-q Quiet - Turn off terninal output -q Quiet - Turn off terninal output
-t Send A Telegram Notice -t Send A Telegram Notice
-T Set notify Line number to use (first line is default)
-s Send A SMS Notice -s Send A SMS Notice
-M Set sms Line number to use (first line is default)
-S Set smsto Line number to use (first line is default)
-l Show A Linux Notice via zenity -l Show A Linux Notice via zenity
-h display this help menu -h display this help menu
@ -97,7 +100,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:baqtslf:I: opt; do while getopts hc:C:o:v:B:A:baqtT:sS:M:lf:I: opt; do
case $opt in case $opt in
I) I)
if (( "$OPTARG" == 2 )); then if (( "$OPTARG" == 2 )); then
@ -144,9 +147,21 @@ while getopts hc:C:o:v:B:A:baqtslf:I: opt; do
t) t)
Telegram=1 Telegram=1
;; ;;
T)
TelegramID=$OPTARG
Telegram=1
;;
s) s)
SMS=1 SMS=1
;; ;;
S)
smstoID=$OPTARG
SMS=1
;;
M)
smsID=$OPTARG
SMS=1
;;
l) l)
LinuxNotice=1 LinuxNotice=1
;; ;;
@ -185,8 +200,11 @@ while getopts hc:C:o:v:B:A:baqtslf:I: opt; do
esac esac
done done
# set call ID
CALL_ID=$(echo -n "${API_target}${smsID}${smstoID}${TelegramID}" | md5sum | sed 's/ .*$//')
# BUILD Cointracker file per/API # BUILD Cointracker file per/API
COINTracker="${VDMHOME}/.cointracker_${API_target}" COINTracker="${VDMHOME}/.cointracker_${CALL_ID}"
# make sure the tracker file is set # make sure the tracker file is set
if [ ! -f "$COINTracker" ] if [ ! -f "$COINTracker" ]
then then

View File

@ -20,10 +20,13 @@
# main is loaded # main is loaded
MAINLOAD=1 MAINLOAD=1
# Do some prep work # Do some prep work
command -v jq >/dev/null 2>&1 || { echo >&2 "We require jq for this script to run, but it's not installed. Aborting."; exit 1; } command -v jq >/dev/null 2>&1 || { echo >&2 "We require jq for this script to run, but it's not installed. Aborting."; exit 1; }
command -v curl >/dev/null 2>&1 || { echo >&2 "We require curl for this script to run, but it's not installed. Aborting."; exit 1; } command -v curl >/dev/null 2>&1 || { echo >&2 "We require curl for this script to run, but it's not installed. Aborting."; exit 1; }
command -v bc >/dev/null 2>&1 || { echo >&2 "We require bc for this script to run, but it's not installed. Aborting."; exit 1; } command -v bc >/dev/null 2>&1 || { echo >&2 "We require bc for this script to run, but it's not installed. Aborting."; exit 1; }
command -v sed >/dev/null 2>&1 || { echo >&2 "We require sed for this script to run, but it's not installed. Aborting."; exit 1; }
command -v md5sum >/dev/null 2>&1 || { echo >&2 "We require md5sum for this script to run, but it's not installed. Aborting."; exit 1; }
# load notify # load notify
. "$DIR/functions.sh" . "$DIR/functions.sh"
@ -36,6 +39,7 @@ command -v bc >/dev/null 2>&1 || { echo >&2 "We require bc for this script to ru
# Some global defaults # Some global defaults
Factory=0 Factory=0
# basic settings # basic settings
Currency="BTC" Currency="BTC"
Target="USD" Target="USD"
@ -47,14 +51,18 @@ TargetBelow=0
TargetAbove=0 TargetAbove=0
BelowValue=0 BelowValue=0
AboveValue=0 AboveValue=0
# message settings # message settings
send=0 send=0
sendSwitch=2 sendSwitch=2
sendKey=$(TZ=":ZULU" date +"%m/%d/%Y" ) sendKey=$(TZ=":ZULU" date +"%m/%d/%Y" )
allowEcho=1 allowEcho=1
Telegram=0 Telegram=0
TelegramID=1
LinuxNotice=0 LinuxNotice=0
SMS=0 SMS=0
smsID=1
smstoID=1
# API URL # API URL
API_show=1 API_show=1

View File

@ -28,10 +28,12 @@ function notifyMe() {
exit 1 exit 1
fi fi
# get first line # get first line
local NOTIFY=$(head -n 1 "$DIR/notify") local NOTIFY=$(sed -n "${TelegramID}p" < "$DIR/notify")
# get the keys # get the keys
IFS=$' ' IFS=$' '
local keys=( $NOTIFY ) local keys=( $NOTIFY )
# set chatid & token # set chatid & token
local chatid="${keys[0]}" local chatid="${keys[0]}"
local token="${keys[1]}" local token="${keys[1]}"

4
sms.sh
View File

@ -36,8 +36,8 @@ function smsMe() {
# set Args # set Args
local message="$1" local message="$1"
# get first line # get first line
local SMSd=$(head -n 1 "$DIR/sms") local SMSd=$(sed -n "${smsID}p" < "$DIR/sms")
local to=$(head -n 1 "$DIR/smsto") local to=$(sed -n "${smstoID}p" < "$DIR/smsto")
# get the keys # get the keys
IFS=$' ' IFS=$' '
local keyss=( $SMSd ) local keyss=( $SMSd )