I was recently looking for a way to help Twitch viewers by Channel points to enable you to get VIP status.
The whole process should be completely automated and just as automatically the VIP status be withdrawn after one month.
Here is a small Tutorialhow you can do this with my method with the Streamer.bot can implement.

Streamer.bot

First of all: With the Streamer.bot you have many, many more options 🙂
I will now describe only the bare minimum to implement the above.
Requirement is that you have created a channel point reward for VIP.

Step 1: Download Streamer.bot

Download here the Streamer.bot Download, unpack the archive and place the folder in a directory of your choice.
This includes the entire program, you don't have to install anything.

Start the Streamer.bot.exe and it's best to create a shortcut for it on your desktop.

Step 2: Link your Twitch account

Log in at Platforms -> Twitch -> Accounts -> Broadcaster Account with your Twitch account.
If you want, you can also connect an extra bot account here.

Streamer.bot Account

Step 3: Create actions

Lie down with Right-click in the white field under Actions 2 actions, once “VIP Add” and once “VIP Check

Streamer.bot Actions

Step 4: Create triggers

The actions also need one Triggerthat triggers this.

In the case of "VIP Add“ the action should be triggered as soon as someone triggers the channel points reward.
To do this, right-click in the white field under Triggers and select Twitch -> Channel Reward -> Reward Redemption

For the "VIP Check“ I set up a timer that should trigger this action every 30 minutes.
To do this, you must first set the timer under Settings -> Timed Actions right-click and select “Add”:

Streamer.bot Timer

Afterwards you can go back to the action by right-clicking in the white field under Triggers on Core -> Timed Actions select the timer:

Streamer.bot Trigger

Step 5: Create sub-actions

Now we put the Sub-Actions that should be executed when the trigger initiates the action.

VIP Add

  1. Right-click under Sub-Actions: Twitch -> Moderation -> Add VIP, as Source Type you leave the preselected User.
  2. Right-click under Sub-Actions: Twitch -> User -> Get User Info for Target, as Source Type you choose User
  3. Right-click under Sub-Actions: Core -> C# -> Execute C# Code

After adding Execute C# Code A small window opens in which you can enter your own code.
Here you insert the (customized) code:

using System;
using System.IO;

public class CPPHInline
{
public bool Execute()
{
// Get the username from the argument
CPH.TryGetArg(“targetUser”, out string user);

// Get the current date, formatted as "dd.MM.yyyy"
string currentDate = DateTime.Now.ToString(“dd.MM.yyyy”);

// Path to the CSV file
string filePath = @“C:\Users\Mike\Documents\Streamer.bot-x64-0.2.2\data\VIP.csv„; // Change this to the actual Streamer.bot location

// Create the entry with username and date
string csvLine = $“{user},{currentDate}\n“;

// Write the entry to the CSV file
// 'AppendAllText' adds the text to the end of the file without overwriting existing data
File.AppendAllText(filePath, csvLine);

return true;
}
}

Using this code, when redeeming channel points, the viewer’s name and the date are converted into a CSV file registered.
It is best to use the data Streamer.bot folder, otherwise there may be problems with Windows rights.

VIP Check

At VIP Check only a sub-action needs to be created, here just right-click and then click Core -> C# -> Execute C# Code.

Here you insert the following code:

using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;

public class CPPHInline
{
public bool Execute()
{
// Path to the CSV file
string filePath = @“C:\Users\Mike\Documents\Streamer.bot-x64-0.2.2\data\VIP.csv„; // Change this to the actual Streamer.bot location

// Current date
DateTime currentDate = DateTime.Now;

// Open the file and read it line by line
List lines = new List (File.ReadAllLines(filePath));
List updatedLines = newList ();

bool changesMade = false;

foreach (var line in lines)
{
// Split the line into username and date
string[] parts = line.Split(',');
if (parts.Length < 2)
{
updatedLines.Add(line); // Keep line if it is not correctly formatted
continue;
}

string userName = parts[0];
string dateString = parts[1];

// Try to parse the date
if (DateTime.TryParseExact(dateString, “dd.MM.yyyy”, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime vipDate))
{
// Check if the date is at least one month ago
if ((currentDate – vipDate).TotalDays >= 30) // Here you can adjust the number of days, in this example 30 days
{
// Remove VIP status
CPH.TwitchRemoveVip(userName);
Console.WriteLine($"VIP status for {userName} removed because the status is older than one month.");
changesMade = true;
continue; // Do not add the line to the updated lines
}
}
// Add line to the updated lines if no change is needed
updatedLines.Add(line);
}

// Only write if changes have been made
if (changesMade)
{
File.WriteAllLines(filePath, updatedLines);
Console.WriteLine("The file has been updated.");
}

return true;
}
}

This code reads the stored file and checks in each line whether the date has been set for longer than 1 month here.
If so, the viewer's VIP status will be removed and the name will be deleted from the file.

That's it, with this you have done everything 🙂
Please leave me some feedback if you don't understand something, so I can work on it further.
Otherwise, have fun with Stream!

All tutorials


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *