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('')