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").
Carl Worth [Sat, 9 Jan 2021 06:19:29 +0000 (22:19 -0800)]
Reject puzzle edit if "solved" and "solution" are inconsistent
There's an argument here that we really shouldn't be giving the user
two different fields if we're forcing them to be edited together, but
that's what we have right now.
Carl Worth [Sat, 9 Jan 2021 02:44:29 +0000 (18:44 -0800)]
Implement update of puzzle when edit_puzzle dialog is submitted
Processing all user input and updating the database with the changes.
This isn't _quite_ updating everything in the channel and the sheet
that should be changed. To do that we simply need to refactor the code
that's currently doing that in various places to do it all in one
place.
Carl Worth [Sat, 9 Jan 2021 01:23:32 +0000 (17:23 -0800)]
Implement a dialog box to edit a puzzle
This is connected to the "pencil" buttons that were recently added to
the /hunt output as well as the Turbot home view.
So far, this brings up an editable dialog with the puzzle state but
doesn't actually do anything with any of the edits made when the user
saves the dialog.
Carl Worth [Fri, 8 Jan 2021 01:51:22 +0000 (17:51 -0800)]
Revamp the TODO list
The primary thing here is a sorted list of everything we want to
complete before a feature freeze, (which we're doing one weekend
before MH 2021 and will be followed by some test hunt over the weekend
both to flush out bugs and to get more of the team comfortable with
Turbot).
Carl Worth [Thu, 7 Jan 2021 17:05:34 +0000 (09:05 -0800)]
Wire up a function to handle the edit_puzzle button
It doesn't actually _do_ anything yet, but should at least prevent the
warning sign which was appearing before.
And this should let us see if the action_id field is a good way of
plumbing the hunt_id and puzzle_id through to the handler for the
press of the edit_puzzle button.
Carl Worth [Tue, 5 Jan 2021 18:57:23 +0000 (10:57 -0800)]
Update TODO now that /hunt accepts a search term
Given the way the original TODO item was written, (as adding support
to both /home and to the Turbot home screen), this recent feature
addition doesn't delete an entire item from the TODO list, but it does
deserve to.
Carl Worth [Tue, 5 Jan 2021 18:43:44 +0000 (10:43 -0800)]
Use Slack back-tick quoting for search terms
This is cleaner both for preventing misinterpreting asterisks and also
more clear than re-inserting quotation marks for search terms that
include spaces.
Carl Worth [Tue, 5 Jan 2021 18:39:49 +0000 (10:39 -0800)]
Tweak bolding of hunt lead-in line from search results
Using bold just for the puzzle status word. (This is an attempt to
avoid Slack seeing a '*' in a regular expression of a search term and
think that it means to make something bold.)
Carl Worth [Tue, 5 Jan 2021 16:31:34 +0000 (08:31 -0800)]
Add search terms to the /hunt command
Now, `/hunt <search-term>` can be used to list puzzles matching
<search-term>. As before, it will display only unsolved puzzles by
default, but `/hunt all <search-term>` or `/hunt solved <search-term>`
can be used to display other puzzles as well.
Carl Worth [Tue, 5 Jan 2021 02:41:07 +0000 (18:41 -0800)]
Farm blocks-creation code out to various supporting files
The code will be easier to manage with separate hunt, round, puzzle,
and channel.py files each responsible for maintaining their own
functionality. We don't yet have any classes in any of these files,
(just functions that look things up in the database and that generate
Slack blocks), but we may end up doing classes later, (particularly if
we start wanting methods to update a single attribute in the database
for a given item, etc.).
Carl Worth [Sat, 2 Jan 2021 17:24:53 +0000 (09:24 -0800)]
Prevent failure of /solved command if /state had never been run
The recent code to make /solved clear the /state field was buggy in
that it would result in a dispatch_failed error in Slack if /state had
never been invoked previously.
Carl Worth [Sat, 2 Jan 2021 07:20:01 +0000 (23:20 -0800)]
TODO: Add a low-priority item for using a URL shortener
One downside of doing something like this is that it would introduce a
dependence on another third-party service, so I'm not really all that
keen on pursuing this.
Carl Worth [Sat, 2 Jan 2021 05:31:20 +0000 (21:31 -0800)]
Drop leading/trailing spaces and empty strings when parsing rounds
Since we're dealing with user input here, it's easy for their to be
leading and trailing space (which we don't want as part of the round
name), or even an accidentally emty round (from two consecutive
commas). Drop any of those spaces and ignore any empty round strings.
Carl Worth [Sat, 2 Jan 2021 05:22:21 +0000 (21:22 -0800)]
Fix storage of rounds for new puzzle creation
To store an array of strings rather than storing each character from
the round string as an individual round (oops!).
That is, before this fix, if the user typed a round name of "Colors" the
database would store a rounds array for the puzzle with values of "C",
"o", "l", "o", "r", and "s".
Carl Worth [Fri, 1 Jan 2021 19:13:28 +0000 (11:13 -0800)]
Drop TODO item regarding audio/video calls
Nathan is planning on signing up for a paid plan with Slack
temporarily (over the period of Mystery Hunt) specifically to get
access to Slack video calls. These are already fully integrated
(allowing a call to everyone who belongs to a channel) which means
that that will allow for a call to everyone working on a given
puzzle. So I don't think we'll need any specific work to integrate
Turbot with this approach.
Carl Worth [Fri, 1 Jan 2021 19:06:26 +0000 (11:06 -0800)]
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.