slackbot.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:drift 作者: dgnorth 项目源码 文件源码
def post_message(message):
    if not SLACKBOT_TOKEN:
        print "Slackbot key not found, cannot notify slack of '%s'" % message
        print "Set the environment variable DRIFT_SLACKBOT_KEY to remedy."
        return

    final_message = "{}: {}".format(getpass.getuser(), message)
    try:
        from slacker import Slacker
    except ImportError:
        print "Message '{}' not posted to slack".format(message)
        print "Slack integration disabled. Enable slack with 'pip install slacker'"
    try:
        slack = Slacker(SLACKBOT_TOKEN)
        slack.chat.post_message(NOTIFICATION_CHANNEL, final_message)
    except Exception as e:
        log.warning("Cannot post '%s' to Slack: %s", final_message, e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号