프로그래밍/Python

Using Slack Webhook in Python

bluecandyg 2022. 8. 17. 13:48
  • Python에서 Webhook 을 이용한 Slack 메시지 전송

  • '`' 의 경우 Markdown으로 Block 형태의 메시지를 전송
  • Message는 Json Type으로 전송
import requests

def send_slackMessage(message_value : str, loggin_level : str):
    slack_webhook = 'https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxxxxx'
    
    payload = {'text' : f'`{loggin_level}`\r\n```{message_value}```'}
    requests.post(slack_webhook, json=payload)

'프로그래밍 > Python' 카테고리의 다른 글

[Python3] ZIP Function  (0) 2023.01.12
Using Rotating-Logging in Python  (0) 2022.08.17
Zip Extract on Memory (Python)  (0) 2022.08.17
FTP Sending From Memory (Python)  (0) 2022.08.17
Python 실행 파일 만들기  (0) 2021.06.29