Esempio n. 1
0
        public static void LoginToSteam(SteamGeneratorResponse account)
        {
            ConsEx.Write("Waiting for Steam.. ", ConsoleColor.Yellow);

            SpinWait.SpinUntil(() => Process.GetProcessesByName("steam").Length != 0);

            ConsEx.WriteRaw("found!\n", ConsoleColor.Green);

            Thread.Sleep(1000); // Steam really loves subprocesses.

            var steamProcesses   = Process.GetProcessesByName("steam");
            var steamProcessPath = steamProcesses[0].MainModule.FileName;

            foreach (var steamProcess in steamProcesses)
            {
                using (steamProcess)
                {
                    steamProcess.Kill();
                }
            }

            Process.Start(new ProcessStartInfo
            {
                FileName  = steamProcessPath,
                Arguments = $"-login {account.Username} {account.Password} " +
                            $"{(Program.Settings.GetConfigEntry<bool>("should_auto_start_game") ? $"-applaunch {Program.Settings.GetConfigEntry<long>("auto_start_gameid")}" : "")}" +
                            $"{(Program.Settings.GetConfigEntry<bool>("speed_up_steam") ? "-noverifyfiles" : "")}" +
                            $"{(Program.Settings.GetConfigEntry<bool>("silent_steam_launch") ? "-silent" : "")}",
                UseShellExecute = false
            });
        }
Esempio n. 2
0
        public static void UpdateAPILimitations(bool returnOnFail = false)
        {
            int result;
            var wResp = string.Empty;

            try
            {
                wResp  = new WebClient().DownloadString("http://accgen.jdevcloud.com/steam/api?stats=1");
                result = int.Parse(wResp);
            }
            catch
            {
                // Verification pending?

                SteamGeneratorResponse sGResp = null;

                try
                {
                    sGResp = JsonConvert.DeserializeObject <SteamGeneratorResponse>(wResp);
                }
                catch
                {
                    if (returnOnFail)
                    {
                        return;
                    }

                    ReportFatalError(false);
                }

                if (sGResp == null)
                {
                    if (returnOnFail)
                    {
                        return;
                    }

                    ReportFatalError(false);
                }

                if (sGResp.Success == -1)
                {
                    if (returnOnFail)
                    {
                        return;
                    }

                    ReportFatalError(false);
                }

                if (sGResp.Success == 0)
                {
                    if (returnOnFail)
                    {
                        return;
                    }

                    if (sGResp.ErrorMessage.ToLowerInvariant().Contains("verification"))
                    {
                        ConsEx.WriteRaw("\n\n");
                        ConsEx.Write("Hey. You need to get through captcha verification.\n");
                        ConsEx.Write("I'll open a website for you..\n");

                        Process.Start("http://accgen.undo.it/");

                        ConsEx.Write("Check console title for more info..");

                        while (true)
                        {
                            for (var i = 10; i >= 0; i--)
                            {
                                Console.Title = $"Steam Account Switcher ({i} seconds until re-checking..)";
                                Thread.Sleep(1000);
                            }

                            UpdateAPILimitations(true);

                            if (AccountsRequestedToday == -1)
                            {
                                continue;
                            }

                            // Console is kinda broken right now. Why fix?
                            // ez

                            Process.Start(Environment.GetCommandLineArgs()[0]);
                            Environment.Exit(0);
                        }
                    }

                    ReportFatalError(true, sGResp.ErrorMessage);
                }

                return;
            }

            Console.Title          = $"Steam Account Switcher ({AccountsPerDay-result} accs left)";
            AccountsRequestedToday = result;
        }