示例#1
0
        static void Main(string[] args)
        {
            /*
             * new Thread(() =>
             * {
             *  Thread.CurrentThread.IsBackground = true;
             *  ArkChatTest();
             * }).Start();
             * Console.ReadLine();s
             * return;*/

            RconConnection rc = RconConnection.ConnectToRcon("10.0.1.13", 27020, ""); //127.0.0.1

            Console.WriteLine("connected");
            while (true)
            {
                string msg = Console.ReadLine();
                if (msg == "die")
                {
                    break;
                }
                RconResponse rr = rc.SendCommand(msg);
                Console.WriteLine("sent");
                Console.WriteLine("response status: " + rr.status.ToString());
                Console.WriteLine("response: " + rr.body);
            }


            rc.DisposeNetworking();
            Console.WriteLine("disconnected");
            Console.ReadLine();
        }
示例#2
0
        public async Task Execute(CommandContext ctx, [Description("The command to execute")] string command, params string[] args)
        {
            await ctx.TriggerTypingAsync();

            //Build the command
            StringBuilder builder = new StringBuilder();

            builder.Append(command).Append(" ");

            for (int i = 0; i < args.Length; i++)
            {
                builder.Append(args[i]).Append(" ");
            }

            //Execute the rcon
            RconResponse response = await RCON.Execute(builder.ToString());

            //Prepare the description
            bool   hasErrored  = false;
            string description = "RCON executed ";

            //HAve we actually got a message?
            if (!string.IsNullOrEmpty(response.Message))
            {
                description += "and the server responded with: ``` " + response.Message + " ```";
            }
            else
            {
                description += "and the server had a empty response.";
            }

            //Have we errored?
            if (!string.IsNullOrEmpty(response.Error))
            {
                description += "\n\nThe rcon ran into a error while processing the command: ``` " + response.Error + " ```";
                hasErrored   = true;
            }

            //Create the embed
            var embed = new ResponseBuilder(ctx)
            {
                Author = new DiscordEmbedBuilder.EmbedAuthor()
                {
                    Name    = "Hyperlight\'s Current IP",
                    Url     = "http://hyperlight.chickatrice.net/",
                    IconUrl = "https://i.imgur.com/KLNIH31.png"
                },
                Description = description,
                Color       = hasErrored ? new DiscordColor(255, 96, 96) : new DiscordColor(12794879),
            };

            //Send it away!
            await ctx.RespondAsync(embed : embed);
        }
示例#3
0
        static void ArkChatTest()
        {
            //Connect, then spam.
            RconConnection rc = RconConnection.ConnectToRcon("10.0.1.13", 27020, "");

            Console.WriteLine("connected");
            Random rand = new Random();
            int    good = 0;
            int    bad  = 0;

            while (true)
            {
                Thread.Sleep(300);
                string uuid = RandomString(24, rand);
                string msg  = "ServerChat This is a test. Please ignore. APP_ENDORANCE_TEST_ID_" + uuid;
                //Send chat
                rc.SendCommand(msg);
                RconResponse rr = rc.SendCommand("GetChat");
                bool         ok = rr.status == RconResponseStatus.Ok;
                if (ok)
                {
                    //Check to see if it contains it
                    ok = rr.body.Contains(uuid);
                }
                if (!ok)
                {
                    Console.Write("\r" + rr.body + "\n");
                }
                Console.Write("\rGot message " + uuid + " - Status: " + ok + " - RawStatus: " + rr.status.ToString() + " - OK: " + good.ToString() + " - Bad: " + bad.ToString());
                if (ok)
                {
                    good++;
                }
                else
                {
                    bad++;
                }
            }
        }
示例#4
0
 private static void FormatResponse(RconResponse response)
 {
     Console.ForegroundColor = ConsoleColor.Cyan;
     Console.WriteLine(response.Content);
     Console.ForegroundColor = ConsoleColor.Gray;
 }
 private void ConsoleCallback(RconResponse rconResponse)
 {
     Console.WriteLine(rconResponse.Content);
     if (rconResponse.Content.Split(':').First() == "running")
     {
         IsRunning = Convert.ToBoolean(rconResponse.Content.Split(':').Last());
         IsAslInitComplete = true;
     }
     if (rconResponse.Content.Split(':').First() == "state")
     {
         switch (rconResponse.Content.Split(':').Last())
         {
             case "installing":
                 IsInstalling = true;
                 break;
             case "finishedinstalling":
                 IsInstalling = false;
                 break;
             case "stopped":
                 IsRunning = false;
                 IsInstalling = false;
                 break;
         }
     }
 }