Exemple #1
0
        private static void StartAuthenticatorBot()
        {
            ConsoleWriter.Default.PrintCaption("AuthenticatorBot");

            ConsoleWriter.Default.PrintMessage(
                "Initializing terminal, press enter for the list of valid commands.");

            using (var bot = new AuthenticatorBot(SettingsExtension.Load <AuthenticatorBotSettings>(), new Logger()))
            {
                bot.StartBot().Wait();

                new ConsoleTerminal("AuthenticatorBot", new Dictionary <string, Action <string[]> >
                {
                    {
                        "", strings =>
                        {
                            ConsoleWriter.Default.WritePaddedText("Valid commands are as follow:", 6,
                                                                  ConsoleColor.Cyan);
                            ConsoleWriter.Default.WritePaddedText("start - Starts the bot if stopped", 6,
                                                                  ConsoleColor.Cyan);
                            ConsoleWriter.Default.WritePaddedText("stop - Stops the bot if already started", 6,
                                                                  ConsoleColor.Cyan);
                            ConsoleWriter.Default.WritePaddedText(
                                "confirm {tradeofferid} [tradeofferid2] [...] - Confirms one or more trade offer", 6,
                                ConsoleColor.Cyan);
                            ConsoleWriter.Default.WritePaddedText(
                                "deny {tradeofferid} [tradeofferid2] [...] - Denies one or more trade offers", 6,
                                ConsoleColor.Cyan);
                            ConsoleWriter.Default.WritePaddedText("exit - quit - Exits terminal and kills the bot", 6,
                                                                  ConsoleColor.Cyan);
                        }
                    },
Exemple #2
0
        private static void ClearSettings()
        {
            ConsoleWriter.Default.PrintCaption("Clear Settings");
            var sure = ConsoleWriter.Default.PrintQuestion <bool>("Are your sure");

            if (sure)
            {
                var authenticatorSettings = SettingsExtension.Exist <AuthenticatorBotSettings>()
                    ? SettingsExtension.Load <AuthenticatorBotSettings>()
                    : null;
                string authenticatorJson = null;

                if (authenticatorSettings?.Authenticator != null)
                {
                    authenticatorJson = authenticatorSettings.Authenticator.Serialize();
                }

                SettingsExtension.Clear <SteamKitBotSettings>();
                SettingsExtension.Clear <TradeOfferBotSettings>();
                SettingsExtension.Clear <AuthenticatorBotSettings>();

                if (authenticatorSettings != null)
                {
                    ConsoleWriter.Default.PrintWarning(
                        "All settings cleared. Following is the serialized version of Authenticator object created by AuthenticatorBot; " +
                        "keep it safe or you might loss access to that account."
                        );

                    ConsoleWriter.Default.WriteColoredTextLine(authenticatorJson, ConsoleColor.Red);
                }
                else
                {
                    ConsoleWriter.Default.PrintSuccess("All settings cleared.");
                }
            }

            ConsoleWriter.Default.PrintSeparator();
        }