Global and user variables¶
C# methods for a Run C# code step. See C# methods for how to use them.
GetGlobalVar¶
Reads a global variable (one shared by all actions). The type you ask for, like int, is what you get. Pass false to read a temporary (not saved) one.
T? GetGlobalVar<T>(string varName, bool persisted = true)
Gives back: The value, or the empty default (like 0) when it is missing or was stored the other way (saved vs temporary).
Example
int deaths = CPH.GetGlobalVar<int>("deaths");
CPH.LogInfo($"Deaths so far: {deaths}");
SetGlobalVar¶
Stores a global variable that every action can read. Saved means it is kept when Cuebot restarts. Pass false at the end to keep it only until Cuebot restarts.
void SetGlobalVar(string varName, object? value, bool persisted = true)
Gives back: Nothing.
Example
CPH.SetGlobalVar("deaths", 5);
UnsetGlobalVar¶
Deletes a global variable. Pass false to delete a temporary (not saved) one; it only deletes the one stored that way.
void UnsetGlobalVar(string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetGlobalVar("deaths");
GetGlobalVarValues¶
Gives you a list of all saved global variables, each with its name, value and last change. Pass false to list the temporary ones instead.
List<GlobalVariableValue> GetGlobalVarValues(bool persisted = true)
Gives back: A list of global variables.
Example
var globals = CPH.GetGlobalVarValues();
CPH.LogInfo($"You have {globals.Count} saved globals.");
ClearNonPersistedGlobals¶
Deletes every temporary (not saved) global variable at once. Saved ones stay.
void ClearNonPersistedGlobals()
Gives back: Nothing.
Example
CPH.ClearNonPersistedGlobals();
GetTwitchUserVar¶
Reads a Twitch viewer's variable, by their login name. The type you ask for (like int) is what you get. Cuebot ignores the saved true/false here.
T? GetTwitchUserVar<T>(string userLogin, string varName, bool persisted = true)
Gives back: The value, or the empty default (like 0 or empty) when the viewer or variable is not found.
Example
int points = CPH.GetTwitchUserVar<int>("coolviewer", "points");
CPH.LogInfo($"Points: {points}");
GetTwitchUserVarById¶
Reads a Twitch viewer's variable, by their user id. The type you ask for (like int) is what you get. Cuebot ignores the saved true/false here.
T? GetTwitchUserVarById<T>(string userId, string varName, bool persisted = true)
Gives back: The value, or the empty default (like 0 or empty) when the viewer or variable is not found.
Example
int points = CPH.GetTwitchUserVarById<int>("12345678", "points");
CPH.LogInfo($"Points: {points}");
SetTwitchUserVar¶
Stores a variable for one Twitch viewer, by their login name. Pass false at the end to keep it only until Cuebot restarts.
void SetTwitchUserVar(string userLogin, string varName, object? value, bool persisted = true)
Gives back: Nothing.
Example
CPH.SetTwitchUserVar("coolviewer", "points", 100);
SetTwitchUserVarById¶
Stores a variable for one Twitch viewer, by their user id. Pass false at the end to keep it only until Cuebot restarts.
void SetTwitchUserVarById(string userId, string varName, object? value, bool persisted = true)
Gives back: Nothing.
Example
CPH.SetTwitchUserVarById("12345678", "points", 100);
UnsetTwitchUserVar¶
Deletes one variable of a Twitch viewer, by their login name. Cuebot ignores the saved true/false here.
void UnsetTwitchUserVar(string userLogin, string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetTwitchUserVar("coolviewer", "points");
UnsetTwitchUserVarById¶
Deletes one variable of a Twitch viewer, by their user id. Cuebot ignores the saved true/false here.
void UnsetTwitchUserVarById(string userId, string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetTwitchUserVarById("12345678", "points");
UnsetAllTwitchUsersVar¶
Deletes one variable from every Twitch viewer at once. Cuebot ignores the saved true/false here.
void UnsetAllTwitchUsersVar(string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetAllTwitchUsersVar("points");
GetTwitchUsersVar¶
Gives you a list of every Twitch viewer who has this variable, with their id, name, value and last change. Pass false to list the ones not saved instead.
List<UserVariableValue<T>> GetTwitchUsersVar<T>(string varName, bool persisted = true)
Gives back: A list of viewers and their values (empty when nobody has it).
Example
var all = CPH.GetTwitchUsersVar<int>("points");
CPH.LogInfo($"{all.Count} viewers have points.");
GetYouTubeUserVar¶
Reads a YouTube viewer's variable, by their login name. The type you ask for (like int) is what you get. Cuebot ignores the saved true/false here.
T? GetYouTubeUserVar<T>(string userName, string varName, bool persisted = true)
Gives back: The value, or the empty default (like 0 or empty) when the viewer or variable is not found.
Example
int points = CPH.GetYouTubeUserVar<int>("Cool Viewer", "points");
CPH.LogInfo($"Points: {points}");
GetYouTubeUserVarById¶
Reads a YouTube viewer's variable, by their user id. The type you ask for (like int) is what you get. Cuebot ignores the saved true/false here.
T? GetYouTubeUserVarById<T>(string userId, string varName, bool persisted = true)
Gives back: The value, or the empty default (like 0 or empty) when the viewer or variable is not found.
Example
int points = CPH.GetYouTubeUserVarById<int>("UCabc123", "points");
CPH.LogInfo($"Points: {points}");
SetYouTubeUserVar¶
Stores a variable for one YouTube viewer, by their login name. Pass false at the end to keep it only until Cuebot restarts.
void SetYouTubeUserVar(string userName, string varName, object? value, bool persisted = true)
Gives back: Nothing.
Example
CPH.SetYouTubeUserVar("Cool Viewer", "points", 100);
SetYouTubeUserVarById¶
Stores a variable for one YouTube viewer, by their user id. Pass false at the end to keep it only until Cuebot restarts.
void SetYouTubeUserVarById(string userId, string varName, object? value, bool persisted = true)
Gives back: Nothing.
Example
CPH.SetYouTubeUserVarById("UCabc123", "points", 100);
UnsetYouTubeUserVar¶
Deletes one variable of a YouTube viewer, by their login name. Cuebot ignores the saved true/false here.
void UnsetYouTubeUserVar(string userName, string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetYouTubeUserVar("Cool Viewer", "points");
UnsetYouTubeUserVarById¶
Deletes one variable of a YouTube viewer, by their user id. Cuebot ignores the saved true/false here.
void UnsetYouTubeUserVarById(string userId, string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetYouTubeUserVarById("UCabc123", "points");
UnsetAllYouTubeUsersVar¶
Deletes one variable from every YouTube viewer at once. Cuebot ignores the saved true/false here.
void UnsetAllYouTubeUsersVar(string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetAllYouTubeUsersVar("points");
GetYouTubeUsersVar¶
Gives you a list of every YouTube viewer who has this variable, with their id, name, value and last change. Pass false to list the ones not saved instead.
List<UserVariableValue<T>> GetYouTubeUsersVar<T>(string varName, bool persisted = true)
Gives back: A list of viewers and their values (empty when nobody has it).
Example
var all = CPH.GetYouTubeUsersVar<int>("points");
CPH.LogInfo($"{all.Count} viewers have points.");
GetKickUserVar¶
Reads a Kick viewer's variable, by their login name. The type you ask for (like int) is what you get. Cuebot ignores the saved true/false here.
T? GetKickUserVar<T>(string userLogin, string varName, bool persisted = true)
Gives back: The value, or the empty default (like 0 or empty) when the viewer or variable is not found.
Example
int points = CPH.GetKickUserVar<int>("coolviewer", "points");
CPH.LogInfo($"Points: {points}");
GetKickUserVarById¶
Reads a Kick viewer's variable, by their user id. The type you ask for (like int) is what you get. Cuebot ignores the saved true/false here.
T? GetKickUserVarById<T>(string userId, string varName, bool persisted = true)
Gives back: The value, or the empty default (like 0 or empty) when the viewer or variable is not found.
Example
int points = CPH.GetKickUserVarById<int>("987654", "points");
CPH.LogInfo($"Points: {points}");
SetKickUserVar¶
Stores a variable for one Kick viewer, by their login name. Pass false at the end to keep it only until Cuebot restarts.
void SetKickUserVar(string userLogin, string varName, object? value, bool persisted = true)
Gives back: Nothing.
Example
CPH.SetKickUserVar("coolviewer", "points", 100);
SetKickUserVarById¶
Stores a variable for one Kick viewer, by their user id. Pass false at the end to keep it only until Cuebot restarts.
void SetKickUserVarById(string userId, string varName, object? value, bool persisted = true)
Gives back: Nothing.
Example
CPH.SetKickUserVarById("987654", "points", 100);
UnsetKickUserVar¶
Deletes one variable of a Kick viewer, by their login name. Cuebot ignores the saved true/false here.
void UnsetKickUserVar(string userLogin, string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetKickUserVar("coolviewer", "points");
UnsetKickUserVarById¶
Deletes one variable of a Kick viewer, by their user id. Cuebot ignores the saved true/false here.
void UnsetKickUserVarById(string userId, string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetKickUserVarById("987654", "points");
UnsetAllKickUsersVar¶
Deletes one variable from every Kick viewer at once. Cuebot ignores the saved true/false here.
void UnsetAllKickUsersVar(string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetAllKickUsersVar("points");
GetKickUsersVar¶
Gives you a list of every Kick viewer who has this variable, with their id, name, value and last change. Pass false to list the ones not saved instead.
List<UserVariableValue<T>> GetKickUsersVar<T>(string varName, bool persisted = true)
Gives back: A list of viewers and their values (empty when nobody has it).
Example
var all = CPH.GetKickUsersVar<int>("points");
CPH.LogInfo($"{all.Count} viewers have points.");
GetUserVar¶
Older name for GetTwitchUserVar: reads a Twitch viewer's variable by their login name. The type you ask for is what you get.
T? GetUserVar<T>(string userName, string varName, bool persisted = true)
Gives back: The value, or the empty default (like 0) when not found.
Example
int points = CPH.GetUserVar<int>("coolviewer", "points");
CPH.LogInfo($"Points: {points}");
SetUserVar¶
Older name for SetTwitchUserVar: stores a variable for a Twitch viewer by their login name. Pass false at the end to keep it only until Cuebot restarts.
void SetUserVar(string userName, string varName, object? value, bool persisted = true)
Gives back: Nothing.
Example
CPH.SetUserVar("coolviewer", "points", 100);
UnsetUserVar¶
Older name for UnsetTwitchUserVar: deletes one variable of a Twitch viewer by their login name.
void UnsetUserVar(string userName, string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetUserVar("coolviewer", "points");
UnsetUser¶
Deletes all variables of one Twitch viewer, by their login name. Nothing happens when Cuebot does not know them.
void UnsetUser(string userName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetUser("coolviewer");
UnsetAllUsersVar¶
Deletes one variable from every viewer on every platform (Twitch, YouTube and Kick) at once.
void UnsetAllUsersVar(string varName, bool persisted = true)
Gives back: Nothing.
Example
CPH.UnsetAllUsersVar("points");
ClearNonPersistedUserGlobals¶
Deletes every temporary (not saved) viewer variable on every platform at once. Saved ones stay.
void ClearNonPersistedUserGlobals()
Gives back: Nothing.
Example
CPH.ClearNonPersistedUserGlobals();