def post_message_to_slack(self, channel, message, debug=False):
slack_response = {}
try:
# SlackHQ Repository for integrating with the Slack API:
# https://github.com/slackhq/python-slackclient
import slackclient
slack = slackclient.SlackClient(self.m_slack_token)
slack_response = slack.api_call("chat.postMessage", channel=channel, text=message, username=self.m_bot_name, as_user=True)
if "error" in slack_response:
print "\nERROR: Slack API call had an error(" + str(slack_response["error"]) + ")\n"
except Exception, e:
err_msg = "Failed to post message to slack with Ex(" + str(e) + ") SlackResponse(" + str(slack_response) + ")"
print "ERROR: " + str(err_msg)
# end of try/ex
# end of post_message_to_slack
# end of SlkMsg
评论列表
文章目录