]> git.cworth.org Git - turbot/log
turbot
3 years agoRemove code (previously disabled) to invite users to new puzzle channel
Carl Worth [Thu, 31 Dec 2020 21:53:27 +0000 (13:53 -0800)]
Remove code (previously disabled) to invite users to new puzzle channel

Instead, add a message to the hunt channel with a link to the new
puzzle channel whenever a new puzzle is created.

3 years agoRename local variable from item to puzzle
Carl Worth [Thu, 31 Dec 2020 21:51:33 +0000 (13:51 -0800)]
Rename local variable from item to puzzle

The overly-generic name here was not at at useful.

With this specific name, the code will be much more clear when it says
things like hunt['channel_id'] vs. puzzle['channel_id'].

3 years agoRename primary-key attribute from PK to hunt_id
Carl Worth [Thu, 31 Dec 2020 20:05:13 +0000 (12:05 -0800)]
Rename primary-key attribute from PK to hunt_id

I was just about to add a separate attribut to every item in the
database named hunt_id when I realized that that was totally redundant
with our existing PK attribute (whose values were simply the hunt_id
prefixed by "hunt-" in all cases).

Since we're not using the PK field in any generalized sense, (that is,
it's _always_ populated with the hunt_id value), it's much simpler and
more efficient to just name it "hunt_id" and store the hunt_id valeu
ther directly (without any prefix).

3 years agoRename hunt_id_index to is_hunt_index
Carl Worth [Thu, 31 Dec 2020 19:52:43 +0000 (11:52 -0800)]
Rename hunt_id_index to is_hunt_index

Backed, of course, by a new is_hunt attribute.

The rationale here is that the whole point of this index is to be a
sparse attribute so that the code can efficiently query all existing
hunts. But meanwhile, it's useful for puzzles to have a "hunt_id"
attribute, which would confict with the goal of having "hunt_id" be
sparse and populated only for hunts and not puzzles.

So the fix here is to make hunt_id universal, and instead have a
separate "is_hunt" attribute which is the sparse one, (and will
clearly never be populated for a puzzle).

3 years agoDon't put an attribute into the database for 'url' that is left blank
Carl Worth [Thu, 31 Dec 2020 18:29:54 +0000 (11:29 -0700)]
Don't put an attribute into the database for 'url' that is left blank

The URL field, (for either a hunt or a puzzle), is an optional
parameter, (the user creating the hunt or puzzle may or may not
provide a URL). Immediately prior to this commit, if a user left the
URL field blank, the submission handler was receiving a value of None
and inserting that as an attribute in the database.

This was problematic as subsequent code, (such as sheet creation),
would be prepared for an item to have no url key at all, but was not
prepared for the key to be present but for the value to be empty.

We fix this in this commit by explicitly _not_ inserting a None value
for url as an attribute in the database item, (instead, not supplying
a url attribute at all).

3 years agoConvert /puzzle puzzle creation to all-one-table database schema
Carl Worth [Thu, 31 Dec 2020 17:31:24 +0000 (10:31 -0700)]
Convert /puzzle puzzle creation to all-one-table database schema

So we put the hunt ID into the PK field and the puzzle ID into the SK field,
(allowing puzzle items to be distinguished from hunt items in the table).

While doing this, we also disable the feature of inviting all hunt
users to the new puzzle. This is both because that code hasn't been
ported to the new schema, and also because that feature is planned to
be eliminated anyway.

3 years agoHome: Update query for finding puzzles to new all-one-table schema
Carl Worth [Thu, 31 Dec 2020 17:22:04 +0000 (10:22 -0700)]
Home: Update query for finding puzzles to new all-one-table schema

Previously, we looked in a separate per-hunt table to find the puzzles
for a hunt. Now, instead, we look in the single "turbot" table and
find puzzles for a hunt by looking for items whose PK is
"hunt-<HUNT_ID>" and whose SK starts with "puzzle-".

3 years agoRework message given when bootstrapping the turbot table
Carl Worth [Thu, 31 Dec 2020 17:16:27 +0000 (10:16 -0700)]
Rework message given when bootstrapping the turbot table

This provides a little more information, (such as that a user should
wait a minute before retrying), and is a little more polite, (saying
"please").

3 years agoTurbot home: Use recently added hunt_id_index to find existing hunts
Carl Worth [Thu, 31 Dec 2020 17:14:17 +0000 (10:14 -0700)]
Turbot home: Use recently added hunt_id_index to find existing hunts

This fixes the home view to correctly use the new single-table schema to
find the list of available hunts. This view is now working to display
the names of active hunts a user belongs to.

(No puzzles are listed yet. That part of the home view still needs to be
brought up to date with the latest schema.)

3 years agoTurbot home: Report "you do not belong to any hunts" if that is the case
Carl Worth [Thu, 31 Dec 2020 16:41:45 +0000 (09:41 -0700)]
Turbot home: Report "you do not belong to any hunts" if that is the case

Instead of having the header "Hunts you belong to" followed by nothing.

3 years agoAdd a hunt_id attribute and index to the database for hunts
Carl Worth [Wed, 30 Dec 2020 20:31:12 +0000 (13:31 -0700)]
Add a hunt_id attribute and index to the database for hunts

This will allow the Turbot home view to scan the hunt_id_index to find
all existing hunts, (without having to scan non-hunt items from the
database).

3 years agoFix stale usage of "puzzle_table"
Carl Worth [Wed, 30 Dec 2020 20:21:55 +0000 (13:21 -0700)]
Fix stale usage of "puzzle_table"

We no longer haave a separate table for puzzles, but instead the single
"turb.table" holds all of our data.

This doesn't fully convert this code to the new single-table schema,
but it should at least let things pass the flake8 test and deployment.

3 years agoRequire flake8 to pass before performing deployment
Carl Worth [Wed, 30 Dec 2020 20:19:19 +0000 (13:19 -0700)]
Require flake8 to pass before performing deployment

Trying to speed up debug cycles by catching errors without having to
wait for them to show up in CloudWatch logs.

3 years agoAdd a "make flake" recipe and clean up some style bugs flake8 noticed
Carl Worth [Wed, 30 Dec 2020 20:17:43 +0000 (13:17 -0700)]
Add a "make flake" recipe and clean up some style bugs flake8 noticed

We also ignore some rules about whether or not there's a space on
either side of some operators, since I fundmanetally disagree with
flake8 on some of these.

3 years agoBeginning of transition to single-table database schema
Carl Worth [Tue, 29 Dec 2020 23:33:37 +0000 (16:33 -0700)]
Beginning of transition to single-table database schema

This is aiming for a one-big-table approach, (which is the DynamoDB
best practice), instead of having one table for hunts and then a
separate per-hunt table for puzzles.

This new approach will be more flexible as we start adding database
items for rounds, etc. In the old approach, rounds would likely have
become yet another hunt-specific table, and the number of per-hunt
tables would have started to become rather messy.

With this new schema, rounds can instead be just another item, where
hunts, rounds, and puzzles can all be intermingled as items in the
same table.

To get this all to work, we are creating secondary indexes for
querying items from the database via attributes other than the primary
key, (for example a "channel_id" index).

As of this commit, the "New Hunt" button works in that it:

  * Creates the turbot DynamoDB table if it doesn't exist

  * Inserts a new item into the table for the hunt itself (active=False)

  * Marks the sheet_url of the item as "pending"

  * Creates a new channel for the hunt

  * Responds to the channel_created event

  * Creates a Google sheet for the hunt

  * Stores the sheet_url in the database

  * Marks the hunt as active=True in the database

  * Reports to the Slack channel that things are working

So that much is working, but everything else has yet to be converted
to the new schema. So things that don't yet work include at least:

  * The turbot "Home" view doesn't yet display anything

  * The /puzzle command doesn't work yet

3 years agoRework the TODO list to capture recent-discussed priorities
Carl Worth [Mon, 28 Dec 2020 16:49:20 +0000 (09:49 -0700)]
Rework the TODO list to capture recent-discussed priorities

Thanks, Nathan!

3 years agoAdd TODO item for displaying who has current roles
Carl Worth [Mon, 28 Dec 2020 16:28:13 +0000 (09:28 -0700)]
Add TODO item for displaying who has current roles

This was an idea proposed during the recent hunt kickoff meeting.

3 years agoDrop quotation marks from around puzzle name
Carl Worth [Sun, 27 Dec 2020 20:40:56 +0000 (12:40 -0800)]
Drop quotation marks from around puzzle name

This is already being formatted as a link, so we don't need quoation
marks as well.

3 years agoAdd (and use) a new function find_hunt_for_hunt_id
Carl Worth [Sun, 27 Dec 2020 20:34:58 +0000 (12:34 -0800)]
Add (and use) a new function find_hunt_for_hunt_id

The code to call get_table_item with a hunt_id was broken, (since in
the schema, hunt_id is not the key, only channel_id is), so instead we
need to scan the table looking for a matching hunt_id. We already had
code to do this is find_hunt_for_channel, so here we factor that out
into a new function, find_hunt_for_hunt_id and call it instead of
get_table_item.

3 years agoAdd hunt_id to the puzzle table (instead of orig_channel_name)
Carl Worth [Sun, 27 Dec 2020 20:11:59 +0000 (12:11 -0800)]
Add hunt_id to the puzzle table (instead of orig_channel_name)

A recent commit (to announce /solved in the main hunt channel)
expected to find hunt_id in this table, but it wasn't there. So we add
it in this commit. And while adding it, we drop the orig_channel_name
field, (which embedded both hunt_id and channel_id into a single field
in the database so would have made renaming of the hunt_id rather
awkward).

3 years agoFix Makefile to not hard-code python3.8
Carl Worth [Sun, 27 Dec 2020 19:42:07 +0000 (11:42 -0800)]
Fix Makefile to not hard-code python3.8

Apparently I'm using python 3.9 now. Fix the Makefile so that the
deploy recipe should work with any version of python.

3 years agoMake the /solved command report to the hunt's channel
Carl Worth [Sun, 27 Dec 2020 19:35:15 +0000 (11:35 -0800)]
Make the /solved command report to the hunt's channel

So that there's a log in the main hunt channel for when each puzzle
gets solved.

3 years agoRework find_hunt_for_channel to return a hunt dictionary
Carl Worth [Sun, 27 Dec 2020 19:25:03 +0000 (11:25 -0800)]
Rework find_hunt_for_channel to return a hunt dictionary

It's going to be most convenient to return hunt and puzzle dictionaries
that contain all entries from the database, (rather than a hard-coded
tuple which is likely to not contain every piece of data we'll eventually
want to have).

3 years agoUse consistent formatting for channel name and spreadsheet name
Carl Worth [Sun, 27 Dec 2020 18:48:23 +0000 (10:48 -0800)]
Use consistent formatting for channel name and spreadsheet name

Specifically, using a prefix of "SOLVED: " when a puzzle is solved.

3 years agoSimply typo fix
Carl Worth [Sun, 27 Dec 2020 18:47:54 +0000 (10:47 -0800)]
Simply typo fix

It's AWS, not AW.

3 years agoUpdate TODO
justin melvin [Sat, 28 Nov 2020 06:59:01 +0000 (22:59 -0800)]
Update TODO

3 years agoAppend "-solved" to puzzle channel names when /solved
justin melvin [Sat, 28 Nov 2020 06:49:59 +0000 (22:49 -0800)]
Append "-solved" to puzzle channel names when /solved

3 years agoUpdate TODO
justin melvin [Sat, 28 Nov 2020 06:27:51 +0000 (22:27 -0800)]
Update TODO

3 years agoTypo
justin melvin [Sat, 28 Nov 2020 06:22:26 +0000 (22:22 -0800)]
Typo

3 years agoFinally I found out how to make the stupid batch API work
justin melvin [Sat, 28 Nov 2020 06:16:48 +0000 (22:16 -0800)]
Finally I found out how to make the stupid batch API work

3 years agoI am not a fan of this api's documentation
justin melvin [Sat, 28 Nov 2020 04:59:24 +0000 (20:59 -0800)]
I am not a fan of this api's documentation

3 years agoFix function arguments
justin melvin [Sat, 28 Nov 2020 04:51:52 +0000 (20:51 -0800)]
Fix function arguments

3 years agoFix typo
justin melvin [Sat, 28 Nov 2020 04:42:56 +0000 (20:42 -0800)]
Fix typo

3 years agoRename sheets with 'SOLVED - ' prefix when /solved
justin melvin [Sat, 28 Nov 2020 04:34:20 +0000 (20:34 -0800)]
Rename sheets with 'SOLVED - ' prefix when /solved

3 years agoUpdate TODO list
justin melvin [Sat, 28 Nov 2020 00:23:41 +0000 (16:23 -0800)]
Update TODO list

3 years agoQuote parameters to HYPERLINK
justin melvin [Sat, 28 Nov 2020 00:18:10 +0000 (16:18 -0800)]
Quote parameters to HYPERLINK

3 years agoFix arguments to HYPERLINK
justin melvin [Sat, 28 Nov 2020 00:03:33 +0000 (16:03 -0800)]
Fix arguments to HYPERLINK

3 years agoFix typo and make hyperlinks in the sheets work
justin melvin [Thu, 26 Nov 2020 05:22:47 +0000 (21:22 -0800)]
Fix typo and make hyperlinks in the sheets work

3 years agoAdd some additional todo items from Justin Melvin
Carl Worth [Sun, 1 Nov 2020 18:00:56 +0000 (10:00 -0800)]
Add some additional todo items from Justin Melvin

Thanks for these additional ideas!

3 years agoAdd a TODO file
Carl Worth [Sun, 1 Nov 2020 17:55:32 +0000 (09:55 -0800)]
Add a TODO file

With all the ideas gathered during the recent Teammate Hunt.

3 years agoUse blocks to send the welcome message
Carl Worth [Fri, 23 Oct 2020 21:29:06 +0000 (14:29 -0700)]
Use blocks to send the welcome message

This approach has the benefit of allowing separate sections, (I tried
doing this with newlines in the 'text' parameter but they were getting
swallowed by Slack).

3 years agoAdd a welcome message to any new puzzle channel that is created.
Carl Worth [Fri, 23 Oct 2020 18:16:20 +0000 (11:16 -0700)]
Add a welcome message to any new puzzle channel that is created.

This gives links to the original puzzle's URL and also explains how to
use the /state and /solved commands.

3 years agoLimit Turbot home display to hunts a user belongs to
Carl Worth [Fri, 23 Oct 2020 14:48:55 +0000 (07:48 -0700)]
Limit Turbot home display to hunts a user belongs to

Membership is determined by membership in a hunt's primary slack channel.

3 years agoAdd some links to the puzzle sheet when originally creating it
Carl Worth [Fri, 23 Oct 2020 14:18:31 +0000 (07:18 -0700)]
Add some links to the puzzle sheet when originally creating it

Linking both to the original puzzle as well as to the slack channel.

3 years agoUse a clean name for the hunt's sheet as well
Carl Worth [Fri, 23 Oct 2020 13:49:02 +0000 (06:49 -0700)]
Use a clean name for the hunt's sheet as well

Just as we did for the puzzle's sheet in the previous commit.

3 years agoName sheet based on puzzle name, not puzzle channel ID
Carl Worth [Fri, 23 Oct 2020 13:47:38 +0000 (06:47 -0700)]
Name sheet based on puzzle name, not puzzle channel ID

We don't have the same restrictions on the sheet name that we have on
the channel name, so let the original name go through.

3 years agoDrop the puzzle ID field from the /puzzle dialog
Carl Worth [Fri, 23 Oct 2020 13:41:41 +0000 (06:41 -0700)]
Drop the puzzle ID field from the /puzzle dialog

Much easier to just have the bot generate this instead.

3 years agoAdd some feedback to the puzzle's channel when a puzzle is solved
Carl Worth [Fri, 23 Oct 2020 13:18:54 +0000 (06:18 -0700)]
Add some feedback to the puzzle's channel when a puzzle is solved

Without this, the '/solved' command felt rather anti-climactic.

3 years agoAdd a slack_send_message function
Carl Worth [Fri, 23 Oct 2020 13:07:36 +0000 (06:07 -0700)]
Add a slack_send_message function

Just to replace the ugliness of turb.slack_client.chat_postMessage

3 years agoCache SSM parameter values into environment variables
Carl Worth [Fri, 23 Oct 2020 12:54:27 +0000 (05:54 -0700)]
Cache SSM parameter values into environment variables

The goal here is to reduce SSM parameter reads/writes. Hopefully, as
AWS reuses a container for multiple calls to our Lambda function,
these values can be read from the environment instead of needing to
reach out to AWS.

The reason we want to reduce calls to SSM functions in that AWS Free
Tier gives us only 20,000 KMS requests compared to 1,000,000 AWS
Lambda requests.

3 years agoAfter creating spreadsheets, make them writable by anyone with a link
Carl Worth [Fri, 23 Oct 2020 04:40:36 +0000 (21:40 -0700)]
After creating spreadsheets, make them writable by anyone with a link

This requires a new scope for our credentials, and a new service. But
with those in place, it's just a single API call.

3 years agoFix bug that was causing a dispatch_failed on /puzzle in a non-puzzle channel
Carl Worth [Fri, 23 Oct 2020 00:47:21 +0000 (17:47 -0700)]
Fix bug that was causing a dispatch_failed on /puzzle in a non-puzzle channel

This was some return-type mismatch and other breakage from recent
reworking of channel_is_hunt.

3 years agoAdd an implementation of the /solved command
Carl Worth [Fri, 23 Oct 2020 00:40:43 +0000 (17:40 -0700)]
Add an implementation of the /solved command

For marking a known solution to a puzzle.

3 years agoAdd display of state string to turbot view of each puzzle
Carl Worth [Fri, 23 Oct 2020 00:34:01 +0000 (17:34 -0700)]
Add display of state string to turbot view of each puzzle

This will be helpful in getting an overview of things.

3 years agoAdd missing return value for /state command
Carl Worth [Fri, 23 Oct 2020 00:31:20 +0000 (17:31 -0700)]
Add missing return value for /state command

So that it can be happy now.

3 years agoActually wire up the state command
Carl Worth [Fri, 23 Oct 2020 00:28:27 +0000 (17:28 -0700)]
Actually wire up the state command

Or else it won't do anything.

3 years agoDon't allow capital letters in a hunt or puzzle ID
Carl Worth [Fri, 23 Oct 2020 00:25:48 +0000 (17:25 -0700)]
Don't allow capital letters in a hunt or puzzle ID

Since Slack won't allow them in a channel name.

3 years agoAdd a /state command to let users indicate the state of a puzzle
Carl Worth [Fri, 23 Oct 2020 00:24:28 +0000 (17:24 -0700)]
Add a /state command to let users indicate the state of a puzzle

And this state is shoved into the channel topic.

3 years agoReduce the burst of noise from turbot on channel creation
Carl Worth [Thu, 22 Oct 2020 22:52:04 +0000 (15:52 -0700)]
Reduce the burst of noise from turbot on channel creation

This takes the number of messages it spews from 5 down to 2, so
reducing a bunch of extraneous noise.

3 years agoAt channel creation time, lodge Puzzle and Sheet URLs into channel topic
Carl Worth [Thu, 22 Oct 2020 22:44:53 +0000 (15:44 -0700)]
At channel creation time, lodge Puzzle and Sheet URLs into channel topic

And the channel description as well, (which isn't as useful but does
appear in some places).

3 years agoMake the puzzle's name a link to the sheet
Carl Worth [Thu, 22 Oct 2020 22:07:19 +0000 (15:07 -0700)]
Make the puzzle's name a link to the sheet

Otherwise, there's just a wall of "Channel" and "Sheet" links which is
disorienting.

3 years agoAdd links to puzzle url and sheet_url on the turbot home app
Carl Worth [Thu, 22 Oct 2020 21:51:59 +0000 (14:51 -0700)]
Add links to puzzle url and sheet_url on the turbot home app

So that whatever links people want, they can all be easily found.

3 years agoUse absolute URLs to link to channels
Carl Worth [Thu, 22 Oct 2020 12:15:04 +0000 (05:15 -0700)]
Use absolute URLs to link to channels

This way we can just make the puzzle name a link rather than having
the noise of the channel name present in the view too, (which doesn't
actually add anything).

3 years agoAdd a list of puzzles under each hunt on the Turbot home tab
Carl Worth [Thu, 22 Oct 2020 11:08:30 +0000 (04:08 -0700)]
Add a list of puzzles under each hunt on the Turbot home tab

Giving a simple overview of all puzzles in one place, including an emoji
indication of whether the puzzle is solved or not.

3 years agoDrop handling of a "placeholder" value for channel_id
Carl Worth [Thu, 22 Oct 2020 11:03:54 +0000 (04:03 -0700)]
Drop handling of a "placeholder" value for channel_id

We're not using this anymore, (instead starting out with active=False
until the hunt is really up and running).

3 years agoTeach '/puzzle' how to do its magic in a puzzle channel
Carl Worth [Thu, 22 Oct 2020 10:54:27 +0000 (03:54 -0700)]
Teach '/puzzle' how to do its magic in a puzzle channel

By looking up the corresponding hunt in the database, we can now invoke
a '/puzzle' command in the channel of any existing puzzle in the hunt.

3 years agoDrop the hunt_channel_id from the metadata passed in the puzzle modal
Carl Worth [Thu, 22 Oct 2020 10:36:51 +0000 (03:36 -0700)]
Drop the hunt_channel_id from the metadata passed in the puzzle modal

We've now got another handoff, from the puzzle modal's submission
handler to a separate channel_created event before the hunt's
channel_id is needed. And by then we've lost the context of this
private_metadata, (so the current code scans through the database
'hunts' table to find the ID). Given all that, we can drop this unused
field from the metadata.

3 years agoSome simple flake8 fixes
Carl Worth [Thu, 22 Oct 2020 10:36:10 +0000 (03:36 -0700)]
Some simple flake8 fixes

Thanks flake8 for keeping me on my toes!

3 years agofixup
Carl Worth [Thu, 22 Oct 2020 10:34:50 +0000 (03:34 -0700)]
fixup

3 years agoDefer all sheet creation until after the channel is created
Carl Worth [Thu, 22 Oct 2020 07:50:09 +0000 (00:50 -0700)]
Defer all sheet creation until after the channel is created

Specifically, we no longer attempt to do sheet creation in the handler
for the interaction of the user submitting a modal dialog. The reason
that was a a bad idea is that the sheet creation can take several
seconds, (including time to copy data from a template sheet, etc.),
while Slack will timeout after merely 3 seconds of a user submission
and report an error.

This way, we can promptly validate the user's input (giving them a
clean error on the form if necessary), then simply create the channel
in the handler and primomptly return (so Slack doesn't timeout).

Then, separately, we now have a listener setup for the channel_created
event and in _that_ handler we do all the sheet creation necessary. We
have all the time we want here since channel_created is just an event
without a user waiting for a response, so Slack doesn't impose a
3-second timeout on us.

3 years agoCreate the hunts table if it doesn't already exist
Carl Worth [Thu, 22 Oct 2020 09:37:04 +0000 (02:37 -0700)]
Create the hunts table if it doesn't already exist

I just realized I was probably missing a necessary index on the hunts
table, meaning I need to destroy it ad recreate it. But I don't want
to do that manually without any code to capture what I did.

And if I'm going to write code, I might as well have that code called
implcitly as needed. So that's what's present here, the code necessary
to create the hunts table if it doesn't already exist.

3 years agoImplement a new `/puzzle` slash command to create a puzzle
Carl Worth [Wed, 21 Oct 2020 23:12:42 +0000 (16:12 -0700)]
Implement a new `/puzzle` slash command to create a puzzle

This command doesn't (yet) accept any arguments. Instead, it pops up a
modal dialog to prompt for the puzzle name, ID, and URL.

The command also only works from a top-level hunt channel.

Some things that would be nice improvements here:

  * Auto-fill the puzzle ID based on the puzzle name without
    punctuation and spaces replaced with underscores.

  * Allow the command to work from the channel of any puzzle in the
    hunt

  * Fix the bug that the modal dialog reports an error even when
    things work correctly, (the problem is that the lambda is taking
    more than the maximum 3 seconds that Slack is willing to wait for
    a response).

3 years agoCombine actions.py and commands.py into interaction.py
Carl Worth [Wed, 21 Oct 2020 23:00:20 +0000 (16:00 -0700)]
Combine actions.py and commands.py into interaction.py

We're about to create a new slash command that fires up a modal, and
the response to that modal will be an action. So we want the
implementation of that slash command (which creates the view for the
modal) to be in the same file as the handler for the action.

So we combine these together for now.

If this file become unwieldy later, we can re-separate things based on
functional groups, (interactions related to hunts, puzzles, word-play
utilities, etc.), but always keeping the view creators and the
view-submission handlers together for any given view.

3 years agoDon't shove the local variable hunts_table into the turb object
Carl Worth [Wed, 21 Oct 2020 20:41:07 +0000 (13:41 -0700)]
Don't shove the local variable hunts_table into the turb object

It's not a very clean thing to do, and it's never referenced anywhere
else anyway.

3 years agoDrop unused initialization of submission_handlers dictionary
Carl Worth [Wed, 21 Oct 2020 20:38:40 +0000 (13:38 -0700)]
Drop unused initialization of submission_handlers dictionary

We don't use this dictionary with any statically-initialized keys,
(such as "new_hunt" as we have it here). Instead, this dictionary is
populated dynamically with keys that are view IDs. So we can just drop
this initialization here and everything continues to work as is.

3 years agoMake text optional for slash commands
Carl Worth [Wed, 21 Oct 2020 18:57:45 +0000 (11:57 -0700)]
Make text optional for slash commands

We're planning a new approach which is to make it so that a slash
command with no argument string pops up a modal dialog. For this to
work, we have to allow for a body that includes no 'text' key.

3 years agoDont' allow hunt_id to contain a hyphen
Carl Worth [Wed, 21 Oct 2020 18:46:09 +0000 (11:46 -0700)]
Dont' allow hunt_id to contain a hyphen

We're planning to use a hyphen in the puzzles' channel names to
separate the hunt_id from the rest of the puzzle's channel name, so
the hunt_id itself must not contain any hyphen.

3 years agoRename 'slug' field in hunt table to 'hunt_id'
Carl Worth [Wed, 21 Oct 2020 18:40:38 +0000 (11:40 -0700)]
Rename 'slug' field in hunt table to 'hunt_id'

We were already using the name "Hunt ID" in all user-visibile
interfaces, so there was no good justification for having a totally
different name internally.

3 years agoAdd a stub function for hanlding a shortcut invocation
Carl Worth [Wed, 21 Oct 2020 16:39:54 +0000 (09:39 -0700)]
Add a stub function for hanlding a shortcut invocation

We're not currently pursuing this option, (because the global shortcuts
are annoyingly truly global---they would be a lot more useful it the
payload included the ID of the current channel from where they were
invoked). But here's the stub in case we ever want to start using these
in the future.

3 years agoAdd validation of the "Hunt ID" (slug) field
Carl Worth [Tue, 20 Oct 2020 19:06:29 +0000 (12:06 -0700)]
Add validation of the "Hunt ID" (slug) field

This gives the user a clean message stating the requirements of the field
and preventing the submission until this field is valid.

3 years agoAllow input blocks to be optional
Carl Worth [Tue, 20 Oct 2020 18:59:27 +0000 (11:59 -0700)]
Allow input blocks to be optional

And use this to make the "Hunt URL" field optional (since some hunts
might not have any URL).

3 years agoCorrect the code storing the picked base64 token
Carl Worth [Tue, 20 Oct 2020 01:48:08 +0000 (18:48 -0700)]
Correct the code storing the picked base64 token

Using 'str()' here was incorrect. That did go from a bytes value to a
string, but it did it by adding "b'" to the beginning and "'" to the
end, breaking the parsing of the base64 value.

Here, instead, we use the decode('us-ascii') method on the bytes value.

3 years agoMention the newly-created sheet in the newly-created Slack channel
Carl Worth [Tue, 20 Oct 2020 01:40:33 +0000 (18:40 -0700)]
Mention the newly-created sheet in the newly-created Slack channel

There's no point in having a sheet if nobody ever sees it.

3 years agoSome style fixes pointed out by flake8
Carl Worth [Mon, 19 Oct 2020 22:12:27 +0000 (15:12 -0700)]
Some style fixes pointed out by flake8

Just to keep things clean so that flake8 can point out useful problems
like in the previous commit. No functional changes here.

3 years agoFix a broken line of code in turbot/actions.py
Carl Worth [Mon, 19 Oct 2020 22:11:56 +0000 (15:11 -0700)]
Fix a broken line of code in turbot/actions.py

Thanks to flake8 for pointing out that this code was functionally broken.

3 years agoCreate a sheet for the hunt when creating a new hunt
Carl Worth [Mon, 19 Oct 2020 21:43:40 +0000 (14:43 -0700)]
Create a sheet for the hunt when creating a new hunt

I don't know how much we'll need this, but here it is for consistency.

This commit adds support for the Google sheets API (accessed via a
pickled token from an encrypted SSM parameter). This will be very
handy in the future when creating sheets for each puzzle channel, etc.

3 years agogsheets-authenticate: Change to using base64 to encode the pickled token
Carl Worth [Sat, 17 Oct 2020 14:48:29 +0000 (07:48 -0700)]
gsheets-authenticate: Change to using base64 to encode the pickled token

This allows the final token to be used in places where arbitrary
binary data cannot be (such as an environment variable, etc.).

3 years agoInvite user to new hunt channel when they create a hunt
Carl Worth [Sat, 17 Oct 2020 01:06:31 +0000 (18:06 -0700)]
Invite user to new hunt channel when they create a hunt

Kind of silly to leave out the initiating user, you see.

3 years agoCreate a new Slack channel when creating a hunt
Carl Worth [Sat, 17 Oct 2020 00:43:31 +0000 (17:43 -0700)]
Create a new Slack channel when creating a hunt

Using the slug of the hunt for the channel name.

Some thoughts on improving this:

  * Should we modify the slug in some way to distinguish this as a
    hunt channel?

  * We should definitely do validation of the legality of the slug for
    a channel name.

  * We should invite the triggering user to the channel

  * We should put the hunt URL into the topic or description

  * Do we want to create a sheet for hunt channels or only for puzzle
    channels?

3 years agoGracefully handle placeholder text for hunt channel ID
Carl Worth [Sat, 17 Oct 2020 00:28:01 +0000 (17:28 -0700)]
Gracefully handle placeholder text for hunt channel ID

Letting the user know that a Slack channel is still being created
if the channel ID is a placeholder value.

3 years agoFix new hunt submission to not rely on global python state
Carl Worth [Sat, 17 Oct 2020 00:21:17 +0000 (17:21 -0700)]
Fix new hunt submission to not rely on global python state

It was only by accident that what I had written happened to work,
(apparently AWS reuses Lambda containers within a 30-minute window or
so). Obviously, I don't want to rely on anything like that, so instead
in this commit I take advantage of the "private_metadata" field that
Slack offers for me to pass data back and forth on a view and use that
to decide which function to invoke to handle view submission.

3 years agoHandle the submission of the "New Hunt" modal
Carl Worth [Fri, 16 Oct 2020 20:22:15 +0000 (13:22 -0700)]
Handle the submission of the "New Hunt" modal

By creating a new entry in the hunts table.

As part of this change we rework turbot/views.py so that the block
functions it had are now in turbot/blocks.py (where they are usefully
shared). Meanwhile, the actual views that were being created are now
created above in events.py, actions.py, etc. where they can be
associated with functions to handle the submission of those views,
etc.

3 years agoRename 'channel' to 'channel_id'
Carl Worth [Fri, 16 Oct 2020 20:26:21 +0000 (13:26 -0700)]
Rename 'channel' to 'channel_id'

Tracking a change made to the (non-) schema of the database. Here
'channel_id' is more clear for how this is used, (where I would have
expected 'channel' to be the actual name of the channel).

3 years agoRemove a debugging print statement
Carl Worth [Fri, 16 Oct 2020 20:25:59 +0000 (13:25 -0700)]
Remove a debugging print statement

Just to keep the code and the logs clean

3 years agoIntroduce a new modal view when the user clicks the "New Hunt" button
Carl Worth [Wed, 14 Oct 2020 04:28:10 +0000 (21:28 -0700)]
Introduce a new modal view when the user clicks the "New Hunt" button

This modal doesn't yet _do_ anything but it shows the basic idea of how
we'll be collecting data.

3 years agoPlumb the turb class down through all the functions here
Carl Worth [Wed, 14 Oct 2020 04:26:55 +0000 (21:26 -0700)]
Plumb the turb class down through all the functions here

It might not be that pythonic to do this with just a simple structure
and functions and not with any methods, but that's actually what I prefer
at this point at least.

3 years agoAdd a link each hunt's channel in the Home view
Carl Worth [Wed, 14 Oct 2020 01:19:56 +0000 (18:19 -0700)]
Add a link each hunt's channel in the Home view

Making it much easier to get to the hunt, of course.

3 years agoAdd list of active hunts to the turbot Home tab
Carl Worth [Wed, 14 Oct 2020 00:43:02 +0000 (17:43 -0700)]
Add list of active hunts to the turbot Home tab

Finally starting to hook this Lambda up to our database for the first time.

3 years agoGive turbot/events.py the same dispatch-table treatment
Carl Worth [Tue, 13 Oct 2020 23:46:39 +0000 (16:46 -0700)]
Give turbot/events.py the same dispatch-table treatment

Just like the previous two commits.

3 years agoAdd a dispatch table for actions as well
Carl Worth [Tue, 13 Oct 2020 23:42:00 +0000 (16:42 -0700)]
Add a dispatch table for actions as well

Just as for slash commands in the previous commit, this will help make
turbot/actions.py easier to maintain.