Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bp.route('/request', methods=['GET', 'POST'])
- def process_request():
- approved = False
- payload = json.loads(request.form['payload'])
- print(payload['actions'])
- actions = payload['actions']
- for action in actions:
- if action['text']['text'] == 'Approve':
- approved = True
- if action['text']['text'] == 'Deny':
- approved = False
- print(payload['user']['username'])
- username = payload['user']['username']
- if approved:
- message = f"*@{username}* approved this request"
- else:
- message = f"*@{username}* denied this request"
- test = {"type": "section", "text": {"type": "mrkdwn", "text": message}}
- for block in payload['message']['blocks']:
- if block.get('type', None) == "actions":
- payload['message']['blocks'].remove(block)
- payload['message']['blocks'].append(test)
- response_url = payload['response_url']
- print(payload['response_url'])
- resp = requests.post(response_url, data=json.dumps(payload['message']), headers={'Content-Type': 'application/json'})
- print(resp.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement