comments and detailed error
This commit is contained in:
parent
9030ed65a7
commit
5f9af46eaa
@ -1,63 +1,70 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
source .env
|
source .env # import credentials
|
||||||
mkdir -p ~/.cache/bml-cli/
|
mkdir -p ~/.cache/bml-cli/ # make cookie dir
|
||||||
TG_BOTAPI='https://api.telegram.org/bot'
|
|
||||||
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'
|
|
||||||
COOKIE=~/.cache/bml-cli/cookie
|
|
||||||
|
|
||||||
if [ ! -f delay ]
|
if [ ! -f delay ] # if delay file missing
|
||||||
then
|
then
|
||||||
echo 160 > delay
|
echo 160 > delay # make delay file with 160 sec
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
LOGIN=$(curl -s -c $COOKIE $BML_URL/login --data-raw username=$BML_USERNAME --data-raw password=${BML_PASSWORD} | jq -r .code)
|
|
||||||
if [ "$LOGIN" = "0" ]
|
LOGIN=$(curl -s -c $COOKIE $BML_URL/login --data-raw username=$BML_USERNAME --data-raw password=${BML_PASSWORD} | jq -r .code) ## attempt to login
|
||||||
|
|
||||||
|
if [ "$LOGIN" = "0" ] # if Login success
|
||||||
then
|
then
|
||||||
PROFILE=$(curl -s -b $COOKIE $BML_URL/profile | jq -r '.payload | .profile | .[] | .profile' | head -n 1)
|
PROFILE=$(curl -s -b $COOKIE $BML_URL/profile | jq -r '.payload | .profile | .[] | .profile' | head -n 1) # get Personal Profile
|
||||||
curl -s -b $COOKIE $BML_URL/profile --data-raw profile=$PROFILE > /dev/null
|
curl -s -b $COOKIE $BML_URL/profile --data-raw profile=$PROFILE > /dev/null # select Personal Profile
|
||||||
else
|
else # if login failed
|
||||||
echo Something went wrong.. Probably your account locked or wrong username password OR your IP Blocked by CF
|
echo 'Something went wrong..'
|
||||||
echo Code: $LOGIN
|
echo ""
|
||||||
exit
|
echo '"Code: 20" means your account locked, Please set password from "https://www.bankofmaldives.com.mv/internetbanking/forgot_password"'
|
||||||
|
echo '"Code: 2" means your username or password is in correct, Please check .env to see if theyre entered correctly'
|
||||||
|
echo ""
|
||||||
|
echo Code: $LOGIN # show error code
|
||||||
|
echo 'Run "curl https://www.bankofmaldives.com.mv/" and see if you get "Error code 1020", if you do this means your IP blocked'
|
||||||
|
echo 'exiting...'
|
||||||
|
exit # close
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CHECKDIFF1=$(echo $HISTORY | wc -c)
|
CHECKDIFF1=$(echo $HISTORY | wc -c) # check intial and previous history
|
||||||
HISTORY=$(curl -s -b $COOKIE $BML_URL/account/$BML_ACCOUNTID/history/today | jq -r '.payload | .history | .[]')
|
HISTORY=$(curl -s -b $COOKIE $BML_URL/account/$BML_ACCOUNTID/history/today | jq -r '.payload | .history | .[]') # request history
|
||||||
CHECKDIFF2=$(echo $HISTORY | wc -c)
|
CHECKDIFF2=$(echo $HISTORY | wc -c) # check new history
|
||||||
DELAY=$(cat delay)
|
DELAY=$(cat delay) # read delay file and get value
|
||||||
|
|
||||||
if [ "$CHECKDIFF1" != "$CHECKDIFF2" ]
|
if [ "$CHECKDIFF1" != "$CHECKDIFF2" ] # if previous history do not match with new history
|
||||||
then
|
then
|
||||||
DESCRIPTION=$(echo $HISTORY | jq -r .description | head -n1)
|
DESCRIPTION=$(echo $HISTORY | jq -r .description | head -n1) # get last trascation description
|
||||||
AMOUNT=$(echo $HISTORY | jq -r .amount | head -n1)
|
AMOUNT=$(echo $HISTORY | jq -r .amount | head -n1) # get last trascation amount
|
||||||
if [ "$DESCRIPTION" = "Transfer Credit" ]
|
if [ "$DESCRIPTION" = "Transfer Credit" ] # if last trascation is description is Transfer Credit
|
||||||
then
|
then
|
||||||
FROMTOAT=From
|
FROMTOAT=From
|
||||||
ENTITY=$(echo $HISTORY | jq -r .narrative3 | head -n1)
|
ENTITY=$(echo $HISTORY | jq -r .narrative3 | head -n1) # get last persona or place name
|
||||||
elif [ "$DESCRIPTION" = "Transfer Debit" ]
|
elif [ "$DESCRIPTION" = "Transfer Debit" ] # if last trascation descripton is Transfer Debit
|
||||||
then
|
then
|
||||||
FROMTOAT=To
|
FROMTOAT=To
|
||||||
ENTITY=$(echo $HISTORY | jq -r .narrative3 | head -n1)
|
ENTITY=$(echo $HISTORY | jq -r .narrative3 | head -n1) # get last person or place name
|
||||||
elif [ "$DESCRIPTION" = "ATM Withdrawal" ]
|
elif [ "$DESCRIPTION" = "ATM Withdrawal" ] # if last trascation descripton is ATM Withdrawal
|
||||||
then
|
then
|
||||||
FROMTOAT=At
|
FROMTOAT=At
|
||||||
ENTITY=$(echo $HISTORY | jq -r .narrative3 | head -n1)
|
ENTITY=$(echo $HISTORY | jq -r .narrative3 | head -n1) #get last ATM name
|
||||||
elif [ "$DESCRIPTION" = "Salary" ]
|
elif [ "$DESCRIPTION" = "Salary" ] # if last trascation descripton is Salary
|
||||||
then
|
then
|
||||||
FROMTOAT=From
|
FROMTOAT=From
|
||||||
ENTITY=$(echo $HISTORY | jq -r .narrative2 | head -n1)
|
ENTITY=$(echo $HISTORY | jq -r .narrative2 | head -n1) # get last trascation company name
|
||||||
fi
|
fi
|
||||||
echo $DESCRIPTION
|
echo $DESCRIPTION
|
||||||
echo $FROMTOAT: $ENTITY
|
echo $FROMTOAT: $ENTITY
|
||||||
echo $CURRENCY: $AMOUNT
|
echo $CURRENCY: $AMOUNT
|
||||||
DESCRIPTION=`echo $DESCRIPTION | sed "s/ /%20/g"` #Fix spaces
|
DESCRIPTION=`echo $DESCRIPTION | sed "s/ /%20/g"` # Fix spaces for curl
|
||||||
ENTITY=`echo $ENTITY | sed "s/ /%20/g"` #Fix spaces
|
ENTITY=`echo $ENTITY | sed "s/ /%20/g"` # Fix spaces curl
|
||||||
TGTEXT=$(echo $DESCRIPTION%0A$FROMTOAT:%20$ENTITY%0A$CURRENCY:%20$AMOUNT)
|
TGTEXT=$(echo $DESCRIPTION%0A$FROMTOAT:%20$ENTITY%0A$CURRENCY:%20$AMOUNT) # format text for telegram
|
||||||
curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=$TGTEXT > /dev/null
|
curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=$TGTEXT > /dev/null #send to telegram
|
||||||
echo "Next check in $DELAY seconds"
|
echo "Next check in $DELAY seconds"
|
||||||
else
|
else
|
||||||
echo "nothing new..checking again in $DELAY seconds"
|
echo "nothing new..checking again in $DELAY seconds"
|
||||||
fi
|
fi
|
||||||
sleep $DELAY
|
|
||||||
|
sleep $DELAY # initiate delay read from delay file
|
||||||
|
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user