VodOnDemand.TwitchEverywhere.Irc 0.10.0

dotnet add package VodOnDemand.TwitchEverywhere.Irc --version 0.10.0                
NuGet\Install-Package VodOnDemand.TwitchEverywhere.Irc -Version 0.10.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VodOnDemand.TwitchEverywhere.Irc" Version="0.10.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VodOnDemand.TwitchEverywhere.Irc --version 0.10.0                
#r "nuget: VodOnDemand.TwitchEverywhere.Irc, 0.10.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install VodOnDemand.TwitchEverywhere.Irc as a Cake Addin
#addin nuget:?package=VodOnDemand.TwitchEverywhere.Irc&version=0.10.0

// Install VodOnDemand.TwitchEverywhere.Irc as a Cake Tool
#tool nuget:?package=VodOnDemand.TwitchEverywhere.Irc&version=0.10.0                

TwitchEverywhere.Irc

TwitchEverywhere.Irc is a .NET library that allows connecting to a Twitch chat using IRC 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. TwitchEverywhere.Irc uses Rx.NET to provide a reactive API for handling messages from Twitch.

The library will support the latest LTS version of .NET and non LTS versions IF it is newer than the LTS version. So for example before .NET 8, the library supported .NET 6 (LTS) and 7 but once .NET 8 was released support for 6 and 7 was dropped.

How To Use It

You will need to provide the following values as parameters to the TwitchEverywhere.Core.TwitchConnectionOptions record:

TwitchConnectionOptions options = new(
    Channel: channel,
    AccessToken: accessToken,
    RefreshToken: refreshToken,
    ClientId: clientId,
    ClientSecret: clientSecret,
    ClientName: clientName
);

Next create an instance of the IrcClient and pass in the options to the constructor.

internal class TwitchConnection(
    TwitchConnectionOptions options
) {
    private readonly IrcClient m_ircClient = new( options );
    
    // implementation
}

Then define a method that will consume the observables returned from TwitchEverywhere. Each message type has its own observable that you can subscribe to and it will return a strong type.


// This example only handles MessageType.PrivMsg but you can handle other types here too
public async Task ConnectToIrcClientRx() {
    
    // TaskCompletionSource is only needed for the CLI app to prevent it from exiting early
    TaskCompletionSource<bool> tcs = new();

    IrcClientObservable observable = m_ircClient.ConnectToChannelRx();

    IDisposable privObservable = observable.PrivMsgObservable.Subscribe( 
        msg => PrivMessageCallback(msg)
    );

    try {
        await tcs.Task;
    } finally{
        joinObservable.Dispose();
        privObservable.Dispose();
    }
}

Now whenever TwitchEverywhere receives a message it will pass it to the appropriate observable 🎉

Sample CLI App

There is a sample CLI application here 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

See the README in the TwitchEverywhere.Benchmark project here

Supported Functionality

IRC Commands

See the related Twitch documentation here

Name API Link Data Type Link
CLEARCHAT CLEARCHAT Twitch API ClearChat Type
CLEARMSG CLEARMSG Twitch API ClearMsg Type
GLOBALUSERSTATE GLOBALUSERSTATE Twitch API GlobalUserState Type
HOSTTARGET HOSTTARGET Twitch API HostTargetMsg Type
NOTICE NOTICE Twitch API NoticeMsg Type
RECONNECT RECONNECT Twitch API ReconnectMsg Type
ROOMSTATE ROOMSTATE Twitch API RoomStateMsg Type
USERNOTICE USERNOTICE Twitch API UserNotice Type
USERSTATE USERSTATE Twitch API UserState Type
WHISPER WHISPER Twitch API WHISPER Type
CLEARCHAT

See CLEARCHAT tags

CLEARMSG

See CLEARMSG tags

GLOBALUSERSTATE

See GLOBALUSERSTATE tags

HOSTTARGET
Field Support
HostingChannel ✅
Channel ✅
NumberOfViewers ✅
IsHostingChannel ✅
NOTICE

See NOTICE tags

RECONNECT

No fields for RECONNECT, use the presence of this message as a signal to reconnect to Twitch. See the Twitch API docs for more infomation.

ROOMSTATE

See ROOMSTATE tags

USERNOTICE

See USERNOTICE tags

USERSTATE

See USERSTATE tags

WHISPER

See WHISPER tags

IRC Membership

See the related Twitch documentation here.

Name API Link Data Type Link
JOIN JOIN Twitch API Join Type
PART PART Twitch API Part Type
JOIN
Field Support
Channel ✅
User ✅
PART
Field Support
Channel ✅
User ✅

IRC Tags

See the related Twitch documentation here.

Name Support API Link Data Type Link
PRIVMSG ✅ PRIVMSG Twitch API PrivMsg Type
CLEARCHAT ✅ CLEARCHAT Twitch API ClearChat Type
CLEARMSG ✅ CLEARMSG Twitch API ClearMSG Type
GLOBALUSERSTATE ✅ GLOBALUSERSTATE Twitch API GlobalUserState Type
NOTICE ✅ NOTICE Twitch API NoticeMsg Type
ROOMSTATE ✅ ROOMSTATE Twitch API RoomState Type
USERNOTICE ✅ USERNOTICE Twitch API UserNotice Type
USERSTATE ✅ USERSTATE Twitch API UserState Type
WHISPER ✅ WHISPER Twitch API UserNotice Type
PRIVMSG Tags
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 Tags
Field Support
BanDuration ✅
RoomId ✅
TargetUserId ✅
Timestamp ✅
CLEARMSG Tags
Field Support
Login ✅
RoomId ✅
TargetMessageId ✅
Timestamp ✅
GLOBALUSERSTATE Tags
Field Support
BadgeInfo ✅
Badges ✅
Color ✅
DisplayName ✅
EmoteSets ✅
Turbo ✅
UserId ✅
UserType ✅
NOTICE Tags
Field Support
MsgId ✅
TargetUserId ✅
ROOMSTATE Tags
Field Support
EmoteOnly ✅
FollowersOnly ✅
R9K ✅
RoomId ✅
Slow ✅
SubsOnly ✅
USERNOTICE Tags
Field Support
BadgeInfo ✅
Badges ✅
Color ✅
DisplayName ✅
Emotes ✅
Id ✅
Login ✅
Mod ✅
MsgId ✅
RoomId ✅
Subscriber ✅
SystemMsg ✅
TmiSentTs ✅
Turbo ✅
UserId ✅
UserType ✅
USERSTATE Tags
Field Support
BadgeInfo ✅
Badges ✅
Color ✅
DisplayName ✅
EmoteSets ✅
Id ✅
Mod ✅
Subscriber ✅
Turbo ✅
UserType ✅
WHISPER Tags
Field Support
Badges ✅
Color ✅
DisplayName ✅
Emotes ✅
MessageId ✅
ThreadId ✅
Turbo ✅
UserId ✅
UserType ✅
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.10.0 105 8/29/2024
0.9.0 111 5/1/2024
0.8.0 142 3/13/2024
0.7.3 132 3/10/2024
0.7.0 103 2/22/2024
0.6.1 123 1/21/2024
0.6.0 107 1/20/2024
0.5.0 135 1/8/2024