From 8ee19b5dec1280ff92b6e8d8286d2b99b60a8472 Mon Sep 17 00:00:00 2001 From: nalbam Date: Wed, 5 Jun 2024 15:57:26 +0900 Subject: [PATCH 1/4] send err msg --- handler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/handler.py b/handler.py index 2845aef..d2f58d9 100644 --- a/handler.py +++ b/handler.py @@ -333,6 +333,8 @@ def conversation(say: Say, thread_ts, content, channel, user, client_msg_id): except Exception as e: print("conversation: Error: {}".format(e)) + chat_update(channel, latest_ts, f"```{e}```") + # Get image from URL def get_image_from_url(image_url, token=None): From ac2213e44c454c6aac555b43b4dbc91b0d2f6518 Mon Sep 17 00:00:00 2001 From: nalbam Date: Wed, 5 Jun 2024 16:02:55 +0900 Subject: [PATCH 2/4] check bot_id --- handler.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/handler.py b/handler.py index d2f58d9..a2dbd10 100644 --- a/handler.py +++ b/handler.py @@ -401,7 +401,8 @@ def handle_mention(body: dict, say: Say): event = body["event"] - if "bot_id" in event: # Ignore messages from the bot itself + if "bot_id" in event and event["bot_id"] == bot_id: + # Ignore messages from the bot itself return channel = event["channel"] @@ -429,7 +430,8 @@ def handle_message(body: dict, say: Say): event = body["event"] - if "bot_id" in event: # Ignore messages from the bot itself + if "bot_id" in event: + # Ignore messages from the bot itself return channel = event["channel"] From 3db050551448715103fa4a68546a0d52c72a503c Mon Sep 17 00:00:00 2001 From: nalbam Date: Wed, 5 Jun 2024 16:13:49 +0900 Subject: [PATCH 3/4] fix allowed_channel_ids --- handler.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/handler.py b/handler.py index a2dbd10..b6267b8 100644 --- a/handler.py +++ b/handler.py @@ -29,7 +29,7 @@ ANTHROPIC_TOKENS = int(os.environ.get("ANTHROPIC_TOKENS", 1024)) # Set up the allowed channel ID -ALLOWED_CHANNEL_IDS = os.environ.get("ALLOWED_CHANNEL_IDS", "AAA,CCC,EEE,GGG") +ALLOWED_CHANNEL_IDS = os.environ.get("ALLOWED_CHANNEL_IDS", "") ENABLE_IMAGE = os.environ.get("ENABLE_IMAGE", "False") @@ -407,10 +407,11 @@ def handle_mention(body: dict, say: Say): channel = event["channel"] - allowed_channel_ids = ALLOWED_CHANNEL_IDS.split(",") - if channel not in allowed_channel_ids: - # say("Sorry, I'm not allowed to respond in this channel.") - return + if ALLOWED_CHANNEL_IDS != "": + allowed_channel_ids = ALLOWED_CHANNEL_IDS.split(",") + if channel not in allowed_channel_ids: + # say("Sorry, I'm not allowed to respond in this channel.") + return thread_ts = event["thread_ts"] if "thread_ts" in event else event["ts"] user = event["user"] From ea92fe2ae64030379bc9691e4daebeef7a506706 Mon Sep 17 00:00:00 2001 From: nalbam Date: Wed, 5 Jun 2024 16:14:17 +0900 Subject: [PATCH 4/4] fix allowed_channel_ids None --- handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/handler.py b/handler.py index b6267b8..e1a4d02 100644 --- a/handler.py +++ b/handler.py @@ -29,7 +29,7 @@ ANTHROPIC_TOKENS = int(os.environ.get("ANTHROPIC_TOKENS", 1024)) # Set up the allowed channel ID -ALLOWED_CHANNEL_IDS = os.environ.get("ALLOWED_CHANNEL_IDS", "") +ALLOWED_CHANNEL_IDS = os.environ.get("ALLOWED_CHANNEL_IDS", "None") ENABLE_IMAGE = os.environ.get("ENABLE_IMAGE", "False") @@ -407,7 +407,7 @@ def handle_mention(body: dict, say: Say): channel = event["channel"] - if ALLOWED_CHANNEL_IDS != "": + if ALLOWED_CHANNEL_IDS != "None": allowed_channel_ids = ALLOWED_CHANNEL_IDS.split(",") if channel not in allowed_channel_ids: # say("Sorry, I'm not allowed to respond in this channel.")