Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
1afa115f75 | |||
fabefad887 | |||
e98f1ea5d3 | |||
142d5a2e50 | |||
4d9fa187b2 | |||
07e683e10a | |||
|
096d7ff627 | ||
|
33f1bacdf1 | ||
|
bd6f130483 | ||
|
f87baa1ebb | ||
|
990ddfb70f | ||
|
0ee2747375 | ||
|
bb85b64e76 |
0
.cache/.gitkeep
Normal file
0
.cache/.gitkeep
Normal file
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
.env
|
||||
delay
|
||||
cookie
|
||||
.cache/*
|
||||
.cache/cookie
|
||||
|
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /root
|
||||
|
||||
RUN apk update \
|
||||
&& apk add bash curl jq
|
||||
|
||||
COPY bml-tg-notify.sh .
|
||||
|
||||
CMD ["./bml-tg-notify.sh"]
|
@ -1,4 +1,6 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
|
||||
|
||||
source .env # import credentials, tg api, cookie path, bml api
|
||||
|
||||
|
||||
@ -10,13 +12,13 @@ fi
|
||||
}
|
||||
|
||||
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
|
||||
$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
|
||||
}
|
||||
|
||||
getaccountdetails(){
|
||||
REQACCOUNTDETAILS=$(curl -s -b $COOKIE $BML_URL/account/$BML_ACCOUNTID | jq -r .payload)
|
||||
REQACCOUNTDETAILS=$($curl -s -b $COOKIE $BML_URL/account/$BML_ACCOUNTID | jq -r .payload)
|
||||
ACCOUNTTYPE=$(echo $REQACCOUNTDETAILS | jq -r .product)
|
||||
ACCOUNTNUMBER=$(echo $REQACCOUNTDETAILS | jq -r .accountNumber)
|
||||
CURRENCY=$(echo $REQACCOUNTDETAILS | jq -r .currency)
|
||||
@ -24,18 +26,18 @@ CURRENCY=$(echo $REQACCOUNTDETAILS | jq -r .currency)
|
||||
|
||||
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
|
||||
$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
|
||||
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
|
||||
}
|
||||
@ -58,6 +60,8 @@ req_history
|
||||
|
||||
if [ "$LOGIN_STATUS" != "true" ]
|
||||
then
|
||||
echo "Looks like app or web was opened... checking again in $APP_OPEN_DELAY"
|
||||
sleep $APP_OPEN_DELAY
|
||||
login
|
||||
break & loop
|
||||
fi
|
||||
@ -70,7 +74,7 @@ then
|
||||
if [ "$CHECKDIFF2" = "1" ]
|
||||
then
|
||||
echo "=============" ; echo NEW DAY ; echo "============="
|
||||
# curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=GO%20TO%20SLEEP%0AITS%0000
|
||||
# $curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=GO%20TO%20SLEEP%0AITS%0000
|
||||
else
|
||||
echo $HISTORY | jq
|
||||
DESCRIPTION=$(echo $HISTORY | jq -r .description | head -n1) ; echo $DESCRIPTION # get last trascation description
|
||||
@ -91,6 +95,10 @@ then
|
||||
then
|
||||
FROMTOAT=From
|
||||
ENTITY=$(echo $HISTORY | jq -r .narrative2 | head -n1) ; echo $ENTITY # get last trascation company name
|
||||
elif [ "$DESCRIPTION" = "Prepaid Top-Up" ] # if last trascation descripton is Prepaid Top-Up
|
||||
then
|
||||
FROMTOAT=To
|
||||
ENTITY=$(echo $HISTORY | jq -r .narrative3 | head -n1) ; echo $ENTITY # get name..idk
|
||||
fi
|
||||
send_tg
|
||||
fi
|
||||
|
8
docker-compose.yml
Normal file
8
docker-compose.yml
Normal file
@ -0,0 +1,8 @@
|
||||
version: '3.5'
|
||||
services:
|
||||
#########################
|
||||
app:
|
||||
build: .
|
||||
image: bml-tg-notify
|
||||
restart: always
|
||||
env_file: .env
|
28
env.sample
28
env.sample
@ -1,12 +1,28 @@
|
||||
# EDIT THESE TO YOUR CONFIG
|
||||
BML_USERNAME='' #Your BML Username
|
||||
BML_PASSWORD='' #Your BML Password
|
||||
BML_ACCOUNTID='' #Your BML Account ID,NOT to be confused with account number, read the README.md on how to obtain this.
|
||||
# BML Config
|
||||
# Your BML Username
|
||||
BML_USERNAME=''
|
||||
# Your BML Password
|
||||
BML_PASSWORD=''
|
||||
# Your BML Account ID,NOT to be confused with account number,
|
||||
# read the README.md on how to obtain this.
|
||||
BML_ACCOUNTID=''
|
||||
|
||||
TG_BOT_TOKEN='' #Your Telegram Bot API Token, Contact @BotFather on Telegram to obtain token
|
||||
TG_CHATID='' #Your Telegram chat ID, This could be your user, group, supergroup or channel ID, add "-100" first if supergroup or channel
|
||||
# Delays
|
||||
# Delay in seconds for script to stop if logged in from another device
|
||||
APP_OPEN_DELAY='600'
|
||||
# Delay in seconds for script to check for new transactions
|
||||
NORMAL_DELAY='40'
|
||||
|
||||
# Telegram Config
|
||||
# Your Telegram Bot API Token, Contact @BotFather on Telegram to obtain token
|
||||
TG_BOT_TOKEN=''
|
||||
# Your Telegram chat ID, This could be your user, group, supergroup or channel ID
|
||||
# add "-100" first if supergroup or channel
|
||||
TG_CHATID=''
|
||||
|
||||
# DO NOT EDIT THESE UNLESS YOU KNOW WHAT YOURE DOING
|
||||
COOKIE=.cache/cookie #No need to change
|
||||
COOKIE=.cache/cookie
|
||||
curl='curl'
|
||||
TG_BOTAPI='https://api.telegram.org/bot'
|
||||
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'
|
||||
|
5
run-bml-tg-notify
Executable file
5
run-bml-tg-notify
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
|
||||
SCREEN=$(basename $(pwd))
|
||||
screen -S $SCREEN -p 0 -X quit
|
||||
screen -S $SCREEN -U -m -d bash bml-tg-notify.sh
|
Loading…
x
Reference in New Issue
Block a user