Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void Connect(string nick, string owner, string server, string chan, string password)
- {
- int port = 6667;
- string buf;
- System.Net.Sockets.TcpClient sock = new System.Net.Sockets.TcpClient();
- System.IO.TextReader input;
- System.IO.TextWriter output;
- sock.Connect(server, port);
- input = new System.IO.StreamReader(sock.GetStream());
- output = new System.IO.StreamWriter(sock.GetStream());
- output.Write(
- "PASS " + password + "\r\n" +
- "NICK " + nick + "\r\n"
- );
- output.Flush();
- for (buf = input.ReadLine(); ; buf = input.ReadLine())
- {
- Console.WriteLine(buf);
- var result = buf.Substring(buf.LastIndexOf(':') + 1);
- if (buf.Contains("PRIVMSG"))
- {
- {
- output.WriteLine(
- "PRIVMSG #"+chan+" :"+result+" \r\n"
- );
- output.Flush();
- }
- }
- if (buf.StartsWith("PING ")) output.Write(buf.Replace("PING", "PONG") + "\r\n"); output.Flush();
- if (buf[0] != ':') continue;
- if (buf.Split(' ')[1] == "001")
- {
- output.Write(
- "JOIN #"+chan+" \r\n"
- );
- output.Flush();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement