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)
评论列表
文章目录