IRCTokens 1.4.0

dotnet add package IRCTokens --version 1.4.0
NuGet\Install-Package IRCTokens -Version 1.4.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="IRCTokens" Version="1.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IRCTokens --version 1.4.0
#r "nuget: IRCTokens, 1.4.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 IRCTokens as a Cake Addin
#addin nuget:?package=IRCTokens&version=1.4.0

// Install IRCTokens as a Cake Tool
#tool nuget:?package=IRCTokens&version=1.4.0

IRCTokens

this is a c# port of jesopo's irctokens

available on nuget

usage

tokenization

using IRCTokens;

...

var line = new Line("@id=123 :ben!~ben@host.tld PRIVMSG #channel :hello there!");
Console.WriteLine(line);
Console.WriteLine(line.Format());

formatting

var line = new Line {Command = "USER", Params = new List<string> {"user", "0", "*", "real name"}};
Console.WriteLine(line);
Console.WriteLine(line.Format());

stateful

see the full example in TokensSample/Client.cs

public class Client
{
    private readonly byte[] _bytes;
    private readonly StatefulDecoder _decoder;
    private readonly StatefulEncoder _encoder;
    private readonly Socket _socket;

    public Client()
    {
        _decoder = new StatefulDecoder();
        _encoder = new StatefulEncoder();
        _socket  = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
        _bytes   = new byte[1024];
    }

    public void Start()
    {
        _socket.Connect("127.0.0.1", 6667);
        while (!_socket.Connected) Thread.Sleep(1000);

        Send(new Line {Command = "NICK", Params = new List<string> {"tokensbot"}});
        Send(new Line {Command = "USER", Params = new List<string> {"tokensbot", "0", "*", "real name"}});

        while (true)
        {
            var bytesReceived = _socket.Receive(_bytes);

            if (bytesReceived == 0)
            {
                Console.WriteLine("! disconnected");
                _socket.Shutdown(SocketShutdown.Both);
                _socket.Close();
                break;
            }

            var lines = _decoder.Push(_bytes, bytesReceived);

            foreach (var line in lines)
            {
                Console.WriteLine($"< {line.Format()}");

                switch (line.Command)
                {
                    case "PING":
                        Send(new Line {Command = "PONG", Params = line.Params});
                        break;
                    case "001":
                        Send(new Line {Command = "JOIN", Params = new List<string> {"#test"}});
                        break;
                    case "PRIVMSG":
                        Send(new Line
                        {
                            Command = "PRIVMSG", Params = new List<string> {line.Params[0], "hello there"}
                        });
                        break;
                }
            }
        }
    }

    private void Send(Line line)
    {
        Console.WriteLine($"> {line.Format()}");
        _encoder.Push(line);
        while (_encoder.PendingBytes.Length > 0)
            _encoder.Pop(_socket.Send(_encoder.PendingBytes, SocketFlags.None));
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on IRCTokens:

Package Downloads
IRCStates

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.0 82 4/17/2024
1.2.0 424 11/10/2021
1.1.0 529 11/10/2020
1.0.2 664 7/8/2020
1.0.1 735 5/17/2020
1.0.0 706 5/16/2020