Libraries

s&box libraries

Twitch API

carsonk.twitchapi

A stupid simple Library that allows you to subscribe to events from Twitch Chat, with additional metadata for users/messages.

About

Twitch API

A stupid simple Library that allows you to subscribe to events from Twitch Chat, with additional metadata such as Badges, Emotes, whether or not a user is Moderator, Subscriber, Turbo, ect.

Here's how you do suff via code:

using TwitchAPI;

public class MyComponent : Component
{
TwitchChatConnection TwitchChat;
List<TwitchChatMessage> MessageHistory { get; set; }

protected override void OnEnabled()
{
// Connect to the Chat
TwitchChat = new TwitchChatConnection("CarsonKompon");

// Subscribe to the different events
TwitchChat.OnMessageReceieved += OnMessageReceieved;
TwitchChat.OnMessagesCleared += OnMessagesCleared;
}

protected override void OnDisabled()
{
if(TwitchChat is null) return;

// Disconnect/Dispose of the connection
TwitchChat?.Dispose();

// Un-subscribe from the events
TwitchChat.OnMessageReceieved -= OnMessageReceieved;
TwitchChat.OnMessagesCleared -= OnMessagesCleared;
}

void OnMessageReceived(TwitchChatMessage message)
{
// Add the message to the message history
MessageHistory.Add(message);

// "!test" command that only works for Moderators and subs
if(message.Message == "!test" && (message.User.IsModerator || message.User.IsSubscriber))
{
Log.Info("Testing!");
return;
}

// Otherwise, print the message to the console
Log.Info($"{message.Username}: {message.Message}");
}

void OnMessagesCleared()
{
// Clear the message history
MessageHistory.Clear();
}
}

There's also a TwitchComponent included which can be used for simple ActionGraph-based solutions.

twitchttvapiutilitiesutilsstreamchat

Media

More by Carson Kompon

01
MediaHelpers thumbnail
MediaHelpers carsonk.mediahelpers

A library used to retrieve video stream urls for use with the VideoPlayer class.

videoplayermediavideohelper
+0 24h
15favorites
10upvotes
72%Wilson score
02
Razor Panel Tooltips thumbnail
Razor Panel Tooltips carsonk.razor_tooltips

A custom tooltip system that lets you use razor panels instead of a string

razortooltipui
+0 24h
6favorites
5upvotes
44%Wilson score
03
RichText Razor Panels thumbnail
RichText Razor Panels carsonk.richtextpanels

Adds a <RichText/> element which can parse text into custom Razor Panels

razorrichtextui
+0 24h
3favorites
4upvotes
51%Wilson score
04
Editor All Chat thumbnail
Editor All Chat carsonk.editor_all_chat

A global chat that lets you talk with anyone else using the library who's currently in the Editor.

chateditor
+0 24h
2favorites
6upvotes
61%Wilson score
05
TikTokTTS thumbnail
TikTokTTS carsonk.tiktoktts

No summary provided.

ttstexttospeechtiktok
+0 24h
1favorites
4upvotes
51%Wilson score
06
SFXR thumbnail
SFXR carsonk.sfxr

No summary provided.

sfxrsfxsoundsaudiosound
+0 24h
1favorites
2upvotes
34%Wilson score