Exemple #1
0
        private static void ShowMenuAddWatcher()
        {
            bool menuClose = false;

            while (!menuClose)
            {
                Prompts.PromptMenuAction("Add a Watcher");
                var  friendlyName    = Prompts.PromptQuestion("Enter a name for this tracker");
                var  pageURL         = Prompts.PromptQuestion("Enter the page URL to monitor");
                var  keyWord         = Prompts.PromptQuestion("Enter the keyword you want to look for (case sensitive)");
                bool alertOnNotExist = Prompts.PromptYesNo($"Do you want the alert to trigger when this keyword doesn't exist?{Environment.NewLine} (if no then alert triggers when the keyword does exist)");
                var  newTracker      = new TrackedProduct()
                {
                    FriendlyName           = friendlyName,
                    PageURL                = pageURL,
                    Keyword                = keyWord,
                    AlertOnKeywordNotExist = alertOnNotExist
                };
                Prompts.PromptWatcherAlertType(newTracker);
                newTracker.Save();
                Log.Information("Created new tracker! {Tracker}", newTracker);
                Console.Write($"Successfully created tracker! {Environment.NewLine}URL: {newTracker.PageURL}");
                menuClose = true;
                StopForMessage();
                Console.Clear();
            }
            Log.Information("Exited Menu AddWatcher");
        }
Exemple #2
0
        private static void ShowMenuSettings()
        {
            bool menuClose = false;

            while (!menuClose)
            {
                var      menuTitle   = "Settings Menu";
                var      description = "Select a setting to modify or an action:";
                string[] choices     = new string[]
                {
                    "Back to the Main Menu",
                    "Show Running Environment & Settings Details",
                    "Check for an Update",
                    "Email Settings",
                    "Enable Beta Updates"
                };
                int answer = Prompts.PromptMenu(menuTitle, choices, description);
                switch (answer)
                {
                case 1:
                    menuClose = true;
                    break;

                case 2:
                    ShowEnvironmentVariables();
                    break;

                case 3:
                    bool updateAvailable = Core.CheckForUpdate();
                    if (updateAvailable)
                    {
                        Console.WriteLine("An update is available and is downloading now, we'll alert you when it's ready");
                    }
                    else
                    {
                        Console.WriteLine("You are on the latest version!");
                    }
                    StopForMessage();
                    break;

                case 4:
                    Prompts.PromptEmailSettings();
                    break;

                case 5:
                    Constants.Config.BetaUpdates = Prompts.PromptYesNo("Would you like to get Beta versions of this app? (Some updates may be unstable)");
                    break;

                default:
                    Log.Information("Answer entered wasn't a valid presented option");
                    Console.WriteLine("Answer entered isn't one of the options, please press enter and try again");
                    Console.ReadLine();
                    break;
                }
                Console.Clear();
            }
        }
Exemple #3
0
        internal static void CloseApp()
        {
            var answer = true;

            #if !DEBUG
            answer = Prompts.PromptYesNo("Are you sure you want to close the bot?");
            #endif
            Log.Debug("Closing app called w/ an answer", answer, Constants.CloseApp);
            if (answer)
            {
                Constants.CloseApp = true;
            }
            Log.Information("Closing app", answer, Constants.CloseApp);
            Core.SaveEverything();
        }
Exemple #4
0
        private static void ShowMenuTestKeywordOnWebpage()
        {
            bool menuClose = false;

            while (!menuClose)
            {
                Prompts.PromptMenuAction("Test Keyword On Webpage");
                var      webpage  = Prompts.PromptQuestion("Enter the webpage URL");
                var      keyword  = Prompts.PromptQuestion("Enter the keyword");
                WebCheck webCheck = null;

                try
                {
                    webCheck = Communication.WebCheckForKeyword(webpage, keyword).WaitAndUnwrapException();
                    Console.WriteLine("The webpage that was returned was empty/blank");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error from webpage: {ex.Message}");
                }

                if (webCheck != null)
                {
                    if (webCheck.KeywordExists)
                    {
                        Console.WriteLine("The keyword was found!");
                    }
                    else
                    {
                        Console.WriteLine($"Webpage Response StatusCode: {webCheck.ResponseCode}");
                        Console.WriteLine("The keyword wasn't found on the webpage :(");
                    }
                }
                var tryAgain = Prompts.PromptYesNo("Would you like to do another test?");
                if (!tryAgain)
                {
                    menuClose = true;
                }
                Console.Clear();
            }
            Log.Information("Exited Menu TestKeywordOnWebpage");
        }
Exemple #5
0
        private static void ShowMenuModifySingleWatcher(TrackedProduct selectedTracker)
        {
            Console.Clear();
            bool menuClose     = false;
            bool removeWatcher = false;

            while (!menuClose)
            {
                string menuName    = $"Modify: {selectedTracker.FriendlyName}";
                string description = "Select the property you wish to modify:";
                var    answer      = Prompts.PromptMenuTrackerProperties(menuName, description);

                switch (answer)
                {
                case 1:
                    menuClose = true;
                    break;

                case 2:
                    selectedTracker.FriendlyName = Prompts.PromptQuestion("Enter a new Friendly Name");
                    break;

                case 3:
                    selectedTracker.PageURL = Prompts.PromptQuestion("Enter a new Page URL");
                    break;

                case 4:
                    selectedTracker.Keyword = Prompts.PromptQuestion("Enter a new keyword");
                    break;

                case 5:
                    selectedTracker.AlertOnKeywordNotExist = Prompts.PromptYesNo("Alert when keyword doesn't exist?");
                    break;

                case 6:
                    selectedTracker.Enabled = Prompts.PromptYesNo("Do you want this watcher enabled?");
                    break;

                case 7:
                    Prompts.PromptWatcherAlertType(selectedTracker);
                    break;

                case 8:
                    ShowWatcherProperties(selectedTracker);
                    break;

                case 9:
                    removeWatcher = Prompts.PromptYesNo("Are you sure you want to delete this watcher?");
                    menuClose     = true;
                    break;

                default:
                    Log.Information("Answer entered wasn't a valid presented option");
                    Console.WriteLine("Answer entered isn't one of the options, please press enter and try again");
                    Console.ReadLine();
                    break;
                }
                if (removeWatcher)
                {
                    selectedTracker.Delete();
                }
                else
                {
                    selectedTracker.Save();
                }
            }
            Log.Information("Exited Menu ModifySingleWatcher");
        }