Repository navigation
Reference CSharp System
Also on the Cuebot Docs site.
C# methods for a Run C# code step. See C# methods for how to use them.
Sends a /me line in your Twitch chat, shown in italics. If that is not possible, it is sent as a normal chat message. Empty text sends nothing.
void SendAction(string action, bool bot = true, bool fallback = true)Gives back: Nothing.
Example
CPH.SendAction("waves at everyone in chat");Fires a custom event by name. Actions with a "Custom code event" trigger for that name run, and get this action's variables unless you pass false.
void TriggerEvent(string eventName, bool useArgs = true)Gives back: Nothing.
Example
CPH.TriggerEvent("confetti");Presses keys on your keyboard for you, like {F13} or ^{S} for Ctrl+S (+ is Shift, % is Alt). Fails with "not supported" when Cuebot cannot press keys on this computer.
void KeyboardPress(string keyPress)Gives back: Nothing.
Example
CPH.KeyboardPress("{F13}");Runs one method (with no inputs) from another "Execute C# code" sub-action. It finds that code by its "Code name" setting, or as the first C# code in the action with that name.
bool ExecuteMethod(string codeName, string methodName)Gives back: What the method gives back (true for methods that give nothing). false when the code or method is not found.
Example
bool ok = CPH.ExecuteMethod("Helpers", "ResetScores");
CPH.LogInfo($"Reset worked: {ok}");Fires a custom event by name, with the values of a JSON text (like {"amount": 50}) as its variables. Actions with a "Custom code event" trigger for that name run.
void TriggerCodeEvent(string eventName, string json)Gives back: Nothing.
Example
CPH.TriggerCodeEvent("confetti", "{\"amount\": 50}");Makes text safe to put in a web link, for example spaces become %20.
string UrlEncode(string text)Gives back: The safe text.
Example
string safe = CPH.UrlEncode("hello world & friends");
CPH.LogInfo(safe);Makes text safe to put inside a JSON text value: quotes, backslashes and line breaks get a backslash in front.
string EscapeString(string text)Gives back: The escaped text.
Example
string safe = CPH.EscapeString("She said \"hi\"");
CPH.LogInfo(safe);Sends a small message (UDP) to a port on this computer only (127.0.0.1). Text is sent as is; anything else is sent as JSON.
int BroadcastUdp(int port, object? data)Gives back: How many bytes were sent.
Example
int sent = CPH.BroadcastUdp(9000, "flash");
CPH.LogInfo($"Sent {sent} bytes.");Older form: adds a Twitch user to one of your groups by their number id. The group must already exist.
bool AddUserToGroup(int userId, string groupName)Gives back: true when they were added. false when they were already in it or the group does not exist.
Example
bool added = CPH.AddUserToGroup(12345678, "Regulars");
CPH.LogInfo($"Added: {added}");Older form: takes a Twitch user out of one of your groups by their number id.
bool RemoveUserFromGroup(int userId, string groupName)Gives back: true when they were removed. false when they were not in it.
Example
bool removed = CPH.RemoveUserFromGroup(12345678, "Regulars");
CPH.LogInfo($"Removed: {removed}");Older form: checks whether a Twitch user (by their number id) is in one of your groups.
bool UserInGroup(int userId, string groupName)Gives back: true when they are in the group, otherwise false.
Example
bool inGroup = CPH.UserInGroup(12345678, "Regulars");
CPH.LogInfo($"In group: {inGroup}");Older form: posts a message to a Discord channel through its webhook link, with an optional bot name and read-aloud (TTS) switch, but no picture.
string DiscordPostTextToWebhook(string webhookUrl, string content, string? username, bool textToSpeech)Gives back: The new Discord 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!", "Cuebot", false);
CPH.LogInfo($"Message id: {id}");Sends bytes through one of your WebSocket clients (set up on the Servers page). Cuebot turns the bytes into text first. 0 is your first client.
void WebsocketSend(byte[] data, int connection = 0)Gives back: Nothing.
Example
byte[] data = System.Text.Encoding.UTF8.GetBytes("hello");
CPH.WebsocketSend(data, 0);Cuebot by Tech Daddy Digital · MIT license · Privacy
Cuebot Docs (the same pages, nicer to read)
- Home
- Start here
-
Guides
- Chat commands
- Overlays and alerts
- Writing your own overlay widgets
- Text-to-speech
- Music and now playing
- Points, store and giveaways
- Subathons and goals
- Stream apps and devices
- VTuber apps
- Stream Deck
- The phone app
- Donations and integrations
- Discord bot
- The setup assistant and AI tools
- The assistant on your own computer
- Moving from Streamer.bot
- Cuebot's servers
- Writing code (C# and Python)
- Python in detail
- Using your own code editor
- Controlling Cuebot from other programs
- Backups and your data
- Linux
- Command-line options
- Troubleshooting
- What's experimental
- Reference
