Introduction
CPHInline Class
CPH
refers to the original development name of Streamer.bot, ChannelPointsHandler
When you add a new Execute C# Code sub-action, you will be greeted with the following code snippet:
using System;
public class CPHInline
{
public bool Execute()
{
// your main code goes here
return true;
}
}
Within all C# code actions you have access to the CPH
class, allowing you to make calls to internal Streamer.bot methods.
Execute()
When your C# sub-action is executed, the Execute()
method is always called.
This is where you should place your main code logic, as shown in the example below:
public bool Execute()
{
CPH.LogInfo("Hello from C#");
return true;
}
Normally this method returns true
to allow execution of any subsequent sub-actions.
If for some reason you would like to cancel further execution, and skip any remaining sub-actions in the current action, you can return false
.
public bool Execute()
{
if (someCondition) {
CPH.LogInfo("This action will now stop executing further sub-actions.");
return false; // Stop execution of further sub-actions
}
return true; // Allow further execution
}
Custom Methods
You can also define your own custom methods within the CPHInline
class, and call them from within the Execute()
method.
public bool Execute()
{
CPH.LogInfo("Starting execution...");
CustomMethod();
return true;
}
public void CustomMethod()
{
CPH.LogInfo("Hello from a custom method!");
}
Video Tutorials
Explore some introductory video tutorials on using C# in Streamer.bot