Skip to main content

Default template for PDM package

Project description

ClutchTimeAlerts - NBA Clutch Time Alert Service

Ruff PyPI version

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

clutchtimealerts-0.2.1.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clutchtimealerts-0.2.1-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file clutchtimealerts-0.2.1.tar.gz.

File metadata

  • Download URL: clutchtimealerts-0.2.1.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.23.0 CPython/3.13.2 Linux/6.8.0-1021-azure

File hashes

Hashes for clutchtimealerts-0.2.1.tar.gz
Algorithm Hash digest
SHA256 dfb769d46020c158c673f85449725452050cdee0899a828ad245db72df29ec5c
MD5 dd43c1f055613e5cd56b4a2e40c60b52
BLAKE2b-256 725aac5cd801d60a8b35d096c5e1daff17fb5009fae3065bc02cd796cf627a7e

See more details on using hashes here.

File details

Details for the file clutchtimealerts-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: clutchtimealerts-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.23.0 CPython/3.13.2 Linux/6.8.0-1021-azure

File hashes

Hashes for clutchtimealerts-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ffd00b1e047360e88ddaf8e474c9ad6723687f5a786d422890c4da97f112eab3
MD5 220f74413786728ef99826e36faf9a13
BLAKE2b-256 8117c7cb54d75ce24a83864ce37385e2563a37129c07a55050d27b66d06cbed6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page