<commit_before>﻿namespace irc.protocol
open System
open System.Collections.Generic
open System.IO
open System.Linq
open System.Net
open System.Net.Sockets
open System.Net.Security
open System.Text
open System.Security.Cryptography.X509Certificates

type public IIrcServer = interface
    abstract member WriteMessage : string -> unit
    abstract member MessageRecievedEvent : IEvent<MessageRecievedEventArgs>
    abstract member HostName : string with get
end

type Client = { client:TcpClient; hostName:string }
type internal IrcServer(serverNames:IEnumerable<string>, port:int, remoteCertificateValidationCallback:RemoteCertificateValidationCallback, userCertificateSelectionCallback:LocalCertificateSelectionCallback, encryptionPolicy:EncryptionPolicy, encoding:Encoding) as this = class
    let TcpConnect (serverName:string):Async<Client option> =
        async{
            try
                let! host = Async.FromBeginEnd(serverName, (fun (name:string, callback:AsyncCallback, obj:Object) -> Dns.BeginGetHostEntry(name, callback, obj)), Dns.EndGetHostEntry)
                let client = new TcpClient()
                do! Async.FromBeginEnd(host.AddressList, port, (fun (x:IPAddress[], y:int, z:AsyncCallback, obj:Object) -> client.BeginConnect(x, y, z, obj)), client.EndConnect)
                return option.Some({client = client; hostName = serverName})
            with
                :? System.Net.Sockets.SocketException -> return None
        }
    let DoConnect(serverNames:seq<string>) = 
        async{                  
            return Seq.pick (fun x ->
                            TcpConnect x
                            |> Async.RunSynchronously) serverNames
        }
    let SslConnect(client:Client) = 
        async{<commit_msg>add nickname value type<commit_after>﻿namespace irc.protocol
open System
open System.Collections.Generic
open System.IO
open System.Linq
open System.Net
open System.Net.Sockets
open System.Net.Security
open System.Text
open System.Text.RegularExpressions
open System.Security.Cryptography.X509Certificates

type public NickName(nick:string) = class
    let nickRegex = Regex("^[\w\[\]\`\\\^\{\|\}][\w\[\]\`\\\^\{\|\}]{0,8}$", RegexOptions.ECMAScript ||| RegexOptions.CultureInvariant)
    do if not (nickRegex.IsMatch nick)
       then raise (ArgumentException("Nick contains invalid characters", "nick"))
    member this.Value : string = nick
end


type public IIrcServer = interface
    abstract member WriteMessage : string -> unit
    abstract member MessageRecievedEvent : IEvent<MessageRecievedEventArgs>
    abstract member HostName : string with get
end

type Client = { client:TcpClient; hostName:string }
type internal IrcServer(serverNames:IEnumerable<string>, port:int, remoteCertificateValidationCallback:RemoteCertificateValidationCallback, userCertificateSelectionCallback:LocalCertificateSelectionCallback, encryptionPolicy:EncryptionPolicy, encoding:Encoding) as this = class
    let TcpConnect (serverName:string):Async<Client option> =
        async{
            try
                let! host = Async.FromBeginEnd(serverName, (fun (name:string, callback:AsyncCallback, obj:Object) -> Dns.BeginGetHostEntry(name, callback, obj)), Dns.EndGetHostEntry)
                let client = new TcpClient()
                do! Async.FromBeginEnd(host.AddressList, port, (fun (x:IPAddress[], y:int, z:AsyncCallback, obj:Object) -> client.BeginConnect(x, y, z, obj)), client.EndConnect)
                return option.Some({client = client; hostName = serverName})
            with
                :? System.Net.Sockets.SocketException -> return None
        }
    let DoConnect(serverNames:seq<string>) = 
        async{                  
            return Seq.pick (fun x ->
                            TcpConnect x
                            |> Async.RunSynchronously) serverNames
        }
    let SslConnect(client:Client) = 
        async{
{'fraction_non_alphanumeric': 0.09583439815997956, 'fraction_numerical': 0.0020444671607462305, 'mean_word_length': 3.190578158458244, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '572072', 'n_tokens_mistral': 1047, 'n_tokens_neox': 1019, 'n_words': 254}