From 92afd8cb28e075970a312075012a7f36c8d09d90 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 28 Nov 2023 17:45:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20ma?= =?UTF-8?q?rkdown=20#19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adminpanelapp/templates/send_telegram_message.html | 33 ++++++++++++++++++---- adminpanelapp/views.py | 11 ++++++-- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/adminpanelapp/templates/send_telegram_message.html b/adminpanelapp/templates/send_telegram_message.html index 71d99e8..4514379 100644 --- a/adminpanelapp/templates/send_telegram_message.html +++ b/adminpanelapp/templates/send_telegram_message.html @@ -1,8 +1,29 @@ + + + + Отправка сообщений + + +
{% csrf_token %} -
-
-    
-  
-
-
\ No newline at end of file +
+ +
+
+ +
+
+ +
+ + +

+ Пример разметки
+
+ • *Жирный текст*
+ • `номер карты` При нажатии пользователем на текст, заключенный в ``, автоматически копируется
+ • _курсив_
+

+ + \ No newline at end of file diff --git a/adminpanelapp/views.py b/adminpanelapp/views.py index a256528..45bce75 100644 --- a/adminpanelapp/views.py +++ b/adminpanelapp/views.py @@ -10,9 +10,16 @@ def send_telegram_message(request, chat_id): message = request.POST.get('message') bot_token = GetTelegramBotApiToken() - url = f'https://api.telegram.org/bot{bot_token}/sendMessage?text={message}&chat_id={chat_id}' + url = f'https://api.telegram.org/bot{bot_token}/sendMessage' + + payload = { + 'chat_id': chat_id, + 'text': message, + 'parse_mode': 'markdown' + } + + response = requests.post(url, json=payload) - response = requests.get(url) if response.status_code == 200: messages.success(request, "Сообщение успешно отправлено") back_url = reverse('')