예제 #1
0
        static void HandleCommands()
        {
            ShowMenu         = !Config.BypassMenu;
            BotHandler.Exit += () =>
            {
                if (!Updater.IsUpdate)
                {
                    if (BotHandler.ChinoProcess.ExitCode == 3)
                    {
                        ShowMenu = true;
                        MenuHandler.Display();
                    }
                }
                else
                {
                    Updater.IsUpdate = false;
                }
            };
            while (Running)
            {
                if (ShowMenu)
                {
                    MenuHandler.Display();
                }
                else
                {
                    BotHandler.Start();
                    ShowMenu = false;
                    Logger.HungLogs.ForEach(t => Logger.Log(t.Message, t.Module, t.Color, t.Severity));
                    Logger.HungLogs.Clear();
                }
                string input = Console.ReadLine();

                HandleCommand(input);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Logger.SetupLogger();

            Logger.Log("Chino-chan handler loading...");
            ConfigEditor = new ConfigEditor();

loadConfig:
            Logger.Log("Loading config...");
            Config = LoadConfig(ConfigPath);
            Logger.Log("Config loaded!", Color: ConsoleColor.Green);
            if (Config.IsNewConfig())
            {
                Config.SaveConfig();
                Logger.Log("Your config is outdated! Please check your configuration to avoid future crashes, and press enter!", Color: ConsoleColor.Cyan);
                ConfigEditor.FillEmpty(Config);
                goto loadConfig;
            }

            Logger.Log("Checking libraries...");
            if (!CheckLibraries())
            {
                Logger.Log("Please install the libraries / runtimes mentioned above! Press enter to exit!", Color: ConsoleColor.Red);
                Console.ReadLine();
                Environment.Exit(1);
            }
            Logger.Log("Checking libraries done!", Color: ConsoleColor.Green);

            Logger.Log("Initializing Webhook manager...");
            Manager = new WebhookManager(Config);
            Logger.Log("Webhook manager initialized!", Color: ConsoleColor.Green);

            Logger.Log("Initializing Bot handler...");
            BotHandler = new BotHandler(Config);
            Logger.Log("Handler initialized!", Color: ConsoleColor.Green);

            Logger.Log("Initializing updater...");
            Updater    = new Updater(Config);
            BotUpdate += () =>
            {
                Updater.Update(true);
            };
            HandlerUpdate += () =>
            {
                Updater.Update(false);
            };
            Logger.Log("Updater initialized!", Color: ConsoleColor.Green);

            Logger.Log("Initializing Remote Console...");
            RemoteConsole = new RemoteConsole(Config);
            Logger.Log("Remote Console initialized!", Color: ConsoleColor.Green);


            Logger.Log("Initializing menu...");
            MenuHandler = new MenuHandler();
            MenuHandler.Add("Start", () =>
            {
                BotHandler.Start();
                ShowMenu = false;
            });
            MenuHandler.Add("Edit Config", () =>
            {
                ConfigEditor.EditAll(Config);
                Logger.Log("Restart the program for the changes to take effect.");
            });
            MenuHandler.Add("Exit", () =>
            {
                BotHandler.Quit();
                Environment.Exit(0);
            });
            Console.Clear();

            Logger.Log("Starting Webhook manager...");
            if (Manager.Start())
            {
                Logger.Log("Webhook manager successfully started!", Color: ConsoleColor.Green);
                Console.Clear();
            }
            RemoteConsole.Start();
            Console.WriteLine();
            HandleCommands();
        }