does it work? yes, can you explain how? no
This commit is contained in:
parent
3fd69f55bb
commit
4d1094fe88
@ -1,17 +1,63 @@
|
||||
#!/bin/bash
|
||||
source .env # import credentials, tg api, cookie path, bml api
|
||||
|
||||
|
||||
init(){
|
||||
if [ ! -f delay ] # if delay file missing
|
||||
then
|
||||
echo 160 > delay # make delay file with 160 sec
|
||||
fi
|
||||
while true; do
|
||||
}
|
||||
|
||||
login(){
|
||||
curl -s -c $COOKIE $BML_URL/login --data-raw username=$BML_USERNAME --data-raw password=${BML_PASSWORD} # attempt to login and generate cookie
|
||||
PROFILE=$(curl -s -b $COOKIE $BML_URL/profile | jq -r '.payload | .profile | .[] | .profile' | head -n 1) ; echo $PROFILE # get Personal Profile
|
||||
curl -s -b $COOKIE $BML_URL/profile --data-raw profile=$PROFILE # select Personal Profile
|
||||
}
|
||||
|
||||
send_tg(){
|
||||
TGTEXT=$(echo $DESCRIPTION%0A$FROMTOAT: $ENTITY%0A$CURRENCY: $AMOUNT | sed "s/ /%20/g") ; echo $TGTEXT # format text for telegram
|
||||
curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=$TGTEXT #send to telegram
|
||||
echo "Next check in $DELAY seconds"
|
||||
}
|
||||
|
||||
req_history(){
|
||||
REQ_HISTORY=$(curl -s -b $COOKIE $BML_URL/account/$BML_ACCOUNTID/history/today) ; echo $REQ_HISTORY
|
||||
LOGIN_STATUS=$(echo $REQ_HISTORY | jq -r .success) ; echo $LOGIN_STATUS
|
||||
}
|
||||
|
||||
check_diff(){
|
||||
CHECKDIFF1=$(echo $HISTORY | wc -c) ; echo $CHECKDIFF1 # check intial and previous history
|
||||
HISTORY=$(curl -s -b $COOKIE $BML_URL/account/$BML_ACCOUNTID/history/today | jq -r '.payload | .history | .[]') ; echo $HISTORY # request history
|
||||
#HISTORY=$(curl -s -b $COOKIE $BML_URL/account/$BML_ACCOUNTID/history/today | jq -r '.payload | .history | .[]') ; echo $HISTORY # request history
|
||||
HISTORY=$(echo $REQ_HISTORY | jq -r '.payload | .history | .[]') ; echo $HISTORY
|
||||
CHECKDIFF2=$(echo $HISTORY | wc -c) ; echo $CHECKDIFF2 # check new history
|
||||
}
|
||||
|
||||
read_delay(){
|
||||
DELAY=$(cat delay) ; echo $DELAY # read delay file and get value
|
||||
}
|
||||
|
||||
echo_delay(){
|
||||
echo "Nothing new....Next check in $DELAY seconds"
|
||||
}
|
||||
|
||||
init
|
||||
login
|
||||
|
||||
loop(){
|
||||
while true; do
|
||||
|
||||
req_history
|
||||
|
||||
if [ "$LOGIN_STATUS" != "true" ]
|
||||
then
|
||||
login
|
||||
break & loop
|
||||
fi
|
||||
|
||||
check_diff
|
||||
read_delay
|
||||
|
||||
if [ "$CHECKDIFF1" != "$CHECKDIFF2" ] # if previous history do not match with new history
|
||||
then
|
||||
if [ "$CHECKDIFF2" = "1" ]
|
||||
@ -30,7 +76,7 @@ then
|
||||
then
|
||||
FROMTOAT=To
|
||||
ENTITY=$(echo $HISTORY | jq -r .narrative3 | head -n1) ; echo $ENTITY # get last person or place name
|
||||
elif [ "$DESCRIPTION" = "ATM Withdrawal" ] || [ "$DESCRIPTION" = "Purchase" ] # if last trascation descripton is ATM Withdrawal
|
||||
elif [ "$DESCRIPTION" = "Cash Deposit-ATM" ] [ "$DESCRIPTION" = "ATM Withdrawal" ] || [ "$DESCRIPTION" = "Purchase" ] # if last trascation descripton is ATM Withdrawal
|
||||
then
|
||||
FROMTOAT=At
|
||||
ENTITY=$(echo $HISTORY | jq -r .narrative3 | head -n1) ; echo $ENTITY #get last ATM name
|
||||
@ -39,14 +85,12 @@ then
|
||||
FROMTOAT=From
|
||||
ENTITY=$(echo $HISTORY | jq -r .narrative2 | head -n1) ; echo $ENTITY # get last trascation company name
|
||||
fi
|
||||
TGTEXT=$(echo $DESCRIPTION%0A$FROMTOAT: $ENTITY%0A$CURRENCY: $AMOUNT | sed "s/ /%20/g") ; echo $TGTEXT # format text for telegram
|
||||
curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=$TGTEXT #send to telegram
|
||||
echo "Next check in $DELAY seconds"
|
||||
unset DESCRIPTION ; unset AMOUNT ; unset FROMTOAT ; unset ENTITY ; unset TGTEXT
|
||||
send_tg
|
||||
fi
|
||||
else
|
||||
|
||||
echo "nothing new..checking again in $DELAY seconds"
|
||||
echo_delay
|
||||
fi
|
||||
sleep $DELAY # initiate delay read from delay file
|
||||
done
|
||||
}
|
||||
loop
|
||||
|
Loading…
x
Reference in New Issue
Block a user