(c) 2016-24 J. W. Crockett, Jr.1, @joshcvt
resetter is a lightweight Python 3.11 Slack bot to fetch game statuses and results. Originally built for Major League Baseball, requesting the targeted team's status from the MLB.com GDX API, it has since been ported to StatsAPI for MLB and can also scrape NHL scores from NHL.com (now via the 2023 NHLE API) and college football scores from ESPN.com. It can post on a schedule to a Slack webhook stored in SSM Parameter Store if you set that up as well. It's built using the Chalice framework.
The code is licensed under the MIT License. The data belongs to its respective league/association owners and/or their licensees.1
To use this:
pip install -f requirements.txt
(which will install the Chalice CLI)terraform/slackkey
to store the webhook in Parameter Store. Take the output ARN of the parameter, copy .chalice/sample-policy-dev.json
to .chalice/policy-dev.json
and update the parameter ARN there..chalice/sample-config-no-custom-policy.json
to .chalice/config.json
.DEFAULT_PARAM
in app.py
unless you're Washington Nationals fans like the people in the Slack where this was originally deployedapp.py
, check out the SCHEDULED_POST*
lines, including a cron schedule in UTC. Adjust them as you desire or empty them out. If you do not want scheduled posts, you will need to comment out the @app.schedule
decorator on the scoreboardPoster
function. Not being able to directly parameterize this is a Chalice limitation.chalice deploy
and note the given API Gateway URL. Then set up a Slash Command custom integration for your Slack team, paste in the API Gateway URL that Chalice gave you, set it as a GET request, and configure everything else at your leisure.Testing is league-by-league from your development environment against live data, mostly because the leagues change both their feed spec and some of the data included in it infuriatingly often (varying capitalization of branded arena names is just the tip of the iceberg) such that static test data is of very limited use (and also actual data is all copyright the leagues, and I don't want to tempt the copyright dragons any more than necessary). The test_league.py
scripts fire off a varying set of requests for real and non-existent teams, generally for yesterday, today and tomorrow (so you get finished games, potentially in-progress today, and games that haven't started yet).
1. The developer of this application claims no rights to or control over the league/association data sources it targets or the data contained within. Users of this application are themselves solely responsible for assuring that their use of this application, the sources and the data contained within complies with any and all terms and conditions set by the owners of the data sources.