TODO Migrate to aiogram v3 using Migration FAQ (2.x -> 3.0) guide.
This repository contains pet project - telegram bot designed for sending reminders (notifications) for taking medications :)
Link to the working telegram bot here - @medication_notification_bot (currently shut down).
-
Setup and activate your local python environment. Here are few guides on how to do it.
-
Install requirements:
pip install -r requirements-ci.txt
-
Create
.envfile:cp app/.env.template app/.env
-
Setup MongoDB. You have few options:
4.1. you can use any already existing MongoDB (in docker, in any cloud provider, etc.):
- create new database;
- update
DATABASE_URLin.envfile;
4.2. you can set up MongoDB locally. For example, you can use this guide or any other guide.
-
Obtain Telegram Bot Token by creating Telegram Bot. Here (
Obtain Your Bot Tokensection) is a guide on how to do it. UpdateTELEGRAM_BOT_TOKENin.envfile. -
If you want to receive logs notifications (when user takes medication or when new user starts using bot) you need to fill
TELEGRAM_CHANNEL_IDin.envfile and you will receive logs notifications in telegram private channel. Here is guide on how to obtain telegram private channel id. UpdateTELEGRAM_CHANNEL_IDin.envfile. -
This app uses a webhook approach to processing bot updates. In order to do it your localhost has to be put on the internet. You can achieve this by using ngrok. You need to install it and run:
./ngrok http 8000
After running above command you will see something like this:
You will need to copy Forwarding part (for example, on the screenshot it will be https://03d2-146-70-181-35.ngrok-free.app) and update APP_BASE_URL in .env file.
- It's time to run application:
uvicorn app.run:app --reload
- Go to 127.0.0.1:8000 in your web browser.
To run tests use following command:
pytest tests/If you want to check code coverage use following command:
pytest --cov-config=.coveragerc --cov=app tests/