Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (vars): Add $pollTitle and $pollChoices Variables #2777

Open
wants to merge 10 commits into
base: v5
Choose a base branch
from

Conversation

phroggster
Copy link
Collaborator

@phroggster phroggster commented Sep 3, 2024

Description of the Change

  • Add a $pollTitle variable that provides the name of a poll being started, updated, and/or ended.
  • Add a $pollChoices variable that can return any piece of information about poll choices for the same event types without requiring $objectWalkPath or $arrayElement-style walking:.
  • Raw $pollChoices will yield an array of the choices available (with id, index, points, title, votes properties), but accepts three optional parameters:
Param Name Param Description Acceptable Values
propertySelector Chooses which value to select from the poll choices. count (number of choices), raw (return whole objects), index, points, title, votes
sortOrder Changes the sorting order to allow for index (default) and total votes sorting. "votes" for totalVotes DESC; anything else: index ASC sort.
desiredIndex Select which poll choice item to return using 1-based indexing. 0/null (returns all elements), or a number between 1-5 to get choice index 0-4.

Here's a few $pollChoices use cases:

Usage Description Example Use Case
$pollChoices[count] Gets the count of choices listed. There were 4 choices available in the poll.
$pollChoices[votes, votes, 1] Gets the number of votes cast for the most-voted item. Option x won with 173 votes cast for it.
$pollChoices[index, votes, 1] Gets the 1-based index of the most-voted item. Option 2 won with x votes cast for it.
$pollChoices[votes, index, 1] Gets the number of votes cast for the first item. Option 1 received 18 votes cast for it.
$pollChoices[points] Gets an array of point votes used on all items. There were $math[$arrayJoin[$pollChoices[points], " + "]] total channel point votes cast on all options.

Complaints

  • Simulate event doesn't work with any of this, manual execution does. 🤷
  • 1-based array indexing is the devil, but does present a better UX.

Applicable Issues

#2348 (partial), #2732 (partial)

Testing

  • Tested just about everything I could, but I welcome a bigger hammer to smash this with.
  • However, I'm not affiliated, so a lot of this is out of my testing reach.

Screenshots

N/A

- $pollChoices provides for just about every imaginable piece of info
  about polling options for Poll Started, Poll Progress, and Poll Ended
  events.
- Meanwhile, $pollTitle is a bit more focused for just the title of a
  poll.
- Fix mismatched metadata for the poll-progress and poll-end events.
- Implements the remaining bits of crowbartools#2732
- and add manual triggering to $pollChoices
- "title" is a valid propertySelector.
- Ignore an empty string (or anything falsy) as a propertySelector.
- Better commentary
- Include choice IDs in raw object returns (raw or null property
  selector).
- Simulate more realistic IDs in polling event metadata.
@dennisrijsdijk
Copy link
Collaborator

would you mind adding "partially resolves #2348" into your applicable issues?

@dennisrijsdijk
Copy link
Collaborator

dennisrijsdijk commented Sep 4, 2024

image
Noticed something when simulating event. The Choices header will show up empty due to the way the modal parses the manualMetadata. This is related to how manualMetadata is parsed internally.

@dennisrijsdijk
Copy link
Collaborator

Some questions that came up as I looked into this PR further:

Can you expose the channel points vote cost?
Can you expose channel points votes for the winning choice?

@phroggster
Copy link
Collaborator Author

Can you expose the channel points vote cost?

We could cache the poll started event data somewhere, then do maths with it, but we'd have to do so in the twurple poll started callback, not in our start poll effect. Otherwise, the information would be missing if the poll was externally started.

Can you expose channel points votes for the winning choice?

I've corrected my description: channel points votes is what the "points" property selector will give out. Twitch's event docs for this are so confusing though, so I'm honestly absolutely clueless as to what any of this means at a high level. Aren't all poll votes locked behind channel points now, and totalVotes essentially locked to channelPointsVotes in the event data?

@dennisrijsdijk
Copy link
Collaborator

Aren't all poll votes locked behind channel points now, and totalVotes essentially locked to channelPointsVotes in the event data?

poll votes, I believe, are a combination between free votes, and channelPointsVotes

@phroggster phroggster marked this pull request as draft September 4, 2024 22:32
@phroggster
Copy link
Collaborator Author

Converting to a draft, while we get a similar interface ironed out with predictions.

CKY- and others added 2 commits September 5, 2024 14:51
Add simulate event controls to $pollChoices. Thanks CK!
@phroggster
Copy link
Collaborator Author

phroggster commented Sep 5, 2024

We now have simulate events functioning properly thanks to CKY. Going to leave this as a draft until we get predictions alongside with similar functionality, but I believe this is officially ready for merging.

@phroggster
Copy link
Collaborator Author

phroggster commented Sep 5, 2024

I retract my last comment. The manualMetadata change to get simulate event working broke manually running the events. Back to the drawing board.... Edit: #2784 fixes my complaint on this.

@CKY- CKY- removed the Needs Testing label Sep 6, 2024
@phroggster phroggster marked this pull request as ready for review September 6, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants