コード例 #1
0
        public static void ProcessGetInboxResponse(Client client, GetInboxResponse getInboxResponse)
        {
            var notification_count = getInboxResponse.Inbox.Notifications.Count();

            switch (getInboxResponse.Result)
            {
            case GetInboxResponse.Types.Result.Unset:
                break;

            case GetInboxResponse.Types.Result.Failure:
                Logger.Error($"There was an error, viewing your notifications!");
                break;

            case GetInboxResponse.Types.Result.Success:
                if (getInboxResponse.Inbox.Notifications.Count > 0)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Cyan, $"We got {notification_count} new notification(s):");

                    int i = 1;     // We do not want to show then "Notification #0"

                    RepeatedField <string> notificationIDs      = new RepeatedField <string>();
                    RepeatedField <Int64>  createTimestampMsIDs = new RepeatedField <Int64>();

                    foreach (var notification in getInboxResponse.Inbox.Notifications)
                    {
                        string created_time = Utils.TimeMStoString(notification.CreateTimestampMs, "0:MM/dd/yy H:mm:ss");
                        string expires_time = Utils.TimeMStoString(notification.ExpireTimeMs, "0:MM/dd/yy H:mm:ss");
                        string log_response = $"Notification: #{i} (Created on: {created_time} | Expires: {expires_time}) " +
                                              $"ID: {notification.NotificationId} | Title: {notification.TitleKey} | Category: {notification.Category} | " +
                                              $"Variables: {notification.Variables} | Labels: {notification.Labels}";
                        Logger.ColoredConsoleWrite(ConsoleColor.Cyan, log_response);

                        notificationIDs.Add(notification.NotificationId);
                        createTimestampMsIDs.Add(notification.CreateTimestampMs);
                        i++;
                    }
                    client.LastTimePlayedTs = Utils.GetTime();

                    UpdateNotificationResponse updateNotificationResponse = client.Misc.UpdateNotificationMessage(notificationIDs, createTimestampMsIDs);

                    Logger.ColoredConsoleWrite(ConsoleColor.Cyan, $"Info: Notifications {updateNotificationResponse.State}");

                    // For future use: GYM_REMOVAL_7140377d6634458eb73a6640f1c8de maybe check on what notification we recieved? Ex: Pokemon kicked out of gym
                }
                break;
            }
        }
コード例 #2
0
        public static void ProcessGetInboxResponse(Client client, GetInboxResponse response)
        {
            if (response == null)
            {
                return;
            }
            Logger.Debug("Result:" + response.Result);
            var i = 0;

            /*foreach (var element in response.Inbox.BuiltinVariables) {
             *  Logger.Debug($"BuiltinVariable {i}: {element}");
             *  i++;
             * }*/
            i = 0;
            foreach (var element in response.Inbox.Notifications)
            {
                Logger.Debug($"Notification {i}: {element}");
                i++;
            }
        }
コード例 #3
0
        public async static void ProcessGetInboxResponse(Client client, GetInboxResponse getInboxResponse)
        {
            var notifcation_count = getInboxResponse.Inbox.Notifications.Count();

            switch (getInboxResponse.Result)
            {
            case GetInboxResponse.Types.Result.Unset:
                break;

            case GetInboxResponse.Types.Result.Failure:
                APIConfiguration.Logger.InboxStatusUpdate($"There was an error, viewing your notifications!", ConsoleColor.Red);
                break;

            case GetInboxResponse.Types.Result.Success:
                if (getInboxResponse.Inbox.Notifications.Count > 0)
                {
                    APIConfiguration.Logger.InboxStatusUpdate($"We got {notifcation_count} new notification(s).", ConsoleColor.Magenta);
                    RepeatedField <string> notificationIDs      = new RepeatedField <string>();
                    RepeatedField <string> categorieIDs         = new RepeatedField <string>();
                    RepeatedField <Int64>  createTimestampMsIDs = new RepeatedField <Int64>();

                    foreach (var notification in getInboxResponse.Inbox.Notifications)
                    {
                        notificationIDs.Add(notification.NotificationId);
                        createTimestampMsIDs.Add(notification.CreateTimestampMs);
                        categorieIDs.Add(notification.Category);
                    }

                    NotificationState notificationState = NotificationState.Viewed;
                    //await client.Misc.OptOutPushNotificationCategory(categorieIDs).ConfigureAwait(false);
                    UpdateNotificationResponse updateNotificationResponse = await client.Misc.UpdateNotification(notificationIDs, createTimestampMsIDs, notificationState).ConfigureAwait(false);

                    APIConfiguration.Logger.InboxStatusUpdate($"Notifications {updateNotificationResponse.State}.", ConsoleColor.Magenta);
                }
                break;
            }
        }
コード例 #4
0
        public static void ProcessCommonResponses(Client client, RepeatedField <ByteString> responses, bool processBuddyWalked = true, bool processInBox = true)
        {
            if (responses != null)
            {
                var checkChallengeResponse = new CheckChallengeResponse();
                if (responses.Count > 1)
                {
                    checkChallengeResponse.MergeFrom(responses[1]);
                    CommonRequest.ProcessCheckChallengeResponse(client, checkChallengeResponse);
                }

                var getHatchedEggsResponse = new GetHatchedEggsResponse();
                if (responses.Count > 2)
                {
                    getHatchedEggsResponse.MergeFrom(responses[2]);
                    CommonRequest.ProcessGetHatchedEggsResponse(client, getHatchedEggsResponse);
                }

                var getInventoryResponse = new GetInventoryResponse();
                if (responses.Count > 3)
                {
                    getInventoryResponse.MergeFrom(responses[3]);
                    CommonRequest.ProcessGetInventoryResponse(client, getInventoryResponse);
                }

                var checkAwardedBadgesResponse = new CheckAwardedBadgesResponse();
                if (responses.Count > 4)
                {
                    checkAwardedBadgesResponse.MergeFrom(responses[4]);
                    CommonRequest.ProcessCheckAwardedBadgesResponse(client, checkAwardedBadgesResponse);
                }

                var downloadSettingsResponse = new DownloadSettingsResponse();
                if (responses.Count > 5)
                {
                    downloadSettingsResponse.MergeFrom(responses[5]);
                    CommonRequest.ProcessDownloadSettingsResponse(client, downloadSettingsResponse);
                }
                var index = 5;
                if (processBuddyWalked)
                {
                    index++;
                    var getBuddyWalkedResponse = new GetBuddyWalkedResponse();
                    if (responses.Count > index)
                    {
                        getBuddyWalkedResponse.MergeFrom(responses[index]);
                        CommonRequest.ProcessGetBuddyWalkedResponse(client, getBuddyWalkedResponse);
                    }
                }
                if (processInBox)
                {
                    index++;
                    var getInboxResponse = new GetInboxResponse();

                    if (responses.Count > index)
                    {
                        getInboxResponse.MergeFrom(responses[index]);
                        CommonRequest.ProcessGetInboxResponse(client, getInboxResponse);
                    }
                }
            }
        }
コード例 #5
0
 private void OnInboxDataReceived(object sender, GetInboxResponse data)
 {
     // Inbox data
 }
コード例 #6
0
        public async Task <GetPlayerResponse> DoLogin()
        {
            Client.Reset();

            // Don't wait for background start of killswitch.
            // jjskuld - Ignore CS4014 warning for now.
#pragma warning disable 4014
            Client.KillswitchTask.Start();
#pragma warning restore 4014

            GetPlayerResponse player = await Client.Player.GetPlayer(false, true).ConfigureAwait(false); // Set false because initial GetPlayer does not use common requests.

            if (player.Warn)
            {
                APIConfiguration.Logger.LogFlaggedInit($"This account {Client.Player.PlayerData.Username} seems to be flagged, it is recommended to not use bot on this account for now!");
                if (Client.Settings.AutoExitBotIfAccountFlagged)
                {
                    APIConfiguration.Logger.LogFlaggedInit("\n\rThe bot will close in 10 seconds.");
                    Thread.Sleep(10000);
                    Environment.Exit(0);
                }
            }

            if (player.Banned)
            {
                APIConfiguration.Logger.LogErrorInit("This account seems to be banned");
            }

            APIConfiguration.Logger.LogDebug("GetPlayer done.");
            await RandomHelper.RandomDelay(10000).ConfigureAwait(false);

            await Client.Download.GetRemoteConfigVersion().ConfigureAwait(false);

            APIConfiguration.Logger.LogDebug("GetRemoteConfigVersion done.");
            await RandomHelper.RandomDelay(300).ConfigureAwait(false);

            //var getAssetDigest = await Client.Download.GetAssetDigest().ConfigureAwait(false);
            //Client.PageOffset = getAssetDigest.PageOffset;
            await Client.Download.GetAssetDigest().ConfigureAwait(false);

            APIConfiguration.Logger.LogDebug("GetAssetDigest done.");
            await RandomHelper.RandomDelay(300).ConfigureAwait(false);

            //var getItemTemplates = await Client.Download.GetItemTemplates().ConfigureAwait(false);
            //Client.PageOffset = getItemTemplates.PageOffset;
            await Client.Download.GetItemTemplates().ConfigureAwait(false);

            APIConfiguration.Logger.LogDebug("GetItemTemplates done.");
            await RandomHelper.RandomDelay(300).ConfigureAwait(false);

            //Need get storeitems

            //New on protos:
            var ids = await Client.Misc.FetchAllNews().ConfigureAwait(false);

            var newids = new RepeatedField <string>();
            foreach (var id in ids.CurrentNews.NewsArticles)
            {
                newids.Add(id.Id);
            }
            APIConfiguration.Logger.LogDebug("FetchAllNews done.");
            await RandomHelper.RandomDelay(300).ConfigureAwait(false);

            await Client.Misc.MarkReadNewsArticle(newids).ConfigureAwait(false);

            APIConfiguration.Logger.LogDebug("MarkReadNewsArticle done.");
            await RandomHelper.RandomDelay(300).ConfigureAwait(false);

            await Client.Player.GetPlayerProfile().ConfigureAwait(false);

            APIConfiguration.Logger.LogDebug("GetPlayerProfile done.");
            await RandomHelper.RandomDelay(300).ConfigureAwait(false);

            GetInboxResponse req = await Client.Misc.GetInbox(true, false, 0L).ConfigureAwait(false);

            CommonRequest.ProcessGetInboxResponse(Client, req);
            await RandomHelper.RandomDelay(300).ConfigureAwait(false);

            return(player);
        }
コード例 #7
0
ファイル: Session.cs プロジェクト: Zacban/POGOLib
 internal void OnInboxNotification(GetInboxResponse inboxdata)
 {
     InboxDataReceived?.Invoke(this, new GetInboxResponse(inboxdata));
 }