While reading a course on creating telegram bots, I saw a comment from the person who created the telegram bot sea battle. I also wanted to create my own bot, but using modern technologies, libraries, databases and optimization.
My project is a full-fledged bot created to read books directly from telegram. You can select a book, flip through the pages, go to the table of contents and select the desired page there, add pages to bookmarks, click on them and delete them. There are also convenient commands for going to the beginning of the book or continuing reading from the place where you finished.
Language
Framework
Databases
Libraries
Other
I wrote a python bot using aiogram. I used two databases: Postgresql for storing user data, books and bookmarks, and Redis for caching data and optimizing work. The bot takes data about books via API from a third-party service and stores them in the database. With the help of the Aiocron library, the database is updated every hour. I also connected an alembic to initialize the database and create migrations
Method 1: Via docker-compose
- Create a .env file and paste the data from the .env.example file into it
- In REDIS_HOST and POSTGRES_HOST, specify the names of docker-compose services (redis and db)
- In BOT_TOKEN, specify the token of your telegram bot created earlier via BotFather
- In the terminal, enter the following command:
docker-compose up --build
Method 2: Via virtual environment
- Create and activate a python virtual environment
- In the terminal, enter the following command:
pip3 install -r requirements.txt
- Create a .env file and paste the data from the .env.example file into it
- In REDIS_HOST and POSTGRES_HOST, specify localhost
- In BOT_TOKEN, specify the token of your telegram bot created earlier via BotFather
- In the terminal, enter the following command:
watchfiles --filter python 'python -m bot'