コード例 #1
0
        public async Task MainAsync(string[] args)
        {
            if (args.Contains(arg => arg.Contains("entryWidth=")))
            {
                EntryHeight = int.Parse(args.First(arg => arg.Contains("entryHeight=")).Split('=')[1]);
            }
            if (args.Contains(arg => arg.Contains("entryWidth=")))
            {
                EntryWidth = int.Parse(args.First(arg => arg.Contains("entryWidth=")).Split('=')[1]);
            }

            Console.WriteLine("Running");

            WebServer.Start();

            var            shop = ShopV2.Get();
            DateTimeOffset time = shop.ShopDate.AddDays(1);

            Console.WriteLine("The shop will generate at " + time);

            shop = null;

            int generated = 0;

            Scheduler.Default.Schedule(time, reschedule =>
            {
                var shop = ShopV2.Get(out Status status);
                if (status == Status.NOT_READY)
                {
                    reschedule(DateTimeOffset.Now.AddSeconds(5));
                }
                else
                {
                    DrawShop(shop);
                    Console.WriteLine("\"Generated\": " + time);
                    Console.WriteLine($"Number: {++generated}");
                    shop = null;

                    reschedule(time.AddDays(1));
                }
            });

            Console.WriteLine("Enter key to enable commands:");
            DoCommand(Console.ReadLine());

            await Task.Delay(-1);
        }
コード例 #2
0
        public void DoCommand(string command)
        {
            if (authed)
            {
                switch (command)
                {
                case "generate shop":
                    GenerateShop();
                    break;

                case "draw shop":
                    DrawShop(ShopV2.Get());
                    break;

                case "clear cache":
                    Directory.Delete($"{Root}Cache", true);
                    Console.WriteLine("Cleared cache!");
                    break;

                case "tweet":
                    Console.WriteLine("Enter Status:");
                    TwitterManager.Tweet(Console.ReadLine());
                    break;

                default:
                    Console.WriteLine("Wrong command!");
                    break;
                }
            }
            else if (command == Environment.GetEnvironmentVariable("COMMANDSKEY"))
            {
                authed = true;
                Console.WriteLine("Commands enabled");
            }

            Console.WriteLine(authed ? "Enter command:" : "Wrong key.\nTry again:");
            DoCommand(Console.ReadLine());
        }