Skip to content

Instantly share code, notes, and snippets.

@solidpple
Created March 16, 2018 06:09
Show Gist options
  • Save solidpple/0695545a42c24dc78af944a1ea087f95 to your computer and use it in GitHub Desktop.
Save solidpple/0695545a42c24dc78af944a1ea087f95 to your computer and use it in GitHub Desktop.
# -*- encoding: utf8 -*-
def send_log_to_slack(text):
channel = '<channel_name>'
import datetime
from slacker import Slacker
token = "<token>"
slack = Slacker(token)
attachments_dict = dict()
attachments_dict['pretext'] = text
#attachments_dict['title'] = ""
#attachments_dict['title_link'] = ""
attachments_dict['fallback'] = text # "1급 비밀 메시지"
#attachments_dict['text'] = text
#attachments_dict['mrkdwn_in'] = ["text", "pretext"] # 마크다운을 적용시킬 인자들을 선택
attachments = [attachments_dict]
slack.chat.post_message(channel=channel, text=None, attachments=attachments, as_user=False)
import sys
send_log_to_slack(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment