2025-05-09 03:19:04 +00:00

101 lines
2.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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:
```go
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:
```go
var CustomTeamNames = map[string]string{
"bama": "alabama",
"osu": "ohio state",
}
```
## Local Development
1. Clone the repository and navigate to its root:
```bash
git clone https://git.ewnix.net/phlux/matrix-scores-bot.git
cd matrix-scores-bot
```
2. Initialize Go modules and download dependencies:
```bash
go mod init matrix-scores-bot
go mod tidy
```
3. Build and run:
```bash
go run main.go
```
4. Invite the bot to a Matrix room and send commands:
```text
!cfb alabama
!cbb duke 12/05
```
## Docker Deployment
1. Build the Docker image:
```bash
docker build -t matrix-scores-bot:latest .
```
2. Run the container:
```bash
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