private static SniperInfo ParseLine(string line)
        {
            var match = Regex.Match(line,
                                    @"(?<id>\d+)\|(?<lat>\-?\d+[\,|\.]\d+)\|(?<lon>\-?\d+[\,|\.]\d+)\|(?<expires>\d+)\|(?<verified>[1|0])\|\|");

            if (match.Success)
            {
                var sniperInfo = new SniperInfo();
                var pokemonId  = PokemonParser.ParseById(Convert.ToInt64(match.Groups["id"].Value));
                sniperInfo.Id = pokemonId;
                var lat = Convert.ToDouble(match.Groups["lat"].Value, CultureInfo.InvariantCulture);
                var lon = Convert.ToDouble(match.Groups["lon"].Value, CultureInfo.InvariantCulture);

                sniperInfo.Latitude  = Math.Round(lat, 7);
                sniperInfo.Longitude = Math.Round(lon, 7);

                var expires = Convert.ToInt64(match.Groups["expires"].Value);
                if (expires != default(long))
                {
                    var epoch     = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                    var untilTime = epoch.AddSeconds(expires).ToLocalTime();
                    if (untilTime < DateTime.Now)
                    {
                        return(null);
                    }
                    sniperInfo.ExpirationTimestamp = DateTime.Now.AddMinutes(Constants.MaxExpirationInTheFuture) < untilTime?
                                                     DateTime.Now.AddMinutes(Constants.MaxExpirationInTheFuture) : untilTime;
                }
                sniperInfo.ChannelInfo = new ChannelInfo {
                    server = Channel
                };
                return(sniperInfo);
            }
            return(null);
        }
        public static List <SniperInfo> FilterNonAvailableAndUpdateMissingPokemonId(List <SniperInfo> sniperInfos)
        {
            if (!GlobalSettings.VerifyOnSkiplagged)
            {
                return(sniperInfos);
            }
            var newSniperInfos      = new List <SniperInfo>();
            var filteredSniperInfos = SkipLaggedCache.FindUnSentMessages(sniperInfos);

            foreach (var sniperInfo in filteredSniperInfos)
            {
                var scanResult = ScanLocation(new GeoCoordinates(sniperInfo.Latitude, sniperInfo.Longitude));
                if (scanResult.Status == "fail" || scanResult.Status == "error")
                {
                    sniperInfo.Verified = false;
                    newSniperInfos.Add(sniperInfo);
                }
                else if (scanResult.pokemons != null)
                {
                    var st = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                    var t  = DateTime.Now.ToUniversalTime() - st;
                    var currentTimestamp  = t.TotalMilliseconds;
                    var pokemonsToFeed    = PokemonParser.ParsePokemons(GlobalSettings.PokekomsToFeedFilter);
                    var filteredPokemon   = scanResult.pokemons.Where(q => pokemonsToFeed.Contains(PokemonParser.ParseById(q.pokemon_id)));
                    var notExpiredPokemon = filteredPokemon.Where(q => q.expires < currentTimestamp);

                    if (notExpiredPokemon.Any())
                    {
                        foreach (var pokemonLocation in notExpiredPokemon)
                        {
                            SniperInfo newSniperInfo = new SniperInfo();

                            if (sniperInfo.Id.Equals(pokemonLocation.Id))
                            {
                                newSniperInfo.IV = sniperInfo.IV;
                            }
                            newSniperInfo.Id                  = PokemonParser.ParseById(pokemonLocation.pokemon_id);
                            newSniperInfo.Latitude            = pokemonLocation.latitude;
                            newSniperInfo.Longitude           = pokemonLocation.longitude;
                            newSniperInfo.Verified            = true;
                            newSniperInfo.ExpirationTimestamp = FromUnixTime(pokemonLocation.expires);
                            newSniperInfos.Add(newSniperInfo);
                        }
                    }
                    else
                    {
                        Log.Trace($"No snipable pokemon found at {sniperInfo.Latitude.ToString(CultureInfo.InvariantCulture)},{sniperInfo.Longitude.ToString(CultureInfo.InvariantCulture)}");
                    }
                }
            }
            return(newSniperInfos);
        }
        private static SniperInfo Map(TrackemonResult result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParseById(result.id);

            sniperInfo.Id = pokemonId;

            sniperInfo.Latitude  = result.latitude;
            sniperInfo.Longitude = result.longitude;


            sniperInfo.ExpirationTimestamp = DateTime.Now.AddTicks(result.expiration);
            return(sniperInfo);
        }
Exemple #4
0
        public static List <PokemonId> ParseBinary(string binairy)
        {
            if (binairy.Length != pokemonSize)
            {
                throw new Exception("Needs to be at least 3 times as big");
            }
            List <PokemonId> pokemonId = new List <PokemonId>();
            var bins = binairy.ToCharArray();

            for (int i = 0; i < pokemonSize; i++)
            {
                if (bins[i] == '1')
                {
                    pokemonId.Add(PokemonParser.ParseById(i));
                }
            }
            return(pokemonId);
        }
Exemple #5
0
        private static SniperInfo Map(TrackemonResult result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParseById(result.id);

            sniperInfo.Id = pokemonId;

            sniperInfo.Latitude    = Math.Round(result.latitude, 7);
            sniperInfo.Longitude   = Math.Round(result.longitude, 7);
            sniperInfo.ChannelInfo = new ChannelInfo {
                server = Channel
            };

            var timeStamp = DateTime.Now.AddTicks(result.expiration);

            sniperInfo.ExpirationTimestamp = DateTime.Now.AddMinutes(Constants.MaxExpirationInTheFuture) < timeStamp?
                                             DateTime.Now.AddMinutes(Constants.MaxExpirationInTheFuture) : timeStamp;

            return(sniperInfo);
        }
        private SniperInfo Map(PokezzPokemon result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParseById(result.id);

            if (!_pokemonIdsToFind.Contains(pokemonId))
            {
                return(null);
            }
            sniperInfo.Id        = pokemonId;
            sniperInfo.Latitude  = result.lat;
            sniperInfo.Longitude = result.lng;
            if (result.time != default(long))
            {
                var epoch     = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                var untilTime = epoch.AddMilliseconds(result.time).ToLocalTime();
                if (untilTime < DateTime.Now)
                {
                    return(null);
                }
                sniperInfo.ExpirationTimestamp = untilTime;
            }
            return(sniperInfo);
        }
        public List <SniperInfo> FilterNonAvailableAndUpdateMissingPokemonId(List <SniperInfo> sniperInfos)
        {
            if (!GlobalSettings.VerifyOnSkiplagged)
            {
                return(sniperInfos);
            }
            if (!_skipLaggedWorking)
            {
                Log.Debug($"Skiplagged is marked as down, not checking {sniperInfos.Count} sniperInfos");
                return(sniperInfos);
            }
            var newSniperInfos = new List <SniperInfo>();

            foreach (var sniperInfo in sniperInfos)
            {
                if (sniperInfo.Verified)
                {
                    newSniperInfos.Add(sniperInfo);
                    continue;
                }
                var scanResult = ScanLocation(new GeoCoordinates(sniperInfo.Latitude, sniperInfo.Longitude));
                if (scanResult.Status == "fail" ||
                    scanResult.Status == "error" ||
                    scanResult.pokemons == null ||
                    !scanResult.pokemons.Any())
                {
                    sniperInfo.Verified = false;
                    newSniperInfos.Add(sniperInfo);
                }
                else if (scanResult.pokemons != null && scanResult.pokemons.Any())
                {
                    var st = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                    var t  = DateTime.Now.ToUniversalTime() - st;
                    var currentTimestamp = t.TotalMilliseconds;
                    var pokemonsToFeed   = PokemonParser.ParsePokemons(GlobalSettings.PokekomsToFeedFilter);
                    var filteredPokemon  =
                        scanResult.pokemons.Where(q => pokemonsToFeed.Contains(PokemonParser.ParseById(q.pokemon_id)));
                    var notExpiredPokemon = filteredPokemon.Where(q => q.expires < currentTimestamp).ToList();

                    if (notExpiredPokemon.Any())
                    {
                        foreach (var pokemonLocation in notExpiredPokemon)
                        {
                            var newSniperInfo = new SniperInfo();

                            if (((long)sniperInfo.Id).Equals(pokemonLocation.Id))
                            {
                                newSniperInfo.IV = sniperInfo.IV;
                            }
                            newSniperInfo.Id          = PokemonParser.ParseById(pokemonLocation.pokemon_id);
                            newSniperInfo.Latitude    = Math.Round(pokemonLocation.latitude, 7);
                            newSniperInfo.Longitude   = Math.Round(pokemonLocation.longitude, 7);
                            newSniperInfo.Verified    = true;
                            newSniperInfo.VerifiedOn  = DateTime.Now;
                            newSniperInfo.ChannelInfo = sniperInfo.ChannelInfo;
                            var timeStamp = FromUnixTime(pokemonLocation.expires);
                            newSniperInfo.ExpirationTimestamp = DateTime.Now.AddMinutes(Constants.MaxExpirationInTheFuture) < timeStamp?DateTime.Now.AddMinutes(Constants.MaxExpirationInTheFuture) : timeStamp;

                            newSniperInfos.Add(newSniperInfo);
                        }
                    }
                    else
                    {
                        sniperInfo.Verified = false;
                        newSniperInfos.Add(sniperInfo);
                        Log.Trace(
                            $"No snipable pokemon found at {sniperInfo.Latitude.ToString(CultureInfo.InvariantCulture)},{sniperInfo.Longitude.ToString(CultureInfo.InvariantCulture)}");
                    }
                }
            }
            return(newSniperInfos);
        }