/twitch-net

An unoffical .NET Wrapper for the Twitch API (https://www.twitch.tv)

Primary LanguageC#MIT LicenseMIT

About

Twitch .NET is an unoffical Twitch API Wrapper targeting .NET Core 5.0. Currently supporting full capabilities of Twitchs IRC Chat.

Twitch .NET is still work in progress, if you are missing any features dont hesitate to contact me.

Why Twitch .NET?

Twitch .NET is focusing on clean archtitecture, decoupling and performance for every user by default.
We offer full Dependency Injection support.

If you are familiar with Discord .NET you will easily be able to write your very own Twitch Bot in under 10 minutes.

Benchmarks: Coming soon..

Installation

Install Twitch .NET via nuget now.

Basic Setup

Below are basic examples of how to utilize the Twitch .NET API.

Twitch.Client

 public class Program
    {
        static async Task Main(string[] args)
            => await new TwitchController().InitializeTwitchClientAsync();
    }


    public class TwitchController
    {
        private readonly TwitchBot _twitchBot;

        public TwitchController()
        {
            _twitchBot = new TwitchBot();
        }

        public async Task InitializeTwitchClientAsync()
        {

            var commander = new TwitchCommander(_twitchBot);

            await _twitchBot.LoginAsync("nick", "oauth:token");

            await _twitchBot.JoinAsync("yourChannel");


            await commander.InitalizeCommanderAsync(
                serviceCollection: BuildServiceCollection(),
                assembly: Assembly.GetEntryAssembly()
            );
            
            await Task.Delay(-1);
        }

        private static IServiceCollection BuildServiceCollection()
            => new ServiceCollection()
            .AddSingelton<YourDependency>();

Twitch.Command

public class TestModule : BaseModule
    {
        private readonly YourDependency _dependency;
        
        public TestModule(YourDependency dependency)
        {
            _dependency = dependency;
        }


        //Triggers on !test textAfterCommand
        [Command("test")]
        public async Task TestCommand(string value)
        {
            await _dependency.AddAsync(value);
            await SendAsync($"{UserProxy.Name} sent a message: {value}");
        }

Notes

If you expirence any issues while using Twitch .NET, dont hesitate to contact me via Discord ThatNandoTho#1852, or just report an issue!