티스토리 뷰

공부

[Python] slack message bot

승가비 2020. 5. 30. 04:47
728x90

https://corikachu.github.io/articles/python/python-slack-bot-slacker

 

[Python] Slacker를 이용한 Slack Bot 만들기 | Corikachu

개발 커뮤니티 GDG SSU 내부 슬랙에서 운영하고 있는 봇이 어떻게 만들어 졌는지 간단하게 확인해 봅시다.

corikachu.github.io

from slacker import Slacker

from const import *
from utils.string_utils import StringUtils


class Slack:
    def __init__(self):
        pass

    @staticmethod
    def send(message, token, channel):
        if token is None:
            token = TOKEN_SLACK
        if channel is None:
            channel = SLACK_CHANNEL

        message = StringUtils.linebreak(message)
        slack = Slacker(token)
        slack.chat.post_message('#'+channel, message)
        return message
728x90

'공부' 카테고리의 다른 글

[Developer] Common Sense  (0) 2020.05.30
[Spark] merge small files  (0) 2020.05.30
[Jenkins X slack] build alarm  (0) 2020.05.30
[Python] export PYTHONPATH='/xxx/xxx'  (0) 2020.05.30
[Sh] sudo -s  (0) 2020.05.30
댓글