Пример #1
0
        private static void OnSnipePokemon(ISession session, string message)
        {
#pragma warning disable IDE0018 // Inline variable declaration - Build.Bat Error Happens if We Do
            ulong encounterid;
            var   match = Regex.Match(message, "42\\[\"snipe-pokemon\",(.*)]");
            if (match != null && !string.IsNullOrEmpty(match.Value) && !string.IsNullOrEmpty(match.Groups[1].Value))
            {
                var data = JsonConvert.DeserializeObject <EncounteredEvent>(match.Groups[1].Value);

                //not your snipe item, return need more encrypt here and configuration to allow catch others item
                if (string.IsNullOrEmpty(session.LogicSettings.DataSharingConfig.DataServiceIdentification) ||
                    string.IsNullOrEmpty(data.RecieverId) ||
                    data.RecieverId.ToLower() != session.LogicSettings.DataSharingConfig.DataServiceIdentification.ToLower())
                {
                    return;
                }

                var move1 = PokemonMove.Absorb;
                var move2 = PokemonMove.Absorb;
                Enum.TryParse(data.Move1, true, out move1);
                Enum.TryParse(data.Move1, true, out move2);
                ulong.TryParse(data.EncounterId, out encounterid);

                bool caught = CheckIfPokemonBeenCaught(data.Latitude, data.Longitude, data.PokemonId, encounterid,
                                                       session);
                if (caught)
                {
                    Logger.Write("[SNIPE IGNORED] - Your snipe pokemon has already been caught by bot",
                                 Logic.Logging.LogLevel.Sniper);
                    return;
                }

                MSniperServiceTask.AddSnipeItem(session, new MSniperServiceTask.MSniperInfo2()
                {
                    UniqueIdentifier = data.EncounterId,
                    Latitude         = data.Latitude,
                    Longitude        = data.Longitude,
                    EncounterId      = encounterid,
                    SpawnPointId     = data.SpawnPointId,
                    Level            = data.Level,
                    PokemonId        = (short)data.PokemonId,
                    Iv          = data.IV,
                    Move1       = move1,
                    ExpiredTime = data.ExpireTimestamp,
                    Move2       = move2
                }, true).Wait();
            }
#pragma warning restore IDE0018 // Inline variable declaration - Build.Bat Error Happens if We Do
        }
Пример #2
0
 private static void OnSocketMessageRecieved(ISession session, object sender, MessageEventArgs e)
 {
     try
     {
         OnPokemonRemoved(session, e.Data);
         OnPokemonUpdateData(session, e.Data);
         OnPokemonData(session, e.Data);
         OnSnipePokemon(session, e.Data);
         OnServerMessage(session, e.Data);
     }
     catch (Exception ex)
     {
         Logger.Debug("ERROR TO ADD SNIPE< DEBUG ONLY " + ex.Message + "\r\n " + ex.StackTrace);
     }
 }
Пример #3
0
        public static async Task Start(Session session, CancellationToken cancellationToken)
        {
            //Disable autosniper service until finger out how to make it work with API change

            await Task.Delay(30000, cancellationToken); //delay running 30s

            ServicePointManager.Expect100Continue = false;

            cancellationToken.ThrowIfCancellationRequested();

            while (true && !termintated)
            {
                var socketURL = servers.Dequeue();
                Logger.Write($"Connecting to {socketURL} ....");
                await ConnectToServer(session, socketURL);

                servers.Enqueue(socketURL);
            }
        }
Пример #4
0
        private static void onSocketMessageRecieved(ISession session, object sender, MessageEventArgs e)
        {
            try
            {
                OnPokemonData(session, e.Data);
                OnSnipePokemon(session, e.Data);

                //ONFPMBridgeData(session, e.Data); //Nolonger use
            }

            #pragma warning disable 0168 // Comment Suppress compiler warning - ex is used in DEBUG section
            catch (Exception ex)
            #pragma warning restore 0168
            {
                // Comment Suppress compiler warning - ex is used in DEBUG section
                #if DEBUG
                Logger.Write("ERROR TO ADD SNIPE< DEBUG ONLY " + ex.Message + "\r\n " + ex.StackTrace,
                             Logic.Logging.LogLevel.Info, ConsoleColor.Yellow);
                #endif
            }
        }