Browse Source

Корректно посылаем в телеграм текст в т.ч. с нечитаемыми символами #11

например, #
pull/32/head
Artur Galyamov 2 years ago
parent
commit
765bcab97d
  1. 5
      cms/promoters.py

5
cms/promoters.py

@ -1,5 +1,6 @@
import abc
import os
from urllib.parse import urlencode
import requests
@ -24,8 +25,10 @@ class TelegramPromoter(Promoter):
channel_id = os.getenv('TELEGRAM_CHAT_ID')
long_text = f'{self.article.body}\n{self.article.link}'
querystring = (('chat_id', channel_id), ('text', long_text))
encoded_querystring = urlencode(querystring)
send_message_url = f'https://api.telegram.org/bot{bot_token}/sendMessage?chat_id={channel_id}&text={long_text}'
send_message_url = f'https://api.telegram.org/bot{bot_token}/sendMessage?{encoded_querystring}'
response = requests.get(send_message_url)
result = response.json()

Loading…
Cancel
Save