Skip to content

aymogo/django_delivery_bot

Repository files navigation

django-delivery-bot

How to run

Quickstart: Polling & SQLite

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

Run locally using docker-compose

If you want just to run all the things locally, you can use Docker-compose which will start all containers for you.

Create .env file.

You can switch to PostgreSQL just by uncommenting it's DATABASE_URL and commenting SQLite variable.

cp .env_example .env

Docker-compose

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.

Enter django shell:

docker exec -it dtb_django bash

Create superuser for Django admin panel

python manage.py createsuperuser

To see logs of the container:

docker logs -f dtb_django

About

Telegram bot works on delivery.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages