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
-
Open
config/config.go
. -
Add your Matrix credentials:
return &Config{ Homeserver: "https://matrix.your-server.net", UserID: "@your-bot:your-server.net", AccessToken: "YOUR_ACCESS_TOKEN", }
-
(Optional) Define custom team name aliases:
var CustomTeamNames = map[string]string{ "bama": "alabama", "osu": "ohio state", }
Local Development
-
Clone the repository and navigate to its root:
git clone https://git.ewnix.net/phlux/matrix-scores-bot.git cd matrix-scores-bot
-
Initialize Go modules and download dependencies:
go mod init matrix-scores-bot go mod tidy
-
Build and run:
go run main.go
-
Invite the bot to a Matrix room and send commands:
!cfb alabama !cbb duke 12/05
Docker Deployment
-
Build the Docker image:
docker build -t matrix-scores-bot:latest .
-
Run the container:
docker run -d --name matrix-scores-bot matrix-scores-bot:latest
Note: The bot’s 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