A Google AppEngine code to receive push notifications from The Blue Alliance and post them on Slack via push notifications as well.
Starting 2021 this code got rewritten to run on GCS Cloud Functions rather than on GCS App Engine. Functions is a simpler, one function focused, microservices kind of platform. No need to deploy a whole App Engine to process simple push requests from TBA and perform another own push request to Slack.
If you are familiar with old good AWS Lambda Functions. GC Functions is pretty much the same thing.
Deploy the content of main.py as a Google Cloud Function using Python3 (tested with Python 3.7). Set the "entryPoint" as "tba_to_slack". Then configure the VARIABLES as described below. Then go to your account at TBA and point your webhook to the Trigger URL of the Function you just deployed.
To configure this Cloud Function for your team you'll have to setup a few environment variables under "Runtime environment variables" section when you create or edit the Function.
- SLACK_TEST: "/services/A99A9AAA9/DUMMY555/d1Fake8-Fake-Fake-xyzzz"
- SLACK_PROD: "/services/A99A9AAA9/DUMMY555/d1Fake8-Fake-Fake-xyzzz"
As of now (3/26/2022) the switching between TEST and PROD is not implemented yet. By default the main.py function's code simply reads one of them from the environment variables. The idea behind it is that you can setup two incoming web hooks in your Slack workspace: one PROD for the general use and point it to a channel that most of people read; and then another, TEST, as the name suggests for testiing. The testing web hook may point to a testing channel that is intended to receive all the noise so you can use TBA's testing functionality, e.g. ping and other test requests. To switch between TEST and PROD simply change the name of the env variable in the Cloud Function's code editing window, or the value of the variable (both options require a re-deploy).
- TBA_SECRET: "ERRORS 3130 are awesome"
This secret is setup when you create a new Webhook at TBA. It used to be an arbitrary string provided by user. But now it seems it's autogenerated by TBA and shows up under the Webhook ID in your TBA Account page. Simply copy and paste that string from TBA to the Cloud Functions settings.
- TARGET_TZ: US/Central
The time zone that all time will be shown in Slack. The function can't know what timezone every your teammate is in. So it's up to you which timezone you choose for everyone.
- FRC_TEAM: 3130
This team number will be emphasized in Slack messages for readability.