Bot that will send telegram message in case of electricity state was changed.
- Install python > 3.10
- Install
make
andnohup
- Install poetry
pip install poetry
- Install package
poetry install
- Create in project folder file named
.env
and specify thereAPI_TOKEN
,CHAT_ID
andIP_TO_CHECK
, example can be taken from.test.env
file - Bot is ready, run it via
poetry run electricitybot
command or viamake run
command
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/electricitybot
Do not forget to create enviroment variables withAPI_TOKEN
,CHAT_ID
andIP_TO_CHECK
prior 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.