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:
cottongin
2026-04-05 04:54:05 -04:00
parent 88cc140087
commit bec3615d2b
6 changed files with 235 additions and 24 deletions

View File

@@ -36,8 +36,9 @@ type AuthResponse struct {
// VoteRequest represents a vote submission to the API
type VoteRequest struct {
Username string `json:"username"`
Vote string `json:"vote"` // "up" or "down"
Vote string `json:"vote"` // "up" or "down"
Timestamp string `json:"timestamp"`
Ticker string `json:"ticker,omitempty"` // ticker symbol targeting a specific game
}
// VoteResponse represents the API response to a vote submission
@@ -214,8 +215,9 @@ func (c *Client) ensureAuthenticated() error {
return c.Authenticate()
}
// SendVote sends a vote to the Jackbox API
func (c *Client) SendVote(username, voteType string, timestamp time.Time) error {
// SendVote sends a vote to the Jackbox API.
// ticker is optional; when non-empty the API resolves the target game by symbol.
func (c *Client) SendVote(username, voteType string, timestamp time.Time, ticker string) error {
// Ensure we're authenticated
if err := c.ensureAuthenticated(); err != nil {
return fmt.Errorf("authentication failed: %w", err)
@@ -230,6 +232,7 @@ func (c *Client) SendVote(username, voteType string, timestamp time.Time) error
Username: username,
Vote: voteType,
Timestamp: timestamp.Format(time.RFC3339),
Ticker: ticker,
}
jsonBody, err := json.Marshal(voteReq)
@@ -266,7 +269,7 @@ func (c *Client) SendVote(username, voteType string, timestamp time.Time) error
return fmt.Errorf("re-authentication failed: %w", err)
}
// Retry the vote
return c.SendVote(username, voteType, timestamp)
return c.SendVote(username, voteType, timestamp, ticker)
}
if resp.StatusCode == http.StatusConflict {