Skip to content

Commit

Permalink
delete message on cancel
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Devyatkin <[email protected]>
  • Loading branch information
Andrey9kin committed Sep 10, 2021
1 parent e55a3d8 commit 574b448
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions helpers_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ def approve_request(ack, respond, body):
# Acknowledge action request
ack()
print(body)
print('User pressed approve. update message and exit 0')
username = body['user']['username']
original_text = body['message']['blocks'][0]['text']['text']
respond(original_text + f'\n\nApproved by {username} 👍')
os._exit(0)

@app.action(cancel_action_id)
def approve_request(ack, respond, body):
def approve_request(ack, client, body):
# Acknowledge action request
ack()
print(body)
username = body['user']['username']
original_text = body['message']['blocks'][0]['text']['text']
respond(original_text + f'\n\nCanceled by {username} ❌')
print('User pressed cancel. Delete message and exit 1')
client.chat_delete(channel=body['container']['channel_id'], ts=body['container']['message_ts'])
os._exit(1)

@app.middleware
Expand Down

0 comments on commit 574b448

Please sign in to comment.