예제 #1
0
        public static void Main(string[] args)
        {
            Console.CancelKeyPress += OnProcessExit;
            LoadSettings();

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Is(Enum.Parse <LogEventLevel>(_settings.Options.LogLevel))
                         .WriteTo.Console()
                         .CreateLogger();

            var core = new BotCore(_settings);

            core.EnableCaching <LevelCache>();
            core.EnableAssemblyLocalization();

            core.RegisterController <TelegramController>();
            core.RegisterController <VkController>();
            core.RegisterController <DiscordController>();

            var commands = core.RegisterModule <CommandsModule>();

            commands.RegisterConverter <UserConverter>();
            commands.RegisterConverter <ChatConverter>();
            commands.RegisterConverter <RouteConverter>();

            var router = core.Router;

            router.AddHandler <PrimaryMiddleware>();
            router.AddHandler <UsersMiddleware>();
            router.AddHandler <ReplicatingMiddleware>();

            router.AddHandler <TestCommand>();
            router.AddHandler <SudoCommand>();
            router.AddHandler <ChatsCommand>();
            router.AddHandler <UsersCommand>();
            router.AddHandler <RoutesCommand>();
            router.AddHandler <HelpCommand>();

            HelpMessage.Init(commands.GetCommands());
            core.Start();
            Core = core;

            CreateAdmins();

            if (Options.Changelog)
            {
                BroadcastChangelog();
            }

            Log.Information("Replica started");

            Thread.Sleep(Timeout.Infinite);
        }