init commit new repo
This commit is contained in:
parent
c4940b153c
commit
bffff8f70d
38
README.md
38
README.md
@ -1,2 +1,36 @@
|
|||||||
# bml-tg-notify
|
# BML-TG-NOTIFICATION
|
||||||
Push Notification BML Transcations to Telegram
|
## Push Notification BML Transcations to Telegram
|
||||||
|
|
||||||
|
### Requriements
|
||||||
|
`curl` `jq`
|
||||||
|
- Install with whatever package manager you use.
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
```
|
||||||
|
git clone https://github.com/shihaamabr/bml-tg-notify.git
|
||||||
|
cd bml-tg-notify
|
||||||
|
chmod +x bml-tg-notify.sh
|
||||||
|
./bml.sh
|
||||||
|
```
|
||||||
|
- `mv env.sample .env`
|
||||||
|
- Edit the contents of .env to your config\
|
||||||
|
#### .env Sample
|
||||||
|
```
|
||||||
|
BML_USERNAME='' #Your BML Username
|
||||||
|
BML_PASSWORD='' #Your BML Password
|
||||||
|
BML_ACCOUNTID='' #Your BML Account ID, NOT ACCOUNT NUMBER!
|
||||||
|
CURRENCY='MVR' #Change if you're setting to a USD Account.
|
||||||
|
TG_BOT_TOKEN='' #Your Telegram Bot token, This can be optiained by talking to BotFather on Telegram https://t.me/BotFather
|
||||||
|
TG_CHATID='' #Your Telegram Chat ID
|
||||||
|
```
|
||||||
|
`echo XX > delay`
|
||||||
|
- where XX is the time in seconds you want to delay script run.\
|
||||||
|
- Please note that if the XX value is less than a certain value, you could get rate limited.
|
||||||
|
|
||||||
|
```
|
||||||
|
chmod +x bml-tg-notify.sh
|
||||||
|
./bml-tg-notify.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### Bugs
|
||||||
|
- You tell me :)
|
||||||
|
54
bml-tg-notify.sh
Executable file
54
bml-tg-notify.sh
Executable file
@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source .env
|
||||||
|
mkdir -p ~/.cache/bml-cli/
|
||||||
|
TG_BOTAPI='https://api.telegram.org/bot'
|
||||||
|
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'
|
||||||
|
COOKIE=~/.cache/bml-cli/cookie
|
||||||
|
|
||||||
|
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" ]
|
||||||
|
then
|
||||||
|
PROFILE=$(curl -s -b $COOKIE $BML_URL/profile | jq -r '.payload | .profile | .[] | .profile' | head -n 1)
|
||||||
|
curl -s -b $COOKIE $BML_URL/profile --data-raw profile=$PROFILE > /dev/null
|
||||||
|
else
|
||||||
|
echo Something went wrong.. Probably your account locked or wrong username password OR your IP Blocked by CF
|
||||||
|
echo Code: $LOGIN
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
CHECKDIFF1=$(echo $HISTORY | wc -c)
|
||||||
|
HISTORY=$(curl -s -b $COOKIE $BML_URL/account/$BML_ACCOUNTID/history/today | jq -r '.payload | .history | .[]')
|
||||||
|
CHECKDIFF2=$(echo $HISTORY | wc -c)
|
||||||
|
DELAY=$(cat delay)
|
||||||
|
|
||||||
|
if [ "$CHECKDIFF1" != "$CHECKDIFF2" ]
|
||||||
|
then
|
||||||
|
DESCRIPTION=$(echo $HISTORY | jq -r .description | head -n1)
|
||||||
|
AMOUNT=$(echo $HISTORY | jq -r .amount | head -n1)
|
||||||
|
if [ "$DESCRIPTION" = "Transfer Credit" ]
|
||||||
|
then
|
||||||
|
FROMTO=From
|
||||||
|
ENTITY=$(echo $HISTORY | jq -r .narrative3 | head -n1)
|
||||||
|
elif [ "$DESCRIPTION" = "Transfer Debit" ]
|
||||||
|
then
|
||||||
|
FROMTO=To
|
||||||
|
ENTITY=$(echo $HISTORY | jq -r .narrative3 | head -n1)
|
||||||
|
elif [ "$DESCRIPTION" = "Salary" ]
|
||||||
|
then
|
||||||
|
FROMTO=From
|
||||||
|
ENTITY=$(echo $HISTORY | jq -r .narrative2 | head -n1)
|
||||||
|
fi
|
||||||
|
echo $DESCRIPTION
|
||||||
|
echo $FROMTO: $ENTITY
|
||||||
|
echo $CURRENCY: $AMOUNT
|
||||||
|
DESCRIPTION=`echo $DESCRIPTION | sed "s/ /%20/g"` #Fix spaces
|
||||||
|
ENTITY=`echo $ENTITY | sed "s/ /%20/g"` #Fix spaces
|
||||||
|
TGTEXT=$(echo $DESCRIPTION%0A$FROMTO:%20$ENTITY%0A$CURRENCY:%20$AMOUNT)
|
||||||
|
curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=$TGTEXT > /dev/null
|
||||||
|
echo "Next check in $DELAY seconds"
|
||||||
|
else
|
||||||
|
echo "nothing new..checking again in $DELAY seconds"
|
||||||
|
fi
|
||||||
|
sleep $DELAY
|
||||||
|
done
|
6
env.sample
Normal file
6
env.sample
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
BML_USERNAME=''
|
||||||
|
BML_PASSWORD=''
|
||||||
|
BML_ACCOUNTID=''
|
||||||
|
CURRENCY='MVR'
|
||||||
|
TG_BOT_TOKEN=''
|
||||||
|
TG_CHATID=''
|
After Width: | Height: | Size: 93 B |
Loading…
x
Reference in New Issue
Block a user