This commit prepares the musiclink bot for production deployment on NixOS. Changes: - Refactored service layer to support Dependency Injection for API URLs. - Added 'internal/bot/bot_integration_test.go' for mock-based integration testing. - Added 'flake.nix' and 'flake.lock' for reproducible Nix builds. - Added 'README.md', 'LICENSE', and '.gitignore'. - Verified build and tests pass locally.
77 lines
2.1 KiB
Markdown
77 lines
2.1 KiB
Markdown
# 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 designed to work as a sidecar to **[Matterbridge](https://github.com/42wim/matterbridge)**.
|
|
|
|
* **Connectivity**: Connects to Matterbridge via its WebSocket API. This allows MusicLink to support any chat platform Matterbridge supports (Discord, Slack, Telegram, Matrix, IRC, etc.).
|
|
* **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 running instance of [Matterbridge](https://github.com/42wim/matterbridge) (if running in production)
|
|
|
|
### Building
|
|
|
|
```bash
|
|
go build -o musiclink ./cmd/musiclink
|
|
```
|
|
|
|
### Configuration
|
|
|
|
1. Copy the example configuration:
|
|
```bash
|
|
cp config.example.toml config.toml
|
|
```
|
|
|
|
2. Edit `config.toml` to match your Matterbridge WebSocket settings:
|
|
```toml
|
|
[matterbridge]
|
|
url = "ws://localhost:4242/api/websocket"
|
|
token = "your-matterbridge-api-token"
|
|
gateway = "main" # The gateway name defined in your matterbridge.toml
|
|
username = "MusicLink"
|
|
```
|
|
|
|
### Running
|
|
|
|
```bash
|
|
./musiclink -config config.toml
|
|
```
|
|
|
|
## Testing
|
|
|
|
The project includes both unit tests and integration tests.
|
|
|
|
### Run All Tests
|
|
|
|
```bash
|
|
go test ./...
|
|
```
|
|
|
|
### Integration Tests
|
|
|
|
The integration tests (in `internal/bot/bot_integration_test.go`) mock both the Matterbridge WebSocket server and the music resolution API. This allows you to verify the bot's full logic flow without external dependencies.
|
|
|
|
```bash
|
|
go test -v internal/bot/bot_integration_test.go
|
|
```
|
|
|
|
### Smoke Test
|
|
|
|
A manual smoke test script is available in `cmd/smoketest`:
|
|
|
|
```bash
|
|
go run cmd/smoketest/main.go
|
|
```
|
|
|
|
## License
|
|
|
|
[MIT](LICENSE)
|