The fastest way to run the bot is to run it in polling mode using SQLite database without all Celery workers for background jobs. This should be enough for quickstart:
git clone https://github.com/ohld/django-telegram-bot
cd django-telegram-bot
Create virtual environment (optional)
python3 -m venv dtb_venv
source dtb_venv/bin/activate
Install all requirements:
pip install -r requirements.txt
Create .env
file in root directory and copy-paste this or just run cp .env_example .env
,
don't forget to change telegram token:
DJANGO_DEBUG=True
DATABASE_URL=sqlite:///db.sqlite3
TELEGRAM_TOKEN=<PASTE YOUR TELEGRAM TOKEN HERE>
Run migrations to setup SQLite database:
python manage.py migrate
Create superuser to get access to admin panel:
python manage.py createsuperuser
Run bot in polling mode:
python run_polling.py
If you want to open Django admin panel which will be located on http://localhost:8000/tgadmin/:
python manage.py runserver
If you want just to run all the things locally, you can use Docker-compose which will start all containers for you.
You can switch to PostgreSQL just by uncommenting it's DATABASE_URL
and commenting SQLite variable.
cp .env_example .env
To run all services (Django, Postgres, Redis, Celery) at once:
docker-compose up -d --build
Check status of the containers.
docker ps -a
It should look similar to this:
Try visit Django-admin panel.
docker exec -it dtb_django bash
python manage.py createsuperuser
docker logs -f dtb_django