Exemplo n.º 1
0
        public void Execute(PokemonId pokeid, GeoCoordinate remoteCoords)
        {
            GeoCoordinate returnCoords = new GeoCoordinate();

            returnCoords.Latitude  = _client.CurrentLatitude;
            returnCoords.Longitude = _client.CurrentLongitude;
            returnCoords.Altitude  = _client.CurrentAltitude;
            var result = _client.Player.UpdatePlayerLocation(returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude).Result;

            if (_botSettings == null && _client == null)
            {
                SendToLog($" client or settings are not set");
                return;
            }

            try
            {
                remoteCoords.Altitude = LocationUtils.getAltitude(remoteCoords.Latitude, remoteCoords.Longitude);

                SendToLog($"Trying to capture {pokeid}  at { remoteCoords.Latitude } / {remoteCoords.Longitude}");
                SendToLog(LocationUtils.FindAddress(remoteCoords.Latitude, remoteCoords.Longitude));
                result = _client.Player.UpdatePlayerLocation(remoteCoords.Latitude, remoteCoords.Longitude, remoteCoords.Altitude).Result;

                SendToLog($"We are at sniping location...");
                SendToLog($"Waiting {GlobalVars.SnipeOpts.WaitSecond} seconds for Pokemon to appear...");
                RandomHelper.RandomSleep(GlobalVars.SnipeOpts.WaitSecond * 1000, GlobalVars.SnipeOpts.WaitSecond * 1100);

                var catchedID = TrySnipePokemons(pokeid, returnCoords);
                if ((catchedID > 0) && GlobalVars.SnipeOpts.TransferIt)
                {
                    var trResult = Logic.objClient.Inventory.TransferPokemon(catchedID).Result;
                    if (trResult.Result == ReleasePokemonResponse.Types.Result.Success)
                    {
                        SendToLog("Pokemon was transfered.");
                        SendToLog("Candies awarded: " + trResult.CandyAwarded);
                    }
                }

                // Restore Position
                result = _client.Player.UpdatePlayerLocation(returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude).Result;

                SendToLog($"Location after Snipe : {returnCoords.Latitude} / {returnCoords.Longitude} / {returnCoords.Altitude}");
                SendToLog(LocationUtils.FindAddress(returnCoords.Latitude, returnCoords.Longitude));

                RandomHelper.RandomSleep(20000, 22000);  // Avoid cache after snipe
            }
            catch (Exception ex)
            {
                Logger.ExceptionInfo(ex.ToString());
                SendToLog($"Go to {returnCoords.Latitude} / {returnCoords.Longitude} / {returnCoords.Altitude}.");
                result = _client.Player.UpdatePlayerLocation(returnCoords.Latitude, returnCoords.Longitude, returnCoords.Altitude).Result;
            }

            GlobalVars.SnipeOpts.Enabled    = false;
            GlobalVars.SnipeOpts.ID         = PokemonId.Missingno;
            GlobalVars.SnipeOpts.Location   = null;
            GlobalVars.SnipeOpts.WaitSecond = 6;
            GlobalVars.SnipeOpts.NumTries   = 3;
        }
Exemplo n.º 2
0
        public void Execute()
        {
            Logger.SelectedLevel = LogLevel.Error;
            Logger.Warning("Source code and binary files of this bot are absolutely free and open-source!");
            Logger.Warning("If you've paid for it. Request a chargeback immediately!");
            Logger.Warning("You only need pay for a key to access to Hash Service");

            if (GlobalVars.Debug.VerboseMode)
            {
                Logger.SelectedLevel = LogLevel.Debug;
                Logger.ColoredConsoleWrite(ConsoleColor.Red, $"LogLevel set to {Logger.SelectedLevel}. Many logs will be generated.");
            }

            #region Log Logger

            Logger.Info($"Starting Execute on login server: {BotSettings.AuthType}");

            if (BotSettings.LogPokemons)
            {
                Logger.Info("You enabled Pokemonlogging. It will be saved to \"\\Logs\\PokeLog.txt\"");
            }

            if (BotSettings.LogTransfer)
            {
                Logger.Info("You enabled manual transfer logging. It will be saved to \"\\Logs\\TransferLog.txt\"");
            }

            if (BotSettings.LogEvolve)
            {
                Logger.Info("You enabled Evolution Logging. It will be saved to \"\\Logs\\EvolutionLog.txt\"");
            }

            #endregion

            #region Set Counters and Location

            Setout.sessionStart = DateTime.UtcNow;

            Logger.Info("Setting Pokemon Catch Count: to 0 for this session");

            Setout.pokemonCatchCount = 0;

            Logger.Info("Setting Pokestop Farmed Count to 0 for this session");

            Setout.pokeStopFarmedCount = 0;

            if (GlobalVars.ContinueLatestSession)
            {
                Setout.LoadSession();
            }

            objClient.CurrentAltitude  = BotSettings.DefaultAltitude;
            objClient.CurrentLongitude = BotSettings.DefaultLongitude;
            objClient.CurrentLatitude  = BotSettings.DefaultLatitude;

            #endregion

            #region Fix Altitude

            if (Math.Abs(objClient.CurrentAltitude) < double.Epsilon)
            {
                objClient.CurrentAltitude   = LocationUtils.getAltitude(objClient.CurrentLatitude, objClient.CurrentLongitude);
                BotSettings.DefaultAltitude = objClient.CurrentAltitude;

                Logger.Warning($"Altitude was 0, resolved that. New Altitude is now: {objClient.CurrentAltitude}");
            }

            #endregion

            #region Use Proxy

            if (BotSettings.proxySettings.enabled)
            {
                Logger.Error("===============================================");
                Logger.Error("Proxy enabled.");
                Logger.Error($"ProxyIP: { BotSettings.proxySettings.hostName }:{BotSettings.proxySettings.port}");
                Logger.Error("===============================================");
            }

            #endregion

            #region Login & Start
            //Restart unless killswitch thrown
            while (restartLogic)
            {
                try
                {
                    objClient.Login.DoLogin().Wait();
                    Logger.Debug("login done");

                    TelegramLogic.Instantiante();

                    PostLoginExecute();

                    Logger.Info("All Pokestops in range was already visited.");
                }
                catch (PtcOfflineException)
                {
                    Logger.Error("PTC Servers are probably down.");
                }
                catch (AggregateException ae) {
                    foreach (var e in ae.Flatten().InnerExceptions)
                    {
                        if (e is LoginFailedException)
                        {
                            Logger.Error(e.Message);
                            Logger.Error("Exiting in 10 Seconds.");
                            RandomHelper.RandomSleep(10000, 10001);
                            Environment.Exit(0);
                        }
                        else if (e is GoogleException)
                        {
                            Logger.Error("Login Failed. Your credentials are wrong or Google Account is banned.");
                            Logger.Error("Exiting in 10 Seconds.");
                            RandomHelper.RandomSleep(10000, 10001);
                            Environment.Exit(0);
                        }
                        else if (e is AccountNotVerifiedException)
                        {
                            Logger.Error("Your PTC Account is not activated.");
                            Logger.Error("Exiting in 10 Seconds.");
                            RandomHelper.RandomSleep(10000, 10001);
                            Environment.Exit(0);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
                catch (Exception ex)
                {
                    #region Log Error
                    Exception realerror = ex;
                    while (realerror.InnerException != null)
                    {
                        realerror = realerror.InnerException;
                    }
                    Logger.ExceptionInfo(ex.Message + "/" + realerror + "/" + ex.GetType());
                    #endregion
                }

                TelegramLogic.Stop();
                var msToWait = 50000;
                Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Restarting in over {(msToWait+5000)/1000} Seconds.");
                RandomHelper.RandomSleep(msToWait, msToWait + 10000);
            }
            #endregion
        }