/
Ksq
/
app_flet
Обзор
Документация
Войти
/
Ksq
/
app_flet
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
utils/request.py
23 строки
665 B
KSQ-web
добавление файлов в репозиторий
05 ноя 2024, 13:45
05 ноя 2024, 13:45
90ecde1
Код
Авторство
О чём код?
import requests url = 'https://api.telegram.org/bot' def sendMessage(token, channel, text): try: return requests.post( url=f'{url}{token}/sendMessage', data={'chat_id': channel, 'text': text, 'parse_mode': 'HTML'} ).json() except Exception as error: return error def sendMessagePhoto(token, channel, photo, caption): data = {'chat_id': channel, 'caption': caption} link = f'{url}{token}/sendPhoto?chat_id={channel}' with open(photo, 'rb') as image_file: result = requests.post(link, data=data, files={'photo': image_file}) return result.json()