From 61c7e9b02ec31580d7f9cae0913ee816d88f82a4 Mon Sep 17 00:00:00 2001 From: JnTon <84038748+JnTon@users.noreply.github.com> Date: Sun, 14 Apr 2024 18:46:33 +0200 Subject: [PATCH] Update ToEnWikipediaBot.py --- ToEnWikipediaBot.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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