Compare commits

...

13 Commits
beta ... main

Author SHA1 Message Date
1afa115f75
run from current dir 2022-10-25 23:19:46 +05:00
fabefad887
fix.cache 2022-10-23 23:00:29 +05:00
e98f1ea5d3
fucccckkkk 2022-10-23 22:32:04 +05:00
142d5a2e50
cleaner(?) env.sample 2022-09-23 20:08:25 +05:00
4d9fa187b2
docker file test NOT WORKING 2022-09-23 20:07:44 +05:00
07e683e10a
anti-bot antibot 2022-04-15 23:57:54 +05:00
Shihaam Abdul Rahman
096d7ff627 added screen script 2022-01-18 18:39:18 +00:00
Shihaam Abdul Rahman
33f1bacdf1 added support for prepaid topup 2022-01-18 18:38:54 +00:00
Shihaam Abdul Rahman
bd6f130483
Merge pull request #4 from shihaamabr/test-extended-sleep
clean up env.sample
2021-09-19 23:38:40 +05:00
Shihaam Abdul Rahman
f87baa1ebb clean up env.sample 2021-09-19 18:32:42 +00:00
Shihaam Abdul Rahman
990ddfb70f
Merge pull request #3 from shihaamabr/test-extended-sleep
Test extended sleep
2021-09-19 23:22:29 +05:00
Shihaam Abdul Rahman
0ee2747375 added extended app open delay 2021-09-19 20:21:21 +05:00
Shihaam Abdul Rahman
bb85b64e76 added extended app open delay 2021-09-19 20:20:51 +05:00
7 changed files with 62 additions and 15 deletions

0
.cache/.gitkeep Normal file
View File

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
.env
delay
cookie
.cache/*
.cache/cookie

10
Dockerfile Normal file
View 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"]

View File

@ -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
View File

@ -0,0 +1,8 @@
version: '3.5'
services:
#########################
app:
build: .
image: bml-tg-notify
restart: always
env_file: .env

View File

@ -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
View 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