Python/Python__works

slacker

말하는감자 2020. 2. 13. 19:04
from slacker import Slacker
slack = Slacker('슬래커키')
slack_color = '333CCC'
slack_title = '타이틀메세지'
slack_text = '[slack으로 보낼 메세지] \n {}'.format('보내고싶은말이요')

#만약 보낼 메세지가 json이라면
body = {
    "key": "val"
}
slack_text = json.dumps(body, ensure_ascii=False)
#이렇게 고쳐줘야지 한글이 안깨지고 나와요 -ㅁ-;;
slack_msg = [{
    'color': slack_color,
    'title': slack_title,
    'text': slack_text
}]
slack.chat.post_message('#채널이름', text='음..', attachments=slack_msg)

'Python > Python__works' 카테고리의 다른 글

formatter  (0) 2020.02.26
python json.loads  (0) 2020.02.18
python pickle aes  (0) 2020.02.13
socket으로 서버 이름 확인하기  (0) 2020.02.13
application.yml 에서 db 접속 정보 읽어오기  (0) 2020.02.13