Carl Worth [Tue, 29 Sep 2020 18:15:54 +0000 (11:15 -0700)]
Add a listener for the Slack "channel_created" event
Currently this just posts a simple message when a channel is
created. Eventually, we'll want to do something different such as
creating a puzzle sheet and linking/pinning it to the channel.
Carl Worth [Tue, 29 Sep 2020 16:59:42 +0000 (09:59 -0700)]
Abstract out two slack-related functions
The two new functions are slack_is_valid_request and slack_send_reply.
These functions provide some shared code for dealing with slack to
avoid code duplication.
These functions also provide a debug mode (that doesn't use slack at
all). This is a convenience for testing the implementation of slash
commands in a local "make run" session without needing to touch Slack
endpoints at all. (Instead, all requests are considered valid and
slack replies are simply printed to stdout.)
Carl Worth [Tue, 29 Sep 2020 15:35:46 +0000 (08:35 -0700)]
Convert "make run" to use "flask run" instead of direct python script execution
This will simplify some future work (regarding reorganizing the code into
a package, etc.) so that we don't have to try to simultaneously support
running as both a script and as a module.
Carl Worth [Tue, 29 Sep 2020 13:20:59 +0000 (06:20 -0700)]
Use a raw string for a regular expression
Previously, the string had an unrecognized escape sequence ('\*').
With a non-raw string we could have doubled the backslash, but it's
much cleaner to just use a raw string instead, (so that backslashes
are used for regular-expression escaping, and not also for string
escaping).
Carl Worth [Tue, 29 Sep 2020 13:12:55 +0000 (06:12 -0700)]
Fix some code style issues identified by flake8
Some of the things fixed include TAB based indentation of a
documentation string, some unneeded semicolons, a missing exception
name, and an excessively long line.
Carl Worth [Sun, 27 Sep 2020 21:45:34 +0000 (14:45 -0700)]
Add signature verification fo the /rot slash command
This prevents someone abusing our bot by spoofing messages appearing
to have come from Slack. This way we won't reply to any command
request unless it actually comes from Slack.
Carl Worth [Sat, 26 Sep 2020 05:02:45 +0000 (22:02 -0700)]
Restore handling of error events from Slack
This is better than what I had copied from the example a few commits
ago because this properly logs through the python logging system, (so
the error message will appear in the Apache log file).
Carl Worth [Sat, 26 Sep 2020 04:47:32 +0000 (21:47 -0700)]
Fix turbot.wsgi to be able to find its environment variables
We can't rely on the current working directory of the Apache process,
so we need to use an explicit path here in order to find our file
with environment variables in it.
I want to start with this to ensure I can at least get a correct
challenge working. After I get this working this way, I'll plan to put
direct flask code back in place and integrated with the web server via
WSGI.
Carl Worth [Sat, 26 Sep 2020 02:01:48 +0000 (19:01 -0700)]
Initial commit of turbot
Turbot will eventually be a Slack bot for the Halibut That Bass team.
As of this commit, turbot.py is just a simple flask app implementing a
REST API (to query, add, delete TODO items). Additionally, this commit
includes the Makefile pieces to manage python dependencies and to
deploy the program to our server.
There's not yet any actual Slack-application code here yet.