- Add !votes command (IRC + Kosmi) showing per-session and all-time vote
breakdowns for the current game via new Jackbox API endpoints
(GET sessions/{id}/games, sessions/{id}/votes, games/{id})
- Fix vote tally broadcasting: remove debounce timer, announce tallies
only at game transitions or session end instead of after every vote
- Add !kreconnect IRC command to manually trigger Kosmi reconnection
- Add WebSocket ping/pong keepalive and write mutex to Kosmi client
for connection stability
- Add watchConnection() auto-reconnect on unexpected Kosmi disconnects
- Remove old 2025-10-31 chat summaries; add votes command design doc
Made-with: Cursor
2.1 KiB
2.1 KiB
!votes Command Design
Summary
Add a !votes IRC/Kosmi command that displays session and all-time vote data for the currently playing game. The response is broadcast to all connected chats via the gateway. If there is no active session, no playing game, or any API call fails, the command logs the reason and silently does nothing.
Output Format
Matches the existing vote tally style:
🗳️ Split the Room • 14👍 3👎 (Score: +11) | All-time: 127
- Left side: session votes for the current game (upvotes, downvotes, net score)
- Right side: all-time
popularity_scorefrom the game catalog
Architecture
Uses the gateway-level event routing pattern (same as !kreconnect).
Flow
- User types
!votesin IRC or Kosmi - Bridge detects the command, sends
EventVotesQueryonb.Remote, returns without relaying - Gateway router catches the event in
handleReceive handleEventVotesQueryfetches data from the Jackbox API:GetActiveSession()to get session IDGetSessionGames(sessionID)to find the game with status "playing"GetSessionVotes(sessionID)to get per-game vote breakdownGetGame(gameID)to get all-timepopularity_score
- Formats the message and broadcasts via
broadcastJackboxMessage
Failure handling
All failures are logged at warn level and produce no chat output:
- No Jackbox client configured
- No active session
- No game currently playing
- API errors on any of the fetch calls
- No vote data found for the current game
Files Changed
bridge/config/config.go-- addEventVotesQueryconstantbridge/jackbox/client.go-- addGetSessionGames,GetSessionVotes,GetGamemethods and response structsbridge/irc/handlers.go-- detect!votescommand, emit eventbridge/kosmi/kosmi.go-- detect!votescommand, emit eventgateway/router.go-- callhandleEventVotesQueryinhandleReceivegateway/handlers.go-- implementhandleEventVotesQuery
API Endpoints Used
GET /api/sessions/active(existing)GET /api/sessions/{id}/games(new client method)GET /api/sessions/{id}/votes(new client method)GET /api/games/{id}(new client method)