feat: announce poll lifecycle events to IRC and Kosmi

Handle poll.start, poll.ending, voting.ended, and poll.ending.cancelled
WebSocket messages from the upstream GamePicker API. Broadcasts opening,
closing-countdown, and closed announcements with per-bridge bold
formatting (IRC control codes vs asterisks for Kosmi).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cottongin
2026-05-12 22:48:01 -04:00
parent c88b75f30d
commit c5e0fe06b0
4 changed files with 288 additions and 48 deletions

View File

@@ -119,7 +119,7 @@ func (r *Router) Start() error {
// Start webhook server if Jackbox is enabled
if r.JackboxManager.IsEnabled() {
if err := r.JackboxManager.StartWebhookServer(r.broadcastJackboxMessage); err != nil {
if err := r.JackboxManager.StartWebhookServer(r.broadcastJackboxMessage, r.broadcastJackboxFormattedMessage); err != nil {
r.logger.Errorf("Failed to start Jackbox webhook server: %v", err)
}
}
@@ -274,3 +274,34 @@ func (r *Router) broadcastJackboxMessage(message string) {
}
}
}
// broadcastJackboxFormattedMessage broadcasts per-bridge formatted messages.
// IRC bridges receive ircMsg (with IRC control codes), all others receive plainMsg.
func (r *Router) broadcastJackboxFormattedMessage(ircMsg, plainMsg string) {
if r.JackboxManager != nil && r.JackboxManager.IsMuted() {
r.logger.Debugf("Jackbox formatted message suppressed (muted): %s", plainMsg)
return
}
r.logger.Infof("Broadcasting formatted Jackbox message: %s", plainMsg)
for _, gw := range r.Gateways {
for _, br := range gw.Bridges {
text := plainMsg
if br.Protocol == "irc" {
text = ircMsg
}
msg := config.Message{
Text: " " + text,
Username: "Jackbox",
Account: "jackbox",
Event: config.EventUserAction,
}
if _, err := br.Send(msg); err != nil {
r.logger.Errorf("Failed to send formatted Jackbox message to %s: %v", br.Account, err)
}
}
}
}