tweaks to websocket

This commit is contained in:
cottongin
2026-02-07 00:06:20 -05:00
parent 673c8025ee
commit 1e0cb63b1c

View File

@@ -306,7 +306,7 @@ func (c *WebSocketClient) handleGameAdded(data json.RawMessage) {
if gameData.Game.RoomCode != "" { if gameData.Game.RoomCode != "" {
if c.enableRoomCodeImage { if c.enableRoomCodeImage {
// Try to upload room code image (for Kosmi) - image contains all info // Try to upload room code image (for Kosmi) - image contains all info
c.broadcastWithRoomCodeImage(gameData.Game.Title, gameData.Game.RoomCode) c.broadcastWithRoomCodeImage(message, gameData.Game.Title, gameData.Game.RoomCode)
} else { } else {
// Use IRC text formatting (fallback) // Use IRC text formatting (fallback)
roomCodeText := fmt.Sprintf(" - Room Code \x02\x11%s\x0F", gameData.Game.RoomCode) roomCodeText := fmt.Sprintf(" - Room Code \x02\x11%s\x0F", gameData.Game.RoomCode)
@@ -324,7 +324,8 @@ func (c *WebSocketClient) handleGameAdded(data json.RawMessage) {
// broadcastWithRoomCodeImage generates, uploads, and broadcasts a room code image // broadcastWithRoomCodeImage generates, uploads, and broadcasts a room code image
// The image contains all the information (game title, room code, etc.) // The image contains all the information (game title, room code, etc.)
func (c *WebSocketClient) broadcastWithRoomCodeImage(gameTitle, roomCode string) { // The message parameter should contain the full game announcement including any vote results
func (c *WebSocketClient) broadcastWithRoomCodeImage(message, gameTitle, roomCode string) {
c.log.Infof("🎨 Starting room code image generation and upload for: %s - %s", gameTitle, roomCode) c.log.Infof("🎨 Starting room code image generation and upload for: %s - %s", gameTitle, roomCode)
// Generate room code image (animated GIF) with game title embedded // Generate room code image (animated GIF) with game title embedded
@@ -333,7 +334,7 @@ func (c *WebSocketClient) broadcastWithRoomCodeImage(gameTitle, roomCode string)
if err != nil { if err != nil {
c.log.Errorf("❌ Failed to generate room code image: %v", err) c.log.Errorf("❌ Failed to generate room code image: %v", err)
// Fallback to plain text (no IRC formatting codes for Kosmi) // Fallback to plain text (no IRC formatting codes for Kosmi)
fallbackMessage := fmt.Sprintf("🎮 Coming up next: %s - Room Code %s", gameTitle, roomCode) fallbackMessage := fmt.Sprintf("%s - Room Code %s", message, roomCode)
if c.messageCallback != nil { if c.messageCallback != nil {
c.messageCallback(fallbackMessage) c.messageCallback(fallbackMessage)
} }
@@ -349,7 +350,7 @@ func (c *WebSocketClient) broadcastWithRoomCodeImage(gameTitle, roomCode string)
if err != nil { if err != nil {
c.log.Errorf("❌ Failed to upload room code image: %v", err) c.log.Errorf("❌ Failed to upload room code image: %v", err)
// Fallback to plain text (no IRC formatting codes for Kosmi) // Fallback to plain text (no IRC formatting codes for Kosmi)
fallbackMessage := fmt.Sprintf("🎮 Coming up next: %s - Room Code %s", gameTitle, roomCode) fallbackMessage := fmt.Sprintf("%s - Room Code %s", message, roomCode)
if c.messageCallback != nil { if c.messageCallback != nil {
c.messageCallback(fallbackMessage) c.messageCallback(fallbackMessage)
} }
@@ -358,9 +359,9 @@ func (c *WebSocketClient) broadcastWithRoomCodeImage(gameTitle, roomCode string)
c.log.Infof("✅ Step 2 complete: Uploaded to %s", imageURL) c.log.Infof("✅ Step 2 complete: Uploaded to %s", imageURL)
// Now that upload succeeded, send the full announcement with game title and URL // Now that upload succeeded, send the full announcement with the message and URL
c.log.Infof("📢 Step 3: Broadcasting game announcement with URL...") c.log.Infof("📢 Step 3: Broadcasting game announcement with URL...")
fullMessage := fmt.Sprintf("🎮 Coming up next: %s %s", gameTitle, imageURL) fullMessage := fmt.Sprintf("%s %s", message, imageURL)
if c.messageCallback != nil { if c.messageCallback != nil {
c.messageCallback(fullMessage) c.messageCallback(fullMessage)
c.log.Infof("✅ Step 3 complete: Game announcement sent with URL") c.log.Infof("✅ Step 3 complete: Game announcement sent with URL")