removed jq depdency, added HTTP codes, removed unknown error

This commit is contained in:
Shihaam Abdul Rahman 2022-02-20 14:47:50 +05:00
parent 8e268b6480
commit 104a9f63b0
2 changed files with 20 additions and 22 deletions

View File

@ -4,7 +4,7 @@
## Getting started.
### Requriements
`curl` `jq` `screen`
`curl` `screen`
- Install with whatever package manager you use.
- Make SURE they are installed before continuing!
### Clone repo and Configure

40
bml-status-tg-bot Normal file → Executable file
View File

@ -1,27 +1,25 @@
#!/bin/bash
source .env
STATUS_OLD=$(curl -s $BML_URL/login | jq .code)
COUNT=0
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
COUNT=$(echo $[$COUNT+1])
STATUS=$(curl -si $BML_URL/login | head -n1 | awk '{print $2}')
if [ "$STATUS" = "200" ]
then
TEXT="🟢BML Online"
else
TEXT="🔴BML Down"
fi
if [ "$STATUS" != "$STATUS_OLD" ]
then
STATUS_OLD=$STATUS
if [ "$COUNT" != "1" ]
then
TGTEXT=$(echo Status: $TEXT%0ACode: HTTP $STATUS | sed "s/ /%20/g")
curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=${TGTEXT}
fi
fi
echo ""; echo "";echo Status: $TEXT;echo Code: $STATUS;echo Count: $COUNT; echo Telegram: $TGTEXT;echo ""
sleep $DELAY
done