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:**
```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
```

View File

@ -351,7 +351,7 @@ function sendTime () {
local target_type="$1"
local target_value="$2"
# 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
if (( "$sendSwitch" == 2 ))
then

View File

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

View File

@ -20,10 +20,13 @@
# main is loaded
MAINLOAD=1
# 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 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 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
. "$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
Factory=0
# basic settings
Currency="BTC"
Target="USD"
@ -47,14 +51,18 @@ TargetBelow=0
TargetAbove=0
BelowValue=0
AboveValue=0
# message settings
send=0
sendSwitch=2
sendKey=$(TZ=":ZULU" date +"%m/%d/%Y" )
allowEcho=1
Telegram=0
TelegramID=1
LinuxNotice=0
SMS=0
smsID=1
smstoID=1
# API URL
API_show=1

View File

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

4
sms.sh
View File

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