Add ticker symbol voting (e.g. QPL3++, TMP2--)
Extend vote detection to recognize game ticker symbols alongside the existing thisgame++/-- syntax. Each symbol maps to a specific game so users can vote for any game by its stock-style ticker. The matched ticker is sent to the API via a new optional `ticker` field in the vote request. Made-with: Cursor
This commit is contained in:
@@ -252,16 +252,15 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
|
||||
rmsg.Text = string(output)
|
||||
}
|
||||
|
||||
// Check for votes (thisgame++ or thisgame--)
|
||||
// Check for votes (thisgame++/-- or ticker symbol++/--)
|
||||
// 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 isVote, voteType, ticker := jackbox.DetectVote(rmsg.Text); isVote {
|
||||
b.Log.Debugf("Detected vote from %s: %s (ticker=%q)", event.Source.Name, voteType, ticker)
|
||||
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 {
|
||||
if err := b.jackboxClient.SendVote(event.Source.Name, voteType, timestamp, ticker); err != nil {
|
||||
b.Log.Errorf("Failed to send vote to Jackbox API: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user