import telegram from django.http import HttpResponse from django.shortcuts import render def send_message(request): if request.method == 'POST': # Получение данных из POST-запроса chat_id = request.POST.get('chat_id') message_text = request.POST.get('message_text') # Создание объекта Telegram Bot bot = telegram.Bot(token='YOUR_TELEGRAM_BOT_TOKEN') # Отправка сообщения bot.send_message(chat_id=chat_id, text=message_text) # Возвращение ответа return HttpResponse('Message sent to Telegram.') else: return render(request, 'send_message.html')