public string mainLoop(int startTime) { Information information = new Information(); ChannelActions ChanActs = new ChannelActions(); ChanModes mode = new ChanModes(); Loader load = new Loader(); CTCP ctcp = new CTCP(); UserControl users = new UserControl(); httpRegex = new Regex(@"(?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*))*)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*))?)?)|(?:ftp://(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;?&=])*)(?::(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;?&=])*))?@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?))(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&=])*))*)))"); try { ThreadStart userThreadStart = new ThreadStart(users.userControl); Thread userThread = new Thread(userThreadStart); userThread.Start(); } catch (Exception e) { Console.WriteLine(e.ToString()); } while (true) { while ((inputLine = reader.ReadLine()) != null) { Console.WriteLine(inputLine); if (inputLine.IndexOf("376") >= 0) //End of MOTD { writer.WriteLine("JOIN " + channel); writer.Flush(); } else break; while ((inputLine = reader.ReadLine()) != null) { Console.WriteLine(inputLine); if (ctcp.isCTCP()) ctcp.processCTCPType(); else if (inputLine == ("PING :" + server)) { writer.WriteLine("PONG " + server); writer.Flush(); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": op me") >= 0 && information.sender() == owner) { mode.setMode("+o", owner); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": op") >= 0) { string realSender = information.sender(); string realMsg = information.msg(); information.sendNamesToSrv(); inputLine = reader.ReadLine(); if (information.isOped(realSender) || information.sender() == owner && information.senderHost() == ownerhost) mode.setMode("+o", realMsg.Substring(nick.Length + 5)); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": voice me") >= 0 || inputLine.ToLower().IndexOf(nick.ToLower() + ": voice ") >= 0) { mode.setMode("+v", information.sender()); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": uptime") >= 0) { Uptime uptime = new Uptime(); uptime.uptime(startTime); } else if (inputLine.IndexOf("PART " + channel) >= 0) { users.userPart(); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": die") >= 0 && information.sender() == owner) { writer.WriteLine("QUIT :My master killed me"); writer.Flush(); cleanup(); return "ok"; } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": topic") >=0 && information.sender() == owner) { mode.setTopic(); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": !load") >= 0 && information.sender() == owner) { load.createAD("load"); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": !unload") >= 0 && information.sender() == owner) { load.createAD("unload"); } else if (Regex.IsMatch(inputLine, httpRegex.ToString()) && information.sender() != nick) { HttpHeader hh = new HttpHeader(); ThreadStart thStart = new ThreadStart(hh.processHeader); Thread th = new Thread(thStart); th.Start(); } if (inputLine.StartsWith("ERROR")) { Console.WriteLine(inputLine); return "error"; } } } } }