slack.py 文件源码

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

项目:homeassistant 作者: NAStools 项目源码 文件源码
def send_message(self, message="", **kwargs):
        """Send a message to a user."""
        import slacker

        if kwargs.get(ATTR_TARGET) is None:
            targets = [self._default_channel]
        else:
            targets = kwargs.get(ATTR_TARGET)

        data = kwargs.get('data')
        attachments = data.get('attachments') if data else None

        for target in targets:
            try:
                self.slack.chat.post_message(target, message,
                                             as_user=self._as_user,
                                             username=self._username,
                                             icon_emoji=self._icon,
                                             attachments=attachments,
                                             link_names=True)
            except slacker.Error as err:
                _LOGGER.error("Could not send slack notification. Error: %s",
                              err)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号