start.py 文件源码

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

项目:iwant-bot 作者: kiwicom 项目源码 文件源码
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.'})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号