A Telegram bot based on aiogram and aiohttp with cloud-based NoSQL-database MongoDB implemented through pymongo package. The solution has REST API service and is based on asynchronous patterns. Also, the bot is written with static typing for self-checking and improving the readability of the code.
- 📝 Passing tests
- ⏰ Reminders (bot can remind you to pass a test by your self-defined time)
- 📊 Statistics of your results
- 🌍 EN/UA/RU multilanguage supporting
- 🐳 Dockerized
- 📡 Full-provided REST API
- 🎛 Full testing coverage provided by pytest and unittest libraties.
The main mission of the bot - helping people (especially developers) to prevent burnout and depression. The bot allows:
- passing the evidence based psychological assessments (currently, only The Beck Depression Inventory Test
BDI-II
) with a user-friendly interface based on the Telegram inline keyboard. - viewing dynamics changes (by plots implemented by matplotlib and seaborn) of a user's mental condition (time-series of tests results) to control it and notice patterns.
- getting human-readable interpretations of tests result for a better understanding own mental condition.
- Python3.9 or newer.
- Pyenv
- MongoDB Atlas
- Docker
I created a Bash script that provides a simple and quick initialization of the bot. The script creates and activates a virtual environment or docker container, installs packages from requirements.txt
, replaces constants with private access tokens for Telegram Bot API and MongoDB, and starts the bot.
YOUR_TELEGRAM_BOT_TOKEN
is a Telegram Bot Access Token. There is a getting token here through creating a new Telegram bot.YOUR_MONGO_DB_CONNECTION_STRING
is a connection string for MongoDB that is accessible after the MongoDB Cluster creation. See details.
$ git clone https://github.com/annagerd/psybot.git
$ cd psybot
Then there are two ways to start the bot: natively by Python or by Docker.
- The only thing you need is to run an
init.sh
file by the following command in your CLI:
$ ./init.sh python YOUR_TELEGRAM_BOT_TOKEN YOUR_MONGO_DB_CONNECTION_STRING
- If you haven't installed Docker, install it.
- Run the Docker
- Run an
init.sh
file by the following command in your CLI.
$ ./init.sh docker YOUR_TELEGRAM_BOT_TOKEN YOUR_MONGO_DB_CONNECTION_STRING
The bot should start if you used the correct syntax and passed the right data. Congrats!
- Deployment (Heroku, Vercel or DigitalOcean).
- Add more tests (depression, anxiety, burnout and etc).
- Start to create an IT ecosystem of psychological self-care with the bot as a part of it.
- Aiogram 3 docs. This version is used in my project.
- Aiogram 2 docs. I don't use this version here, but the docs of the second version are also useful because of a lot of useful information and advices that is still actual for also the third version.
- Aiohttp docs. This library is a core library of aiogram web server, and it's also used here for REST API endpoints.
- Docker docs. The bot is dockerized to be independent of environment.
- Asyncio and threading libraries docs. These libraries are used for:
- reminding users;
- parallel launching of the bot and the REST API server.
- MongoDB docs. Full MongoDB docs.
- MongoDB Python Start Guide. Simple instructions about using MongoDB with Python programming language.
- MongoDB References. References that can help you to work with Mongo API.
- Matplotlib References. Full Matplotlib API docs. It will be useful for the customization of the bot's plots.
- Static Typing in Python. It will be useful for dynamic typing languages users who want to understand static typing in Python.
- Telegram Bot API docs. Official Bot API docs provided by the Telegram.