private static List <SniperInfo> GetSniperInfoFrom_pokewatchers(ISession session, List <PokemonId> pokemonIds) { var uri = $"http://pokewatchers.com/api.php?act=grab"; ScanResult_pokewatchers scanResult_pokewatchers; try { var handler = new ClearanceHandler(); // Create a HttpClient that uses the handler. var client = new HttpClient(handler); // Use the HttpClient as usual. Any JS challenge will be solved automatically for you. var fullresp = "{ \"pokemons\":" + client.GetStringAsync(uri) .Result.Replace(" M", "Male") .Replace(" F", "Female") .Replace("Farfetch'd", "Farfetchd") .Replace("Mr.Maleime", "MrMime") + "}"; scanResult_pokewatchers = JsonConvert.DeserializeObject <ScanResult_pokewatchers>(fullresp); } catch (Exception ex) { // most likely System.IO.IOException session.EventDispatcher.Send(new ErrorEvent { Message = "(PokeWatchers.com) " + ex.Message }); return(new List <SniperInfo>()); } if (scanResult_pokewatchers.pokemons != null) { foreach (var pokemon in scanResult_pokewatchers.pokemons) { try { var SnipInfo = new SniperInfo(); SnipInfo.Id = pokemon.pokemon; var coordsArray = pokemon.cords.Split(','); SnipInfo.Latitude = Convert.ToDouble(coordsArray[0], CultureInfo.InvariantCulture); SnipInfo.Longitude = Convert.ToDouble(coordsArray[1], CultureInfo.InvariantCulture); SnipInfo.TimeStampAdded = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Math.Round(pokemon.timeadded / 1000d)) .ToLocalTime(); SnipInfo.ExpirationTimestamp = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Math.Round(pokemon.timeend / 1000d)) .ToLocalTime(); SnipeLocations.Add(SnipInfo); } catch { } } var locationsToSnipe = SnipeLocations?.Where(q => (!session.LogicSettings.UseTransferIvForSnipe || (q.IV == 0 && !session.LogicSettings.SnipeIgnoreUnknownIv) || (q.IV >= session.Inventory.GetPokemonTransferFilter(q.Id).KeepMinIvPercentage)) && !LocsVisited.Contains(new PokemonLocation(q.Latitude, q.Longitude)) && !(q.ExpirationTimestamp != default(DateTime) && q.ExpirationTimestamp > new DateTime(2016) && // make absolutely sure that the server sent a correct datetime q.ExpirationTimestamp < DateTime.Now) && (q.Id == PokemonId.Missingno || pokemonIds.Contains(q.Id))).ToList() ?? new List <SniperInfo>(); return(locationsToSnipe.OrderBy(q => q.ExpirationTimestamp).ToList()); } return(new List <SniperInfo>()); }
private static List <SniperInfo> GetSniperInfoFrom_pokezz(ISession session, List <PokemonId> pokemonIds) { var options = new IO.Options(); options.Transports = ImmutableList.Create("websocket"); var socket = IO.Socket("http://pokezz.com", options); var hasError = false; var waitforbroadcast = new ManualResetEventSlim(false); var pokemons = new List <PokemonLocation_pokezz>(); socket.On("pokemons", msg => { socket.Close(); var data = JArray.FromObject(msg); foreach (var pokeToken in data.Children()) { var Token = pokeToken.ToString() .Replace(" M", "Male") .Replace(" F", "Female") .Replace("Farfetch'd", "Farfetchd") .Replace("Mr.Maleime", "MrMime"); pokemons.Add(JToken.Parse(Token).ToObject <PokemonLocation_pokezz>()); } waitforbroadcast.Set(); }); socket.On(Socket.EVENT_ERROR, () => { socket.Close(); hasError = true; waitforbroadcast.Set(); }); socket.On(Socket.EVENT_CONNECT_ERROR, () => { socket.Close(); hasError = true; waitforbroadcast.Set(); }); waitforbroadcast.Wait(); if (!hasError) { foreach (var pokemon in pokemons) { var SnipInfo = new SniperInfo(); SnipInfo.Id = pokemon.name; SnipInfo.Latitude = pokemon.lat; SnipInfo.Longitude = pokemon.lng; SnipInfo.TimeStampAdded = DateTime.Now; SnipInfo.ExpirationTimestamp = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Math.Round(pokemon.time / 1000d)).ToLocalTime(); SnipInfo.IV = pokemon._iv; if (pokemon.verified || !session.LogicSettings.GetOnlyVerifiedSniperInfoFromPokezz) { SnipeLocations.Add(SnipInfo); } } var locationsToSnipe = SnipeLocations?.Where(q => (!session.LogicSettings.UseTransferIvForSnipe || (q.IV == 0 && !session.LogicSettings.SnipeIgnoreUnknownIv) || (q.IV >= session.Inventory.GetPokemonTransferFilter(q.Id).KeepMinIvPercentage)) && !LocsVisited.Contains(new PokemonLocation(q.Latitude, q.Longitude)) && !(q.ExpirationTimestamp != default(DateTime) && q.ExpirationTimestamp > new DateTime(2016) && // make absolutely sure that the server sent a correct datetime q.ExpirationTimestamp < DateTime.Now) && (q.Id == PokemonId.Missingno || pokemonIds.Contains(q.Id))).ToList() ?? new List <SniperInfo>(); return(locationsToSnipe.OrderBy(q => q.ExpirationTimestamp).ToList()); } session.EventDispatcher.Send(new ErrorEvent { Message = "(Pokezz.com) Connection Error" }); return(new List <SniperInfo>()); }