Skip to content

holohup/homework_bot_en

Repository files navigation

Yandex.Practicum Homework Telegram Bot

For those of us who are tired of constantly refreshing the webpage after sending our work for code review to check its status. Here's a bot that checks for updates every 10 minutes and, if the status has changed, sends a notification via Telegram.

The bot takes full advantage of Yandex.Practicum homework API and Telegram Bot API. It is capable of error handling and reporting on its own - there's no need to restart it after it's launched. Every breath is logged, currently to stdout, but this behavior can be easily adjusted to your needs.

You've got to be a Yandex.Practicum student to get this bot going - the API requires an OAuth token from Yandex.

Technology stack

The bot has been tested to work with Python 3.7 - 3.10. It also uses Python-Telegram-Bot library v. 13.7 and requests 2.26.0

Installation

  1. Copy and paste the following code into a terminal in a directory where your bots live:
git clone https://github.com/holohup/homework_bot_en && cd homework_bot_en
  1. Acquire all the necessary tokens.

Depending on which path you choose to follow, fill either the .env.sample, or the Dockerfile.sample file with those credentials and remove the .sample extension. In the end, you should either have a .env or a Dockerfile (or both) filled with the requisites.

  1. There're two ways to install and launch the robot:
  • Using a virtual environment
 python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt && python homework.py
  • As a docker container. This Linux image choice in Dockerfile has been tested to run both an x86- and ARMv7-based architecture (Raspberry Pi running Raspbian GNU/Linux 11 (bullseye)). It will most likely also run on other SBCs and flavors of Linux, but it hasn't been tested and might require some adjustments in the Dockerfile.
docker build -t hwbot . && docker run -d hwbot

Have fun!