Beispiel #1
0
        public static void Main(string[] args)
        {
#if CORE
            Common.Utility.Environment.InitializeScope(true);
            int port = 4345;
            if (args.Length < 2)
            {
                Console.WriteLine("Please provide at least 2 arguments. <port> <MasterConfig>");
                Console.ReadLine();
                return;
            }
            port = int.Parse(args[0]);
            Consts.Endpoints.ServerConfig = args[1];
            NewCore core = new NewCore(port);
            core.Initialize();
            while (true)
            {
                string input = Console.ReadLine();
                if (input == "refresh")
                {
                    core.Initialize();
                }
                if (input == "exit")
                {
                    return;
                }
            }
#else
            Common.Utility.Environment.InitializeScope(false);
#if CODEFORCES
            NewCore core = new NewCore(80);
            core.Initialize();
            const int AMOUNT     = 200;
            const int BATCH_SIZE = 4;
            bool[]    done       = new bool[AMOUNT];
            Task[]    busy       = new Task[AMOUNT];
            int       left       = AMOUNT;
            int       Busy       = 0;
            FakeFactory._DOMAINS_CACHE = Request.Get(FakeFactory.RAPID_API_DOMAINS_ENDPOINT, new WebHeaderCollection {
                ["X-RapidAPI-Key"] = FakeFactory.RAPID_API
            });
            for (int i = 0; i < AMOUNT; ++i)
            {
                busy[i] = null;
            }
            while (left > 0)
            {
                if (Busy < BATCH_SIZE && Busy < left)
                {
                    for (int i = 0; i < AMOUNT; ++i)
                    {
                        if (!done[i] && busy[i] == null)
                        {
                            int id = i;
                            ++Busy;
                            busy[id] =
                                Task.Run(() => {
                                try {
                                    FakeFactory.CreateFake();
                                } finally {
                                    --left;
                                    --Busy;
                                    done[id] = true;
                                }
                            });
                        }
                        if (!(Busy < BATCH_SIZE && Busy < left))
                        {
                            break;
                        }
                    }
                }
                Thread.Sleep(1500);
            }

            return;
#endif
            if (args.Length < 1)
            {
                Console.WriteLine("Please provide at least 2 arguments. <port> <MasterConfig>");
                Console.ReadLine();
                return;
            }
            Consts.Endpoints.BotConfig = args[0];
            args = args.Skip(1).ToArray();
            opts.Parse(args);

            if (showHelp)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("If no options are given SteamBot defaults to Bot Manager mode.");
                opts.WriteOptionDescriptions(Console.Out);
                Console.Write("Press Enter to exit...");
                Console.ReadLine();
                return;
            }

            if (args.Length == 0)
            {
                BotManagerMode();
            }
            else if (botIndex > -1)
            {
                BotMode(botIndex);
            }
#endif
        }