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 15, 2024
1 parent b7e4d66 commit 1a020fe
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions ToEnWikipediaBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,18 @@ async def async_lambda_handler(event, context):
application = Application.builder().token(token).build()
setup_handlers(application)

try:
update = Update.de_json(event_body, application.bot)
await application.process_update(update)
return {'statusCode': 200, 'body': json.dumps({'message': 'Success'})}
except Exception as e:
logging.error(f"An error occurred while processing the update: {e}")
return {'statusCode': 500, 'body': json.dumps({'message': 'Internal server error'})}
if 'body' in event:
try:
update_data = json.loads(event['body'])
update = Update.de_json(update_data, application.bot)
await application.process_update(update)
return {'statusCode': 200, 'body': json.dumps({'message': 'Success'})}
except Exception as e:
logger.error(f"An error occurred while processing the update: {e}")
return {'statusCode': 500, 'body': json.dumps({'error': 'Internal server error'})}
else:
logger.error("No update payload found.")
return {'statusCode': 400, 'body': json.dumps({'message': 'No update payload'})}

def lambda_handler(event, context):
print("Received event:", event) # Log the incoming event data
Expand Down

0 comments on commit 1a020fe

Please sign in to comment.