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