MiniTwitch.Irc
1.2.3
See the version list below for details.
dotnet add package MiniTwitch.Irc --version 1.2.3
NuGet\Install-Package MiniTwitch.Irc -Version 1.2.3
<PackageReference Include="MiniTwitch.Irc" Version="1.2.3" />
paket add MiniTwitch.Irc --version 1.2.3
#r "nuget: MiniTwitch.Irc, 1.2.3"
// Install MiniTwitch.Irc as a Cake Addin
#addin nuget:?package=MiniTwitch.Irc&version=1.2.3
// Install MiniTwitch.Irc as a Cake Tool
#tool nuget:?package=MiniTwitch.Irc&version=1.2.3
MiniTwitch.Irc
MiniTwitch.Irc is the component responsible for Twitch chat services. The usage of this package revolves around the IrcClient
class which handles connection, communication and channel management
Features
- Package code is fully documented with XML comments
- Full coverage of chatroom messages and events with convenient APIs
- Built with performance and memory in mind. Nanosecond speeds, with low memory allocation
- Exposes events as
ValueTask
, making for efficient & concurrent usage - Automatically reconnects upon disconnection & automatically rejoins channels
- Simple & customizable ratelimiting of sending messages and joining channels
- Allows for connecting anonymously - No need for authorization if you don't plan to send anything!
- Understand what happens behind the scenes by supplying an
ILogger
. Allows you to use any logging library which implements logging abstractions
Getting Started
here is an example usage of the IrcClient
class:
using MiniTwitch.Irc;
using MiniTwitch.Irc.Models;
namespace MiniTwitchExample;
public class Program
{
static async Task Main()
{
Bot bot = new("myusername", "mytoken");
await bot.Client.ConnectAsync();
await bot.Client.JoinChannel("occluder");
_ = Console.ReadLine();
}
}
public class Bot
{
public IrcClient Client { get; init; }
public Bot(string username, string token)
{
Client = new IrcClient(options =>
{
options.Username = username;
options.OAuth = token;
});
Client.OnChannelJoin += ChannelJoinEvent;
Client.OnMessage += MessageEvent;
}
private ValueTask ChannelJoinEvent(IrcChannel channel)
{
return Client.SendMessage(channel.Name, "Hello from MiniTwitch!");
}
private async ValueTask MessageEvent(Privmsg message)
{
if (message.Content == "penis123")
{
await message.ReplyWith("That's my password!!");
}
else if (message.Content == "Wait a minute!")
{
await Task.Delay(TimeSpan.FromMinutes(1));
await message.ReplyWith("I waited. Now what?");
}
}
}
Subscribing to events
All events use either the Func<T, ValueTask>
or Func<ValueTask>
delegates. Meaning that subscribing methods must have the return type ValueTask
and account for the T
parameter when it's present (see Client.OnMessage
in the example above), the parameter name you set does not matter. Also, if the method doesn't have any asynchronous code you should not mark it as async
and return ValueTask.CompletedTask
, default
or some ValueTask
object instead.
Subscribing can be done either programmatically:
Client.OnMessage += MessageEvent;
private async ValueTask MessageEvent(Privmsg message)
{
...
}
or with anonymous functions:
Client.OnMessage += async message =>
{
...
};
Note that you cannot unsubscribe from events if you used anonymous functions.
Read more about event subscriptions here
Installation
You can add this package to your project by searching for it with the package manager, or by using the NuGet cli tool:
Install-Package MiniTwitch.Irc
Dependencies
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
- Microsoft.Extensions.Logging (>= 7.0.0)
- MiniTwitch.Common (>= 1.1.0)
-
net7.0
- Microsoft.Extensions.Logging (>= 7.0.0)
- MiniTwitch.Common (>= 1.1.0)
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 | |
---|---|---|---|
1.2.12 | 187 | 2/1/2024 | |
1.2.11 | 88 | 1/27/2024 | |
1.2.10 | 111 | 1/10/2024 | |
1.2.9 | 611 | 12/3/2023 | |
1.2.8 | 303 | 11/14/2023 | |
1.2.7 | 132 | 10/12/2023 | |
1.2.6 | 109 | 9/26/2023 | |
1.2.5 | 136 | 9/23/2023 | |
1.2.4 | 196 | 7/1/2023 | |
1.2.3 | 169 | 6/28/2023 | |
1.2.2 | 148 | 6/4/2023 | |
1.2.1 | 151 | 5/30/2023 | |
1.2.0 | 172 | 5/9/2023 | |
1.1.1 | 158 | 5/3/2023 | |
1.1.0 | 171 | 5/1/2023 | |
1.0.0 | 171 | 4/30/2023 |