Skip to content

lolevan/tg_bot_appointment

Repository files navigation

django-telegram-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

Create Django super user

Being inside a container:

python manage.py createsuperuser

After that you can open admin panel of your deployed app which is located at https://<YOURDOMAIN.COM>/tgadmin.

Read app logs

dokku logs dtb -t

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages