slack_agent.py 文件源码

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

项目:python-zentropi 作者: zentropi 项目源码 文件源码
def api_call(self, method, data=None):
        """
        Slack API call.

        https://medium.com/@greut/a-slack-bot-with-pythons-3-5-asyncio-ad766d8b5d8f
        """
        with aiohttp.ClientSession() as session:
            form = aiohttp.FormData(data or {})
            form.add_field('token', self.api_token)
            async with session.post('https://slack.com/api/{0}'.format(method),
                                    data=form) as response:
                if response.status != 200:
                    raise ValueError('{0} with {1} failed.'.format(method, data))
            return await response.json()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号