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);
        }
        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);
        }
        public void Start()
        {
            _webSocketServer = new WebSocketServer();
            SuperSocket.SocketBase.Config.RootConfig rootConfig = new SuperSocket.SocketBase.Config.RootConfig();
            var serverConfig = new SuperSocket.SocketBase.Config.ServerConfig();

            serverConfig.Name                = "PokeFeeder";
            serverConfig.ServerTypeName      = "WebSocketService";
            serverConfig.Ip                  = "Any";
            serverConfig.Port                = GlobalSettings.OutgoingServerPort;
            serverConfig.MaxRequestLength    = 4096;
            serverConfig.MaxConnectionNumber = 100 * 1000;
            serverConfig.SendingQueueSize    = 25;
            serverConfig.SendTimeOut         = 5000;
            var socketServerFactory = new SuperSocket.SocketEngine.SocketServerFactory();

            _webSocketServer.Setup(rootConfig, serverConfig, socketServerFactory);
            _webSocketServer.Start();
            _webSocketServer.NewMessageReceived  += new SessionHandler <WebSocketSession, string>(socketServer_NewMessageReceived);
            _webSocketServer.NewSessionConnected += socketServer_NewSessionConnected;
            _webSocketServer.SessionClosed       += socketServer_SessionClosed;

            UpdateTitle();
            var pokemonIds = GlobalSettings.UseFilter
? PokemonParser.ParsePokemons(new List <string>(GlobalSettings.PokekomsToFeedFilter))
: Enum.GetValues(typeof(PokemonId)).Cast <PokemonId>().ToList();

            _serverUploadFilter = ServerUploadFilterFactory.Create(pokemonIds);
        }
Example #4
0
        public static List <string> LoadFilter()
        {
            if (File.Exists(FilterPath))
            {
                var input        = File.ReadAllText(FilterPath);
                var jsonSettings = new JsonSerializerSettings();
                jsonSettings.Converters.Add(new StringEnumConverter {
                    CamelCaseText = true
                });
                jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace;
                jsonSettings.DefaultValueHandling   = DefaultValueHandling.Populate;
                return(JsonConvert.DeserializeObject <List <string> >(input, jsonSettings).
                       GroupBy(x => PokemonParser.ParsePokemon(x)).
                       Select(y => y.FirstOrDefault()).ToList());
            }
            else
            {
                var output = JsonConvert.SerializeObject(DefaultPokemonsToFeed, Formatting.Indented,
                                                         new StringEnumConverter {
                    CamelCaseText = true
                });

                var folder = Path.GetDirectoryName(FilterPath);
                if (folder != null && !Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                File.WriteAllText(FilterPath, output);
                return(new List <string>());
            }
        }
        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);
        }
Example #6
0
        private async void SnipeMe_Click(object sender, EventArgs e)
        {
            var           array    = SnipeInfo.Text.Split('|');
            PokemonId     idPoke   = PokemonParser.ParsePokemon(array[0]);
            GeoCoordinate geocoord = new GeoCoordinate(double.Parse(array[1]), double.Parse(array[2]));
            var           success  = await Logic.Logic._instance.Snipe(idPoke, geocoord);

            SnipeInfo.Text = "";
        }
Example #7
0
        public static async Task <List <Pokemon> > GetPokemon()
        {
            HttpClient request  = new HttpClient();
            var        response = await request.GetStringAsync("https://pokeapi.co/api/v2/pokemon?limit=151");

            PokemonParser poke = JsonConvert.DeserializeObject <PokemonParser>(response);

            return(poke.results);
        }
        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);
        }
        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(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);
        }
        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);
        }
Example #12
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);
        }
Example #13
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);
        }
Example #14
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);
        }
        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);
        }
Example #16
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(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);
        }
Example #18
0
        public static void Load()
        {
            if (!File.Exists(ConfigFile))
            {
                var output = JsonConvert.SerializeObject(GlobalSettings.DefaultPokemonsToFeed, Formatting.Indented,
                                                         new StringEnumConverter {
                    CamelCaseText = true
                });

                var folder = Path.GetDirectoryName(ConfigFile);
                if (folder != null && !Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                File.WriteAllText(ConfigFile, output);
            }
            GlobalSettings.PokekomsToFeedFilter = GlobalSettings.LoadFilter();
            var set = GlobalSettings.PokekomsToFeedFilter.OrderBy(x => PokemonParser.ParsePokemon(x));

            foreach (var s in set)
            {
                try
                {
                    var id  = PokemonParser.ParsePokemon(s, false);
                    var img = new BitmapImage(
                        new Uri(
                            $"pack://application:,,,/PogoLocationFeeder.GUI;component/Assets/icons/{(int)id}.png",
                            UriKind.Absolute));
                    img.Freeze();
                    GlobalVariables.PokemonToFeedFilterInternal.Add(new PokemonFilterModel(id, img));
                    GlobalVariables.AllPokemonsInternal.Remove(GlobalVariables.AllPokemonsInternal.Single(x => x.Id == id));
                }
                catch (Exception e)
                {
                    Log.Warn("Could not add pokemon to the filter", e);
                }
            }
        }
        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);
        }
Example #20
0
        public static Filter Create(List <DiscordChannels> discordChannels = null)
        {
            List <PokemonId> pokemons = GlobalSettings.UseFilter
                ? PokemonParser.ParsePokemons(new List <string>(GlobalSettings.PokekomsToFeedFilter))
                : Enum.GetValues(typeof(PokemonId)).Cast <PokemonId>().ToList();
            var            pokemonsBinary = PokemonFilterToBinary.ToBinary(pokemons);
            List <Channel> channelInfos   = new List <Channel>();

            if (discordChannels != null && discordChannels.Any())
            {
                foreach (DiscordChannels discordChannel in discordChannels)
                {
                    channelInfos.Add(new Channel()
                    {
                        Server = discordChannel.Server, ChannelName = discordChannel.Name
                    });
                }
            }
            if (GlobalSettings.UsePokeSnipers)
            {
                channelInfos.Add(new Channel()
                {
                    Server = PokeSnipersRarePokemonRepository.Channel
                });
            }
            if (GlobalSettings.UsePokemonGoIVClub)
            {
                channelInfos.Add(new Channel()
                {
                    Server = PokemonGoIVClubRarePokemonRepository.Channel
                });
            }
            if (GlobalSettings.UsePokewatchers)
            {
                channelInfos.Add(new Channel()
                {
                    Server = PokeWatchersRarePokemonRepository.Channel
                });
            }
            if (GlobalSettings.UseTrackemon)
            {
                channelInfos.Add(new Channel()
                {
                    Server = TrackemonRarePokemonRepository.Channel
                });
            }
            if (GlobalSettings.UsePokezz)
            {
                channelInfos.Add(new Channel()
                {
                    Server = PokezzRarePokemonRepository.Channel
                });
            }
            if (GlobalSettings.UsePokeSnipe)
            {
                channelInfos.Add(new Channel()
                {
                    Server = PokeSnipeRarePokemonRepository.Channel
                });
            }
            channelInfos.Add(new Channel()
            {
                Server = Constants.PogoFeeder
            });
            channelInfos.Add(new Channel()
            {
                Server = Constants.Bot
            });

            var filter = new Filter();

            filter.Channels                    = channelInfos;
            filter.Pokemon                     = pokemonsBinary;
            filter.VerifiedOnly                = GlobalSettings.VerifiedOnly;
            filter.Version                     = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            filter.AreaBounds                  = GlobalSettings.UseGeoLocationBoundsFilter ? GlobalSettings.GeoLocationBounds : null;
            filter.MinimumIV                   = GlobalSettings.MinimumIV;
            filter.UnverifiedOnly              = GlobalSettings.UnverifiedOnly;
            filter.UseUploadedPokemon          = GlobalSettings.UseUploadedPokemon;
            filter.PokemonNotInFilterMinimumIV = GlobalSettings.PokemonNotInFilterMinimumIV;
            return(filter);
        }
        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);
        }
 private void testPokemonParsing(string text, PokemonId expectedPokemonId)
 {
     Assert.AreEqual(expectedPokemonId, PokemonParser.ParsePokemon(text));
 }