Bot that will send telegram message in case of electricity state was changed.
- Install python > 3.10
- Install
makeandnohup - Install poetry
pip install poetry - Install package
poetry install - Create in project folder file named
.envand specify thereAPI_TOKEN,CHAT_IDandIP_TO_CHECK, example can be taken from.test.envfile - Bot is ready, run it via
poetry run electricitybotcommand or viamake runcommand
Bot will ping provided IP adress specified in IP_TO_CHECK variable. In case if there will be no response for 4 ping requests in a row, bot will send message about power outage and vice versa.
- build docker image with
docker build . -t f1ashhimself/electricitybot - start docker container with
docker run -h electricitybot --restart unless-stopped -e API_TOKEN=${API_TOKEN} -e CHAT_ID=${CHAT_ID} -e IP_TO_CHECK=${IP_TO_CHECK} -d --name electricitybot f1ashhimself/electricitybotDo not forget to create enviroment variables withAPI_TOKEN,CHAT_IDandIP_TO_CHECKprior run.
Create THREAD_ID value for message_thread_id (please find Bot API documentation) in .env file or pass THREAD_ID enviroment variable into container to send notification to selected Topic in Group chats with over 100 members where Topic enabled. Bot will sent notifaction to Topic called General for Group chats with Topic if THREAD_ID is not set.
