コード例 #1
0
        private static bool ProcessDumpFile()
        {
            string[]      InputLines;
            List <string> OutputList;

            Console.Write("Reading file \"" + _InputFileName + "\"...");
            try
            {
                InputLines = File.ReadAllLines(_InputFileName);
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Console.WriteLine("The input file \"" + _InputFileName + "\" cannot be read. " + ex.Message);
                return(false);
            }
            Console.WriteLine(" Done!");

            OutputList = new List <string>();
            bool OkToProcessLine = false;

            Console.Write("Processing dump file...");
            foreach (string InputLine in InputLines)
            {
                if (InputLine.StartsWith("******* ") == true)
                {
                    OkToProcessLine = true;
                }
                else if (OkToProcessLine == true)
                {
                    if (InputLine.Contains("$ =") == true ||
                        InputLine.Contains("$  =") == true)
                    {
                        OutputList.Add(InputLine);
                    }
                }
            }
            Console.WriteLine(" Done!");

            OutputList.Sort(); // Sort the list

            // Custom code to add to the end
            OutputList.Add("charset 2");
            OutputList.Add("*=$c000");

            Console.Write("Writing file \"" + _OutputFileName + "\"...");
            try
            {
                File.WriteAllLines(_OutputFileName, OutputList);
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Console.WriteLine("The output file \"" + _OutputFileName + "\" cannot be written. " + ex.Message);
                return(false);
            }
            Console.WriteLine(" Done!");

            return(true);
        }
コード例 #2
0
        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.");
            }
        }