Twitch Local Stream Streaks

Description

Track and utilize viewer stream streaks for your Twitch streams!

Use case ideas:

  • Reward users for redeeming a channel point reward multiple streams in a row
  • Maintain your own stream streak tracker for user activity (chat messages, reward redemptions, cheers)
    • This can serve as an alternative to Twitch’s current implementation of watch streaks which is limited to specific devices, channels, and interactions
  • Allow for users to have a permanent record for their highest stream streak

This is not connected/affiliated with Twitch’s official watch streaks. This extension locally tracks when viewers interact with your stream, and manages an internal streak counter per-user. It is not in sync with Twitch’s watch streaks and will only begin tracking viewer activity when imported and enabled.

This extension is limited to Twitch streams at this time as it utilizes the Twitch API to uniquely identify streams by Twitch’s stream ID. Depending on usage and API availability, it can be expanded to serve other platforms in the future.

Import Code

StreamStreakExtension_0.1.3.sb (21.2 KB)

Installation

In Streamer.bot click the Import button in the top menu. Drag the .sb file into the Import String field.

Minimum Required setup

  1. In Streamer.bot, go to the Actions tab and find the action titled [Stream Streak] [EDIT] Update User Streak.

  2. Click on the action once to reveal the sub-actions for it.

  3. In the Triggers window, there will be 3 triggers available by default. Add (or enable) the triggers that you would like to represent the user being “present” for the stream.

    • Default triggers:
      1. Twitch > Channel Reward Redemption (Any) - Disabled
      2. Twitch > Present Viewers - Disabled
      3. Core / Test - Enabled (this is useful for anyone looking to make custom changes and test them out)
    • Each enabled trigger represents an event that will qualify as “activity” for updating a user’s stream streak.
    • For example:
      • If the Present Viewers trigger is enabled, all viewers that are present in chat will get credit for being in the stream whenever the “Present Viewers” trigger fires. By default this should happen every 5 minutes. You can read more about this trigger here.
      • If the Channel Reward Redemption trigger is enabled for all rewards, then any channel point redemption will consider the user “present” for that stream and update their streak accordingly. This is a way to allow users to possibly have their streak updated even sooner than the Present Viewers trigger if they are quick to redeem things upon entering the stream. This also helps in the case where a user drops in, redeems a channel point reward, and leaves before the Present Viewers event fires again.
    • If you’re not sure where to start, it is recommended to enable both the Twitch > Channel Reward Redemption (Any) and Twitch > Present Viewers triggers. This will ensure that users who are present have the best chance of getting credit for it.

This extension uses a real stream ID to keep track of stream streaks, which means it will only increment a user’s stream streak at-most once per stream, even if a user triggers it multiple times. So, if you have both of the triggers above enabled, you don’t have to worry about a user streak being updated endlessly.

Done! The above instructions are enough to:

  • Track user stream streaks
  • Get user stream streaks using the commands in the section at the bottom of this guide

Reminder to enable the commands after importing, as they are disabled by default.

The remaining sections are for optional features such as:

  • Allowing a user to share their stream streak with the chat
  • Adding streak milestones to perform an action when specific stream streaks are met

Optional Sharing User Streaks Setup

The above instructions will track user streaks and allow users to view streaks explicitly via chat command, but they will not trigger any visible events like chat messages or milestone-based stream events when updating a user’s streak. The above is to ensure streaks are properly tracked, but if you’d like to allow users to share their stream streak with an action such as a channel point reward, you can enable this too. Some examples include:

  • Having a channel point reward to Share you streak!
  • Having a channel point reward to Check in that will also share the user’s streak upon redeeming

To enable this:

  1. In Streamer.bot, go to the Actions tab and find the action titled [Stream Streak] [EDIT] Share User Streak.
  2. Click on the action once to reveal the sub-actions for it.
  3. In the Triggers window, there will be 2 triggers available by default. Add (or enable) the triggers that you would like to result in a publicly visibly streak event (like a chat message, sound to play, stream effect, etc).
    • Default triggers:
      1. Twitch > Channel Reward Redemption (Any) - Disabled
      2. Core / Test - Enabled (this is useful for anyone looking to make custom changes and test them out)
    • To enable a specific channel-point reward as the trigger for sharing a streak with the stream:
      1. Double click on the trigger for Twitch > Channel Reward Redemption (Any).
      2. Set the reward to be the desired “Share” redemption.
        share streak reward edit
      3. Click “Ok”.
      4. Right click on the Twitch > Channel Reward Redemption (Any) trigger and click on Enabled to enable it.

This will now allow users to redeem a Channel Point Reward to share their streak with the rest of the stream. To configure what should happen when a user shares their streak (chat message, sound playing, events on specific milestones, etc) see the following Optional setup instructions.

Optional Auto-Chat Message Setup

You can have a message sent to chat showing a user’s streak upon redeeming a channel point reward.

  • Example:
    1. SomeUser redeems a channel point reward for the 3rd stream in a row
    2. Message automatically gets sent to chat with the message: SomeUser has watched 3 streams in a row!

This is Off by default, but can be turned on by doing the following:

  1. Follow the instructions above under Optional Sharing User Streaks Setup. This will enable the channel point trigger.
  2. In Streamer.bot, go to the Actions tab and find the action titled [Stream Streak] [EDIT] Auto Chat Message. Right click on this action and click on the Enabled button to enable it.

That’s it! There is a default message that will send upon a user “sharing” their streak. If you’d like to customize the message that is sent, and perhaps perform additional sub-actions, you can do the following:

  • In the sub-actions window for this action, double click on the Twitch Message... sub-action and edit the message.
    optional chat edit

    • Available arguments relating to stream streaks:
      • %userCurrentStreamStreak% - Represents the user’s current stream streak
      • %userMaxStreamStreak% - Represents the user’s maximum stream streak ever
      • %userLastStreamStreak% - Represents the user’s last stream streak (can be useful if a user has lost their streak)
  • To add any other sub-actions, simply right click within the sub-actions window for this action and add them in there.

The automatic chat message/event will only happen once per-user per-stream. This means that if a user triggers this action multiple times in a stream, a message will only be sent the first time for that user.

For developers: you can utilize the arguments to add custom code for sending different messages depending on whether or not the user has lost their streak. One way to check for this is to see if %userCurrentStreamStreak% is 1 and %userLastStreamStreak% is greater than 1.

Optional Streak Milestone Setup

You can have other actions run when a user reaches and shares a specific streak milestone. A milestone represents watching a specific number of streams in a row.

  • Example:
    1. You create an action (not included in this extension) in Streamer.bot to make an image of confetti appear on your stream
    2. You add a streak milestone to trigger that action upon reaching a streak of 5 streams
    3. A user redeems a channel point reward for the 3rd stream in a row
    4. Nothing happens
    5. Another user redeems a channel point reward for the 5th stream in a row
    6. Image of confetti appears on stream

You can have different actions for different milestones.

  • Some examples of what you can do:
    • 5 streams in a row - send a special message to chat
    • 10 streams in a row - reveal an OBS source
    • 20 streams in a row - a sound plays
    • etc

This is Off by default, but can be turned on by:

  1. Create an action in Streamer.bot for something you’d like to happen upon reaching a streak milestone.
  2. Follow the instructions above under Optional Sharing User Streaks Setup. This will enable the channel point trigger.
  3. In Streamer.bot, go to the Actions tab and find the action titled [Stream Streak] [EDIT] Milestones. Right click on this action and click on the Enabled button to enable it.
  4. Double click on the sub-action for if ("userCurrentStream... to open up the editor window (default milestone with no action exists for a streak of 5)
    optional milestone edit
  5. Set the value field on the 3rd row to be the milestone amount that you’d like to trigger the action.
  6. Click on the row below for do action and select your resulting action from step 1.
  7. To add more milestones, duplicate the sub-action that you just made and repeat steps 1-6.

Done!

Additional Configuration

The minimum required installation steps above are enough to get the extension working. However, the following are remaining configurations for existing/enabled functionality.

[Stream Streak] [EDIT] Get Current Streak Configuration

You can customize the message that is sent for the !streak command. By default, the message will say something like: SomeUser has watched 6 streams in a row!. If you’d like to change this:

  1. In Streamer.bot, go to the Actions tab and find the action titled [Stream Streak] [EDIT] Get Current Streak.
  2. Double click on the the Twitch Message... sub-action to edit the message.
    • Available arguments relating to stream streaks:
      • %targetUserName% - Represents the target’s username
        • Ex 1: !streak will have the sender’s name
        • Ex 2: !streak @someUser will have someUser’s name (@ is optional)
      • %userCurrentStreamStreak% - Represents the user’s current stream streak
      • %userMaxStreamStreak% - Represents the user’s maximum stream streak ever
      • %userLastStreamStreak% - Represents the user’s last stream streak

Unlike the actions above, this command does not update the user’s streak. So, if a user enters a stream and does not yet trigger any of the above-configured actions, their stream streak will show the previously earned streak. Once the user’s streak is updated through any of the above-configured actions, this command will return the latest information.

This command is not designed to trigger any milestones or other major chat events upon reaching a streak. It is merely for a quick check. To enable milestones or chat events upon continuing a user’s streak, follow the “Optional” instructions above for Optional Sharing User Streaks Setup.

Commands

Be sure to enable the following commands after importing as they are off by default.

Command Description Permission
!streak Gets the sender’s stream streak Everyone
!streak <targetUser> Gets the target’s stream streak (@ is optional) Everyone
!refreshstreak Manually gets the latest stream ID from Twitch. This isn’t normally needed as the data will be retrieved from Twitch automatically based on the configured “cache” settings. Mod
!ignorestreak Ignore’s the current stream for stream streaks. This will prevent the current stream ID from being counted and possibly breaking any streaks. Use this when a stream crashes and restarts, but you still want to act like the restarted stream is the same as the previous. Ex: Stream A is running for an hour and crashes. Stream B starts up moments later. Use this command to ignore stream B and continue using Stream A’s ID so any late-joiners won’t have their streaks broken. This can be undone using the !unignorestreak command. Mod
!unignorestreak Manually stops ignoring any stream that has been ignored using the !ignorestreak command. Mod
!spare <targetUser> Restores a user’s streak to their previous value. This can be done unlimited times per user and will just go back and forth between the current value and the previous one. Mod
!setstreak <targetUser> <streakAmount> Sets the target’s stream streak (@ is optional). Example: !setstreak @SomeUser 10 to set SomeUser’s streak to 10. This will also make their existing streak be set to their last streak, allowing their original streak to be restored using the !spare command. Mod
3 Likes

Did a couple test streams now and it worked exceptionally well on my end. Good to approve in my opionion :slight_smile:

Unrelated to the actual approval, but I would love to see an extra usecase that works with the Present Viewers trigger.

2 Likes

Awesome, thank you so much for testing it out!

Also great idea for using the “Present Viewers” trigger. I’ll play around with the implementation to see how to best do this while keeping things neat. I’m going to try implementing an approach to have 2 actions instead of 1 for updating user streaks:

  1. Active streak updates (channel point redemptions, specific commands perhaps). These would trigger an auto-chat message (if enabled) and the milestones (if enabled).
  2. Passive streak updates (user presence, perhaps any chat message if desired). These would update user streaks on their own but not do any of the follow-up actions. Additionally, if a user is marked as present from these, they could still perform one of the “active” triggers to share their streak/have a milestone event occur at most one time.
    • This would also be disabled by default for control purposes, but would be 1 step to enable it for those that want it to count.

That way, streak can be tracked by most user activity/presence, and bot-messages/reactions to streaks won’t spam the chat/call out lurkers. Will get on this and update this post when implemented!

1 Like

Documentation looks great and seems to be a solid build but there’s one issue that would need to be addressed before being approved fully.

You have HttpClient in a using statement which is bad practice and can possibly lead to issues. Please refer to HttpClient and you for an explanation on why it’s a bad practice and a good way to use a HttpClient and properly Dispose of it.

After that is addressed I see no issues with moving this to approved.

Only other thing I saw was your use of fully capitalized variables where it’s good practice to use camelCase variables in C#. However, Nate I believe has addressed it to where variable cases aren’t an issue and it just comes down to good coding practices. I only mention this if you are concerned at all about good practices and as more of an informational point out. Being that it shouldn’t be an issue in SB it wouldn’t hinder it from approval either way.

1 Like

Thank you for taking a look/for the feedback! I’ve updated the import to contain code that uses the HttpClient as modeled in the snippet you linked. As for the capitalized variables, I originally used that for constant/constant-adjacent variables (for my own organization, so not saying this is good practice), but for any future code I submit I’ll be sure to keep it all in camelCase to match the recommended style!

Thanks again for reviewing and let me know there are any other changes/suggestions that come to mind!