# MusicLink Bot MusicLink is a Go-based chat bot that automatically detects music links (Spotify, Apple Music, YouTube, etc.) and responds with links to the same song on other streaming platforms. It solves the "I don't have Spotify" problem in group chats. ## Architecture MusicLink is a Matrix-native bot that connects directly to a Matrix homeserver and replies in the originating room/thread. **E2EE rooms are not supported.** * **Connectivity**: Connects directly to Matrix and supports multiple allowlisted rooms. * **Resolution**: Uses the [idonthavespotify](https://idonthavespotify.sjdonado.com/) API to convert links between services without requiring individual API keys. * **Privacy**: Does not store messages or user data. It only processes messages containing music links. ## Getting Started ### Prerequisites * Go 1.22 or higher * A Matrix homeserver and bot access token ### Building ```bash go build -o musiclink ./cmd/musiclink ``` ### Configuration 1. Copy the example configuration: ```bash cp config.example.toml config.toml ``` 2. Configure Matrix-native mode (replies in the originating room/thread; E2EE rooms not supported): ```toml [matrix] shadow = false # set true to log-only during validation healthAddr = ":8080" # optional health/metrics endpoint server = "https://matrix.example.com" accessToken = "your-matrix-access-token" userId = "@musiclink:example.com" rooms = ["!roomid:example.com"] stateStorePath = "data/matrix-state.db" ``` ### Running ```bash ./musiclink -config config.toml ``` ## Health and Metrics (Matrix-native) If `matrix.healthAddr` is set, MusicLink exposes JSON health stats at `/healthz` (and `/metrics`). Example: ```bash curl http://localhost:8080/healthz ``` ## Testing The project includes both unit tests and integration tests. ### Run All Tests ```bash go test ./... ``` ### Integration Tests No Matrix integration tests are included yet; add them as needed. ### Smoke Test A manual smoke test script is available in `cmd/smoketest`: ```bash go run cmd/smoketest/main.go ``` ## License [MIT](LICENSE)