Carl Worth [Wed, 4 Jan 2023 02:54:09 +0000 (18:54 -0800)]
Add notes on how to update the Google sheets credentials
I had to reverse engineer this a little bit prior to the 2023 Mystery
Hunt, (by trying to use the "New Hunt" button in Turbot and finding an
error of "invalid_grant: Bad Request" coming from
gsheets_creds.refresh(Request()) in the CloudWatch logs for the turbot
lambda).
The new instructions here tell the admin how to update the Gsheets
credentials (by running ./gsheets-authenticate.py) and how to take the
value that results (in the .gsheets-pickle.base64 file) and put it
into the SSM parameter named GSHEETS_PICKLE_BASE64 in ASM Systems
Manager in the AWS interface.
Carl Worth [Mon, 24 Jan 2022 23:21:13 +0000 (15:21 -0800)]
Disable auto-invitation of members to each new puzzle channel
This is a temporary hack at the request of Avram who is still working
on MH 2022 puzzles even after the hunt is over, but he doesn't want to
disturb dozens of people with notifications of new channels.
Carl Worth [Wed, 12 Jan 2022 04:16:15 +0000 (20:16 -0800)]
Add code to auto-invite all users in a hunt to each new puzzle channel
We had originally written the code this way, long ago, but disabled it
(prior to MH 2021) when some people found it intrusive to be invited
to every channel, (rather than selecting the puzzles they were
interested in participating in). And after disabling it we also
deleted the code entirely in commit ef8d8f359be149adbbdbeda88ec4b6bbbebf928e
Prior to MH 2022 we had talked about adding a user preference since
some people would like to be auto-invited. But then we got a lot less
code written than we'd wanted to before MH 2022.
So we decided to add the auto-join feature back, (so that people could
see channels that have huddle icons for easily determining puzzles
that have active activity).
Carl Worth [Wed, 12 Jan 2022 03:58:21 +0000 (19:58 -0800)]
Abbreviate round name to only 7 characters in Slack channel name
Some users were nervous about the round portion of the channel name
overwhelming the space available for channel names, making it
impossible to distinguish one puzzle channel from another in the same
round. Restricting the round prefix to only 7 letters should help
mitigate that.
Carl Worth [Sat, 8 Jan 2022 10:46:43 +0000 (02:46 -0800)]
Announce to the hunt whenever a puzzle receives a new tag
This will hopefully help people stay abreast of puzzles that they are
most interested in (by having a central place to see which tags are
being added to puzzles).
Carl Worth [Sat, 8 Jan 2022 10:12:44 +0000 (02:12 -0800)]
Add tags field to the new_puzzle and edit_puzzle forms
This completes the puzzle edit form so that all state that can be
manipulated with slash commands can also be directly edited with the
interactive dialog form.
Carl Worth [Sat, 8 Jan 2022 09:20:02 +0000 (01:20 -0800)]
Don't set a channel description longer than 250 character.
Oops. The Slack channel description _is_ just as limited as the
channel topic, (only 250 characters). So we have to trim it just like
we trim the channel topic.
At least the description has the title first, so different information
will appear in the topic and description and hopefully everything
necessary at least appears in one place or the other.
Carl Worth [Sat, 8 Jan 2022 09:02:51 +0000 (01:02 -0800)]
Use common code for setting the channel topic and description
Previously, the initial setting of the topic and description was with
custom code, separate from the code that set the topic later due to
puzzle edits. Because of this code duplication, the formatting of
these two sets of code had drifted already. Making the initial setting
of topic use the existing puzzle_channel_topic() function eliminates
the code duplication.
Similarly, we give the channel description the same treatment that we
were already giving the channel topic. That is, we update it whenever
a puzzle edit would cause it to change. While we're doing that, and
since the puzzle description doesn't have the same short limit as the
channel topic, we expand it to be longer, (previously it was the same
text as the initial channel topic). So the new
puzzle_channel_description constructs a more verbose description which
now includes the puzzle title (which the channel topic no longer
includes after the previous commit), and also some helpful message
about links and commands.
Carl Worth [Sat, 8 Jan 2022 09:01:31 +0000 (01:01 -0800)]
Don't put the puzzle name into the channel topic
Since hunt writers do various things to torture us, (see Infinite
Corridor), and since the channel topic has a small limit, don't put
the puzzle title into the topic. Otherwise, a long puzzle title could
force the important links to not appear at all in the topic.
Carl Worth [Sat, 8 Jan 2022 08:27:11 +0000 (00:27 -0800)]
puzzle_copy: Copy the solution list as well
Otherwise, the new puzzle will be pointing at the old puzzle's
solution list, (and the code that looks to see if the solution list
has changed won't notice any change).
This fixes things so that using "/solved" to add a second (or third,
...) to a puzzle will now update the channel's topic, which wasn't
happening before.
Carl Worth [Sat, 8 Jan 2022 02:55:32 +0000 (18:55 -0800)]
Convert the solution data structure back to a list, (but still avoid dupes.)
The put_item call was not happy receiving a set object. So, instead of using
one, we use a lits and just take care to not add any duplicates to the list.
Carl Worth [Sat, 8 Jan 2022 02:31:33 +0000 (18:31 -0800)]
Use a set instead of a list for a puzzle's solution
This allows for cleaner handling when two solvers submit the same
solution back-to-back. Previously the identical solution would appear
multiple times in the list of solutions which was obviously not
helpful.
Carl Worth [Fri, 7 Jan 2022 03:28:42 +0000 (19:28 -0800)]
Add some utility code
None of this is really "part of" turbot, but is instead some
standalone code I've written from time to time either while testing
functionality or when live-tweaking something during hunt as follows:
sheets-test.py: Ensuring Google sheets API works as expected
blocks-test.py: Debugging some Slack blocks formatting
hunt-channel-topic-tweak.py: During MH 2021 it was useful (for
a reason I don't recall at the moment) to be able to manually
tweak the topic of some channels from a script and I whipped
these up at the moment.
It's not clear if any of this will be useful going forward, but just
in case I'm holding onto it for now. We may just want to delete this
code if we find we don't end up using it.
Carl Worth [Fri, 7 Jan 2022 03:24:18 +0000 (19:24 -0800)]
Edit the help messages for "new" and "edit"
The old help messages were confusing. It wasn't always clear that
"[puzzle]" meant an optional argument of literally the word "puzzle"
rather than the name of a particular puzzle to edit.
Instead, we encourage people to use these commands without arguments
(whenever possible, such as "/edit" for hunt or puzzle and "/new" for
puzzle) and to use clear literal arguments when necessary (such as
"/new hunt" from any channel or "/edit hunt" from within a puzzle
channel).
Carl Worth [Fri, 7 Jan 2022 00:55:47 +0000 (16:55 -0800)]
Add a README file for turbot
If nothing else, this will be helpful to remind me what the email
addresses are that I've been using for AWS and Google Drive accounts,
and also what the URL is for editing the Turbot app.
Carl Worth [Sat, 16 Jan 2021 15:47:45 +0000 (07:47 -0800)]
Live fix for apparently overflowing the Slack message limit with hunt details
Condense the Turbot Home view to only link to hunts, not give all the
details.
Change hunt_blocks() function to return an array of array of blocks,
(broken up at the level of a round). Callers now generate one post for
each element in the outer array. Hopefully this gives us a little
breathing room for now.
Carl Worth [Wed, 13 Jan 2021 04:03:36 +0000 (20:03 -0800)]
Switch from using append() to update() for inserting into a spreadsheet
The append() method was the entirely wrong thing: It puts data in as
new rows below existing data. The update() method does what we want,
(sets data at a specific range).
Carl Worth [Tue, 12 Jan 2021 01:56:47 +0000 (17:56 -0800)]
Use consistent channel naming at puzzle creation time
We've had a bug for some time where the puzzle editing code would
construct a name for the puzzle channel based on hunt, and round, and
puzzle type, and puzzle_id but the puzzle creation code was only using
hunt and puzzle_id.
In this commit, we fix the puzzle creation code to use the same
puzzle_channel_name function so that channel names are created
consistently.
This commit also adds a check to reject a puzzle if it has the same
puzzle_id as an existing puzzle.
Carl Worth [Tue, 12 Jan 2021 01:53:36 +0000 (17:53 -0800)]
Add find_puzzle_for_puzzle_id
This exists so that the puzzle-creation code can ensure that it's not
creating a puzzle with the same puzzle_id as an existing
puzzle. Previously, Turbot was just relying on Slack to guarantee
uniqueness, (which worked when channel names were just made from
hunt_id and puzzle_id).
But more recently, the channel names have round names in them as
well. This set up a possible collision where two puzzle with the same
puzzle_id could be created but with different channel names, (if the
two puzzles were placed in different rounds). To be able to fix this
bug we need this query to be able to find a puzzle by means of using
the puzzle_id.
This does require a new index on the database, so that's here too,
(and we're nuking our database to be able to roll this out).
Carl Worth [Tue, 12 Jan 2021 01:52:40 +0000 (17:52 -0800)]
Fix comment string for find_puzzle_for_sort_key
The documentation here was stale and still referring to puzzle_id even
though this function is actually using sort_key, (which is similar but
is also slightly different).
Carl Worth [Mon, 11 Jan 2021 22:25:06 +0000 (14:25 -0800)]
Expand list of pop-culture items to include video games
Perhaps bringing this list more up-to-date, (and also quite compatible
with the proclivities of ✈✈✈ Galactic Trendsetters ✈✈✈ who are writing
this year).
Carl Worth [Mon, 11 Jan 2021 17:54:57 +0000 (09:54 -0800)]
Drop use of response_url in button handlers
Some buttons appear in a context, (like the app's "Home" view), where
there is no response_url, (we can't generate a message there). So we
can't rely on this. And we don't need to anyway, we can use the string
in the reteurn value to get an error message out to the user.
This commit should fix a bunch of broken puzzle edits button in the
Turbot "home" view.
Carl Worth [Mon, 11 Jan 2021 16:00:40 +0000 (08:00 -0800)]
Add a "/hunt edit" command
We expect this to be useful for a situation like Mystery Hunt where we
create the hunt and its channel in advance, invite all the users to
it, and then only later do we learn what the URL of the hunt actually
is.
Carl Worth [Sun, 10 Jan 2021 23:41:57 +0000 (15:41 -0800)]
Add "/new hunt" as a new sub-command of "/new"
This means we now have both "/hunt new" as well as "/new hunt" that
both do the same things. I'm not sure we'll want to keep both around
long-term, but they are both here now so that we can experiment and
see which feels more natural.
Carl Worth [Sun, 10 Jan 2021 21:24:25 +0000 (13:24 -0800)]
Create puzzle sheets in the hunt folder
This will be much nicer to keep our content organized within Google
drive. There will be one folder for each hunt rather than all the
various hunts' puzzles all mixed together at the root level.
Carl Worth [Sun, 10 Jan 2021 17:52:27 +0000 (09:52 -0800)]
Use the Google drive API to create a hunt's sheet within a folder
When a hunt is created, we create a folder in Google drive named
after the hunt_id and the create the hunt's sheet in that folder.
In future commits, we'll change the puzzle sheets to also be created
in this hunt's folder. This way, with all resources in one folder,
that folder can be shared out to members of the hunt, (this could
be used as an alternate access to hunt resources if Slack is not
available for any reason).
Carl Worth [Sat, 9 Jan 2021 15:19:21 +0000 (07:19 -0800)]
Rewrite all of sheets.py to look a little more like turbot code
The only actual intended behavioral change here is that the puzzle
sheet's now nuke the blank first sheet, (and instead have only sheets
copied over from the template).
Carl Worth [Sat, 9 Jan 2021 13:47:33 +0000 (05:47 -0800)]
Fix sheet creation to copy all sheets from our template
Nathan put a lot of word into this template sheet, so it was a shame
the sheets weren't all coming over. It turned out the only reason that
was the case is that the code has a hard-coded list of names of sheets
to copy, (and that, only because I haven't yet figured out the API for
enumerating sheets).
For now, just update the hardcoded list to match what's in the current
template.
Carl Worth [Sat, 9 Jan 2021 13:42:59 +0000 (05:42 -0800)]
Update TODO for recent addition of /tag command
This _almost_ completed the feature as intended. In fact, it went
further in one way in that it's already storing the tags in a field
that is separate from the state string. But it's falling short in that
the edit interface is not currently showing the tags at all.
Carl Worth [Sat, 9 Jan 2021 13:16:20 +0000 (05:16 -0800)]
Use a deep copy when comparing a puzzle to detect state modifications
Since the recent tags is an array, we need a deep copy of the puzzle dict
in order to be able to reliably compare the puzzle prior to the copy with
the one after the copy where a tag has been added or removed.
With this fix, adding or removing a tag now reliably updates the channel
description.
Carl Worth [Sat, 9 Jan 2021 07:51:32 +0000 (23:51 -0800)]
Add new /puzzle command which simply prints the current puzzle
This is the same format one could get from the /hunt command, but
limited to the current puzzle. This is a very convenient way to see
all the puzzle fields and to get access to the pencil button to edit
the current puzzle.
Carl Worth [Sat, 9 Jan 2021 07:04:55 +0000 (23:04 -0800)]
Don't re-set channel and sheet name or channel topic to the same value as before
The puzzle_update_channel_and_sheet function is modified here to
accept an old_puzzle argument in addition to the puzzle argument. By
using this it can decide whether there's any change in the sheet or
channel data before setting it.
This optimization avoids Slack reporting things like:
Turbot renamed the channel from "hunt-puzzle" to "hunt-puzzle"
Carl Worth [Sat, 9 Jan 2021 06:38:26 +0000 (22:38 -0800)]
Unify code to rename channel, set channel description, and rename sheet
With this code, all of those changes are made consistently regardless of
whether the change happens from /state, /solved, or a puzzle edit (which
could set status to either "solved" or "unsolved").