Chat, OBS, speech and sounds¶
C# methods for a Run C# code step. See C# methods for how to use them.
SendMessage¶
Sends a message in your Twitch chat. Cuebot sends it with its connected Twitch account; the bot and fallback settings are ignored. Empty text sends nothing.
void SendMessage(string message, bool bot = true, bool fallback = true)
Gives back: Nothing.
Example
CPH.SendMessage("Thanks for the follow!");
SendYouTubeMessage¶
Sends a message in your YouTube chat. Give a broadcast id to post in that stream's chat, with the bot account (or the broadcaster as fallback). Empty text sends nothing.
void SendYouTubeMessage(string message, bool bot = true, bool fallback = true, string? broadcastId = null)
Gives back: Nothing.
Example
CPH.SendYouTubeMessage("Welcome to the stream!");
SendKickMessage¶
Sends a message in your Kick chat. The bot and fallback settings are ignored. Empty text sends nothing.
void SendKickMessage(string message, bool bot = true, bool fallback = true)
Gives back: Nothing.
Example
CPH.SendKickMessage("Thanks for the follow!");
SendMessageToAll¶
Sends the same message to every chat that is connected right now (Twitch, YouTube, Kick and others). A Cuebot extra. Fails when no chat is connected.
void SendMessageToAll(string message)
Gives back: Nothing.
Example
CPH.SendMessageToAll("Going live in 5 minutes!");
ObsIsConnected¶
Checks whether OBS answers right now. Give a connection number to check another OBS; 0 is the default one.
bool ObsIsConnected(int connection = 0)
Gives back: true when OBS answered, otherwise false.
Example
bool connected = CPH.ObsIsConnected();
CPH.LogInfo($"OBS connected: {connected}");
ObsSetScene¶
Switches OBS to another scene, by its name exactly as OBS shows it. The connection number picks another OBS (0 is the default).
void ObsSetScene(string sceneName, int connection = 0)
Gives back: Nothing.
Example
CPH.ObsSetScene("Gameplay");
ObsGetCurrentScene¶
Asks OBS which scene is live right now.
string ObsGetCurrentScene(int connection = 0)
Gives back: The scene's name, or empty text when OBS did not say.
Example
string scene = CPH.ObsGetCurrentScene();
CPH.LogInfo($"Live scene: {scene}");
ObsSetSourceVisibility¶
Shows (true) or hides (false) a source in an OBS scene. Fails when the scene has no source with that name.
void ObsSetSourceVisibility(string scene, string source, bool visible, int connection = 0)
Gives back: Nothing.
Example
CPH.ObsSetSourceVisibility("Gameplay", "Webcam", true);
ObsShowSource¶
Shows a source in an OBS scene, like your webcam. Fails when the scene has no source with that name.
void ObsShowSource(string scene, string source, int connection = 0)
Gives back: Nothing.
Example
CPH.ObsShowSource("Gameplay", "Webcam");
ObsHideSource¶
Hides a source in an OBS scene. Fails when the scene has no source with that name.
void ObsHideSource(string scene, string source, int connection = 0)
Gives back: Nothing.
Example
CPH.ObsHideSource("Gameplay", "Webcam");
ObsIsSourceVisible¶
Checks whether a source in an OBS scene is showing.
bool ObsIsSourceVisible(string scene, string source, int connection = 0)
Gives back: true when the source is visible, otherwise false.
Example
bool visible = CPH.ObsIsSourceVisible("Gameplay", "Webcam");
CPH.LogInfo($"Webcam visible: {visible}");
ObsToggleSource¶
Flips a source in an OBS scene: hides it when it shows, shows it when it is hidden.
void ObsToggleSource(string scene, string source, int connection = 0)
Gives back: Nothing.
Example
CPH.ObsToggleSource("Gameplay", "Webcam");
ObsShowFilter¶
Turns on a filter in OBS. Give a scene or source name and the filter name. The version with scene and source turns on the source's filter (the scene is not used).
void ObsShowFilter(string sourceName, string filterName, int connection = 0)
void ObsShowFilter(string scene, string source, string filterName, int connection = 0)
Gives back: Nothing.
Example
CPH.ObsShowFilter("Gameplay", "Webcam", "Blur");
ObsHideFilter¶
Turns off a filter in OBS. Give a scene or source name and the filter name. The version with scene and source turns off the source's filter (the scene is not used).
void ObsHideFilter(string sourceName, string filterName, int connection = 0)
void ObsHideFilter(string scene, string source, string filterName, int connection = 0)
Gives back: Nothing.
Example
CPH.ObsHideFilter("Gameplay", "Webcam", "Blur");
ObsSetGdiText¶
Changes the words in an OBS text source. The source is found by its name; the scene is not used.
void ObsSetGdiText(string scene, string source, string text, int connection = 0)
Gives back: Nothing.
Example
CPH.ObsSetGdiText("Gameplay", "Death Counter", "Deaths: 7");
ObsSetBrowserSource¶
Points an OBS browser source at a new web link. The source is found by its name; the scene is not used.
void ObsSetBrowserSource(string scene, string source, string url, int connection = 0)
Gives back: Nothing.
Example
CPH.ObsSetBrowserSource("Gameplay", "Alerts", "https://example.com/alerts");
ObsSetImageSourceFile¶
Shows a different picture file in an OBS image source. The source is found by its name; the scene is not used.
void ObsSetImageSourceFile(string scene, string source, string file, int connection = 0)
Gives back: Nothing.
Example
CPH.ObsSetImageSourceFile("Gameplay", "Emote", @"C:\Stream\Images\hype.png");
ObsSetMediaSourceFile¶
Loads a different video or sound file in an OBS media source. The source is found by its name; the scene is not used.
void ObsSetMediaSourceFile(string scene, string source, string file, int connection = 0)
Gives back: Nothing.
Example
CPH.ObsSetMediaSourceFile("Gameplay", "Clip Player", @"C:\Stream\Clips\win.mp4");
ObsStartStreaming¶
Tells OBS to start streaming (go live).
void ObsStartStreaming(int connection = 0)
Gives back: Nothing.
Example
CPH.ObsStartStreaming();
ObsStopStreaming¶
Tells OBS to stop streaming (end the stream).
void ObsStopStreaming(int connection = 0)
Gives back: Nothing.
Example
CPH.ObsStopStreaming();
ObsStartRecording¶
Tells OBS to start recording.
void ObsStartRecording(int connection = 0)
Gives back: Nothing.
Example
CPH.ObsStartRecording();
ObsStopRecording¶
Tells OBS to stop recording.
void ObsStopRecording(int connection = 0)
Gives back: Nothing.
Example
CPH.ObsStopRecording();
ObsIsStreaming¶
Checks whether OBS is live right now.
bool ObsIsStreaming(int connection = 0)
Gives back: true while OBS is streaming, otherwise false.
Example
bool live = CPH.ObsIsStreaming();
CPH.LogInfo($"OBS live: {live}");
ObsIsRecording¶
Checks whether OBS is recording right now.
bool ObsIsRecording(int connection = 0)
Gives back: true while OBS is recording, otherwise false.
Example
bool recording = CPH.ObsIsRecording();
CPH.LogInfo($"OBS recording: {recording}");
ObsSendRaw¶
Sends any OBS request by its name, with its data written as JSON text. For advanced users who know the obs-websocket requests.
string ObsSendRaw(string requestType, string data, int connection = 0)
Gives back: OBS's answer as JSON text.
Example
string answer = CPH.ObsSendRaw("GetSceneList", "{}");
CPH.LogInfo(answer);
TtsSpeak¶
Says a message out loud with one of your text-to-speech voices, picked by its alias from the Speech page. Tick the bad word filter to clean up the text first.
int TtsSpeak(string voiceAlias, string message, bool badWordFilter = false)
Gives back: Always 0.
Example
CPH.TtsSpeak("Brian", "Welcome to the stream!");
PlaySound¶
Plays a sound file. Volume goes from 0 to 1. With finishBeforeContinuing true, your code waits until the sound ends. The sound name (or file name) lets StopSoundPlayback stop it.
double PlaySound(string fileName, float volume = 1.0f, bool finishBeforeContinuing = false, string? soundName = null, bool useFileName = true)
Gives back: Always 0.
Example
CPH.PlaySound(@"C:\Stream\Sounds\airhorn.mp3", 0.5f);
StopSoundPlayback¶
Stops the sounds playing with this name. The name is the sound name you gave PlaySound, or the file name without its ending.
void StopSoundPlayback(string soundName)
Gives back: Nothing.
Example
CPH.StopSoundPlayback("airhorn");
StopAllSoundPlayback¶
Stops every sound that is playing right now.
void StopAllSoundPlayback()
Gives back: Nothing.
Example
CPH.StopAllSoundPlayback();
DiscordPostTextToWebhook¶
Posts a message to a Discord channel through a webhook link. You can set the name and picture it posts with, and tick text-to-speech. Fails when Discord refuses.
string DiscordPostTextToWebhook(string webhookUrl, string content, string? username = null, string? avatarUrl = null, bool textToSpeech = false)
Gives back: The new message's id, or empty text when Discord did not say.
Example
string id = CPH.DiscordPostTextToWebhook("https://discord.com/api/webhooks/123/abc", "We are live!", "Stream Bot");
CPH.LogInfo($"Posted message {id}");