Advertisement
Guest User

Untitled

a guest
May 27th, 2015
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 KB | None | 0 0
  1.         public static void Connect(string nick, string owner, string server, string chan, string password)
  2.         {
  3.             int port = 6667;
  4.             string buf;
  5.             System.Net.Sockets.TcpClient sock = new System.Net.Sockets.TcpClient();
  6.             System.IO.TextReader input;
  7.             System.IO.TextWriter output;
  8.             sock.Connect(server, port);
  9.             input = new System.IO.StreamReader(sock.GetStream());
  10.             output = new System.IO.StreamWriter(sock.GetStream());
  11.             output.Write(
  12.                 "PASS " + password + "\r\n" +
  13.                 "NICK " + nick + "\r\n"
  14.             );
  15.             output.Flush();
  16.             for (buf = input.ReadLine(); ; buf = input.ReadLine())
  17.             {
  18.                 Console.WriteLine(buf);
  19.                 var result = buf.Substring(buf.LastIndexOf(':') + 1);
  20.                 if (buf.Contains("PRIVMSG"))
  21.                 {
  22.                     if (buf.Contains(":[email protected]"))
  23.                     {
  24.                         output.WriteLine(
  25.                             "PRIVMSG #"+chan+" :"+result+" \r\n"
  26.                         );
  27.                         output.Flush();
  28.                     }
  29.                 }
  30.                 if (buf.StartsWith("PING ")) output.Write(buf.Replace("PING", "PONG") + "\r\n"); output.Flush();
  31.                 if (buf[0] != ':') continue;
  32.                 if (buf.Split(' ')[1] == "001")
  33.                 {
  34.                     output.Write(
  35.                         "JOIN #"+chan+" \r\n"
  36.                     );
  37.                     output.Flush();
  38.                 }
  39.             }
  40.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement