-
-
Save KyMidd/89f33a05df453cca341c1011e90d6fd1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def lambda_handler(event, context): | |
| # .... | |
| # Get the event type | |
| event_type = body.get('type', '') | |
| # Check for edited messages | |
| if ( | |
| event_type == 'event_callback' and | |
| 'edited' in body.get('event', {}) | |
| ): | |
| print('Detected edited message, discarding') | |
| return { | |
| 'statusCode': 200, | |
| 'body': json.dumps({'message': 'Edited message discarded'}) | |
| } | |
| # Only process events we care about | |
| if event_type == 'event_callback': | |
| # Asynchronously invoke the processor Lambda | |
| lambda_client.invoke( | |
| FunctionName=os.environ['PROCESSOR_FUNCTION_NAME'], | |
| InvocationType='Event', # Async invocation | |
| Payload=json.dumps(event) | |
| ) | |
| # Always return 200 OK to Slack quickly | |
| return { | |
| 'statusCode': 200, | |
| 'body': json.dumps({'message': 'Event received'}) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment