You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
708 B
20 lines
708 B
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') |