Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System
- open System.IO
- open System.Net
- open System.Net.Sockets
- open System.Text.RegularExpressions
- open System.Net.Security
- open System.Security.Cryptography.X509Certificates
- (* This bot cannot create or join some channels without registering; registration is also
- required to join servers like idlechat which have daemon checkers.
- Currently, SSL verification is bypassed.
- *)
- let test_toggle = 0
- let server =
- if test_toggle = 1 then "us.idlechat.net"
- else "irc.geekshed.net"
- let port = 6697
- let channel = "#batoto" //mantabot
- let nick = "mantabot"
- let username =
- if server.Contains("idlechat") then "antaMay ayRay"
- else "mantatanta"
- let password = "willSalykadi3?"
- let mutable run = true
- // establish and confirm a connection to the server
- let irc_client = new TcpClient()
- irc_client.Connect(server, port)
- if (irc_client.Connected = false) then Console.WriteLine("Did not connect.")
- else Console.WriteLine("Connected to " + server)
- // get the input and output streams in ssl
- //cheating verification
- let validatecheat = RemoteCertificateValidationCallback(fun _ _ _ _ -> true)
- let selectioncheat = fun _ -> System.Security.Cryptography.X509Certificates.X509Certificate()
- let certificatecheat = LocalCertificateSelectionCallback( fun _ _ _ _ -> selectioncheat)
- let irc_writer =
- let stream = irc_client.GetStream()
- let ssl = new SslStream(stream, true, validatecheat, certificatecheat)
- ssl.AuthenticateAsClient(server)
- ssl
- //non ssl version, for testing
- (*
- let irc_writer =
- let stream = irc_client.GetStream()
- let write = new StreamWriter( stream )
- write
- *)
- // identify with the server and join a room
- let stream = new StreamReader(irc_writer, true)
- let writer = new StreamWriter(irc_writer)
- let send (data: string) =
- writer.WriteLine(data + "\n\r")
- writer.Flush()
- Console.WriteLine("\n<{ " + data)
- Console.Write("\n}> "); Console.Write(stream.Read())
- send ("PASS " + password)
- Console.Write("\n}> "); Console.Write(stream.Read())
- send ("NICK " + nick)
- Console.Write("\n}> "); Console.Write(stream.Read())
- if server.Contains("idlechat") then
- send ("USER " + nick + " " + nick + " " + nick + " :themantarays")// + username) //mantatanta
- else
- send ("USER " + nick + " " + nick + " " + nick + " :mantatanta")
- Console.Write("\n}> "); Console.Write(stream.Read())
- send ("JOIN " + channel)
- Console.Write("\n}> "); Console.Write(stream.Read())
- (*
- send (" :Hello")
- Console.Write("\n}> "); Console.Write(stream.Read())
- *)
- // some flow control stuff
- (*
- let irc_privmsg ( writer : StreamWriter ) ( phrase : string ) =
- writer.WriteLine( "PRIVMSG " + channel + phrase )
- let irc_get_msg ( line : string )=
- line.Substring( line.Substring(1).IndexOf(":") + 2)
- *)
- // main loop operation; homeostasis
- while ((run = true) && (stream.EndOfStream = false)) do
- let line = stream.ReadLine()
- Console.Write("\n}> " + line)
- if (line.Contains("PING")) then
- send ("PONG " + server)
- if (line.Contains("IP address instead")) then
- if (server.Contains("idlechat")) then
- send ("ID " + password)
- send ("PRIVMSG NickServ ID " + password)
- else
- send ("PASS " + password)//("IDENTIFY " + password)
- send ("PRIVMSG NickServ IDENTIFY " + password)
- //send ("JOIN " + channel)
- (*if (line.Contains("PRIVMSG")) then
- if (line.Contains("version") || line.Contains("VERSION")) then
- send ("PRIVMSG " + nick + " on " + Environment.Version.ToString())
- if (line.Contains("date") || line.Contains("DATE")) then
- send (System.DateTime.Now.ToString())
- else Console.Write(line)
- send ("PONG " + server)*)
- //CHANNEL COMMANDS MATCHING
- if (line.Contains("!!exit")) then
- run <- false
- send ("QUIT :Bye~")
- stream.Dispose()
- irc_client.Close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement