From 122a99d8ea8131917f71bcc9a3fe3f74caf97232 Mon Sep 17 00:00:00 2001 From: Rob Siemborski Date: Fri, 6 Dec 2024 14:29:46 -0500 Subject: [PATCH 1/3] Alias !cube.rocks and !cube.sucks for their regular commands. --- zdaemon/cube.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zdaemon/cube.py b/zdaemon/cube.py index 1f0391e..0284c1b 100644 --- a/zdaemon/cube.py +++ b/zdaemon/cube.py @@ -1025,10 +1025,10 @@ def cubeSlackRouter(message): # most recent cube thread. cubeInfo(text, sendResponse, slack_channel=message['channel']) - if (re.search(r"^!cubesucks($|\s)", text)): + if (re.search(r"^!cube\.?sucks($|\s)", text)): cubeSucksSlack(1, message, sendResponse) - if (re.search(r"^!cuberocks($|\s)", text)): + if (re.search(r"^!cube\.?rocks($|\s)", text)): cubeSucksSlack(-1, message, sendResponse) if (re.search(r"^!(slurpcube|cubeslurp)($|\s)", text)): From 8b3f642918d34ec7675fefdee6ad2e4a1b7ccc23 Mon Sep 17 00:00:00 2001 From: Rob Siemborski Date: Wed, 26 Feb 2025 07:29:46 -0500 Subject: [PATCH 2/3] Fix bot handling for non-classic/non-RTM bots. --- zdaemon/zdaemon.py | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/zdaemon/zdaemon.py b/zdaemon/zdaemon.py index ad21e4d..7b37dfc 100644 --- a/zdaemon/zdaemon.py +++ b/zdaemon/zdaemon.py @@ -234,12 +234,23 @@ def zdaemon_slack_router(triggers, ack, say, message): # print ("zdaemon_slack_router event: %s[%s]/%s" % # (message['type'], message['channel_type'], # message['subtype'] if 'subtype' in message else 'None')) + # -- and/or -- + # print(message) - - bridge_bot_message = False + bot_message = False # A message from any bot + bridge_bot_message = False # A message specifically from the bridge bot if ('subtype' in message and - message['subtype'] == 'bot_message' and + message['subtype'] == 'bot_message' or 'bot_id' in message): + # Classic bots use the 'bot_message' subtype, but modern apps do not. + # Regardless, all bots should include a bot_id. + # + # This check is therefore slightly more conservative than we need, + # but we really don't want to find ourselves handling bot messages + # unexpectedly. + bot_message = True + + if (bot_message and 'bot_id' in message): # Need to look up the bot and add the user id to the message. userid = get_slack_bot_userid(message['bot_id']) message['user'] = userid @@ -254,6 +265,9 @@ def zdaemon_slack_router(triggers, ack, say, message): # so only do true messages (no subtype) and replies for now. (note: slack doesn't actually appear # to send the message_replied subtype as of Sep 2024) # + # Note: You really want to do this first before any other check, since we might get a bot + # loop via the other sanity checks below. + # # This gets rid of bot_message explicity (so we avoid loops with other bots), which is nice, # but also removes troublesome things like message_changed and message_deleted which would # need their own very specific handling. @@ -270,14 +284,14 @@ def zdaemon_slack_router(triggers, ack, say, message): # channel. These seem to be paried with a message_changed, which thankfully don't # seem to be relevant for our purposes. # - # Note: You really want to do this first before any other check, since we might get a bot - # loop via the other sanity checks below. + # Apologies for the complexity of this check. It could almost certainly be better. if ('subtype' in message and - (message['subtype'] not in ['thread_broadcast', - 'message_replied', - 'file_share', - 'bot_message'] or - (message['subtype'] == 'bot_message' and not bridge_bot_message))): + (message['subtype'] not in ['thread_broadcast', + 'message_replied', + 'file_share', + 'bot_message'] or + (message['subtype'] == 'bot_message' and not bridge_bot_message)) or + bot_message and not bridge_bot_message): # DEBUG # print("zdaemon_slack_router ignoring message: %s" % message) return From 95c29f10beedda99a69911ed1cf2aeb6eeeea2ba Mon Sep 17 00:00:00 2001 From: Rob Siemborski Date: Thu, 27 Feb 2025 05:32:39 -0500 Subject: [PATCH 3/3] Update many dependencies. - Clear dependabot alerts - Upgrade slack SDKs. --- zdaemon/requirements.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/zdaemon/requirements.txt b/zdaemon/requirements.txt index 8b5df6e..f4bbebb 100644 --- a/zdaemon/requirements.txt +++ b/zdaemon/requirements.txt @@ -1,18 +1,18 @@ cachetools==5.3.2 -certifi==2023.11.17 +certifi==2024.7.4 charset-normalizer==3.3.2 click==8.1.7 cowsay==6.1 distro==1.9.0 -idna==3.6 -Jinja2==3.1.3 +idna==3.7 +Jinja2==3.1.5 MarkupSafe==2.1.5 pytz==2023.4 PyYAML==6.0.2 -requests==2.31.0 +requests==2.32.3 simplejson==3.19.2 -slack-bolt==1.18.1 -slack_sdk==3.27.0 +slack-bolt==1.22.0 +slack_sdk==3.34.0 typing_extensions==4.9.0 -urllib3==2.1.0 +urllib3==2.2.2 zulip==0.9.0