Default template for PDM package
Project description
ClutchTimeAlerts - NBA Clutch Time Alert Service
A service that tracks ongoing NBA games and sends alerts when games enter "clutch time"—the last five minutes of the fourth quarter or overtime when the point difference is five points or fewer. The serivce monitors live game data and sends notifications via configured messaging platforms (such as GroupMe, Slack, etc.) to keep you informed of the most intense moments.
Features
- Real-Time Clutch Detection: Monitors live NBA game data and detects when games enter clutch time.
- Customizable Alerts: Configure the service to send alerts on various platforms (GroupMe, Slack, etc.).
- Multiple Game Support: Tracks multiple NBA games simultaneously to ensure you don't miss any clutch moments.
Supported Notification Types
We currently support the following notification types out of the box:
- GroupMe
- Slack
- Ntfy
- Twilio (SMS)
On our road map we want to expand the supported notification types. If there's a type you want to see supported add an issue or submit a PR for review.
Installation
There are two different supported installation types: Python and Docker.
Python
To install the python package you can install it from PYPI
pip install clutchtimealerts
Alertnatively you can clone the repository then install it directly.
git clone git@github.com:bwalheim1205/clutchtimealerts.git
cd clutchtimealerts
pip install clutchtimealerts
Docker
To install via docker, you can pull image from Docker Hub:
docker pull bwalheim1205/clutchtimealerts
Alertnatively you can build the image from source:
git clone git@github.com:bwalheim1205/clutchtimealerts.git
docker build clutchtimealerts/ -t clutchtimealerts
Usage
Configuration File
The alert system utilizes a yaml configuration file. YAML contains configuration options for SQLite database and alert method configurations. Here is an example of a configuration file
Example Configuration
db_url: clutchtime.db
notifications:
- type: GroupMe
config:
bot_id: "<group-bot-id>"
- type: Slack
nba_teams:
- PHI
- MIL
config:
channel: "#general"
token: "<slack-api-token>"
- type: Twilio
config:
account_sid: "<twilio-accout-sid>"
auth_token: "<twilio-auth-token>"
from: "+14155551212"
to:
- "+14155551212"
- "+14155551212"
- type: Ntfy
config:
host: <ntfy host>
topic: nba_alerts
token: <Ntfy auth token>
YAML Fields
db_url (Optional): DB url to sqlite3 database. Defaults to sqlite:///clutchtime.db
notification_format (Optional): fstring for formatting clutch alert message. Defaults to "Clutch Game\n{HOME_TEAM_TRI} {HOME_TEAM_SCORE} - {AWAY_TEAM_SCORE} {AWAY_TEAM_TRI}\n{NBA_COM_STREAM}"
ot_format (Optional): fstring for formatting ot alert messages. Defaults to "OT{OT_NUMBER} Alert\n{HOME_TEAM_TRI} {HOME_TEAM_SCORE} - {AWAY_TEAM_SCORE} {AWAY_TEAM_TRI}\n{NBA_COM_STREAM}"
nba_teams (Optional): a list of NBA team tricodes that you wish to receive notifications list. Defaluts to all NBA teams
notifications: List of notification configs
- type: class name or common name of the alert type
- notification_format (Optional): fstring for formatting clutch alert messages overwrites global level config.
- ot_format (Optional): fstring for formatting ot alert messages. Overwrites global level config
- nba_teams (Optional): a list of NBA team tricodes that you wish to receive notifications list. Overwrites global level config
- config: kwargs** for the alert classes
Format Langauge
To create a format message we use python fstring format. Below is an example
Example:
"Clutch Game\n{HOME_TEAM_TRI} {HOME_TEAM_SCORE} - {AWAY_TEAM_SCORE} {AWAY_TEAM_TRI}\n{NBA_COM_STREAM}"
Here's a list of valid values that can be used in fstring:
- HOME_TEAM_TRI: Tricode for home team. Ex: PHI
- HOME_TEAM_CITY: City for home team. Ex: Philadelphia
- HOME_TEAM_NAME: Team name for home team. Ex: 76ers
- HOME_TEAM_WINS: Total wins for home team this season
- HOME_TEAM_LOSSES: Total losses for home team this season
- HOME_TEAM_SCORE: Home teams score this game
- AWAY_TEAM_TRI: Tricode for away team. Ex: BOS
- AWAY_TEAM_CITY: City for away team. Ex: Boston
- AWAY_TEAM_NAME: Team name for away team. Ex: Celtics
- AWAY_TEAM_WINS: Total wins for away team this season
- AWAY_TEAM_LOSSES: Total losses for away team this season
- AWAY_TEAM_SCORE: Away teams score this game
- GAME_ID: Id for the hame. Ex: 0022400580
- GAME_CLOCK: Game Clock string. Ex: PT06M01.00S
- GAME_STATUS_TEXT: String for game status. Ex: "Q3 6:01"
- OT_NUMBER: Number for OT Period
- NBA_COM_STREAM: Link to watch game on nba.com
Running Alert Service
Once you've generated a configuration file you can run alert service using one of the following commands
Python
python3 -m clutchtimealerts -f <path-to-config>
Docker
docker run -v <path-to-config>:/app/config.yml clutchtimealerts
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clutchtimealerts-0.2.0.tar.gz.
File metadata
- Download URL: clutchtimealerts-0.2.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.22.2 CPython/3.12.8 Linux/6.8.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e2cb19a898f4709c6cf41b486be31f8e96c3697d6ac31f94d8d7bdf409ab268
|
|
| MD5 |
43da12cb14580cf2831771c91c61d388
|
|
| BLAKE2b-256 |
dfc76f458b1de823b2f8c03070b772939eec107ee0a81c3b04d83315a8cc1e11
|
File details
Details for the file clutchtimealerts-0.2.0-py3-none-any.whl.
File metadata
- Download URL: clutchtimealerts-0.2.0-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.22.2 CPython/3.12.8 Linux/6.8.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec7c6572314577fd245d1ec9780f6ab80f40c8c0ddafee66d89ffa9d93ad19e1
|
|
| MD5 |
b2a56dacd0fc06bc3a6b4091b40b58bd
|
|
| BLAKE2b-256 |
24e66dc373d56c62cb601d73f4b73c1e451c45060ae9839ebb13cede4244a4e1
|