Search code examples
djangotelegram-botpython-telegram-bot

How I can run a telegram bot with the Django project?


Now, to run the bot through Django, I first use the python manage.py runserver command and then follow the link to launch a view with my bot. Can you tell me if there is an easier way to start my bot automatically when starting a Django project?


Solution

  • Actually, you can use a management command to run your bot with something like

    python manage.py runbot

    All Django context, including DB and settings, will be available

    Reference to management command page:

    https://simpleisbetterthancomplex.com/tutorial/2018/08/27/how-to-create-custom-django-management-commands.html