Answer the question
In order to leave comments, you need to log in
Django + nginx + telegrambotapi - is it a real combination?
Hey!
I'm making a telegram bot in python. I wrote the logic, the bot itself is in the process of being created.
Please explain if I think correctly how to connect it all.
I set myself a self-signed certificate, access via https from the site (which is on django) is available.
I create an entry in urls.py: I put a webhook
for the bot on the address, for example https://mydomen.ru/bot
Next, I create a function in the view that contains the body of the bot itself.
Let's say I have a webhook. I write a message to the bot, the telegram server sends a message to https://mydomen.ru/bot,url(r"^bot/", news_views.bot, name='bot')
Dzhang picks up and sends it to the bot in the view, the bot works.
Is everything right with the logic?
I will be grateful for clarifications and links to articles.
Answer the question
In order to leave comments, you need to log in
Yes everything is correct! As for the 403 error: a CSRF token must be present in the django POST request, this is such a protection against an attack on the site. It needs to be disabled on def in view:
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def my_view(request):
return HttpResponse('Hello world')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question