diff --git a/ToEnWikipediaBot.py b/ToEnWikipediaBot.py index a71651e..b379a2d 100644 --- a/ToEnWikipediaBot.py +++ b/ToEnWikipediaBot.py @@ -241,6 +241,19 @@ def lambda_handler(event, context): logger.error("No body found in the event.") return {'statusCode': 400, 'body': json.dumps('No request body found')} + # Process the update + try: + if 'body' in event and event['body']: + update = Update.de_json(json.loads(event['body']), application.bot) + application.process_update(update) + return {'statusCode': 200, 'body': json.dumps('Success')} + else: + logger.error("No body found in the event.") + return {'statusCode': 400, 'body': json.dumps('No request body found')} + except Exception as e: + logger.error(f"An error occurred: {e}") + return {'statusCode': 500, 'body': json.dumps('An internal server error occurred')} + # Ensure this part is not executed when the script is imported as a module in Lambda #if __name__ == '__main__': # Run the bot normally if this script is executed locally