works i guess

This commit is contained in:
Shihaam Abdul Rahman 2021-11-29 18:36:18 +05:00
parent e04ab97beb
commit 667f7f0cd5
3 changed files with 38 additions and 28 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.env
.cookie
.*.kate-swp
.cache/*

46
bml-status-tg-bot.sh Normal file → Executable file
View File

@ -1,28 +1,26 @@
#!/bin/bash
source .env
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
echo Login success
elif [ "$LOGIN" = "20" ]
then
sleep 1.5
echo Account Locked!
echo Please reset password and login again.
elif [ "$LOGIN" = "2" ]
then
echo Password or Username Incorrect
elif [ "$LOGIN" = "37" ]
then
echo Down for Maintenance
echo Try again later
exit
else
echo Unknown Error
exit
fi
while true;
do
STATUS=$(curl -s $BML_URL/login | jq .code)
if [ "$STATUS" = "0" ]
then
TGTEXT="BML%20Online"
elif [ "$STATUS" = "37" ]
then
TGTEXT="BML%20Down"
else
TGTEXT="Unknown%20Error"
fi
if [ "$STATUS" != "$STATUS_OLD" ]
then
STATUS_OLD=$STATUS
curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=$TGTEXT
fi
sleep $DELAY
done

View File

@ -1,5 +1,16 @@
BML_USERNAME=
BML_PASSWORD=
# EDIT THESE TO YOUR CONFIG
# BML Config
BML_USERNAME='' #Your BML Username
BML_PASSWORD='' #Your BML Password
BML_URL=https://www.bankofmaldives.com.mv/internetbanking/api
COOKIE=.cookie
# Delays
DELAY='120' # Delay in seconds for script to check for new transactions
# Telegram Config
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
# DO NOT EDIT THESE UNLESS YOU KNOW WHAT YOURE DOING
COOKIE=.cache/cookie
TG_BOTAPI='https://api.telegram.org/bot'
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'

Before

Width:  |  Height:  |  Size: 106 B

After

Width:  |  Height:  |  Size: 631 B