Skip to content

Commit

Permalink
Update ToEnWikipediaBot.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jnton authored Apr 14, 2024
1 parent 945dac7 commit 61c7e9b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ToEnWikipediaBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 61c7e9b

Please sign in to comment.