From bb477afb5c48d14a836e0d2c8b47c0a9acc93edd Mon Sep 17 00:00:00 2001 From: Markus Keil Date: Thu, 18 Jan 2024 07:14:38 +0100 Subject: [PATCH] deal with non-int message ids --- main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 0f4e5ea..3d8313a 100644 --- a/main.py +++ b/main.py @@ -366,12 +366,17 @@ async def get_last_message_id(channel): last_msg_id = int(initial_content) except ClientError: print("The location is non existent on S3.") + except ValueError: + print("Non-int message id.") else: - if os.path.exists(loc_path): - with open(loc_path, 'r', encoding='utf-8') as f: - f_content = f.read() - last_msg_id = int(f_content) + try: + if os.path.exists(loc_path): + with open(loc_path, 'r', encoding='utf-8') as f: + f_content = f.read() + last_msg_id = int(f_content) + except ValueError: + print("Non-int message id.") return last_msg_id