public void findUnSentMessagesTest()
        {
            MessageCache messageCache = new MessageCache();
            SniperInfo sniperInfo =  new SniperInfo();
            sniperInfo.latitude = 1;
            sniperInfo.longitude = 2;
            sniperInfo.timeStamp = DateTime.Now.AddMilliseconds(100);

            SniperInfo sniperInfo2= new SniperInfo();
            sniperInfo2.latitude = 1;
            sniperInfo2.longitude = 2;

            SniperInfo differntSniperInfo = new SniperInfo();
            differntSniperInfo.latitude = 4;
            differntSniperInfo.longitude = 5;
            differntSniperInfo.timeStamp = DateTime.Now.AddMilliseconds(100);

            List<SniperInfo> unsentMessages = messageCache.findUnSentMessages(new List<SniperInfo>() { sniperInfo });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);

            unsentMessages = messageCache.findUnSentMessages(new List<SniperInfo>() { sniperInfo2 });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(0, unsentMessages.Count);

            unsentMessages = messageCache.findUnSentMessages(new List<SniperInfo>() { differntSniperInfo });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);

            Thread.Sleep(110);

            unsentMessages = messageCache.findUnSentMessages(new List<SniperInfo>() { sniperInfo2 });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);
        }
        private SniperInfo map(Result result)
        {
            SniperInfo sniperInfo = new SniperInfo();
            PokemonId  pokemonId  = PokemonParser.parsePokemon(result.name);

            if (!pokemonIdsToFind.Contains(pokemonId))
            {
                return(null);
            }
            sniperInfo.Id = pokemonId;
            GeoCoordinates geoCoordinates = GeoCoordinatesParser.parseGeoCoordinates(result.coords);

            if (geoCoordinates == null)
            {
                return(null);
            }
            else
            {
                sniperInfo.Latitude  = geoCoordinates.latitude;
                sniperInfo.Longitude = geoCoordinates.longitude;
            }

            sniperInfo.ExpirationTimestamp = Convert.ToDateTime(result.until);
            return(sniperInfo);
        }
Пример #3
0
        public int Remove(SniperInfo toRemove)
        {
            int b = 0;

            _sniperInfoSet.TryRemove(toRemove, out b);
            return(b);
        }
Пример #4
0
        public int Update(SniperInfo sniperInfo)
        {
            int count = Remove(sniperInfo);

            _sniperInfoSet.TryAdd(sniperInfo, count);
            return(count);
        }
Пример #5
0
        private static SniperInfo Map(PokemonCaptureEvent pokemonCaptureEvent)
        {
            var sniperInfo = new SniperInfo();

            sniperInfo.ChannelInfo = new ChannelInfo()
            {
                server = Constants.Bot
            };
            sniperInfo.IV         = pokemonCaptureEvent.Perfection;
            sniperInfo.Id         = pokemonCaptureEvent.Id;
            sniperInfo.Latitude   = Math.Round(pokemonCaptureEvent.Latitude, 7);
            sniperInfo.Longitude  = Math.Round(pokemonCaptureEvent.Longitude, 7);
            sniperInfo.Verified   = true;
            sniperInfo.VerifiedOn = DateTime.Now;
            if (pokemonCaptureEvent is NewPokemonCaptureEvent)
            {
                var newPokemonCaptureEvent = (NewPokemonCaptureEvent)pokemonCaptureEvent;
                sniperInfo.ExpirationTimestamp = FromUnixTime(newPokemonCaptureEvent.Expires);
                sniperInfo.SpawnPointId        = newPokemonCaptureEvent.SpawnPointId;
                sniperInfo.Move1       = newPokemonCaptureEvent.Move1;
                sniperInfo.Move2       = newPokemonCaptureEvent.Move2;
                sniperInfo.EncounterId = newPokemonCaptureEvent.EncounterId;
                if (newPokemonCaptureEvent.CatchTypeText != "normal")
                {
                    Log.Trace("Skipping pokemon because it was not a wild pokemon");
                }
            }
            return(sniperInfo);
        }
        private SniperInfo Map(PokewatchersResult result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            sniperInfo.Id = pokemonId;
            var geoCoordinates = GeoCoordinatesParser.ParseGeoCoordinates(result.coords);

            if (geoCoordinates == null)
            {
                return(null);
            }
            sniperInfo.Latitude  = Math.Round(geoCoordinates.Latitude, 7);
            sniperInfo.Longitude = Math.Round(geoCoordinates.Longitude, 7);

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

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

            sniperInfo.ChannelInfo = new ChannelInfo {
                server = Channel
            };

            return(sniperInfo);
        }
        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 List<SniperInfo> parseMessage(string message)
        {
            var snipeList = new List<SniperInfo>();
            var lines = message.Split(new[] { '\r', '\n' });

            foreach (var input in lines)
            {
                sniperInfo = new SniperInfo();
                GeoCoordinates geoCoordinates = GeoCoordinatesParser.parseGeoCoordinates(input);
                if (geoCoordinates == null)
                {
                    Log.Debug($"Can't get coords from line: {input}");
                    continue;
                }
                else
                {
                    sniperInfo.Latitude = geoCoordinates.latitude;
                    sniperInfo.Longitude = geoCoordinates.longitude;
                }
                double iv = IVParser.parseIV(input);
                sniperInfo.IV = iv;
                parseTimestamp(input);
                PokemonId pokemon = PokemonParser.parsePokemon(input);
                sniperInfo.Id = pokemon;
                snipeList.Add(sniperInfo);
            }

            return snipeList;
        }
Пример #9
0
        public int Increase(SniperInfo sniperInfo)
        {
            int count = Remove(sniperInfo);

            count++;
            _sniperInfoSet.TryAdd(sniperInfo, count);
            return(count);
        }
Пример #10
0
        private static bool IsExpired(SniperInfo sniperInfo)
        {
            var xMinuteAgo = DateTime.Now.AddMinutes(-1 * MinutesToKeepInCache);

            return((sniperInfo.ExpirationTimestamp == default(DateTime) &&
                    sniperInfo.ReceivedTimeStamp < xMinuteAgo) ||
                   (sniperInfo.ExpirationTimestamp != default(DateTime) &&
                    sniperInfo.ExpirationTimestamp < DateTime.Now));
        }
Пример #11
0
        public void FindUnSentMessagesTest()
        {
            var messageCache = MessageCache.Instance;
            var sniperInfo   = new SniperInfo
            {
                Latitude            = 1,
                Longitude           = 2,
                ExpirationTimestamp = DateTime.Now.AddMilliseconds(100),
                ReceivedTimeStamp   = DateTime.Now
            };
            var sniperInfo2 = new SniperInfo
            {
                Latitude          = 1,
                Longitude         = 2,
                ReceivedTimeStamp = DateTime.Now
            };

            var differntSniperInfo = new SniperInfo
            {
                Latitude            = 4,
                Longitude           = 5,
                ExpirationTimestamp = DateTime.Now.AddMilliseconds(100),
                ReceivedTimeStamp   = DateTime.Now
            };

            var unsentMessages = messageCache.FindUnSentMessages(new List <SniperInfo> {
                sniperInfo
            });

            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);
            Assert.AreEqual(1, MessageCache.Instance._clientRepository.Count());

            unsentMessages = messageCache.FindUnSentMessages(new List <SniperInfo> {
                sniperInfo2
            });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(0, unsentMessages.Count);
            Assert.AreEqual(1, MessageCache.Instance._clientRepository.Count());

            unsentMessages = messageCache.FindUnSentMessages(new List <SniperInfo> {
                differntSniperInfo
            });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);
            Assert.AreEqual(2, MessageCache.Instance._clientRepository.Count());

            Thread.Sleep(200);
            Assert.AreEqual(0, MessageCache.Instance._clientRepository.Count());

            unsentMessages = messageCache.FindUnSentMessages(new List <SniperInfo> {
                sniperInfo2
            });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);
        }
Пример #12
0
        private SniperInfo createSniperInfo()
        {
            SniperInfo sniperInfo = new SniperInfo();

            sniperInfo.Id        = POGOProtos.Enums.PokemonId.Abra;
            sniperInfo.Latitude  = 12.345;
            sniperInfo.Longitude = -98.765;
            sniperInfo.IV        = 95.6;
            return(sniperInfo);
        }
        private SniperInfo createSniperInfo()
        {
            var sniperInfo = new SniperInfo();

            sniperInfo.Id        = PokemonId.Abra;
            sniperInfo.Latitude  = 12.345;
            sniperInfo.Longitude = -98.765;
            sniperInfo.IV        = 95.6;
            return(sniperInfo);
        }
        private static SniperInfo Map(PokemongoivclubPokemon result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            sniperInfo.Id        = pokemonId;
            sniperInfo.Latitude  = result.lat;
            sniperInfo.Longitude = result.lon;
            return(sniperInfo);
        }
Пример #15
0
 public bool BotCapture(SniperInfo sniperInfo)
 {
     if (GlobalSettings.IsManaged)
     {
         PogoClient.sniperInfosToSend.Enqueue(sniperInfo);
         MessageCache.Instance.Add(sniperInfo);
         return(true);
     }
     return(false);
 }
        public bool Matches(SniperInfo sniperInfo)
        {
            var pokemonIds = PokemonFilterParser.ParseBinary(Pokemon);

            if (pokemonIds == null || pokemonIds.Contains(sniperInfo.Id))
            {
                return(AreaBounds == null || AreaBounds.Intersects(sniperInfo.Latitude, sniperInfo.Longitude));
            }
            return(false);
        }
 private bool isSentAlready(SniperInfo sniperInfo)
 {
     String coordinates = getCoordinatesString(sniperInfo);
     if(MemoryCache.Default.Contains(coordinates))
     {
         return true;
     }
     DateTime expirationDate = sniperInfo.timeStamp != default(DateTime) ? sniperInfo.timeStamp : DateTime.Now.AddMinutes(15);
     MemoryCache.Default.Add(coordinates, sniperInfo, new DateTimeOffset(expirationDate));
     return false;
 }
Пример #18
0
 protected virtual void OnReceivedViaClients(SniperInfo sniperInfo)
 {
     if (GlobalSettings.IsManaged && GlobalSettings.ShareBotCaptures)
     {
         if (Constants.Bot == sniperInfo.ChannelInfo?.server ||
             Constants.PogoFeeder == sniperInfo.ChannelInfo?.server)
         {
             PogoClient.sniperInfosToSend.Enqueue(sniperInfo);
         }
     }
     ReceivedViaClients?.Invoke(this, sniperInfo);
 }
        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);
        }
Пример #20
0
        public void RemoveExpired()
        {
            SniperInfo foundSniperInfo = null;

            foreach (SniperInfo sniperInfo in _sniperInfoSet.Keys)
            {
                if (IsExpired(sniperInfo))
                {
                    Log.Trace("Expired: " + sniperInfo);
                    Remove(sniperInfo);
                }
            }
        }
Пример #21
0
 public void PrintPokemon(SniperInfo sniperInfo, string server, string channel)
 {
     Application.Current.Dispatcher.BeginInvoke((Action)delegate () {
         var info = new SniperInfoModel
         {
             Info = sniperInfo,
             Icon = new BitmapImage(new Uri(Path.Combine(iconPath, $"{(int)sniperInfo.Id}.png"))),
             Server = server,
             Channel = channel
         };
         InsertToList(info);
     });
 }
Пример #22
0
        public SniperInfo Find(SniperInfo newSniperInfo)
        {
            SniperInfo foundSniperInfo = null;

            foreach (SniperInfo sniperInfo in _sniperInfoSet.Keys)
            {
                if (SniperInfoEquals(sniperInfo, newSniperInfo))
                {
                    foundSniperInfo = sniperInfo;
                }
            }
            return(foundSniperInfo);
        }
Пример #23
0
 public void PrintPokemon(SniperInfo sniperInfo, string server, string channel)
 {
     Application.Current.Dispatcher.BeginInvoke((Action) delegate() {
         var info = new SniperInfoModel
         {
             Info    = sniperInfo,
             Icon    = new BitmapImage(new Uri($"pack://application:,,,/PogoLocationFeeder.GUI;component/Assets/icons/{(int)sniperInfo.Id}.png", UriKind.Absolute)),
             Server  = server,
             Channel = channel
         };
         InsertToList(info);
     });
 }
        private static SniperInfo Map(PokemongoivclubPokemon result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            sniperInfo.Id          = pokemonId;
            sniperInfo.Latitude    = Math.Round(result.lat, 7);
            sniperInfo.Longitude   = Math.Round(result.lon, 7);
            sniperInfo.ChannelInfo = new ChannelInfo {
                server = Channel
            };
            return(sniperInfo);
        }
Пример #25
0
 public void PrintPokemon(SniperInfo sniperInfo, string server, string channel)
 {
     Application.Current.Dispatcher.BeginInvoke((Action) delegate() {
         var info = new SniperInfoModel
         {
             Info    = sniperInfo,
             Icon    = new BitmapImage(new Uri(Path.Combine(iconPath, $"{(int)sniperInfo.Id}.png"))),
             Server  = server,
             Channel = channel
         };
         InsertToList(info);
     });
 }
        public void findUnSentMessagesTest()
        {
            MessageCache messageCache = new MessageCache();
            SniperInfo   sniperInfo   = new SniperInfo();

            sniperInfo.Latitude            = 1;
            sniperInfo.Longitude           = 2;
            sniperInfo.ExpirationTimestamp = DateTime.Now.AddMilliseconds(100);

            SniperInfo sniperInfo2 = new SniperInfo();

            sniperInfo2.Latitude  = 1;
            sniperInfo2.Longitude = 2;

            SniperInfo differntSniperInfo = new SniperInfo();

            differntSniperInfo.Latitude            = 4;
            differntSniperInfo.Longitude           = 5;
            differntSniperInfo.ExpirationTimestamp = DateTime.Now.AddMilliseconds(100);

            List <SniperInfo> unsentMessages = messageCache.findUnSentMessages(new List <SniperInfo>()
            {
                sniperInfo
            });

            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);

            unsentMessages = messageCache.findUnSentMessages(new List <SniperInfo>()
            {
                sniperInfo2
            });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(0, unsentMessages.Count);

            unsentMessages = messageCache.findUnSentMessages(new List <SniperInfo>()
            {
                differntSniperInfo
            });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);

            Thread.Sleep(110);

            unsentMessages = messageCache.findUnSentMessages(new List <SniperInfo>()
            {
                sniperInfo2
            });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);
        }
        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;
        }
Пример #28
0
        private SniperInfo Map(PokeSpawnsPokemon result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            if (!_pokemonIdsToFind.Contains(pokemonId))
            {
                return(null);
            }
            sniperInfo.Id        = pokemonId;
            sniperInfo.Latitude  = result.lat;
            sniperInfo.Longitude = result.lon;
            return(sniperInfo);
        }
        private SniperInfo map(TrackemonResult result)
        {
            SniperInfo sniperInfo = new SniperInfo();
            PokemonId  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);
        }
Пример #30
0
        public void FindUnSentMessagesTest()
        {
            var messageCache = new MessageCache();
            var sniperInfo   = new SniperInfo
            {
                Latitude            = 1,
                Longitude           = 2,
                ExpirationTimestamp = DateTime.Now.AddMilliseconds(100)
            };

            var sniperInfo2 = new SniperInfo
            {
                Latitude  = 1,
                Longitude = 2
            };

            var differntSniperInfo = new SniperInfo
            {
                Latitude            = 4,
                Longitude           = 5,
                ExpirationTimestamp = DateTime.Now.AddMilliseconds(100)
            };

            var unsentMessages = messageCache.FindUnSentMessages(new List <SniperInfo> {
                sniperInfo
            });

            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);

            unsentMessages = messageCache.FindUnSentMessages(new List <SniperInfo> {
                sniperInfo2
            });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(0, unsentMessages.Count);

            unsentMessages = messageCache.FindUnSentMessages(new List <SniperInfo> {
                differntSniperInfo
            });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);

            Thread.Sleep(110);

            unsentMessages = messageCache.FindUnSentMessages(new List <SniperInfo> {
                sniperInfo2
            });
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);
        }
            private static bool IsSentAlready(SniperInfo sniperInfo)
            {
                var coordinates = GetCoordinatesString(sniperInfo);

                if (MemoryCache.Default.Contains(coordinates))
                {
                    Log.Trace($"Skipping duplicate {sniperInfo}");
                    return(true);
                }
                var expirationDate = DateTime.Now.AddMinutes(MinutesToAddInCache);

                MemoryCache.Default.Add(coordinates, sniperInfo, new DateTimeOffset(expirationDate));
                return(false);
            }
Пример #32
0
 private static bool IsSentAlready(SniperInfo sniperInfo)
 {
     var coordinates = GetCoordinatesString(sniperInfo);
     if (MemoryCache.Default.Contains(coordinates))
     {
         Log.Trace($"Skipping duplicate {sniperInfo}");
         return true;
     }
     var expirationDate = sniperInfo.ExpirationTimestamp != default(DateTime)
         ? sniperInfo.ExpirationTimestamp
         : DateTime.Now.AddMinutes(15);
     MemoryCache.Default.Add(coordinates, sniperInfo, new DateTimeOffset(expirationDate));
     return false;
 }
Пример #33
0
        private SniperInfo Map(PokeSnipeResult result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId  = PokemonParser.ParsePokemon(result.name);

            sniperInfo.Id        = pokemonId;
            sniperInfo.Latitude  = result.lat;
            sniperInfo.Longitude = result.lon;

            sniperInfo.ChannelInfo = new ChannelInfo {
                server = Channel
            };
            return(sniperInfo);
        }
        private List <SniperInfo> getJsonList(string reader)
        {
            Wrapper           wrapper = JsonConvert.DeserializeObject <Wrapper>(reader);
            List <SniperInfo> list    = new List <SniperInfo>();

            foreach (Result result in wrapper.results)
            {
                SniperInfo sniperInfo = map(result);
                if (sniperInfo != null)
                {
                    list.Add(sniperInfo);
                }
            }
            return(list);
        }
Пример #35
0
 private static bool SniperInfoEquals(SniperInfo a, SniperInfo b)
 {
     if (Math.Abs(a.Latitude - b.Latitude) <= CoordinatesOffsetAllowed &&
         Math.Abs(a.Longitude - b.Longitude) <= CoordinatesOffsetAllowed)
     {
         if (a.Id.Equals(PokemonId.Missingno) || b.Id.Equals(PokemonId.Missingno))
         {
             return(true);
         }
         if (a.Id.Equals(b.Id))
         {
             return(true);
         }
     }
     return(false);
 }
        private SniperInfo Map(Result result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId = PokemonParser.ParsePokemon(result.name);
            sniperInfo.Id = pokemonId;
            var geoCoordinates = GeoCoordinatesParser.ParseGeoCoordinates(result.coords);
            if (geoCoordinates == null)
            {
                return null;
            }
            sniperInfo.Latitude = geoCoordinates.Latitude;
            sniperInfo.Longitude = geoCoordinates.Longitude;

            sniperInfo.ExpirationTimestamp = Convert.ToDateTime(result.until);
            return sniperInfo;
        }
Пример #37
0
 protected virtual void OnReceivedViaClients(SniperInfo sniperInfo)
 {
     if (GlobalSettings.IsManaged && GlobalSettings.ShareBotCaptures)
     {
         if (Constants.Bot == sniperInfo.ChannelInfo?.server ||
             Constants.PogoFeeder == sniperInfo.ChannelInfo?.server)
         {
             var oldSniperInfo = _serverRepository.Find(sniperInfo);
             if (oldSniperInfo == null || oldSniperInfo.NeedVerification)
             {
                 PogoClient.sniperInfosToSend.Enqueue(sniperInfo);
             }
         }
     }
     ReceivedViaClients?.Invoke(this, sniperInfo);
 }
        private SniperInfo Map(PokewatchersResult result)
        {
            var sniperInfo = new SniperInfo();
            var pokemonId = PokemonParser.ParsePokemon(result.name);
            sniperInfo.Id = pokemonId;
            var geoCoordinates = GeoCoordinatesParser.ParseGeoCoordinates(result.coords);
            if (geoCoordinates == null)
            {
                return null;
            }
            sniperInfo.Latitude = geoCoordinates.Latitude;
            sniperInfo.Longitude = geoCoordinates.Longitude;

            var untilTime = DateTime.Now.AddTicks(result.until);
            sniperInfo.ExpirationTimestamp = untilTime;
            return sniperInfo;
        }
Пример #39
0
 public void PrintPokemon(SniperInfo sniperInfo, ChannelInfo channelInfo)
 {
     Application.Current.Dispatcher.BeginInvoke((Action) delegate
     {
         var info = new SniperInfoModel
         {
             Info = sniperInfo,
             Icon =
                 new BitmapImage(
                     new Uri(
                         $"pack://application:,,,/PogoLocationFeeder.GUI;component/Assets/icons/{(int) sniperInfo.Id}.png",
                         UriKind.Absolute)),
             Server = channelInfo.server,
             Channel = channelInfo.channel
         };
         info.Icon.Freeze();
         InsertToList(info);
         RemoveListExtras();
     });
 }
        public void FindUnSentMessagesTest()
        {
            var messageCache = new MessageCache();
            var sniperInfo = new SniperInfo
            {
                Latitude = 1,
                Longitude = 2,
                ExpirationTimestamp = DateTime.Now.AddMilliseconds(100)
            };

            var sniperInfo2 = new SniperInfo
            {
                Latitude = 1,
                Longitude = 2
            };

            var differntSniperInfo = new SniperInfo
            {
                Latitude = 4,
                Longitude = 5,
                ExpirationTimestamp = DateTime.Now.AddMilliseconds(100)
            };

            var unsentMessages = messageCache.FindUnSentMessages(new List<SniperInfo> {sniperInfo});
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);

            unsentMessages = messageCache.FindUnSentMessages(new List<SniperInfo> {sniperInfo2});
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(0, unsentMessages.Count);

            unsentMessages = messageCache.FindUnSentMessages(new List<SniperInfo> {differntSniperInfo});
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);

            Thread.Sleep(110);

            unsentMessages = messageCache.FindUnSentMessages(new List<SniperInfo> {sniperInfo2});
            Assert.IsNotNull(unsentMessages);
            Assert.AreEqual(1, unsentMessages.Count);
        }
Пример #41
0
        public List<SniperInfo> parseMessage(string message)
        {
            var snipeList = new List<SniperInfo>();
            var lines = message.Split(new[] { '\r', '\n' });

            foreach (var input in lines)
            {
                sniperInfo = new SniperInfo();
                if (!parseGeoCoordinates(input))
                {
                    //Console.WriteLine($"Can't get coords from line: {input}"); // debug output, too much spam
                    continue;
                }
                parseIV(input);
                parseTimestamp(input);
                parsePokemonId(input);

                snipeList.Add(sniperInfo);
            }

            return snipeList;
        }
        private SniperInfo map(Result result)
        {
            SniperInfo sniperInfo = new SniperInfo();
            PokemonId pokemonId = PokemonParser.parsePokemon(result.name);
            if (!pokemonIdsToFind.Contains(pokemonId))
            {
                return null;
            }
            sniperInfo.Id = pokemonId;
            GeoCoordinates geoCoordinates = GeoCoordinatesParser.parseGeoCoordinates(result.coords);
            if (geoCoordinates == null)
            {
                return null;
            }
            else
            {
                sniperInfo.Latitude = geoCoordinates.latitude;
                sniperInfo.Longitude = geoCoordinates.longitude;
            }

            sniperInfo.ExpirationTimestamp = Convert.ToDateTime(result.until);
            return sniperInfo;
        }
 private static SniperInfo Map(PokeSpawnsPokemon result)
 {
     var sniperInfo = new SniperInfo();
     var pokemonId = PokemonParser.ParsePokemon(result.name);
     sniperInfo.Id = pokemonId;
     sniperInfo.Latitude = result.lat;
     sniperInfo.Longitude = result.lon;
     return sniperInfo;
 }
        private SniperInfo map(TrackemonResult result)
        {
            SniperInfo sniperInfo = new SniperInfo();
            PokemonId 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;
        }
        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 = lat;
                sniperInfo.Longitude = lon;

                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 = untilTime;
                }
                return sniperInfo;
            }
            return null;
        }
 private SniperInfo createSniperInfo()
 {
     SniperInfo sniperInfo = new SniperInfo();
     sniperInfo.Id = POGOProtos.Enums.PokemonId.Abra;
     sniperInfo.Latitude = 12.345;
     sniperInfo.Longitude = -98.765;
     sniperInfo.IV = 95.6;
     return sniperInfo;
 }
 private static string GetCoordinatesString(SniperInfo sniperInfo)
 {
     return MessagePrefix + sniperInfo.Latitude + ", " + sniperInfo.Longitude;
 }
 private SniperInfo createSniperInfo()
 {
     var sniperInfo = new SniperInfo();
     sniperInfo.Id = PokemonId.Abra;
     sniperInfo.Latitude = 12.345;
     sniperInfo.Longitude = -98.765;
     sniperInfo.IV = 95.6;
     return sniperInfo;
 }
 private static String getCoordinatesString(SniperInfo sniperInfo)
 {
     return messagePrefix + sniperInfo.latitude + ", " + sniperInfo.longitude;
 }
        private void SendToClients(SniperInfo sniperInfo)
        {
            foreach (var socket in arrSocket) // Repeat for each connected client (socket held in a dynamic array)
            {
                try
                {
                    NetworkStream networkStream = socket.GetStream();
                    StreamWriter s = new StreamWriter(networkStream);

                    s.WriteLine(JsonConvert.SerializeObject(sniperInfo));
                    s.Flush();
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Caught exception: {e.ToString()}");
                }
            }
        }