wow that took awhile
This commit is contained in:
15
bridge/irc/formatting.go
Normal file
15
bridge/irc/formatting.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package birc
|
||||
|
||||
// IRC formatting control codes
|
||||
const (
|
||||
IRCBold = "\x02" // Bold
|
||||
IRCMonospace = "\x11" // Monospace/fixed-width font
|
||||
IRCReset = "\x0F" // Reset all formatting
|
||||
)
|
||||
|
||||
// FormatRoomCode formats a room code with IRC bold and monospace formatting
|
||||
// Returns the code wrapped in bold + monospace with a reset at the end
|
||||
func FormatRoomCode(roomCode string) string {
|
||||
return IRCBold + IRCMonospace + roomCode + IRCReset
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/42wim/matterbridge/bridge/config"
|
||||
"github.com/42wim/matterbridge/bridge/helper"
|
||||
"github.com/42wim/matterbridge/bridge/jackbox"
|
||||
"github.com/lrstanley/girc"
|
||||
"github.com/paulrosania/go-charset/charset"
|
||||
"github.com/saintfish/chardet"
|
||||
@@ -251,6 +252,23 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
|
||||
rmsg.Text = string(output)
|
||||
}
|
||||
|
||||
// Check for votes (thisgame++ or thisgame--)
|
||||
// Only process votes from non-relayed messages
|
||||
if !jackbox.IsRelayedMessage(rmsg.Text) {
|
||||
if isVote, voteType := jackbox.DetectVote(rmsg.Text); isVote {
|
||||
b.Log.Debugf("Detected vote from %s: %s", event.Source.Name, voteType)
|
||||
if b.jackboxClient != nil {
|
||||
go func() {
|
||||
// Use current time as timestamp for IRC messages
|
||||
timestamp := time.Now()
|
||||
if err := b.jackboxClient.SendVote(event.Source.Name, voteType, timestamp); err != nil {
|
||||
b.Log.Errorf("Failed to send vote to Jackbox API: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", event.Params[0], b.Account)
|
||||
b.Remote <- rmsg
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/42wim/matterbridge/bridge"
|
||||
"github.com/42wim/matterbridge/bridge/config"
|
||||
"github.com/42wim/matterbridge/bridge/helper"
|
||||
"github.com/42wim/matterbridge/bridge/jackbox"
|
||||
"github.com/lrstanley/girc"
|
||||
stripmd "github.com/writeas/go-strip-markdown"
|
||||
|
||||
@@ -32,6 +33,7 @@ type Birc struct {
|
||||
FirstConnection, authDone bool
|
||||
MessageDelay, MessageQueue, MessageLength int
|
||||
channels map[string]bool
|
||||
jackboxClient *jackbox.Client
|
||||
|
||||
*bridge.Config
|
||||
}
|
||||
@@ -413,3 +415,9 @@ func (b *Birc) getTLSConfig() (*tls.Config, error) {
|
||||
|
||||
return tlsConfig, nil
|
||||
}
|
||||
|
||||
// SetJackboxClient sets the Jackbox API client for this bridge
|
||||
func (b *Birc) SetJackboxClient(client *jackbox.Client) {
|
||||
b.jackboxClient = client
|
||||
b.Log.Info("Jackbox client injected into IRC bridge")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user