wow that took awhile
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/42wim/matterbridge/bridge"
|
||||
"github.com/42wim/matterbridge/bridge/config"
|
||||
"github.com/42wim/matterbridge/bridge/jackbox"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -26,11 +27,12 @@ type KosmiClient interface {
|
||||
// Bkosmi represents the Kosmi bridge
|
||||
type Bkosmi struct {
|
||||
*bridge.Config
|
||||
client KosmiClient
|
||||
roomID string
|
||||
roomURL string
|
||||
connected bool
|
||||
msgChannel chan config.Message
|
||||
client KosmiClient
|
||||
roomID string
|
||||
roomURL string
|
||||
connected bool
|
||||
msgChannel chan config.Message
|
||||
jackboxClient *jackbox.Client
|
||||
}
|
||||
|
||||
// New creates a new Kosmi bridge instance
|
||||
@@ -154,6 +156,21 @@ func (b *Bkosmi) handleIncomingMessage(payload *NewMessagePayload) {
|
||||
return
|
||||
}
|
||||
|
||||
// Check for votes (thisgame++ or thisgame--)
|
||||
// Only process votes from non-relayed messages
|
||||
if !jackbox.IsRelayedMessage(body) {
|
||||
if isVote, voteType := jackbox.DetectVote(body); isVote {
|
||||
b.Log.Debugf("Detected vote from %s: %s", username, voteType)
|
||||
if b.jackboxClient != nil {
|
||||
go func() {
|
||||
if err := b.jackboxClient.SendVote(username, voteType, timestamp); err != nil {
|
||||
b.Log.Errorf("Failed to send vote to Jackbox API: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create Matterbridge message
|
||||
// Use "main" as the channel name for gateway matching
|
||||
// Don't add prefix here - let the gateway's RemoteNickFormat handle it
|
||||
@@ -169,12 +186,12 @@ func (b *Bkosmi) handleIncomingMessage(payload *NewMessagePayload) {
|
||||
|
||||
// Send to Matterbridge
|
||||
b.Log.Debugf("Forwarding to Matterbridge channel=%s account=%s: %s", rmsg.Channel, rmsg.Account, rmsg.Text)
|
||||
|
||||
|
||||
if b.Remote == nil {
|
||||
b.Log.Error("Remote channel is nil! Cannot forward message")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
b.Remote <- rmsg
|
||||
}
|
||||
|
||||
@@ -219,3 +236,8 @@ func extractRoomID(url string) (string, error) {
|
||||
return "", fmt.Errorf("could not extract room ID from URL: %s", url)
|
||||
}
|
||||
|
||||
// SetJackboxClient sets the Jackbox API client for this bridge
|
||||
func (b *Bkosmi) SetJackboxClient(client *jackbox.Client) {
|
||||
b.jackboxClient = client
|
||||
b.Log.Info("Jackbox client injected into Kosmi bridge")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user