From 7a94f1f8a21207d8badc40bc6798e225c47c2b60 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 1 Jan 2021 11:06:26 -0800 Subject: [PATCH] Restrict a Slack channel topic to 250 characters And terminate it with an ellipsis if the user-provided state string is too long. (It's a bit annoying that Slack returns an error rather than just doing this same thing itself, but whatever.) This satisfies a TODO item since users had encountered this error during our last hunt. --- TODO | 7 ------- turbot/interaction.py | 4 ++++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index dc5b41c..34d5a36 100644 --- a/TODO +++ b/TODO @@ -92,13 +92,6 @@ Un-prioritized items • Decide a good plan for audio/video calls for puzzles and integrate that into Turbot. -• Inspect the CloudWatch logs for our Turbot AWS Lambda during the time - period of the active hunt, (October 24-31), find and diagnose any - errors that occurred during that period. Users reported seeing - "Trouble connecting" (probably during new-puzzle dialog submission) - as well as "dispatch_failed during /state command (perhaps due to a - state string that was very long). - • Think about some way to express solve priority Lower priority diff --git a/turbot/interaction.py b/turbot/interaction.py index 8ccd247..dfe99c1 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -520,6 +520,10 @@ def set_channel_topic(turb, puzzle): if state: description += " {}".format(state) + # Slack only allows 250 characters for a topic + if len(description) > 250: + description = description[:247] + "..." + turb.slack_client.conversations_setTopic(channel=channel_id, topic=description) -- 2.43.0