コード例 #1
0
        public void PostLoginExecute()
        {
            try
            {
                //update user location on map
                Task.Factory.StartNew(() => Logic.Instance.infoObservable.PushNewGeoLocations(new GeoCoordinate(GlobalVars.latitude, GlobalVars.longitude)));
                GetPlayerResponse profil = objClient.Player.GetPlayer();
                objClient.Inventory.ExportPokemonToCSV(profil.PlayerData);
                Setout.Execute();
                ExecuteFarmingPokestopsAndPokemons(objClient);
            }
            catch (AccessTokenExpiredException)
            {
                throw new AccessTokenExpiredException();
            }
            catch (Exception ex)
            {
                Logger.Error($"Exception: {ex}");

                if (BotSettings.RelocateDefaultLocation)
                {
                    Logger.Info("Detected User Request to Relocate to a new farming spot!");
                }
            }
        }
コード例 #2
0
        private bool ExecuteCatchandFarm()
        {
            if (BotSettings.RelocateDefaultLocation)
            {
                return(false);
            }
            if ((long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds > lastsearchtimestamp + 10000)
            {
                lastsearchtimestamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds;

                var mapObjectsResponse = objClient.Map.GetMapObjects().Result.Item1;
                //narrow map data to pokestops within walking distance
                var pokeStops = GetNearbyPokeStops(false, mapObjectsResponse);
                var pokestopsWithinRangeStanding = pokeStops.Where(i => LocationUtils.CalculateDistanceInMeters(objClient.CurrentLatitude, objClient.CurrentLongitude, i.Latitude, i.Longitude) < 40);

                var withinRangeStandingList = pokestopsWithinRangeStanding as IList <FortData> ?? pokestopsWithinRangeStanding.ToList();
                if (withinRangeStandingList.Any())
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Green, $"{withinRangeStandingList.Count} Pokestops within range of user");

                    foreach (var pokestop in withinRangeStandingList)
                    {
                        if (!GlobalVars.Gyms.Spin)
                        {
                            if (pokestop.Type != FortType.Checkpoint)
                            {
                                continue;
                            }
                        }

                        if (pokestop.Type == FortType.Gym)
                        {
                            Logger.Info("Spinning Gym");
                        }

                        var fortInfo = objClient.Fort.GetFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);
                        var farmed   = CheckAndFarmNearbyPokeStop(pokestop, objClient, fortInfo);

                        if (farmed)
                        {
                            pokestop.CooldownCompleteTimestampMs = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds + 300500;
                        }

                        Setout.SetCheckTimeToRun();
                        RandomHelper.RandomSleep(500, 600); // Time between pokestops
                    }
                }
                CatchingLogic.Execute(mapObjectsResponse);

                GymsLogic.Execute();

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
 void checkversion()
 {
     if (Setout.GetServerVersion() > new Version(Application.ProductVersion))
     {
         startDownload();
     }
     else
     {
         MessageBox.Show("Your client is up-to-date.");
         Hide();
     }
 }
コード例 #4
0
        public static void CheckForNewBotVersion()
        {
            try
            {
                var newest = Setout.GetServerVersion();

                if (newest <= Assembly.GetExecutingAssembly().GetName().Version)
                {
                    //ColoredConsoleWrite(ConsoleColor.Yellow, "Awesome! You have already got the newest version! " + Assembly.GetExecutingAssembly().GetName().Version);
                    return;
                }

                Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Bot Version {newest} is available!");
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "We recommend to use this new version.");
            }
            catch (Exception)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.White, "Unable to check for updates now...");
            }
        }
コード例 #5
0
        public async void BotOnMessageReceived(object sender, MessageEventArgs messageEventArgs)
        {
            Message message = messageEventArgs.Message;

            if (message == null || message.Type != MessageType.TextMessage)
            {
                return;
            }
            _chatid = message.Chat.Id;
            try
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "[TelegramAPI] Got Request from " + message.From.Username + " | " + message.Text);
                string username       = _botSettings.TelegramName;
                string telegramAnswer = string.Empty;

                if (username != message.From.Username)
                {
                    using (System.IO.Stream stream = new System.IO.MemoryStream())
                    {
                        PokemonGo.RocketAPI.Logic.Properties.Resources.norights.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                        stream.Position = 0;
                        await _telegram.SendPhotoAsync(_chatid, new FileToSend("norights.jpg", stream), replyMarkup : new ReplyKeyboardHide()).ConfigureAwait(false);
                    }
                    return;
                }

                // [0]-Commando; [1+]-Argument
                var              msgText = message.Text;
                string[]         textCMD = msgText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                TelegramUtilTask cmd     = getTask(textCMD[0]);
                switch (cmd)
                {
                case TelegramUtilTask.UNKNOWN:
                    telegramAnswer = string.Format("Usage:\r\n{0}\r\n{1}\r\n{2}\r\n{3}\r\n{4}\r\n{5}\r\n{6}\r\n{7}\r\n{8}\r\n{9}",
                                                   @"/stats - Get Current Stats",
                                                   @"/livestats - Enable/Disable Live Stats",
                                                   @"/information <topic> - Enable/Disable Information topics",
                                                   @"/top <HowMany?> - Outputs Top (?) Pokemons",
                                                   @"/transfer pokemon cp - transfer pokemons that matches with the given data",
                                                   @"/items  - Outputs Items List",
                                                   @"/drop item amount  - Throws the amount of items given",
                                                   @"/forceevolve - Forces Evolve",
                                                   @"/snipe pokemon latitude, longitude - snipe desired pokemon",
                                                   @"/stopbot - stop running bot");
                    break;

                case TelegramUtilTask.GET_STATS:
                    var ps = _client.Inventory.GetPlayerStats();

                    int    l             = ps.First().Level;
                    long   expneeded     = ((ps.First().NextLevelXp - ps.First().PrevLevelXp) - StringUtils.getExpDiff(ps.First().Level));
                    long   curexp        = ((ps.First().Experience - ps.First().PrevLevelXp) - StringUtils.getExpDiff(ps.First().Level));
                    double curexppercent = (Convert.ToDouble(curexp) / Convert.ToDouble(expneeded)) * 100;
                    string curloc        = _client.CurrentLatitude + "%20" + _client.CurrentLongitude;
                    curloc = curloc.Replace(",", ".");
                    string curlochtml = "https://www.google.com/maps/search/" + curloc + "/";
                    double shortenLng = Math.Round(_client.CurrentLongitude, 3);
                    double shortenLat = Math.Round(_client.CurrentLatitude, 3);
                    var    player     = _client.Player.GetPlayer();
                    telegramAnswer += "\nNickname: " + player.PlayerData.Username;
                    telegramAnswer += "\nLevel: " + ps.First().Level;
                    telegramAnswer += "\nEXP Needed: " + ((ps.First().NextLevelXp - ps.First().PrevLevelXp) - StringUtils.getExpDiff(ps.First().Level));
                    telegramAnswer += $"\nCurrent EXP: {curexp} ({Math.Round(curexppercent)}%)";
                    telegramAnswer += "\nEXP to Level up: " + ((ps.First().NextLevelXp) - (ps.First().Experience));
                    telegramAnswer += "\nKM walked: " + ps.First().KmWalked;
                    telegramAnswer += "\nPokeStops visited: " + ps.First().PokeStopVisits;
                    telegramAnswer += "\nStardust: " + player.PlayerData.Currencies.ToArray()[1].Amount;
                    telegramAnswer += "\nPokemons: " + (_client.Inventory.GetPokemons()).Count() + "/" + player.PlayerData.MaxPokemonStorage;
                    telegramAnswer += "\nItems: " + _client.Inventory.GetItems().Count() + " / " + player.PlayerData.MaxItemStorage;
                    telegramAnswer += "\nCurentLocation:\n" + curlochtml;
                    break;

                case TelegramUtilTask.GET_TOPLIST:
                    int shows = 10;
                    if (textCMD.Length > 1 && !int.TryParse(textCMD[1], out shows))
                    {
                        telegramAnswer += $"Error! This is not a Number: {textCMD[1]}\nNevermind...\n";
                        shows           = 10; //TryParse error will reset to 0
                    }
                    telegramAnswer += "Showing " + shows + " Pokemons...\nSorting...";
                    await _telegram.SendTextMessageAsync(_chatid, telegramAnswer, replyMarkup : new ReplyKeyboardHide()).ConfigureAwait(false);

                    var myPokemons = _client.Inventory.GetPokemons();
                    myPokemons = myPokemons.OrderByDescending(x => x.Cp);
                    var PogoUsername = _client.Player.GetPlayer().PlayerData.Username;
                    telegramAnswer = $"Top {shows} Pokemons of {PogoUsername}:";

                    IEnumerable <PokemonData> topPokemon = myPokemons.Take(shows);
                    foreach (PokemonData pokemon in topPokemon)
                    {
                        telegramAnswer += string.Format("\n{0} |  CP: {1} ({2}% perfect)",
                                                        pokemon.PokemonId,
                                                        pokemon.Cp,
                                                        Math.Round(PokemonInfo.CalculatePokemonPerfection(pokemon), 2));
                    }
                    break;

                case TelegramUtilTask.SWITCH_LIVESTATS:
                    _livestats = SwitchAndGetAnswer(_livestats, out telegramAnswer, "Live Stats");
                    break;

                case TelegramUtilTask.SWITCH_INFORMATION:
                    //_informations = SwitchAndGetAnswer(_informations, out telegramAnswer, "Information");
                    Array topics = Enum.GetValues(typeof(TelegramUtilInformationTopics));
                    if (textCMD.Length > 1)
                    {
                        if (textCMD[1] == "all-enable")
                        {
                            foreach (TelegramUtilInformationTopics topic in topics)
                            {
                                String niceName = topic.ToString().Substring(0, 1).ToUpper() + topic.ToString().Substring(1).ToLower();
                                telegramAnswer     += "Enabled information topic " + niceName + "\n";
                                _information[topic] = true;
                            }
                            break;
                        }
                        else if (textCMD[1] == "all-disable")
                        {
                            foreach (TelegramUtilInformationTopics topic in topics)
                            {
                                String niceName = topic.ToString().Substring(0, 1).ToUpper() + topic.ToString().Substring(1).ToLower();
                                telegramAnswer     += "Disabled information topic " + niceName + "\n";
                                _information[topic] = false;
                            }
                            break;
                        }
                        else
                        {
                            foreach (TelegramUtilInformationTopics topic in topics)
                            {
                                if (textCMD[1].ToLower() == topic.ToString().ToLower())
                                {
                                    String niceName = topic.ToString().Substring(0, 1).ToUpper() + topic.ToString().Substring(1).ToLower();
                                    _information[topic] = !_information[topic];
                                    telegramAnswer      = (_information[topic] ? "En" : "Dis") + "abled information topic " + niceName + "\n";
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (TelegramUtilInformationTopics topic in topics)
                        {
                            String niceName = topic.ToString().Substring(0, 1).ToUpper() + topic.ToString().Substring(1).ToLower();
                            telegramAnswer += " - " + niceName + "\n";
                            telegramAnswer += " -     " + _informationDescription[topic] + "\n";
                            telegramAnswer += " -     Currently " + (_information[topic] ? "enabled" : "disabled") + "\n";
                            telegramAnswer += "\n";
                        }

                        telegramAnswer += " - all-disable\n";
                        telegramAnswer += " -     " + TranslationHandler.GetString("telegram-disable-all", "Disable all topics") + "\n";
                        telegramAnswer += "\n";

                        telegramAnswer += " - all-enable\n";
                        telegramAnswer += " -     " + TranslationHandler.GetString("telegram-enable-all", "Enable all topics") + "\n";
                        telegramAnswer += "\n";
                        break;
                    }

                    break;

                case TelegramUtilTask.RUN_FORCEEVOLVE:
                    IEnumerable <PokemonData> pokemonToEvolve = Setout.GetPokemonToEvolve(true);
                    if (pokemonToEvolve.Count() > 3)
                    {
                        Setout.UseLuckyEgg(_client);
                    }
                    foreach (PokemonData pokemon in pokemonToEvolve)
                    {
                        if (_botSettings.pokemonsToEvolve.Contains(pokemon.PokemonId))
                        {
                            var evolvePokemonOutProto = _client.Inventory.EvolvePokemon((ulong)pokemon.Id);
                            if (evolvePokemonOutProto.Result == POGOProtos.Networking.Responses.EvolvePokemonResponse.Types.Result.Success)
                            {
                                await _telegram.SendTextMessageAsync(_chatid, $"Evolved {pokemon.PokemonId} successfully for {evolvePokemonOutProto.ExperienceAwarded}xp", replyMarkup : new ReplyKeyboardHide()).ConfigureAwait(false);
                            }
                            else
                            {
                                await _telegram.SendTextMessageAsync(_chatid, $"Failed to evolve {pokemon.PokemonId}. EvolvePokemonOutProto.Result was {evolvePokemonOutProto.Result}, stopping evolving {pokemon.PokemonId}", replyMarkup : new ReplyKeyboardHide()).ConfigureAwait(false);
                            }
                            RandomHelper.RandomSleep(2000);
                        }
                    }
                    telegramAnswer = "Done.";
                    break;

                case TelegramUtilTask.RUN_SNIPE:
                    telegramAnswer = ProcessSnipeCommand(msgText.Replace(textCMD[0], "").Trim());
                    break;

                case TelegramUtilTask.FORCE_STOP:
                    var secs = 1;
                    if (textCMD.Length > 1)
                    {
                        int.TryParse(textCMD[1].Trim(), out secs);
                    }
                    telegramAnswer = $"Stopping bot in {secs} seconds";
                    await _telegram.SendTextMessageAsync(_chatid, telegramAnswer, replyMarkup : new ReplyKeyboardHide()).ConfigureAwait(false);

                    _telegram.StopReceiving();
                    RandomHelper.RandomSleep(secs * 1000);
                    Environment.Exit(0);
                    break;

                case TelegramUtilTask.TRANSFER_POKEMON:
                    telegramAnswer = ProcessTransferPokemon(msgText.Replace(textCMD[0], "").Trim());
                    break;

                case TelegramUtilTask.GET_ITEMSLIST:
                    telegramAnswer = ProcessGetItemList();
                    break;

                case TelegramUtilTask.DROP_ITEM:
                    telegramAnswer = ProcessDropItem(msgText.Replace(textCMD[0], "").Trim());
                    break;
                }

                await _telegram.SendTextMessageAsync(_chatid, telegramAnswer, replyMarkup : new ReplyKeyboardHide()).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Logger.Debug(ex.ToString());
                var apiRequestException = ex as ApiRequestException;
                if (apiRequestException != null)
                {
                    await _telegram.SendTextMessageAsync(_chatid, apiRequestException.Message, replyMarkup : new ReplyKeyboardHide()).ConfigureAwait(false);
                }
            }
        }
コード例 #6
0
        private bool CheckAndFarmNearbyPokeStop(FortData pokeStop, Client client, FortDetailsResponse fortInfo)
        {
            if (Setout.count >= 9)
            {
                Setout.Execute();
            }

            if (pokeStop.CooldownCompleteTimestampMs < (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds && BotSettings.FarmPokestops)
            {
                var fortSearch = objClient.Fort.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
                Logger.Debug("================[VERBOSE LOGGING - Pokestop Search]================");
                Logger.Debug($"Result: {fortSearch.Result}");
                Logger.Debug($"ChainHackSequenceNumber: {fortSearch.ChainHackSequenceNumber}");
                Logger.Debug($"Cooldown Complete (MS): {fortSearch.CooldownCompleteTimestampMs}");
                Logger.Debug($"EXP Award: {fortSearch.ExperienceAwarded}");
                Logger.Debug($"Gems Award: {fortSearch.GemsAwarded}");
                Logger.Debug($"Item Award: {fortSearch.ItemsAwarded}");
                Logger.Debug($"Egg Data: {fortSearch.PokemonDataEgg}");
                Logger.Debug("==================================================================");

                switch (fortSearch.Result.ToString())
                {
                case "NoResultSet":
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Pokestop Error: We did not recieve a result from the pokestop.");
                    break;

                case "Success":
                    // It already showed our pokestop Information
                    break;

                case "OutOfRange":
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Pokestop Error: The pokestop is out of range!");
                    break;

                case "InCooldownPeriod":
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Pokestop Warning: The current Pokestop is in the cooldown period.");
                    break;

                case "InventoryFull":
                    Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Pokestop Warning: Your Inventory is full. You did not recieve any items.");
                    break;

                case "ExceededDailyLimit":
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Pokestop Error: You are above your daily limit of pokestops! You should stop farming pokestops.");
                    break;
                }

                Setout.count++;
                var strDate      = DateTime.Now.ToString("HH:mm:ss");
                var pokeStopInfo = $"{fortInfo.Name}{Environment.NewLine}Visited:{strDate}{Environment.NewLine}";

                if (fortSearch.ExperienceAwarded > 0)
                {
                    var egg = "/";

                    if (fortSearch.PokemonDataEgg != null)
                    {
                        egg = fortSearch.PokemonDataEgg.EggKmWalkedTarget + "km";
                    }

                    var items = "";

                    if (fortSearch.ItemsAwarded != null)
                    {
                        items = StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded);
                    }

                    var logrestock = false;

                    if (fortSearch.ItemsAwarded != null)
                    {
                        foreach (var item in fortSearch.ItemsAwarded)
                        {
                            if (item.ItemId == ItemId.ItemPokeBall || item.ItemId == ItemId.ItemGreatBall || item.ItemId == ItemId.ItemUltraBall)
                            {
                                logrestock = true;
                            }
                        }

                        if (logrestock && pokeballoutofstock)
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Detected Pokeball Restock - Enabling Catch Pokemon");

                            CatchingLogic.AllowCatchPokemon = true;
                            pokeballoutofstock = false;
                        }

                        FailedSoftban = 0;
                        BotStats.AddExperience(fortSearch.ExperienceAwarded);
                        Setout.RefreshConsoleTitle(client);
                        Setout.pokeStopFarmedCount++;
                        Setout.SaveSession();

                        Logger.Info($"Farmed XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Egg: {egg}, Items: {items}");

                        var strItems = items.Replace(",", Environment.NewLine);
                        pokeStopInfo += $"{fortSearch.ExperienceAwarded} XP{Environment.NewLine}{fortSearch.GemsAwarded}{Environment.NewLine}{egg}{Environment.NewLine}{strItems}";

                        Logger.Debug("LureInfo: " + pokeStop.LureInfo);
                        if (pokeStop.LureInfo != null)
                        {
                            var pokedata = new MapPokemon();
                            pokedata.EncounterId           = pokeStop.LureInfo.EncounterId;
                            pokedata.PokemonId             = pokeStop.LureInfo.ActivePokemonId;
                            pokedata.Latitude              = pokeStop.Latitude;
                            pokedata.Longitude             = pokeStop.Longitude;
                            pokedata.ExpirationTimestampMs = pokeStop.LureInfo.LureExpiresTimestampMs;
                            pokedata.SpawnPointId          = pokeStop.LureInfo.FortId;

                            infoObservable.PushNewPokemonLocation(pokedata);
                            Logger.Debug("Lured Pokemon: " + pokedata);

                            if (!BotSettings.catchPokemonSkipList.Contains(pokedata.PokemonId) && GlobalVars.CatchPokemon)
                            {
                                if (!lureEncounters.Contains(pokedata.EncounterId.ToString()))
                                {
                                    Logger.ColoredConsoleWrite(ConsoleColor.Green, "Catching Lured Pokemon");
                                    CatchingLogic.CatchLuredPokemon(pokedata.EncounterId, pokedata.SpawnPointId, pokedata.PokemonId, pokedata.Longitude, pokedata.Latitude);

                                    lureEncounters.Add(pokedata.EncounterId.ToString());
                                }
                                else
                                {
                                    Logger.ColoredConsoleWrite(ConsoleColor.Green, "Skipped Lure Pokemon: " + pokedata.PokemonId + " because we have already caught him, or catching pokemon is disabled");
                                }
                            }
                        }

                        double eggs = 0;

                        if (fortSearch.PokemonDataEgg != null)
                        {
                            eggs = fortSearch.PokemonDataEgg.EggKmWalkedTarget;
                        }

                        Telegram?.sendInformationText(TelegramUtil.TelegramUtilInformationTopics.Pokestop, fortInfo.Name, fortSearch.ExperienceAwarded, eggs, fortSearch.GemsAwarded, StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded));
                    }
                }

                Task.Factory.StartNew(() => infoObservable.PushPokeStopInfoUpdate(pokeStop, pokeStopInfo));

                return(true);
            }

            if (!BotSettings.FarmPokestops)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Green, "Farm Pokestop option unchecked, skipping and only looking for pokemon");

                return(false);
            }

            Logger.ColoredConsoleWrite(ConsoleColor.Green, "Pokestop not ready to farm again, skipping and only looking for pokemon");

            return(false);
        }
コード例 #7
0
        private void FarmPokestopOnBreak(FortData[] pokeStops, Client client)
        {
            //check for overlapping pokestops where we are taking a break
            Logger.ColoredConsoleWrite(ConsoleColor.Green, "Reached break location. Using Lures Enabled");

            var pokestopsWithinRangeStanding = pokeStops
                                               .Where(i => LocationUtils
                                                      .CalculateDistanceInMeters(
                                                          objClient.CurrentLatitude,
                                                          objClient.CurrentLongitude,
                                                          i.Latitude,
                                                          i.Longitude) < 40);

            var pokestopCount = pokestopsWithinRangeStanding.Count();

            Logger.ColoredConsoleWrite(ConsoleColor.Green, $"{pokestopCount} Pokestops within range of where you are standing.");

            //Begin farming loop while on break
            do
            {
                foreach (var pokestop in pokestopsWithinRangeStanding)
                {
                    if (BotSettings.RelocateDefaultLocation)
                    {
                        break;
                    }

                    CatchingLogic.Execute();

                    var fortInfo = objClient.Fort.GetFort(pokestop.Id, pokestop.Latitude, pokestop.Longitude);

                    if (BotSettings.UseLureGUIClick || (BotSettings.UseLureAtBreak && !pokestop.ActiveFortModifier.Any() && !addedlure))
                    {
                        if (objClient.Inventory.GetItemAmountByType(ItemId.ItemTroyDisk) > 0)
                        {
                            BotSettings.UseLureGUIClick = false;

                            Logger.ColoredConsoleWrite(ConsoleColor.Magenta, "Adding lure and setting resume walking to 30 minutes");

                            objClient.Fort.AddFortModifier(fortInfo.FortId, ItemId.ItemTroyDisk);

                            Setout.resumetimestamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds + 30000;
                            addedlure = true;
                        }
                    }

                    var farmed = CheckAndFarmNearbyPokeStop(pokestop, objClient, fortInfo);
                    if (farmed)
                    {
                        pokestop.CooldownCompleteTimestampMs = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds + 300500;
                    }

                    Setout.SetCheckTimeToRun();

                    RandomHelper.RandomSleep(30000, 40000);

                    // wait for a bit before repeating farm cycle to avoid spamming
                }

                if (!BotSettings.RelocateDefaultLocation)
                {
                    continue;
                }

                Setout.resumetimestamp      = -10000;
                BotSettings.pauseAtPokeStop = false;

                Logger.ColoredConsoleWrite(ConsoleColor.Magenta, "Exit Command detected - Ending break");
            } while (BotSettings.pauseAtPokeStop);
        }
コード例 #8
0
        private void FncPokeStop(Client client, FortData[] pokeStopsIn, bool metros30)
        {
            var distanceFromStart = LocationUtils
                                    .CalculateDistanceInMeters(
                BotSettings.DefaultLatitude,
                BotSettings.DefaultLongitude,
                objClient.CurrentLatitude,
                objClient.CurrentLongitude);

            lureEncounters.Clear();

            // TODO: do it optionable
            // Reordering array randomly to do it a little more difficult to detect.
            // Random rnd=new Random();
            //FortData[] pokeStops = pokeStopsIn.OrderBy(x => rnd.Next()).ToArray();
            var pokeStops = pokeStopsIn;

            //walk between pokestops in default collection
            var queue = new Queue <FortData>();

            foreach (var pokeStop in pokeStops)
            {
                queue.Enqueue(pokeStop);
            }

            for (var i = pokeStops.Length - 2; i > 0; i--)
            {
                queue.Enqueue(pokeStops[i]);
            }

            while (queue.Count > 0)
            {
                var pokeStop = queue.Dequeue();
                queue.Enqueue(pokeStop);
                #region Mystery Check by Cicklow

                // in Archimedean spiral only capture PokeStops if distance is < to 30 meters!
                if (metros30)
                {
                    var distance1 = LocationUtils
                                    .CalculateDistanceInMeters(
                        objClient.CurrentLatitude,
                        objClient.CurrentLongitude,
                        pokeStop.Latitude,
                        pokeStop.Longitude);

                    if (distance1 > 31 && FailedSoftban < 2)
                    {
                        //Logger.ColoredConsoleWrite(ConsoleColor.Green, "Pokestop mas: " + distance.ToString());
                        continue; //solo agarrar los pokestop que esten a menos de 30 metros
                    }
                }

                #endregion

                //make sure user defined limits have not been reached
                Setout.SetCheckTimeToRun();

                #region Walk defined Route

                if (GlobalVars.NextDestinationOverride.Count > 0)
                {
                    try
                    {
                        do
                        {
                            WalkUserRoute(pokeStops);

                            #region Check for Exit Command

                            if (BotSettings.RelocateDefaultLocation)
                            {
                                break;
                            }

                            #endregion

                            if (!BotSettings.RepeatUserRoute)
                            {
                                continue;
                            }

                            foreach (var geocoord in GlobalVars.RouteToRepeat)
                            {
                                GlobalVars.NextDestinationOverride.AddLast(geocoord);
                            }
                        } while (BotSettings.RepeatUserRoute);
                    }
                    catch (Exception e)
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, "Ignore this: sending exception information to log file.");
                        Logger.AddLog(string.Format("Error in Walk Defined Route: " + e));
                    }
                }

                #endregion

                #region Check for Exit Command


                if (BotSettings.RelocateDefaultLocation)
                {
                    break;
                }

                #endregion

                //get destination pokestop information
                var distance = LocationUtils
                               .CalculateDistanceInMeters(
                    objClient.CurrentLatitude,
                    objClient.CurrentLongitude,
                    pokeStop.Latitude,
                    pokeStop.Longitude);

                var fortInfo = objClient.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                //log error if pokestop not found
                if (fortInfo == null)
                {
                    Task.Factory.StartNew(() => infoObservable.PushPokeStopInfoUpdate(pokeStop, "!!Can't Get PokeStop Information!!"));
                    continue;
                }

                Logger.ColoredConsoleWrite(ConsoleColor.Green, $"Next Pokestop: {fortInfo.Name} in {distance:0.##}m distance.");

                #region Break At Lure Logic

                //check if user wants to break at lured pokestop
                if (BotSettings.BreakAtLure && fortInfo.Modifiers.Any())
                {
                    Setout.pausetimestamp  = -10000;
                    Setout.resumetimestamp = fortInfo.Modifiers.First().ExpirationTimestampMs;
                    var timeRemaining = Setout.resumetimestamp - (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds;

                    Logger.ColoredConsoleWrite(ConsoleColor.Magenta, "Active Lure at next Pokestop - Pausing walk for " + Math.Round(timeRemaining / 60 / 1000, 2) + " Minutes");

                    BotSettings.pauseAtPokeStop = true;
                }

                #endregion

                try
                {
                    WalkWithRouting(pokeStop.Latitude, pokeStop.Longitude);
                }
                catch (Exception e)
                {
                    Logger.ExceptionInfo(string.Format("Error in Walk Default Route: " + e));
                }

                // Pause and farm nearby pokestops
                if (BotSettings.pauseAtPokeStop)
                {
                    FarmPokestopOnBreak(pokeStops, client);
                }
            }
        }
コード例 #9
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
        }
コード例 #10
0
        public void Execute()
        {
            EnabledButton(false, th.TS("Reloading Pokemon list."));
            try
            {
                client = Logic.Logic.objClient;
                if (client.ReadyToUse)
                {
                    RandomHelper.RandomSleep(1000, 1200);

                    var pokemons        = client.Inventory.GetPokemons();
                    var pokemonSettings = Setout.GetPokemonSettings();
                    var pokemonFamilies = Setout.GetPokemonFamilies();
                    var profile         = client.Player;

                    try{
                        PokemonListView.BeginUpdate();
                    }catch (Exception ex1) {
                        Logger.ExceptionInfo(ex1.ToString());
                    }

                    PokemonListView.Items.Clear();

                    foreach (var pokemon in pokemons)
                    {
                        var listViewItem = new ListViewItem();
                        listViewItem.UseItemStyleForSubItems = false;

                        listViewItem.Tag = pokemon;
                        var currentCandy = pokemonFamilies
                                           .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                                           .Select(f => f.Candy_)
                                           .First();

                        var specSymbol = "";
                        if (pokemon.Favorite == 1)
                        {
                            specSymbol = "★";
                        }

                        if ((profile.PlayerResponse.PlayerData.BuddyPokemon != null) && (profile.PlayerResponse.PlayerData.BuddyPokemon.Id == pokemon.Id))
                        {
                            specSymbol = "☉";
                        }
                        listViewItem.Text = specSymbol + th.TS(pokemon.PokemonId.ToString());


                        listViewItem.ToolTipText = StringUtils.ConvertTimeMSinString(pokemon.CreationTimeMs, "dd/MM/yyyy HH:mm:ss");
                        if (pokemon.Nickname != "")
                        {
                            listViewItem.ToolTipText += th.TS("\n+Nickname: {0}", pokemon.Nickname);
                        }

                        var isbad = (pokemon.IsBad)?"Yes":"No";
                        listViewItem.SubItems.Add("" + isbad);

                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Cp));

                        if (checkBox_ShortName.Checked)
                        {
                            listViewItem.SubItems.Add(string.Format("{0}% {1}{2}{3} ({4})", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack.ToString("X"), pokemon.IndividualDefense.ToString("X"), pokemon.IndividualStamina.ToString("X"), (45 - pokemon.IndividualAttack - pokemon.IndividualDefense - pokemon.IndividualStamina)));
                        }
                        else
                        {
                            listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack, pokemon.IndividualDefense, pokemon.IndividualStamina));
                        }
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.GetLevel(pokemon)));

                        # region Evolve Column
                        var settings    = pokemonSettings.FirstOrDefault(x => x.PokemonId == pokemon.PokemonId);
                        var familyCandy = pokemonFamilies.FirstOrDefault(x => x.FamilyId == settings.FamilyId);
                        listViewItem.SubItems.Add("");
                        var    numOfEvolves = 0;
                        String strEvolves   = EvolvesToString(pokemon, settings, familyCandy, out numOfEvolves);
                        // Colour Management
                        listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.DarkRed;
                        if (numOfEvolves == 1)
                        {
                            listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.ForestGreen;
                        }
                        else if (numOfEvolves > 1)
                        {
                            listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.LightPink;
                        }
                        listViewItem.SubItems[listViewItem.SubItems.Count - 1].Text = $"{strEvolves} | C:{familyCandy.Candy_}";
                        # endregion Evolve Column

                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.HeightM, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.WeightKg, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}/{1}", pokemon.Stamina, pokemon.StaminaMax));
                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Move1));
                        listViewItem.SubItems.Add(string.Format("{0} ({1})", pokemon.Move2, PokemonInfo.GetAttack(pokemon.Move2)));
                        listViewItem.SubItems.Add(string.Format("{0}", (int)pokemon.PokemonId));
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.CalculatePokemonPerfectionCP(pokemon).ToString("0.00")));

                        AdditionalPokeData addData = additionalPokeData.FirstOrDefault(x => x.PokedexNumber == (int)pokemon.PokemonId);
                        if (addData != null)
                        {
                            listViewItem.SubItems.Add(addData.Type1);
                            listViewItem.SubItems.Add(addData.Type2);
                        }
                        else
                        {
                            listViewItem.SubItems.Add("");
                            listViewItem.SubItems.Add("");
                        }
                        // NOTE: yyyy/MM/dd is inverted order to can sort correctly as text.
                        listViewItem.SubItems.Add(StringUtils.ConvertTimeMSinString(pokemon.CreationTimeMs, "yyyy/MM/dd HH:mm:ss"));
                        listViewItem.SubItems.Add(th.TS(pokemon.Pokeball.ToString().Replace("Item", "")));
                        listViewItem.SubItems.Add("" + pokemon.NumUpgrades);
                        listViewItem.SubItems.Add("" + pokemon.BattlesAttacked);
                        listViewItem.SubItems.Add("" + pokemon.BattlesDefended);
                        listViewItem.SubItems.Add("" + pokemon.DeployedFortId);
                        if (pokemon.DeployedFortId != "")
                        {
                            listViewItem.SubItems[0].BackColor = Color.Bisque;
                        }

                        var CapturedLatlng = S2Helper.GetLatLng(pokemon.CapturedCellId);
                        listViewItem.SubItems.Add(LocationUtils.FindAddress(CapturedLatlng[0], CapturedLatlng[1]));
                        listViewItem.SubItems.Add("" + pokemon.PokemonDisplay.Gender);
                        var str = "";
                        if (pokemon.PokemonDisplay.Costume != Costume.Unset)
                        {
                            str = pokemon.PokemonDisplay.Costume.ToString();
                        }
                        listViewItem.SubItems.Add("" + str);
                        var form = "";
                        if (pokemon.PokemonDisplay.Form != POGOProtos.Enums.Form.Unset)
                        {
                            form = pokemon.PokemonDisplay.Form.ToString().Replace("Unown", "").Replace("ExclamationPoint", "!").Replace("QuestionMark", "?");
                        }
                        listViewItem.SubItems.Add("" + form);

                        var shiny = (pokemon.PokemonDisplay.Shiny)?"Yes":"No";
                        listViewItem.SubItems.Add("" + shiny);

                        listViewItem.SubItems.Add("" + pokemon.BuddyCandyAwarded);
                        listViewItem.SubItems.Add("" + pokemon.BuddyTotalKmWalked);
                        listViewItem.SubItems.Add("" + pokemon.Id.ToString("X"));

                        var special = "";
                        if (GlobalVars.UseSpritesFolder)
                        {
                            if (pokemon.PokemonId == PokemonId.Unown)
                            {
                                special = form.ToLower();
                            }
                            else if (shiny == "Yes")
                            {
                                special = "s";
                            }
                            else if (pokemon.PokemonDisplay.Costume != Costume.Unset)
                            {
                                special = pokemon.PokemonDisplay.Costume.ToString().ToLower();
                            }
                        }

                        listViewItem.ImageKey = pokemon.PokemonId + special;

                        PokemonListView.Items.Add(listViewItem);
                    }
                    try{
                        PokemonListView.EndUpdate();
                    }catch (Exception ex1) {
                        Logger.ExceptionInfo(ex1.ToString());
                    }
                    PokemonListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    EnabledButton(true);
                    statusTexbox.Text = string.Empty;
                    RefreshTitle();
                }