pycore.py 文件源码

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

项目:sci-pype 作者: jay-johnson 项目源码 文件源码
def post_message_to_slack(self, channel, message, username="algobot", debug=False):

        results                 = self.build_def_hash("Display Error", "Not Run", {
                                            })

        try:
            import slackclient

            if debug:
                self.lg("Posting to Slack(" + str(channel) + ") Message(" + str(message)[0:10] + ")", 6)
            else:
                slack               = slackclient.SlackClient(self.m_slack_node["Token"])
                slack.api_call("chat.postMessage", channel=channel, text=message, username=username, as_user=True)

            if debug:
                self.lg("Done Posting to Slack(" + str(channel) + ")", 6)

        except Exception, e:
            err_msg             = "Failed to post message to slack with Ex(" + str(e) + ")"
            self.lg("ERROR: " + str(err_msg), 0)
            results             = self.build_def_hash("Display Error", str(err_msg), {
                                            })
            results["Status"]   = "FAILED"
        # end of try/ex

        return results
    # end of post_message_to_slack
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号