Пример #1
0
        public void Run(string command, string[] args, string text1, string text2, Bot serverBot)
        {
            if (Program.Importer.ImportThread != null)
                Program.Importer.ImportThread.Abort();

            serverBot.SendChat("Canceled import.");
        }
Пример #2
0
        public void HandleConsoleCommand(string raw, string commandPrefix, Bot serverBot)
        {
            raw = Assistant.StripColors(raw);
            string command = raw.Substring(0, raw.IndexOf(" "));
            command = command.Replace(commandPrefix, "");

            string text1 = raw.Substring(command.Length + 1, raw.Length - (command.Length + 1));
            string[] args = text1.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);

            if (CommandDict.ContainsKey(command))
                CommandDict[command].Run(command, args, text1, "", serverBot);
        }
Пример #3
0
        public void Run(string command, string[] args, string text1, string text2, Bot serverBot)
        {
            if (args.Length > 0) {
                int times = int.Parse(args[0]);

                for (int i = 0; i < times; i++) {
                    serverBot.Position[0] = 0;
                    serverBot.RefreshLocation();
                    Thread.Sleep(100);
                    serverBot.Position[0] = 120;
                    serverBot.RefreshLocation();
                    Thread.Sleep(100);
                }
            }
        }
Пример #4
0
        public void ImportMbotThread(string[] lines, Bot client, short baseX, short baseY, short baseZ)
        {
            foreach (string m in lines) {
                string[] mySplit = m.Split(',');
                int x, y, z, type;

                int.TryParse(mySplit[0], out x);
                int.TryParse(mySplit[1], out y);
                int.TryParse(mySplit[2], out z);
                int.TryParse(mySplit[3].Replace(":", ""), out type);

                if (type != 0)
                    client.PlaceBlock(baseX + x, baseY + y, baseZ + z, (byte)type);
            }
            client.SendChat("Done importing.");
        }
Пример #5
0
        public void ImportMBot(Bot client, short x, short y, short z)
        {
            if (!File.Exists("Imports\\" + ImportFile + ".mbot")) {
                client.SendChat("File not found.");
                return;
            }

            client.SendChat("Importing.");

            using (var sr = new StreamReader("Imports\\" + ImportFile + ".mbot"))
                sr.ReadToEnd().Split(new[] {'\n'}, StringSplitOptions.RemoveEmptyEntries);

            //ImportThread = new Thread(() => ImportMbotThread(BlockLines, Client, X, Y, Z));
            //ImportThread.Start();
            //ImportThread = new Thread(ImportMbotThread);
            //ImportThread.Start(BlockLines, Client, X, Y, Z);
        }
Пример #6
0
        static void Main(string[] args)
        {
            int Bots = 20;
            bool dupelicateNames = false;
            BotsArr = new ClassicBot.Bot[Bots];
            var r = new Random();

            for (int i = 0; i < Bots; i++)
            {
                string name = "uBot" + (dupelicateNames ? r.Next(i) : i);
                BotsArr[i] = new Bot(false, name, "", false);
                BotsArr[i].ErrorMessage += message => Console.WriteLine("Error:" + i + ": " + message);
                BotsArr[i].Connect("potato", false, "127.0.0.1", 25565);
            }

            while (true)
            {
                UpdateLoop();
                Thread.Sleep(1000);
            }
        }
Пример #7
0
        public void HandleServerCommand(string raw, string commandPrefix, Bot serverBot)
        {
            raw = Assistant.StripColors(raw);
            var splits = raw.Split(' ');

            if (splits.Length > 1 && splits[1].StartsWith(commandPrefix)) {
                string name = splits[0].Replace("<", "").Replace(">", "").Replace("[", "").Replace("]", "").Replace(" ", "").Replace(":", "");
                string text1 = raw.Substring(raw.IndexOf(splits[2]), raw.Length - (raw.IndexOf(splits[2])));
                string[] args = text1.Split(' ');

                if (CommandDict.ContainsKey(splits[1].Replace(commandPrefix, "")) )
                    CommandDict[splits[1].Replace(commandPrefix, "")].Run(splits[1], args, text1, "", serverBot);

            }
        }
Пример #8
0
 public void Run(string command, string[] args, string text1, string text2, Bot serverBot)
 {
     if (args.Length > 0)
         serverBot.SendChat(text1.TrimStart(' '));
 }
Пример #9
0
        public void Run(string command, string[] args, string text1, string text2, Bot serverBot)
        {
            var dirInfo = new DirectoryInfo("Imports\\");
            serverBot.SendChat("You have " + dirInfo.GetFiles().Length + " imports.");
            string importString = "";

            foreach (FileInfo b in dirInfo.GetFiles())
                importString += b.Name + ", ";

            serverBot.SendChat(importString.Substring(0, importString.Length - 2));
        }
Пример #10
0
        public void Run(string command, string[] args, string text1, string text2, Bot serverBot)
        {
            if (args.Length > 0) {
                if (!File.Exists("Imports\\" + args[0] + ".mbot")) {
                    serverBot.SendChat("File not found.");
                    return;
                }

                Program.Importer.ImportFile = args[0];
                Program.Importer.Importing = true;
                serverBot.SendChat("Place an iron-ore marker to import.");
            }
        }
Пример #11
0
        static void Main(string[] args)
        {
            var myServer = new Bot(true, "Bot", "Bot", false);
            myServer.ClientSupportedExtensions.Add(CPEExtensions.CustomBlocks);

            Importer = new Importer();
            _logger = new FileLogger("Packets.txt");
            _ch = new CommandHandler();
            _prefix = "!";

            if (args.Length > 0) {
                if (args[0] == "help" || args[0] == "-h" || args[0] == "--help" || args[0] == "/h") {
                    Console.WriteLine("CLI Classic bot");
                    Console.WriteLine("By Umby24");
                    Console.WriteLine("");
                    Console.WriteLine("Usage: CLIBot.exe [verifynames] [UN] [Pass] [URL, Name, or IP] [Port or LogPackets (optional)]");
                    Console.WriteLine("verifynames may be either true or false");
                    Console.WriteLine("service may be either classicube or minecraft.");
                    Console.WriteLine("LogPackets may be true or false.");
                    return;
                }

                if (args.Length < 3) {
                    Console.WriteLine("Invalid number of arguments. See CLIbot.exe -h");
                    return;
                }

                bool testing;

                if (!bool.TryParse(args[0], out testing)) {
                    Console.WriteLine("Verifynames must be either true or false. See CLIbot.exe -h");
                    return;
                }

                if (testing)
                    myServer.VerifyNames = true;

                myServer.Username = args[1];
                myServer.Password = args[2];
                _ipNameorUrl = args[3];

                if (args.Length >= 5) {
                    testing = false;
                    int myInt;
                    bool myBool;

                    if (int.TryParse(args[4], out myInt)) {
                        _port = myInt;
                        testing = true;

                        if (args.Length > 5) {
                            if (bool.TryParse(args[5], out myBool)) {
                                _logPackets = myBool;
                            }
                        }
                    }

                    if (bool.TryParse(args[4], out myBool)) {
                        _logPackets = myBool;
                        testing = true;
                    }

                    if (testing == false) {
                        Console.WriteLine("Argument 6 invalid. See CLIbot.exe -h");
                        return;
                    }
                }
            }

            if (_logPackets) {
                myServer.PacketReceived += packet => _logger.Log(packet);
            }

            myServer.ChatMessage += message => {
                ColoredConsole.ColorConvertingConsole.WriteLine("[Chat] " + message);

                if (message.Contains(_prefix))
                    _ch.HandleServerCommand(message, _prefix, myServer);
            };

            myServer.InfoMessage += message => ColoredConsole.ColorConvertingConsole.WriteLine("&2[Info] &f" + message);

            myServer.ErrorMessage += message => ColoredConsole.ColorConvertingConsole.WriteLine("&4[Error] &f" + message);

            myServer.DebugMessage += message => ColoredConsole.ColorConvertingConsole.WriteLine("&9[Debug] &f" + message);

            myServer.BlockChanged += (x, y, z) => {
                if (Importer.Importing && myServer.ClientWorld.GetBlockId(x, y, z) == 15)
                    Importer.ImportMBot(myServer, x, y, z);
            };

            if (_ipNameorUrl.Contains("http")) {
                myServer.Connect(_ipNameorUrl, true, "127.0.0.1", 25565);
            } else if (_ipNameorUrl.Contains(".") && _ipNameorUrl.Length < 16) {
                myServer.Connect("", false, _ipNameorUrl, _port);
            } else {
                myServer.Connect(_ipNameorUrl, false);
            }

            string input;

            do {
                input = Console.ReadLine();

                if (input != null && input.Contains(_prefix))
                    _ch.HandleConsoleCommand(input, _prefix, myServer);

            } while (input != "quit");

            myServer.Disconnect();
        }
Пример #12
0
 public NetworkManager(Bot core)
 {
     WriteLock = new object();
     ClientBot = core;
     Populate();
 }
Пример #13
0
        public void MakeConnection(string username, string password, bool verifyNames, string serverUrl, string ip = "", int port = 25565, string mppass = "")
        {
            _bot = new Bot(true, username, password, verifyNames);
            _bot.ClientSupportedExtensions.Add(CPEExtensions.CustomBlocks);
            _bot.ClientSupportedExtensions.Add(CPEExtensions.ExtPlayerList);
            RegisterEvents();

            if (ip == "")
                _bot.Connect(serverUrl, true);
            else {
                _bot.MpPass = mppass;
                _bot.Connect("", false, ip, port);
            }
        }