VodOnDemand.TwitchEverywhere.Core
0.2.1
See the version list below for details.
dotnet add package VodOnDemand.TwitchEverywhere.Core --version 0.2.1
NuGet\Install-Package VodOnDemand.TwitchEverywhere.Core -Version 0.2.1
<PackageReference Include="VodOnDemand.TwitchEverywhere.Core" Version="0.2.1" />
paket add VodOnDemand.TwitchEverywhere.Core --version 0.2.1
#r "nuget: VodOnDemand.TwitchEverywhere.Core, 0.2.1"
// Install VodOnDemand.TwitchEverywhere.Core as a Cake Addin #addin nuget:?package=VodOnDemand.TwitchEverywhere.Core&version=0.2.1 // Install VodOnDemand.TwitchEverywhere.Core as a Cake Tool #tool nuget:?package=VodOnDemand.TwitchEverywhere.Core&version=0.2.1
TwitchEverywhere
TwitchEverywhere
is a .NET Core (6 and 7) library that allows connecting to a Twitch chat and subscribing to messages in that chat.
The goal of this library is to provide a lightweight, strongly typed API for clients so they can avoid parsing raw strings as much as possible.
Additionally, Twitch requires an authenticated connection to the IRC server which can get a bit complicated to setup and maintain.
Fortunately TwitchEverywhere
can do that for you! 😀
If you are planning on using TwitchEverywhere
on AWS I suggest using .NET 6 for compatibility reasons.
How To Use It
You will need to provide the following values as parameters to the TwitchConnectionOptions
record:
TwitchConnectionOptions options = new(
Channel: channel,
AccessToken: accessToken,
RefreshToken: refreshToken,
ClientId: clientId,
ClientSecret: clientSecret,
ClientName: clientName
);
Next define a MessageCallback
method that will handle any messages that TwitchEverywhere
sends to your application.
The input will be of type TwitchEverywhere.Types.Message
and return type void
.
// This example only handles MessageType.PrivMsg but you should handle other types here too
private void MessageCallback( Message message ) {
switch( message.MessageType ) {
case MessageType.PrivMsg: {
PrivMsg privMsg = (PrivMsg) message;
PrivMessageCallback( privMsg );
break;
}
default:
// This is just an example, you can handle this case however you wish
throw new ArgumentOutOfRangeException();
}
}
Then initialize TwitchEverywhere
and pass in the options to the constructor.
Finally call the TwitchEverywhere.ConnectToChannel
method and pass in your callback as a parameter.
TwitchEverywhere.TwitchEverywhere twitchEverywhere = new( options );
await twitchEverywhere.ConnectToChannel( MessageCallback );
Now whenever TwitchEverywhere
receives a message it will pass it to your callback! 🎉
Sample CLI App
There is a sample CLI application that is included as an example in this repo and you can use it to connect with Twitch – give it a try!
In order to connect you need to create an appsettings.json
file in the root of the TwitchEverywhereCLI
project with the following parameters:
{
"AccessToken": "your_twitch_access_token",
"RefreshToken": "your_twitch_refresh_token",
"ClientId": "your_client_id",
"ClientSecret": "your_client_secret",
"ClientName": "your_client_name_all_lowercase",
"Channel": "channel_you_want_to_connect_to"
}
Performance
The benchmarks in the TwitchEverywhere.Benchmark project use the BenchmarkDotNet library. You can read more about the methodology that BenchmarkDotNet uses here.
We send 500 messages of each type to TwitchEverywhere
and run it several times to determine an average. The results are below:
Method | Iterations | Mean | Error | StdDev | Allocated |
---|---|---|---|---|---|
PrivMsg | 500 | 7.548 s | 0.1517 s | 0.4473 s | 1693.96 KB |
ClearMsg | 500 | 7.232 s | 0.1001 s | 0.0936 s | 687.69 KB |
ClearChat | 500 | 6.242 s | 0.0269 s | 0.0225 s | 718.94 KB |
NoticeMsg | 500 | 6.249 s | 0.0268 s | 0.0251 s | 628.95 KB |
GlobalUserStateMessage | 500 | 7.370 s | 0.1589 s | 0.4686 s | 951.7 KB |
RoomStateMessage | 500 | 7.891 s | 0.0147 s | 0.0130 s | 774.07 KB |
WhisperMessage | 500 | 7.636 s | 0.1504 s | 0.3003 s | 1.08 MB |
UserNoticeMessage | 500 | 6.291 s | 0.0400 s | 0.0375 s | 1.74 MB |
Supported Functionality
PRIVMSG
Field | Support |
---|---|
Badges | ✅ |
Bits | ✅ |
Color | ✅ |
DisplayName | ✅ |
Emotes | ✅ |
Id | ✅ |
Mod | ✅ |
PinnedChatPaidAmount | ✅ |
PinnedChatPaidCurrency | ✅ |
PinnedChatPaidExponent | ✅ |
PinnedChatPaidLevel | ✅ |
PinnedChatPaidIsSystemMessage | ✅ |
ReplyParentMsgId | ✅ |
ReplyParentUserId | ✅ |
ReplyParentUserLogin | ✅ |
ReplyParentDisplayName | ✅ |
ReplyThreadParentMsg | ✅ |
RoomId | ✅ |
Subscriber | ✅ |
Timestamp | ✅ |
Turbo | ✅ |
UserId | ✅ |
UserType | ✅ |
Vip | ✅ |
CLEARCHAT
Field | Support |
---|---|
BanDuration | ✅ |
RoomId | ✅ |
TargetUserId | ✅ |
Timestamp | ✅ |
CLEARMSG
Field | Support |
---|---|
Login | ✅ |
RoomId | ✅ |
TargetMessageId | ✅ |
Timestamp | ✅ |
GlobalUserState
Field | Support |
---|---|
BadgeInfo | ✅ |
Badges | ✅ |
Color | ✅ |
DisplayName | ✅ |
EmoteSets | ✅ |
Turbo | ✅ |
UserId | ✅ |
UserType | ✅ |
Notice
Field | Support |
---|---|
MsgId | ✅ |
TargetUserId | ✅ |
RoomState
Field | Support |
---|---|
EmoteOnly | ✅ |
FollowersOnly | ✅ |
R9K | ✅ |
RoomId | ✅ |
Slow | ✅ |
SubsOnly | ✅ |
UserNotice
Field | Support |
---|---|
BadgeInfo | ✅ |
Badges | ✅ |
Color | ✅ |
DisplayName | ✅ |
Emotes | ✅ |
Id | ✅ |
Login | ✅ |
Mod | ✅ |
MsgId | ✅ |
RoomId | ✅ |
Subscriber | ✅ |
SystemMsg | ✅ |
TmiSentTs | ✅ |
Turbo | ✅ |
UserId | ✅ |
UserType | ✅ |
UserState
WIP
Whisper
Field | Support |
---|---|
Badges | ✅ |
Color | ✅ |
DisplayName | ✅ |
Emotes | ✅ |
MessageId | ✅ |
ThreadId | ✅ |
Turbo | ✅ |
UserId | ✅ |
UserType | ✅ |
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on VodOnDemand.TwitchEverywhere.Core:
Package | Downloads |
---|---|
VodOnDemand.TwitchEverywhere.Rest
A dotnet library that allows connecting to Twitch REST APIs |
|
VodOnDemand.TwitchEverywhere.Irc
A dotnet library that allows connecting to Twitch |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.9.0 | 135 | 5/1/2024 |
0.8.0 | 165 | 3/13/2024 |
0.7.3 | 140 | 3/10/2024 |
0.7.2 | 119 | 2/25/2024 |
0.7.1 | 128 | 2/25/2024 |
0.7.0 | 119 | 2/22/2024 |
0.6.2 | 116 | 1/28/2024 |
0.6.1 | 118 | 1/21/2024 |
0.6.0 | 125 | 1/20/2024 |
0.5.0 | 134 | 1/8/2024 |
0.4.0 | 121 | 12/10/2023 |
0.3.1 | 139 | 11/8/2023 |
0.3.0 | 135 | 10/23/2023 |
0.2.1 | 131 | 10/21/2023 |
0.2.0 | 125 | 10/16/2023 |
0.1.2 | 138 | 10/14/2023 |
0.1.1 | 131 | 10/13/2023 |
0.1.0 | 135 | 10/10/2023 |
0.0.2 | 155 | 10/8/2023 |
0.0.1 | 144 | 10/7/2023 |