/// <summary> /// Reads a line from the file, splits it according to the file format, and returns the fields as a List of strings /// </summary> /// <exception cref="InvalidOperationException">if the file does not have a consistent format</exception> /// <returns>the fields as a List of strings</returns> public override List <string> ReadLine() { if (!IsParseable) { throw new InvalidOperationException("Attempt to read from a file that does not exhibit a consistent format"); } string InputLine; List <string> Fields = null; while ((InputLine = Rdr.ReadLine()) != null) { ++TotLinesRead; TotBytesRead += InputLine.Length + 2; // CRLF if (SkipLines != 0) { if (++LinesSkippedSoFar <= SkipLines) { continue; } } if (RowsProcessed++ >= MaxRows) { break; } if (HasEOFStr && InputLine.StartsWith(EOFStr)) { break; } Fields = ParseLine(InputLine.Replace("\t", TabReplacementString).TrimEnd()); break; } return(Fields); }
private async void IRC(DiscordClient ctx) { DiscordChannel TOW_Chat = ctx.GetChannelAsync(valores.tow_chat).Result; DiscordChannel Arena_Chat = ctx.GetChannelAsync(valores.arena_chat).Result; DiscordChannel TDM_Chat = ctx.GetChannelAsync(valores.tdm_chat).Result; DiscordChannel Log = ctx.GetChannelAsync(valores.IdLogWall_E).Result; NetworkStream NS; TcpClient IRC; string InputLine; StreamReader Reader; StreamWriter Writer; try { Console.WriteLine("[IRC] [UBGE-Servidores] [Wall-E] Logando no IRC..."); IRC = new TcpClient(IP, Porta); NS = IRC.GetStream(); Reader = new StreamReader(NS); Writer = new StreamWriter(NS); Writer.WriteLine($"NICK {Nome}"); Writer.Flush(); Writer.WriteLine(Usuario); Console.WriteLine("[IRC] [UBGE-Servidores] [Wall-E] Logado no IRC! Conectando..."); Writer.Flush(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"[IRC] [UBGE-Servidores] [Wall-E] [Discord] | A conexão com o servidores: \"TOW, Arena, Semanal\" foi estabelecida com sucesso!"); Console.ResetColor(); await Log.SendMessageAsync($"**[IRC] [UBGE-Servidores] [Wall-E] [Discord]** **|** A conexão com o servidores: ``TOW``, ``Arena``, ``Semanal`` foi estabelecida com sucesso! Chat's sendo enviados nos canais: <#{valores.tow_chat}>, <#{valores.arena_chat}> e <#{valores.tdm_chat}>."); while (true) { while ((InputLine = Reader.ReadLine()) != null) { if (InputLine.Contains("PING :port80a.se.quakenet.org") || InputLine.Contains("PING :port80c.se.quakenet.org") || InputLine.Contains("PING :underworld1.no.quakenet.org") || InputLine.Contains("PING :underworld2.no.quakenet.org") || InputLine.Contains("PING :cymru.us.quakenet.org") || InputLine.Contains("PING :dreamhack.se.quakenet.org")) { InputLine.Replace("PING :port80a.se.quakenet.org", ""); InputLine.Replace("PING :port80c.se.quakenet.org", ""); InputLine.Replace("PING :underworld1.no.quakenet.org", ""); InputLine.Replace("PING :underworld2.no.quakenet.org", ""); InputLine.Replace("PING :cymru.us.quakenet.org", ""); InputLine.Replace("PING :dreamhack.se.quakenet.org", ""); } else { if (InputLine.Contains(":[email protected] PRIVMSG #servidores.ubge :")) { await TOW_Chat.SendMessageAsync($"[UBGE-TOW] | ``{DateTime.Now}`` [-] {InputLine.Replace(":[email protected] PRIVMSG #servidores.ubge :", "")}"); } if (InputLine.Contains(":[email protected] PRIVMSG #servidores.ubge :")) { await Arena_Chat.SendMessageAsync($"[UBGE-Arena] | ``{DateTime.Now}`` [-] {InputLine.Replace(":[email protected] PRIVMSG #servidores.ubge :", "")}"); } if (InputLine.Contains(":[email protected] PRIVMSG #servidores.ubge :")) { await TDM_Chat.SendMessageAsync($"[UBGE-TDM] | ``{DateTime.Now}`` [-] {InputLine.Replace(":[email protected] PRIVMSG #servidores.ubge :", "")}"); } } string[] splitInput = InputLine.Split(' '); if (splitInput[0] == "PING") { string Resposta = splitInput[1]; Writer.WriteLine($"PONG {Resposta}"); Writer.Flush(); } switch (splitInput[1]) { case "001": Writer.WriteLine($"JOIN {Canal}"); Writer.WriteLine("auth Wall-E wall-e2018"); Writer.Flush(); break; default: break; } } //Writer.Close(); //Reader.Close(); //IRC.Close(); } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"[IRC] [UBGE-Servidores] [Wall-E] [Discord] | A conexão com o servidores: \"TOW, Arena, Semanal\" não foi estabelecida com sucesso.\n\nErro: {ex.ToString()}"); Console.ResetColor(); await Log.SendMessageAsync($"**[IRC] [UBGE-Servidores] [Wall-E] [Discord]** **|** A conexão com o servidores: ``TOW``, ``Arena``, ``Semanal`` não foi estabelecida com sucesso.\n\n**Erro:**\n```{ex.ToString()}```"); Console.WriteLine("[Wall-E] Reiniciando..."); await ctx.DisconnectAsync(); await Task.Delay(200); await ctx.ConnectAsync(); Console.WriteLine("[Wall-E] Reiniciei."); await Log.SendMessageAsync($"**[IRC] [UBGE-Servidores] [Wall-E] [Discord]** **|** Me auto-reiniciei e o erro foi consertado! Os IRC's estão funcionando novamente e em perfeito estado. Chat's sendo enviados nos canais: <#{valores.tow_chat}>, <#{valores.arena_chat}> e <#{valores.tdm_chat}>.\n\n*(Fatiou, passou, boa 06)*"); Console.WriteLine("[IRC] [Wall-E] Me auto-reiniciei e o erro foi consertado! Os IRC's estão funcionando em perfeito estado."); } }