Files
IRC-kosmi-relay/docs/setup/BOT_features.md

146 lines
4.7 KiB
Markdown
Raw Normal View History

# Bot Features Guide
2025-10-31 23:56:16 -04:00
This document describes the features available in the Kosmi-IRC relay bot when the Jackbox Game Picker integration is enabled.
2025-10-31 23:56:16 -04:00
## Feature Summary
2025-10-31 23:56:16 -04:00
| Feature | Where | Description |
|---------|-------|-------------|
| Message relay | IRC + Kosmi | Bidirectional chat relay |
| Vote detection | IRC + Kosmi | Automatic `thisgame++/--` and ticker votes |
| `!votes` command | IRC + Kosmi | Query current game vote tally |
| `!kreconnect` | IRC | Reconnect Kosmi bridge |
| `!jreconnect` | IRC | Reconnect Jackbox WebSocket |
| `!reconnect` | IRC | Reconnect all non-IRC services |
| Game announcements | All bridges | Jackbox game/session notifications |
| Room code images | All bridges | Generated room code images in chat |
| Mute toggle | Operator (SIGUSR1) | Suppress Jackbox announcements |
2025-10-31 23:56:16 -04:00
## Vote Detection
2025-10-31 23:56:16 -04:00
The bot automatically detects votes in chat messages from both IRC and Kosmi. Votes are submitted to the Jackbox Game Picker API.
2025-10-31 23:56:16 -04:00
### Current Game Votes
2025-10-31 23:56:16 -04:00
- `thisgame++` -- Upvote the currently playing game
- `thisgame--` -- Downvote the currently playing game
2025-10-31 23:56:16 -04:00
Case-insensitive. Can appear anywhere in the message. The message is still relayed normally.
2025-10-31 23:56:16 -04:00
### Ticker Symbol Votes
2025-10-31 23:56:16 -04:00
- `SYMBOL++` -- Upvote a specific game by ticker symbol
- `SYMBOL--` -- Downvote a specific game by ticker symbol
2025-10-31 23:56:16 -04:00
Symbols are 2-4 alphanumeric characters. See [IRC.md](../IRC.md) for the complete ticker table.
2025-10-31 23:56:16 -04:00
### Loop Prevention
2025-10-31 23:56:16 -04:00
Messages prefixed with `[irc]` or `[kosmi]` (relayed messages) are excluded from vote detection to prevent duplicate counting.
2025-10-31 23:56:16 -04:00
### Deduplication
2025-10-31 23:56:16 -04:00
The API rejects duplicate votes from the same user within 1 second.
2025-10-31 23:56:16 -04:00
## Game Announcements
2025-10-31 23:56:16 -04:00
When connected to the Jackbox API via WebSocket (default) or webhook, the bot broadcasts events to all bridges:
2025-10-31 23:56:16 -04:00
| Event | Example Message |
|-------|----------------|
| Session started | `🎮 Game Night is starting!` |
| Game added | `🎮 Coming up next: Fibbage 4 - Room Code ABCD` |
| Session ended | `🌙 Game Night has ended! Thanks for playing!` |
2025-10-31 23:56:16 -04:00
### Room Code Images
2025-10-31 23:56:16 -04:00
When `EnableRoomCodeImage=true`, game announcements include an uploaded image of the room code. The image is uploaded to the Kosmi CDN. Timing is controlled by `RoomCodeImageDelay` and `RoomCodePlaintextDelay` in config.
2025-10-31 23:56:16 -04:00
If image upload fails, the bot falls back to plaintext.
2025-10-31 23:56:16 -04:00
## IRC Commands
2025-10-31 23:56:16 -04:00
All commands are available to any user in the channel. See [IRC.md](../IRC.md) for complete details.
2025-10-31 23:56:16 -04:00
| Command | Effect |
|---------|--------|
| `!kreconnect` | Reconnect Kosmi bridge |
| `!jreconnect` | Reconnect Jackbox WebSocket |
| `!reconnect` | Reconnect all non-IRC services |
| `!votes` | Show current game vote tally |
2025-10-31 23:56:16 -04:00
`!votes` is also available from Kosmi chat.
2025-10-31 23:56:16 -04:00
## Mute Control
2025-10-31 23:56:16 -04:00
Jackbox announcements can be suppressed without stopping the bot:
2025-10-31 23:56:16 -04:00
- **Start muted**: `./matterbridge -conf matterbridge.toml -muted`
- **Toggle at runtime**: `kill -SIGUSR1 <pid>` or `docker kill -s SIGUSR1 <container>`
2025-10-31 23:56:16 -04:00
When muted, vote detection and normal message relay continue to work. Only Jackbox-driven announcements (session start/end, game added) are suppressed.
2025-10-31 23:56:16 -04:00
See [MUTE_CONTROL.md](MUTE_CONTROL.md) for full details.
2025-10-31 23:56:16 -04:00
## API Communication
2025-10-31 23:56:16 -04:00
### Authentication
2025-10-31 23:56:16 -04:00
The bot authenticates with `POST /api/auth/login` using the `AdminPassword` from config. The JWT is cached in memory and refreshed on 401 responses.
2025-10-31 23:56:16 -04:00
### Vote Submission
2025-10-31 23:56:16 -04:00
Votes are submitted via `POST /api/votes/live` with:
2025-10-31 23:56:16 -04:00
```json
2025-10-31 23:56:16 -04:00
{
"username": "voter_name",
"vote": "up",
"timestamp": "2025-11-01T20:30:00Z",
"ticker": "FBG4"
2025-10-31 23:56:16 -04:00
}
```
The `ticker` field is omitted for `thisgame++/--` votes.
2025-10-31 23:56:16 -04:00
### Event Transport
2025-10-31 23:56:16 -04:00
**WebSocket (default)**: Connects to `wss://<api>/api/sessions/live`, authenticates, and subscribes to the active session. Events arrive in real-time with auto-reconnect.
2025-10-31 23:56:16 -04:00
**Webhook (fallback)**: Starts an HTTP server listening for `POST /webhook/jackbox` with HMAC-SHA256 signature verification.
2025-10-31 23:56:16 -04:00
## Configuration
2025-10-31 23:56:16 -04:00
See [JACKBOX_INTEGRATION.md](JACKBOX_INTEGRATION.md) for the full configuration reference.
2025-10-31 23:56:16 -04:00
Minimal setup:
2025-10-31 23:56:16 -04:00
```toml
[jackbox]
Enabled=true
APIURL="https://your-jackbox-api.example.com"
AdminPassword="your_password"
UseWebSocket=true
2025-10-31 23:56:16 -04:00
```
## Troubleshooting
### Votes not registering
2025-10-31 23:56:16 -04:00
- Check that Jackbox integration is enabled
- Verify an active session exists
- Look for `"Detected vote from"` in debug logs
- Look for `"Failed to send vote"` errors
2025-10-31 23:56:16 -04:00
### Announcements not appearing
2025-10-31 23:56:16 -04:00
- Check that the Jackbox WebSocket is connected
- Verify the bot is not muted (check logs for `MUTED`)
- Use `!jreconnect` to force a WebSocket reconnection
2025-10-31 23:56:16 -04:00
### `!votes` returns nothing
2025-10-31 23:56:16 -04:00
- An active session must exist
- A game must currently have "playing" status
- The Jackbox integration must be enabled and authenticated