/
rnekrasov
/
Python
Обзор
Документация
Войти
/
rnekrasov
/
Python
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
slack_message.py
24 строки
729 B
slowy07
refactor: clean code
30 янв 2022, 04:33
30 янв 2022, 04:33
f0af0c4
Код
Авторство
О чём код?
from __future__ import print_function # Created by sarathkaul on 11/11/19 import json import urllib.request # Set the webhook_url to the one provided by Slack when you create the webhook at https://my.slack.com/services/new/incoming-webhook/ webhook_url = ( "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX" ) slack_data = {"text": "Hi Sarath Kaul"} response = urllib.request.Request( webhook_url, data=json.dumps(slack_data), headers={"Content-Type": "application/json"}, ) print(response) # if response.status_code != 200: # raise ValueError( # 'Request to slack returned an error %s, the response is:\n%s' # % (response.status_code, response.text) # )