From 87900bd556b5ef191291cff27c0b5cc6bb74c56f Mon Sep 17 00:00:00 2001 From: nalbam Date: Thu, 5 Sep 2024 17:19:18 +0900 Subject: [PATCH] Refactor chat_update function to handle exceptions when sending new messages --- handler.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/handler.py b/handler.py index 9893734..9c5e691 100644 --- a/handler.py +++ b/handler.py @@ -214,9 +214,12 @@ def chat_update(say, channel, thread_ts, latest_ts, message="", continue_thread= else: time.sleep(1) - # New message - result = say(text=text, thread_ts=thread_ts) - latest_ts = result["ts"] + try: + # Send a new message + result = say(text=text, thread_ts=thread_ts) + latest_ts = result["ts"] + except Exception as e: + print("chat_update: Error: {}".format(e)) return message, latest_ts