Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Net;
- using System.Net.Sockets;
- namespace ZeroBot
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool Quit = false;
- string BotName;
- string Server;
- int Port;
- string Channel;
- string User;
- if (!File.Exists("BotConfig.txt"))
- {
- Console.Write("Bot Nickname: ");
- BotName = Console.ReadLine();
- Console.Write("Server: ");
- Server = Console.ReadLine();
- Console.Write("Port (Usually 6667): ");
- Port = Int32.Parse(Console.ReadLine());
- Console.Write("Channel: ");
- Channel = Console.ReadLine();
- Console.Write("Bot User: ");
- User = Console.ReadLine();
- string[] lines = { BotName, Server, Port.ToString(), Channel, User };
- File.WriteAllLines("BotConfig.txt", lines);
- }
- else
- {
- Console.WriteLine("BotConfig.txt exists.");
- }
- string[] BotInfo = File.ReadAllLines("BotConfig.txt");
- BotName = BotInfo[0];
- Server = BotInfo[1];
- Port = Int32.Parse(BotInfo[2]);
- Channel = BotInfo[3];
- User = BotInfo[4];
- Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- Console.WriteLine("Socket created");
- IPHostEntry host = Dns.GetHostEntry(Server);
- Console.WriteLine("Host found");
- IPEndPoint endPoint = new IPEndPoint(host.AddressList.First(), Port);
- Console.WriteLine("Endpoint created");
- socket.Connect(endPoint);
- Console.WriteLine("Connected");
- NetworkStream networkstream = new NetworkStream(socket);
- StreamWriter sWriter = new StreamWriter(networkstream, Encoding.UTF8);
- StreamReader sReader = new StreamReader(networkstream, Encoding.UTF8);
- sWriter.WriteLine("USER " + User + " * * :ZeroOne\r\n");
- Console.WriteLine("Sent USER");
- sWriter.WriteLine("NICK " + BotName + "\r\n");
- Console.WriteLine("Sent NICK");
- sWriter.WriteLine("JOIN " + Channel + "\r\n");
- Console.WriteLine("Sent JOIN");
- while (!Quit)
- {
- string input = sReader.ReadLine();
- if (input != null)
- {
- string[] words = input.Split(' ');
- if (words[0] == "PING")
- {
- sWriter.WriteLine("PONG " + words[1] + "\r\n");
- }
- Console.WriteLine(input);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment