def handle_slack_button(request):
payload = multidict_to_dict(await request.post())
body = json.loads(payload['payload'])
print(f'INFO: Button request body:\n{body}.')
try:
verify_request_token(body)
except (KeyError, TokenError) as err:
print(f'INFO: Invalid token: {err}')
return web.json_response({'text': 'Unverified message.'})
if body['actions'][0]['name'] == 'Cancel':
if 'text' not in body:
body['text'] = ''
if 'user_id' not in body:
body['user_id'] = body['user']['id']
iwant_object = IwantRequest(body, (), (), _slack_user_pattern)
iwant_object.cancel_iwant_task()
return web.json_response({'text': 'Request was cancelled.'})
评论列表
文章目录