コード例 #1
0
ファイル: Program.cs プロジェクト: xxxx0107/Pokemont
        private static void ReadCommands()
        {
            while (true)
            {
                var input = System.Console.ReadLine();
                if (input == "exit")
                {
                    Environment.Exit(1);
                }

                if (input == "GUI")
                {
                    if (Globals.pokeList)
                    {
                        Task.Run(() =>
                        {
                            PokemonList.ShowDialog();
                        });
                    }
                    else
                    {
                        Task.Run(() =>
                        {
                            PokemonList = new Pokemons();
                            PokemonList.ShowDialog();
                        });
                    }
                }

                if (input == "items")
                {
                    new Logic.Logic(new Settings()).ListItems();
                }
            }
        }
コード例 #2
0
 public Stats()
 {
     InitializeComponent();
     Task.Run(update);
     if (Globals.pokeList)
     {
         list = true;
         Task.Run(() =>
         {
             pokemonList.ShowDialog();
         });
     }
     else
     {
         list = false;
     }
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: Bin-Dja/PokemonGo-Bot
        static void Main(string[] args)
        {
            configureNBug();
            SleepHelper.PreventSleep();
            if (args != null && args.Length > 0)
            {
                foreach (string arg in args)
                {
                    if (arg.Contains(","))
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Found coordinates in command line: {arg}");
                        if (File.Exists(lastcords))
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Last coords file exists, trying to delete it");
                            File.Delete(lastcords);
                        }
                        cmdCoords = arg;
                    }
                }
            }
            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
            }
            if (!File.Exists(pokelog))
            {
                File.Create(pokelog).Close();
            }
            if (!File.Exists(manualTransferLog))
            {
                File.Create(manualTransferLog).Close();
            }
            if (!File.Exists(EvolveLog))
            {
                File.Create(EvolveLog).Close();
            }
            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                int i = 1;

                //TODO Implement JSON Load

                if (Globals.usePwdEncryption)
                {
                    Globals.password = Encryption.Decrypt(Globals.password);
                }

                if (cmdCoords != string.Empty)
                {
                    string[] crdParts = cmdCoords.Split(',');
                    Globals.latitute  = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                    Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                }
                Logger.ColoredConsoleWrite(ConsoleColor.Yellow, $"Starting at: {Globals.latitute},{Globals.longitude}");
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());
                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                    });
                }
            }

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Globals.infoObservable.HandleNewHuntStats += SaveHuntStats;

            Task.Run(() =>
            {
                CheckVersion();
                try
                {
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }
                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
            });
            System.Console.ReadLine();
            SleepHelper.AllowSleep();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Cenkyavuz/PokemonGo-Bot
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0)
            {
                foreach (string arg in args)
                {
                    if (arg.Contains(","))
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Found coordinates in command line: {arg}");
                        if (File.Exists(lastcords))
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Last coords file exists, trying to delete it");
                            File.Delete(lastcords);
                        }

                        cmdCoords = arg;
                    }
                }
            }

            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        try
                        {
                            switch (i)
                            {
                                case 0:
                                    if (line == "Google")
                                        Globals.acc = Enums.AuthType.Google;
                                    else
                                        Globals.acc = Enums.AuthType.Ptc;
                                    break;
                                case 1:
                                    Globals.username = line;
                                    break;
                                case 2:
                                    Globals.password = line;
                                    break;
                                case 3:
                                    if (line.Split('.').Length - 1 > 1)
                                    { // Coords in one line, comma-delimited.
                                        string[] crdParts = line.Split(',');
                                        Globals.latitute = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                        Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                        i++;
                                    }
                                    else
                                    {
                                        Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    }
                                    break;
                                case 4:
                                    Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    break;
                                case 5:
                                    Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    break;
                                case 6:
                                    Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    break;
                                case 7:
                                    Globals.radius = int.Parse(line);
                                    break;
                                case 8:
                                    Globals.defLoc = bool.Parse(line);
                                    break;
                                case 9:
                                    Globals.transfer = bool.Parse(line);
                                    break;
                                case 10:
                                    Globals.duplicate = int.Parse(line);
                                    break;
                                case 11:
                                    Globals.evolve = bool.Parse(line);
                                    break;
                                case 12:
                                    Globals.maxCp = int.Parse(line);
                                    break;
                                case 13:
                                    Globals.telAPI = line;
                                    break;
                                case 14:
                                    Globals.telName = line;
                                    break;
                                case 15:
                                    Globals.telDelay = int.Parse(line);
                                    break;
                                case 16:
                                    //Globals.telDelay = int.Parse(line);
                                    // NavigationOption...
                                    break;
                                case 17:
                                    Globals.useluckyegg = bool.Parse(line);
                                    break;
                                case 18:
                                    Globals.gerNames = bool.Parse(line);
                                    break;
                                case 19:
                                    Globals.useincense = bool.Parse(line);
                                    break;
                                case 20:
                                    Globals.ivmaxpercent = int.Parse(line);
                                    break;
                                case 21:
                                    Globals.pokeList = bool.Parse(line);
                                    break;
                                case 22:
                                    Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                                    break;
                                case 23:
                                    Globals.pokevision = bool.Parse(line);
                                    break;
                                case 24:
                                    Globals.useluckyegg = bool.Parse(line);
                                    break;
                                case 25:
                                    Globals.autoIncubate = bool.Parse(line);
                                    break;
                                case 26:
                                    Globals.useBasicIncubators = bool.Parse(line);
                                    break;
                            }
                        }
                        catch (Exception)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Problem with value: {line} (line #{i})");
                            throw;
                        }
                        i++;
                    }
                    if (cmdCoords != string.Empty)
                    {
                        string[] crdParts = cmdCoords.Split(',');
                        Globals.latitute = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                        Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                    }
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, $"Starting at: {Globals.latitute},{Globals.longitude}");
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                            case 0:
                                Globals.pokeball = int.Parse(line);
                                break;
                            case 1:
                                Globals.greatball = int.Parse(line);
                                break;
                            case 2:
                                Globals.ultraball = int.Parse(line);
                                break;
                            case 3:
                                Globals.masterball = int.Parse(line);
                                break;
                            case 4:
                                Globals.revive = int.Parse(line);
                                break;
                            case 5:
                                Globals.toprevive = int.Parse(line);
                                break;
                            case 6:
                                Globals.potion = int.Parse(line);
                                break;
                            case 7:
                                Globals.superpotion = int.Parse(line);
                                break;
                            case 8:
                                Globals.hyperpotion = int.Parse(line);
                                break;
                            case 9:
                                Globals.toppotion = int.Parse(line);
                                break;
                            case 10:
                                Globals.berry = int.Parse(line);
                                break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                            if (Globals.gerNames)
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                            if (Globals.gerNames)
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                            if (Globals.gerNames)
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                    });
                }
            }

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Globals.infoObservable.HandleNewHuntStats += SaveHuntStats;

            Task.Run(() =>
            {

                CheckVersion();

                try
                {
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }
                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: woahthereian/PokemonGo-Bot
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0)
            {
                foreach (string arg in args)
                {
                    if (arg.Contains(","))
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.Green, String.Format("Found coordinates in command line: {0}", arg));
                        if (File.Exists(lastcords))
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Last coords file exists, trying to delete it");
                            File.Delete(lastcords);
                        }

                        cmdCoords = arg;
                    }
                }
            }


            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        try
                        {
                            switch (i)
                            {
                            case 0:
                                if (line == "Google")
                                {
                                    Globals.acc = Enums.AuthType.Google;
                                }
                                else
                                {
                                    Globals.acc = Enums.AuthType.Ptc;
                                }
                                break;

                            case 1:
                                Globals.username = line;
                                break;

                            case 2:
                                Globals.password = line;
                                break;

                            case 3:
                                if (line.Split('.').Length - 1 > 1)
                                {     // Coords in one line, comma-delimited.
                                    string[] crdParts = line.Split(',');
                                    Globals.latitute  = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    i++;
                                }
                                else
                                {
                                    Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                }
                                break;

                            case 4:
                                Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 5:
                                Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 6:
                                Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 7:
                                Globals.radius = int.Parse(line);
                                break;

                            case 8:
                                Globals.defLoc = bool.Parse(line);
                                break;

                            case 9:
                                Globals.transfer = bool.Parse(line);
                                break;

                            case 10:
                                Globals.duplicate = int.Parse(line);
                                break;

                            case 11:
                                Globals.evolve = bool.Parse(line);
                                break;

                            case 12:
                                Globals.maxCp = int.Parse(line);
                                break;

                            case 13:
                                Globals.telAPI = line;
                                break;

                            case 14:
                                Globals.telName = line;
                                break;

                            case 15:
                                Globals.telDelay = int.Parse(line);
                                break;

                            case 16:
                                //Globals.telDelay = int.Parse(line);
                                // NavigationOption...
                                break;

                            case 17:
                                Globals.useluckyegg = bool.Parse(line);
                                break;

                            case 18:
                                Globals.gerNames = bool.Parse(line);
                                break;

                            case 19:
                                Globals.useincense = bool.Parse(line);
                                break;

                            case 20:
                                Globals.ivmaxpercent = int.Parse(line);
                                break;

                            case 21:
                                Globals.pokeList = bool.Parse(line);
                                break;

                            case 22:
                                Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                                break;

                            case 23:
                                Globals.pokevision = bool.Parse(line);
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, String.Format("Problem with value: {0} (line #{1})", line, i));
                            throw e;
                        }
                        i++;
                    }
                    if (cmdCoords != "")
                    {
                        string[] crdParts = cmdCoords.Split(',');
                        Globals.latitute  = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                        Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                    }
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, String.Format("Starting at: {0},{1}", Globals.latitute, Globals.longitude));
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 0:
                            Globals.pokeball = int.Parse(line);
                            break;

                        case 1:
                            Globals.greatball = int.Parse(line);
                            break;

                        case 2:
                            Globals.ultraball = int.Parse(line);
                            break;

                        case 3:
                            Globals.masterball = int.Parse(line);
                            break;

                        case 4:
                            Globals.revive = int.Parse(line);
                            break;

                        case 5:
                            Globals.toprevive = int.Parse(line);
                            break;

                        case 6:
                            Globals.potion = int.Parse(line);
                            break;

                        case 7:
                            Globals.superpotion = int.Parse(line);
                            break;

                        case 8:
                            Globals.hyperpotion = int.Parse(line);
                            break;

                        case 9:
                            Globals.toppotion = int.Parse(line);
                            break;

                        case 10:
                            Globals.berry = int.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                    });
                }
            }

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Globals.infoObservable.HandleNewHuntStats += SaveHuntStats;

            Task.Run(() =>
            {
                CheckVersion();

                try
                {
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }
                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: ZimboBoyd/PokeBot3
        static void Main(string[] args)
        {
            System.Console.WriteLine("Current Version: " + version);
            string urlAddress = "http://pastebin.com/raw/5xi0UDAv";

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream receiveStream = response.GetResponseStream();
                StreamReader readStream = null;
                if (response.CharacterSet == null)
                    readStream = new StreamReader(receiveStream);
                else
                    readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
                data = readStream.ReadToEnd();
                response.Close();
                readStream.Close();
                if (version.Equals(data))
                {
                    System.Console.WriteLine("Newest version: " + data);
                    System.Console.WriteLine("You are already using the newest version.");
                }
                else
                {
                    System.Console.WriteLine("Newest version: " + data);
                    System.Console.WriteLine("There is a newer version avaliable on GitHub. Opening link in 5 Seconds.");
                    Thread.Sleep(5000);
                    Process.Start("http://github.com/shiftcodeYT/PokeBot3/releases/latest");
                    System.Environment.Exit(1);
                }

            }
            else
            {
                System.Console.WriteLine("Couldn't check for Updates. Is Pastebin down?");
            }

            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                            case 0:
                                if (line == "Google")
                                    Globals.acc = Enums.AuthType.Google;
                                else
                                    Globals.acc = Enums.AuthType.Ptc;
                                break;
                            case 1:
                                Globals.username = line;
                                break;
                            case 2:
                                Globals.password = line;
                                break;
                            case 3:
                                Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 4:
                                Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 5:
                                Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 6:
                                Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 7:
                                Globals.radius = int.Parse(line);
                                break;
                            case 8:
                                Globals.defLoc = bool.Parse(line);
                                break;
                            case 9:
                                Globals.transfer = bool.Parse(line);
                                break;
                            case 10:
                                Globals.duplicate = int.Parse(line);
                                break;
                            case 11:
                                Globals.evolve = bool.Parse(line);
                                break;
                            case 12:
                                Globals.maxCp = int.Parse(line);
                                break;
                            case 13:
                                Globals.telAPI = line;
                                break;
                            case 14:
                                Globals.telName = line;
                                break;
                            case 15:
                                Globals.telDelay = int.Parse(line);
                                break;
                            case 16:
                                Globals.telDelay = int.Parse(line);
                                break;
                            case 17:
                                Globals.useluckyegg = bool.Parse(line);
                                break;
                            case 18:
                                Globals.gerNames = bool.Parse(line);
                                break;
                            case 19:
                                Globals.useincense = bool.Parse(line);
                                break;
                            case 21:
                                Globals.ivmaxpercent = int.Parse(line);
                                break;
                            case 23:
                                Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                                break;
                            case 24:
                                Globals.pokevision = bool.Parse(line);
                                break;
                        }
                        i++;
                    }
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                            case 0:
                                Globals.pokeball = int.Parse(line);
                                break;
                            case 1:
                                Globals.greatball = int.Parse(line);
                                break;
                            case 2:
                                Globals.ultraball = int.Parse(line);
                                break;
                            case 3:
                                Globals.revive = int.Parse(line);
                                break;
                            case 4:
                                Globals.potion = int.Parse(line);
                                break;
                            case 5:
                                Globals.superpotion = int.Parse(line);
                                break;
                            case 6:
                                Globals.hyperpotion = int.Parse(line);
                                break;
                            case 7:
                                Globals.berry = int.Parse(line);
                                break;
                            case 8:
                                Globals.masterball = int.Parse(line);
                                break;
                            case 9:
                                Globals.toppotion = int.Parse(line);
                                break;
                            case 10:
                                Globals.toprevive = int.Parse(line);
                                break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                        //Application.Run(new Pokemons());
                    });
                }
            }

            //Application.Run(new Pokemons());

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Task.Run(() =>
            {

                try
                {
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }

                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }
コード例 #7
0
        static void Main(string[] args)
        {
            SleepHelper.PreventSleep();
            if (args != null && args.Length > 0)
            {
                foreach (string arg in args)
                {
                    if (arg.Contains(","))
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Found coordinates in command line: {arg}");
                        if (File.Exists(lastcords))
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Last coords file exists, trying to delete it");
                            File.Delete(lastcords);
                        }

                        cmdCoords = arg;
                    }
                }
            }

            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
            }

            if (!File.Exists(pokelog))
            {
                File.Create(pokelog).Close();
            }

            if (!File.Exists(manualTransferLog))
            {
                File.Create(manualTransferLog).Close();
            }

            if (!File.Exists(EvolveLog))
            {
                File.Create(EvolveLog).Close();
            }

            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                int i = 1;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        try
                        {
                            switch (i)
                            {
                            case 1:
                                if (line == "Google")
                                {
                                    Globals.acc = Enums.AuthType.Google;
                                }
                                else
                                {
                                    Globals.acc = Enums.AuthType.Ptc;
                                }
                                break;

                            case 2:
                                Globals.username = line;
                                break;

                            case 3:
                                Globals.password = line;
                                break;

                            case 4:
                                if (line.Split('.').Length - 1 > 1)
                                {     // Coords in one line, comma-delimited.
                                    string[] crdParts = line.Split(',');
                                    Globals.latitute  = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                    i++;
                                }
                                else
                                {
                                    Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                }
                                break;

                            case 5:
                                Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 6:
                                Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 7:
                                Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;

                            case 8:
                                Globals.radius = int.Parse(line);
                                break;

                            case 9:
                                Globals.defLoc = bool.Parse(line);
                                break;

                            case 10:
                                Globals.transfer = bool.Parse(line);
                                break;

                            case 11:
                                Globals.duplicate = int.Parse(line);
                                break;

                            case 12:
                                Globals.evolve = bool.Parse(line);
                                break;

                            case 13:
                                Globals.maxCp = int.Parse(line);
                                break;

                            case 14:
                                Globals.telAPI = line;
                                break;

                            case 15:
                                Globals.telName = line;
                                break;

                            case 16:
                                Globals.telDelay = int.Parse(line);
                                break;

                            case 17:
                                //Globals.telDelay = int.Parse(line);
                                // NavigationOption...
                                break;

                            case 18:
                                Globals.useluckyegg = bool.Parse(line);
                                break;

                            case 19:

                                break;

                            case 20:
                                Globals.useincense = bool.Parse(line);
                                break;

                            case 21:
                                Globals.ivmaxpercent = int.Parse(line);
                                break;

                            case 22:
                                Globals.pokeList = bool.Parse(line);
                                break;

                            case 23:
                                Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                                break;

                            case 24:
                                //Globals.pokevision = bool.Parse(line);
                                break;

                            case 25:
                                Globals.useluckyegg = bool.Parse(line);
                                break;

                            case 26:
                                Globals.autoIncubate = bool.Parse(line);
                                break;

                            case 27:
                                Globals.useBasicIncubators = bool.Parse(line);
                                break;

                            case 28:
                                Globals.TransferFirstLowIV = bool.Parse(line);
                                break;

                            case 34:
                                Globals.usePwdEncryption = bool.Parse(line);
                                break;
                                //case 35:
                                //    Globals.itemsList = bool.Parse(line);
                                //    break;
                            }
                        }
                        catch (Exception)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Problem with value: {line} (line #{i})");
                            throw;
                        }
                        i++;
                    }
                    if (Globals.usePwdEncryption)
                    {
                        Globals.password = Encryption.Decrypt(Globals.password);
                    }

                    if (cmdCoords != string.Empty)
                    {
                        string[] crdParts = cmdCoords.Split(',');
                        Globals.latitute  = double.Parse(crdParts[0].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                        Globals.longitude = double.Parse(crdParts[1].Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                    }
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, $"Starting at: {Globals.latitute},{Globals.longitude}");
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 1;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 1:
                            Globals.pokeball = int.Parse(line);
                            break;

                        case 2:
                            Globals.greatball = int.Parse(line);
                            break;

                        case 3:
                            Globals.ultraball = int.Parse(line);
                            break;

                        case 4:
                            Globals.masterball = int.Parse(line);
                            break;

                        case 5:
                            Globals.revive = int.Parse(line);
                            break;

                        case 6:
                            Globals.toprevive = int.Parse(line);
                            break;

                        case 7:
                            Globals.potion = int.Parse(line);
                            break;

                        case 8:
                            Globals.superpotion = int.Parse(line);
                            break;

                        case 9:
                            Globals.hyperpotion = int.Parse(line);
                            break;

                        case 10:
                            Globals.toppotion = int.Parse(line);
                            break;

                        case 11:
                            Globals.berry = int.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(Program.throws))
                {
                    string[] lines = File.ReadAllLines(@Program.throws);
                    i = 1;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 1:
                            Globals.excellentthrow = int.Parse(line);
                            break;

                        case 2:
                            Globals.greatthrow = int.Parse(line);
                            break;

                        case 3:
                            Globals.nicethrow = int.Parse(line);
                            break;

                        case 4:
                            Globals.ordinarythrow = int.Parse(line);
                            break;

                        default:
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                        {
                            Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                        }
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                        {
                            Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                        }
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != string.Empty)
                        {
                            Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                        }
                    }
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                    });
                }
                //if (Globals.itemsList)
                //{
                //    Task.Run(() =>
                //    {
                //        Items itemsList = new Items();
                //        itemsList.ShowDialog();
                //    });
                //}
            }


            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Globals.infoObservable.HandleNewHuntStats += SaveHuntStats;

            Task.Run(() =>
            {
                CheckVersion();

                try
                {
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }
                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings(), Globals.infoObservable).Execute().Wait();
                }
            });
            System.Console.ReadLine();
            SleepHelper.AllowSleep();
        }
コード例 #8
0
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 0:
                            if (line == "Google")
                            {
                                Globals.acc = Enums.AuthType.Google;
                            }
                            else
                            {
                                Globals.acc = Enums.AuthType.Ptc;
                            }
                            break;

                        case 1:
                            Globals.username = line;
                            break;

                        case 2:
                            Globals.password = line;
                            break;

                        case 3:
                            Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 4:
                            Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 5:
                            Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 6:
                            Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 7:
                            Globals.radius = int.Parse(line);
                            break;

                        case 8:
                            Globals.defLoc = bool.Parse(line);
                            break;

                        case 9:
                            Globals.transfer = bool.Parse(line);
                            break;

                        case 10:
                            Globals.duplicate = int.Parse(line);
                            break;

                        case 11:
                            Globals.evolve = bool.Parse(line);
                            break;

                        case 12:
                            Globals.maxCp = int.Parse(line);
                            break;

                        case 13:
                            Globals.telAPI = line;
                            break;

                        case 14:
                            Globals.telName = line;
                            break;

                        case 15:
                            Globals.telDelay = int.Parse(line);
                            break;

                        case 16:
                            Globals.telDelay = int.Parse(line);
                            break;

                        case 17:
                            Globals.useluckyegg = bool.Parse(line);
                            break;

                        case 18:
                            Globals.gerNames = bool.Parse(line);
                            break;

                        case 19:
                            Globals.useincense = bool.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 0:
                            Globals.pokeball = int.Parse(line);
                            break;

                        case 1:
                            Globals.greatball = int.Parse(line);
                            break;

                        case 2:
                            Globals.ultraball = int.Parse(line);
                            break;

                        case 3:
                            Globals.revive = int.Parse(line);
                            break;

                        case 4:
                            Globals.potion = int.Parse(line);
                            break;

                        case 5:
                            Globals.superpotion = int.Parse(line);
                            break;

                        case 6:
                            Globals.hyperpotion = int.Parse(line);
                            break;

                        case 7:
                            Globals.berry = int.Parse(line);
                            break;

                        case 8:
                            Globals.masterball = int.Parse(line);
                            break;

                        case 9:
                            Globals.toppotion = int.Parse(line);
                            break;

                        case 10:
                            Globals.toprevive = int.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());


                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                        //Application.Run(new Pokemons());
                    });
                }
            }

            //Application.Run(new Pokemons());

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Task.Run(() =>
            {
                CheckVersion();

                try
                {
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }

                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }
コード例 #9
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Current Version: " + version);
            string urlAddress = "http://pastebin.com/raw/5xi0UDAv";

            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(urlAddress);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream       receiveStream = response.GetResponseStream();
                StreamReader readStream    = null;
                if (response.CharacterSet == null)
                {
                    readStream = new StreamReader(receiveStream);
                }
                else
                {
                    readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
                }
                data = readStream.ReadToEnd();
                response.Close();
                readStream.Close();
                if (version.Equals(data))
                {
                    System.Console.WriteLine("Newest version: " + data);
                    System.Console.WriteLine("You are already using the newest version.");
                }
                else
                {
                    System.Console.WriteLine("Newest version: " + data);
                    System.Console.WriteLine("There is a newer version avaliable on GitHub. Opening link in 5 Seconds.");
                    Thread.Sleep(5000);
                    Process.Start("http://github.com/shiftcodeYT/PokeBot3/releases/latest");
                    System.Environment.Exit(1);
                }
            }
            else
            {
                System.Console.WriteLine("Couldn't check for Updates. Is Pastebin down?");
            }



            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 0:
                            if (line == "Google")
                            {
                                Globals.acc = Enums.AuthType.Google;
                            }
                            else
                            {
                                Globals.acc = Enums.AuthType.Ptc;
                            }
                            break;

                        case 1:
                            Globals.username = line;
                            break;

                        case 2:
                            Globals.password = line;
                            break;

                        case 3:
                            Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 4:
                            Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 5:
                            Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 6:
                            Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                            break;

                        case 7:
                            Globals.radius = int.Parse(line);
                            break;

                        case 8:
                            Globals.defLoc = bool.Parse(line);
                            break;

                        case 9:
                            Globals.transfer = bool.Parse(line);
                            break;

                        case 10:
                            Globals.duplicate = int.Parse(line);
                            break;

                        case 11:
                            Globals.evolve = bool.Parse(line);
                            break;

                        case 12:
                            Globals.maxCp = int.Parse(line);
                            break;

                        case 13:
                            Globals.telAPI = line;
                            break;

                        case 14:
                            Globals.telName = line;
                            break;

                        case 15:
                            Globals.telDelay = int.Parse(line);
                            break;

                        case 16:
                            Globals.telDelay = int.Parse(line);
                            break;

                        case 17:
                            Globals.useluckyegg = bool.Parse(line);
                            break;

                        case 18:
                            Globals.gerNames = bool.Parse(line);
                            break;

                        case 19:
                            Globals.useincense = bool.Parse(line);
                            break;

                        case 21:
                            Globals.ivmaxpercent = int.Parse(line);
                            break;

                        case 23:
                            Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                            break;

                        case 24:
                            Globals.pokevision = bool.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                        case 0:
                            Globals.pokeball = int.Parse(line);
                            break;

                        case 1:
                            Globals.greatball = int.Parse(line);
                            break;

                        case 2:
                            Globals.ultraball = int.Parse(line);
                            break;

                        case 3:
                            Globals.revive = int.Parse(line);
                            break;

                        case 4:
                            Globals.potion = int.Parse(line);
                            break;

                        case 5:
                            Globals.superpotion = int.Parse(line);
                            break;

                        case 6:
                            Globals.hyperpotion = int.Parse(line);
                            break;

                        case 7:
                            Globals.berry = int.Parse(line);
                            break;

                        case 8:
                            Globals.masterball = int.Parse(line);
                            break;

                        case 9:
                            Globals.toppotion = int.Parse(line);
                            break;

                        case 10:
                            Globals.toprevive = int.Parse(line);
                            break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != "")
                        {
                            if (Globals.gerNames)
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            }
                            else
                            {
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                            }
                        }
                    }
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                        //Application.Run(new Pokemons());
                    });
                }
            }

            //Application.Run(new Pokemons());

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Task.Run(() =>
            {
                try
                {
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }

                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: ReeViiS69/PokemonGo-Bot
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0 && args[0].Contains("-nogui"))
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui! If you didnt setup correctly with the GUI. It wont work.");
                foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
                {
                    if (pokemon.ToString() != "Missingno")
                    {
                        GUI.gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    }
                }
                int i = 0;
                if (File.Exists(account))
                {
                    string[] lines = File.ReadAllLines(@account);
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                            case 0:
                                if (line == "Google")
                                    Globals.acc = Enums.AuthType.Google;
                                else
                                    Globals.acc = Enums.AuthType.Ptc;
                                break;
                            case 1:
                                Globals.username = line;
                                break;
                            case 2:
                                Globals.password = line;
                                break;
                            case 3:
                                Globals.latitute = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 4:
                                Globals.longitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 5:
                                Globals.altitude = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 6:
                                Globals.speed = double.Parse(line.Replace(',', '.'), GUI.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                                break;
                            case 7:
                                Globals.radius = int.Parse(line);
                                break;
                            case 8:
                                Globals.defLoc = bool.Parse(line);
                                break;
                            case 9:
                                Globals.transfer = bool.Parse(line);
                                break;
                            case 10:
                                Globals.duplicate = int.Parse(line);
                                break;
                            case 11:
                                Globals.evolve = bool.Parse(line);
                                break;
                            case 12:
                                Globals.maxCp = int.Parse(line);
                                break;
                            case 13:
                                Globals.telAPI = line;
                                break;
                            case 14:
                                Globals.telName = line;
                                break;
                            case 15:
                                Globals.telDelay = int.Parse(line);
                                break;
                            case 16:
                                Globals.telDelay = int.Parse(line);
                                break;
                            case 17:
                                Globals.useluckyegg = bool.Parse(line);
                                break;
                            case 18:
                                Globals.gerNames = bool.Parse(line);
                                break;
                            case 19:
                                Globals.useincense = bool.Parse(line);
                                break;
                            case 21:
                                Globals.ivmaxpercent = int.Parse(line);
                                break;
                            case 23:
                                Globals.keepPokemonsThatCanEvolve = bool.Parse(line);
                                break;
                        }
                        i++;
                    }
                }

                if (File.Exists(items))
                {
                    string[] lines = File.ReadAllLines(@items);
                    i = 0;
                    foreach (string line in lines)
                    {
                        switch (i)
                        {
                            case 0:
                                Globals.pokeball = int.Parse(line);
                                break;
                            case 1:
                                Globals.greatball = int.Parse(line);
                                break;
                            case 2:
                                Globals.ultraball = int.Parse(line);
                                break;
                            case 3:
                                Globals.revive = int.Parse(line);
                                break;
                            case 4:
                                Globals.potion = int.Parse(line);
                                break;
                            case 5:
                                Globals.superpotion = int.Parse(line);
                                break;
                            case 6:
                                Globals.hyperpotion = int.Parse(line);
                                break;
                            case 7:
                                Globals.berry = int.Parse(line);
                                break;
                            case 8:
                                Globals.masterball = int.Parse(line);
                                break;
                            case 9:
                                Globals.toppotion = int.Parse(line);
                                break;
                            case 10:
                                Globals.toprevive = int.Parse(line);
                                break;
                        }
                        i++;
                    }
                }

                if (File.Exists(keep))
                {
                    string[] lines = System.IO.File.ReadAllLines(@keep);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noTransfer.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(ignore))
                {
                    string[] lines = System.IO.File.ReadAllLines(@ignore);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.noCatch.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

                if (File.Exists(evolve))
                {
                    string[] lines = System.IO.File.ReadAllLines(@evolve);
                    foreach (string line in lines)
                    {
                        if (line != "")
                            if (Globals.gerNames)
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), GUI.gerEng[line]));
                            else
                                Globals.doEvolve.Add((PokemonId)Enum.Parse(typeof(PokemonId), line));
                    }
                }

            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUI());

                if (Globals.pokeList)
                {
                    Task.Run(() =>
                    {
                        Pokemons pokemonList = new Pokemons();
                        pokemonList.ShowDialog();
                        //Application.Run(new Pokemons());
                    });
                }
            }

            //Application.Run(new Pokemons());

            Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

            Task.Run(() =>
            {

                CheckVersion();

                try
                {
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (PtcOfflineException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR you credentials are wrong.", LogLevel.Error);
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Trying again in 20 seconds...");
                    Thread.Sleep(20000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
                catch (AccountNotVerifiedException)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Your PTC Account is not activated. Exiting in 10 Seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }

                catch (Exception ex)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Unhandled exception: {ex}", LogLevel.Error);
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(200000);
                    new Logic.Logic(new Settings()).Execute().Wait();
                }
            });
            System.Console.ReadLine();
        }