2025-05-09 03:16:10 +00:00
2025-05-09 03:16:10 +00:00
2025-05-09 03:16:10 +00:00
2025-05-09 03:16:10 +00:00
2025-05-09 03:30:47 +00:00
2025-05-09 03:16:10 +00:00
2025-05-09 03:16:10 +00:00
2025-05-09 03:19:04 +00:00

Matrix Scores Bot

A Matrix bot written in Go that retrieves and displays college football (CFB) and basketball (CBB) scores using the ncaa.ewnix.net API. It listens for !cfb and !cbb commands in Matrix rooms and replies with formatted game information.

Features

  • CFB Scores: !cfb <teamName>
  • CBB Scores: !cbb <teamName> [MM/DD]
  • Automatic conversion of dates to Central Time
  • Custom team name aliases via configuration
  • HTML formatting for bold scores in Matrix
  • Dockerized for easy deployment to Kubernetes (K3s)

Prerequisites

  • Go 1.20+ (for local development)
  • Docker (for building the container)
  • Access to a Matrix homeserver (e.g., Synapse)
  • A bot user created on your Matrix server with an access token

Configuration

  1. Open config/config.go.

  2. Add your Matrix credentials:

    return &Config{
        Homeserver:  "https://matrix.your-server.net",
        UserID:      "@your-bot:your-server.net",
        AccessToken: "YOUR_ACCESS_TOKEN",
    }
    
  3. (Optional) Define custom team name aliases:

    var CustomTeamNames = map[string]string{
        "bama": "alabama",
        "osu":  "ohio state",
    }
    

Local Development

  1. Clone the repository and navigate to its root:

    git clone https://git.ewnix.net/phlux/matrix-scores-bot.git
    cd matrix-scores-bot
    
  2. Initialize Go modules and download dependencies:

    go mod init matrix-scores-bot
    go mod tidy
    
  3. Build and run:

    go run main.go
    
  4. Invite the bot to a Matrix room and send commands:

    !cfb alabama
    !cbb duke 12/05
    

Docker Deployment

  1. Build the Docker image:

    docker build -t matrix-scores-bot:latest .
    
  2. Run the container:

    docker run -d      --name matrix-scores-bot      matrix-scores-bot:latest
    

Note: The bots credentials are hardcoded in config/config.go. Rebuild the image after updating credentials.

Kubernetes (K3s)

You can deploy the bot as a Deployment in K3s. Create a Secret for your access token and mount it, or update config/config.go before building. Follow standard practices for containerized services.

Command Reference

  • !cfb <teamName>: Retrieves the latest college football game info for the specified team.
  • !cbb <teamName> [MM/DD]: Retrieves college basketball game info for the specified team on the given date (defaults to today in Central Time).

License

MIT © Kevin M. Thompson

Description
No description provided
Readme 38 KiB
Languages
Go 94.7%
Dockerfile 5.3%